unityShader模拟星空效果,不使用透明模式,只使用一张纹理
_Speed1("_Speed1",Range(0,0.2))=0.05
_Speed2("_Speed2",Range(0,15))=5
_Speed3("_Speed3",Range(0,5))=1
fixed frag(v2f IN):COLOR{
float2 uv=IN.uv;
//使用sin函数控制偏移的范围
float offset_uv=_Speed1*sin(IN.uv*_Speed2+_Time.x*_Speed3);
uv+=offset_uv;
fixed col_1=tex2D(_MainTex,uv);
//这张图片加UV
uv=IN.uv;
uv-=offset_uv;
fixed col_2=tex2D(_MainTex,uv);
//这张图片减UV
return (col_1+col_2)/2;
//模拟星空
}
_Speed1("_Speed1",Range(0,0.2))=0.05
_Speed2("_Speed2",Range(0,15))=5
_Speed3("_Speed3",Range(0,5))=1
fixed frag(v2f IN):COLOR{
fixed col_1=tex2D(_MainTex,IN.uv);
//背景图不动
float2 uv=IN.uv;
//使用sin函数控制偏移的范围
float offset_uv=_Speed1*sin(IN.uv*_Speed2+_Time.x*_Speed3);
uv+=offset_uv;
fixed col_2=tex2D(_MainTex,uv);
//这张图片减UV
return col_1+col_2;
}
模拟雾效
fixed4 col_1=tex2D(_MainTex,uv);
//采样背景纹理
float offset=0.04 * sin(uv * _F + _Time.y);
//雾效移动
float2 uv2=uv+offset;
uv.y+=0.3;
fixed4 col_2=tex2D(_SecTex,uv2);
//采样雾效纹理
col_1.rgb*=col_2.rgb;
// 相乘, 图像会变暗的, 这样不好吧
col_1.rgb *=4;
// 调整亮度
return col_1;
最后
以上就是刻苦蛋挞最近收集整理的关于unityShader模拟星空效果和雾效的全部内容,更多相关unityShader模拟星空效果和雾效内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复