首页 > 编程知识 正文

梦幻模拟战5完美攻略,火影忍者手游周年总结

时间:2023-05-06 04:08:28 阅读:59626 作者:4508

Unity的天空盒不是动态的。 要支持天气系统的渐变,必须改进,使天匣子成为幻想。

我的shader的高画质处理有一个叫_FANCY_STUFF的multi_compile开关。 在Unity官方的某个shader看来,我很喜欢这个名字。 这是梦。

天匣子主要实现了以下功能:

1 .天匣子可以水平旋转

为什么要水平旋转,是因为我定制了太阳(月亮)。 通过旋转,可以使他们和天匣子的背景图更加一致。 此外,你还可以慢慢旋转天空盒,模拟云的移动。

2 .太阳(月亮)实现了。

程序实现的太阳具有可以移动位置、调整大小和颜色的优点。发光的光也会影响天盒的颜色,但实现原理是根据天盒的像素和世界原点之间的距离来决定太阳颜色的亮度,几何学的意义是天盒的亮度

3 .自下而上的高雾

雾能影响天空吗,还是自下而上的高度雾? 如下图所示,紫色雾自下而上:

4 .无缝切换天匣子背景图

天气系统的必要性,例如从白天到晚上逐渐变化。 太阳变成月亮,背景云也改变。 原理是两个天空盒映射的混合过渡。

5 .太阳晕效应

太阳可以被collider遮挡,如果不被遮挡就会产生光晕

------------- -请参阅

经过以上几个处理,天匣子看起来比较梦幻:

编辑器界面:

shader:

shader ' luoyi nan/scene/skybox ' { properties } _ maintex (' cubemaptexture ',cube )='white'{}_fogcolor ) hinted Float ).2_sundistance ),Float Float )=1_ maintex2(fadingcubemaptexture.don ' tset.',cube )=' white ' { } Float )=0_ anglespeed2(' fadingcubemaptextureanglespeed.don ' tset.',Float )=0.2 )子着色器(tags ) queue pragmavertexvert # pragmafragmentfrag # include ' unity CG.CG Inc ' # pragma multi _ compile _ fancy _ stuff # pragma mami 结构电视机2f { float4pos : SV _ position; float3 texcoord : TEXCOORD0; # if _ fading _ onfloat3tex coord 1: tex coord 1; #endifhalf fog : TEXCOORD2; # if _ fancy _ stuff half3dir : tex coord 3; #endif}; samplerCUBE _MainTex; # if _ fading _ onsamplercube _ maintex 2; half _Angle2; half _AngleSpeed2; fixed _GlobalFadingFactor; #endifhalf _AngleSpeed; # if _ fancy _ stuff fixed4_ globalmainlightdir; fixed4 _GlobalMainLightColor; half _SunDistance; half _SunPower; #endiffixed4 _FogColor; half _Angle; v2fvert(appdata_tv ) {v2f OUT; out.pos=mul(Unity_matrix_MVP,v.vertex ); //天空框水平旋转_Angle =_Time.x * _AngleSpeed; 哈尔夫Sina、辅酶sa; Sincos(Angle、sina、cosa ); fixed2x2m=fixed2x2(Cosa,-sina,sina,cosa ); out.texcoord=half3(mul(m,v.vertex.xz ),v.vertex.y ).xzy; # if _ fading _ on _ angle2=_ time.x * _ anglespeed 2; Sincos(angle2、sina、cosa ); m=2个固定的Cosa,-sina,sina,Cosa ); out.texcoord1=half3(mul(m,v.vertex.xz ),v.vertex.y ).xzy; # endif # if _ fancy _ stuff out.dir=v.vertex.XYZ; #endif//高度雾。 因为高度越低雾越浓,所以v.vertex.y正好相反。 由于取模型空间y值范围[-1,1 ],因此乘以2.halffogfactor=2* (1.0-_ fog color.a )-v.veector )得到的out.fog=saturate (fog //颜色转变范围[ 0,1 ]返回输出; }固定4标志(v2fin ) :SV_target )固定4 final color=te xcube (maintex,IN.texcoord ); # if _ fading _ onfixed4fading color=te xcube (_ maintex 2,IN.texcoord1); finalcolor=lerp(finalcolor,fadingColor,_GlobalFadingFactor ); # endiffinalcolor=lerp (final color,_FogColor,IN.fog ); #if _FANCY_STUFF//太阳half3dir=normalize(in.dir ); //因为天空盒的中心是世界的原点,所以位置在方向. half3dir _ sun=normalize (globalmainlightdir.XYZ ); halfdis=Length(dir_sun-dir ) * _SunDistance; finalcolor=(saturate(max(1/dis,0.01 ) ) * _GlobalMainLightColor ) * _SunPower; #endiffinalColor.a=0; //美术制作天盒阿尔法通道后开放返回最终颜色; }ENDCG}}Fallback Off}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。

  • 相关阅读