当前位置: 移动技术网 > IT编程>移动开发>IOS > IOS metal 编辑器 玻璃材质

IOS metal 编辑器 玻璃材质

2018年10月09日  | 移动技术网IT编程  | 我要评论

fengyangyan.rar,伊达传说,深圳市中医院

ios metal 编辑器 玻璃材质

#include

float4 zfs(float zsl,float3 surfacenormal,float3 surfaceview,texturecube cubetexture,sampler cubesampler)
{
    float4 finalcolorzs=float4(1.0,1.0,1.0,0.0);
    float4 finalcolorfs=float4(1.0,1.0,1.0,0.0);
    float4 finalcolor=float4(1.0,1.0,1.0,0.0);
    float3 vtexturecoord=float3(1.0,1.0,1.0);
    //texturecube cubetexture;
    const float maxh=0.7;
    const float minh=0.2;
    float sizeh=maxh-minh;
    float3 eyedirection=normalize(-surfaceview);
    float testvalue=abs(dot(eyedirection,surfacenormal));
    if(testvalue>maxh)
    {
        vtexturecoord=refract(-eyedirection,surfacenormal,zsl);
        finalcolor=cubetexture.sample(cubesampler,vtexturecoord);
    }else if(testvalue<=maxh&&testvalue>=minh)
    {
        vtexturecoord=reflect(-eyedirection,surfacenormal);
        finalcolorfs=cubetexture.sample(cubesampler,vtexturecoord);
        vtexturecoord=refract(-eyedirection,surfacenormal,zsl);
        finalcolorzs=cubetexture.sample(cubesampler,vtexturecoord);
        float ratio=(testvalue-minh)/sizeh;
        finalcolor=finalcolorzs*ratio+(1.0-ratio)*finalcolorfs;
        
    }else
    {
        vtexturecoord=reflect(-eyedirection,surfacenormal);
        finalcolorfs=cubetexture.sample(cubesampler,vtexturecoord);
    }
   
    return finalcolor;
}
#pragma arguments
texturecube cubetexture;
#pragma transparent
#pragma body
constexpr sampler s(filter::linear,mip_filter::linear);
_output.color.r=zfs(0.97,_surface.normal,_surface.view,cubetexture,s).r;
_output.color.g=zfs(0.955,_surface.normal,_surface.view,cubetexture,s).g;
_output.color.b=zfs(0.94,_surface.normal,_surface.view,cubetexture,s).b;

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网