2013年12月10日

Phong 模型解释

摘要: Phong模型 1 1 inline fixed4 LightingPhong (SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten) 2 2 { 3 3 float diff = dot(s.Normal, lightDir); 4 4 float3 reflectionVector = normalize(2.0 * s.Normal * diff - lightDir); 5 5 float spec = pow(max(0,dot(reflectionVector,viewDir))... 阅读全文

posted @ 2013-12-10 15:59 0x9801 阅读(775) 评论(0) 推荐(0)

Unity Shader杂项

摘要: 法线强度float3 normalMap = UnpackNormal(tex2D(_NormalTex, IN.uv_MainTex));NormalMap = float3(normalMap.x * _NormalIntensity, NormalMap.y * _NormalIntensity, normalMap.z ) 阅读全文

posted @ 2013-12-10 11:09 0x9801 阅读(238) 评论(0) 推荐(0)

Ramp Texture

摘要: 以光照与目视点夹角(0,1)值为uv值,取ramp texture的颜色点改变光照颜色。最终效果是不同光照角度看起来有不同的颜色。inline float4 LightingBasicDiffuse (SurfaceOutput s, fixed3 lightDir, fixed atten){ float difLight = dot(s.Normal,lightDir); float hLambert = difLight * 0.5 + 0.5; float3 ramp = tex2D(_RampTex,float2(hLambert)).rgb; float4 ... 阅读全文

posted @ 2013-12-10 09:56 0x9801 阅读(1111) 评论(0) 推荐(0)

导航