您的位置:首页 > 科技 > IT业 > 音乐网站页面设计_厦门网站制作网页_时事新闻_站内搜索引擎

音乐网站页面设计_厦门网站制作网页_时事新闻_站内搜索引擎

2025/2/27 3:56:49 来源:https://blog.csdn.net/woshiyuyanjia/article/details/143961763  浏览:    关键词:音乐网站页面设计_厦门网站制作网页_时事新闻_站内搜索引擎
音乐网站页面设计_厦门网站制作网页_时事新闻_站内搜索引擎

1.Unity3D 5.4以前,灯光函数的定义:

1.half4 Lighting<Name> (SurfaceOutput s, half3 lightDir, half atten); This is  used in forward rendering path for light models that are not view direction dependent (e.g.  diffuse).2. half4 Lighting<Name> (SurfaceOutput s, half3 lightDir, half3 viewDir, half  atten); This is used in forward rendering path for light models that are view direction  dependent.3. half4 Lighting<Name>_PrePass (SurfaceOutput s, half4 light); This is used in  deferred lighting path.

2.Unity3D 5.5以后,灯光函数的定义:

half4 Lighting<Name> (SurfaceOutput s, UnityGI gi)half4 Lighting<Name> (SurfaceOutput s, half3 viewDir, UnityGI gi);half4 Lighting<Name>_Deferred (SurfaceOutput s, UnityGI gi, out half4 outDiffuseOcclusion, out half4 outSpecSmoothness, out half4 outNormal)half4 Lighting<Name>_PrePass (SurfaceOutput s, half4 light)

3.在 unitylightingcommon.cginc  中可以看到:

struct UnityGI
{UnityLight light;#ifdef DIRLIGHTMAP_SEPARATE#ifdef LIGHTMAP_ONUnityLight light2;#endif#ifdef DYNAMICLIGHTMAP_ONUnityLight light3;#endif#endifUnityIndirect indirect;
};

Shader "Custom/CustomLighting"
{Properties{_Color ("Color", Color) = (1,1,1,1)_MainTex ("Albedo (RGB)", 2D) = "white" {}_SpecPower("Specular Power",float) = 1}SubShader{Tags { "RenderType"="Opaque" }LOD 200CGPROGRAM// Physically based Standard lighting model, and enable shadows on all  light types#pragma surface surf Simple// Use shader model 3.0 target, to get nicer looking lighting#pragma target 3.0sampler2D _MainTex;struct Input{float2 uv_MainTex;};fixed4 _Color;float _SpecPower;// Add instancing support for this shader. You need to check 'Enable  Instancing' on materials that use the shader.// See https://docs.unity3d.com/Manual/GPUInstancing.html for more  information about instancing.// #pragma instancing_options assumeuniformscalingUNITY_INSTANCING_BUFFER_START(Props)// put more per-instance properties hereUNITY_INSTANCING_BUFFER_END(Props)//SurfaceOutput 输出void surf (Input IN, inout SurfaceOutput o){// Albedo comes from a texture tinted by colorfixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;o.Albedo = c.rgb;o.Alpha = c.a;}//SurfaceOutput 输入//Simple:为灯光的入口函数//lightDir:灯光的方向 viewDir 观察角方向 atten 灯光衰减值half4 LightingSimple (SurfaceOutput s, half3 lightDir, half3 viewDir, half   atten){float NDotL = dot(lightDir,s.Normal);half4 result = 0;//漫反射计算result.rgb = s.Albedo * _LightColor0 * NDotL * atten;//高光反射计算half3 H= viewDir - lightDir;float HDotN = dot(H,s.Normal);result.rgb = s.Albedo * _LightColor0 * NDotL * atten +  HDotN*_LightColor0*s.Albedo*_SpecPower;result.a = s.Alpha;return result;}ENDCG}FallBack "Diffuse"
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com