1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| Shader "BRDFDiffuse" { Properties { _EmissiveColor ("Emissive Color", Color) = (1,1,1,1) _AmbientColor ("Ambient Color", Color) = (1,1,1,1) _MySliderValue ("This is a Slider", Range(0,10)) = 2.5 _RampTex ("Ramp Texture", 2D) = "white"{} _MainTex ("Main Texture", 2D) = "white"{} } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf HelloWorld
float4 _EmissiveColor; float4 _AmbientColor; float _MySliderValue; sampler2D _RampTex; sampler2D _MainTex; inline float4 LightingHelloWorld (SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten) { float difLight = dot (s.Normal, lightDir); float rimLight = dot(s.Normal, viewDir); float hLambert = difLight * 0.5 + 0.5; float3 ramp = tex2D(_RampTex, float2(hLambert, rimLight)).rgb; float4 col; col.rgb = s.Albedo * _LightColor0.rgb * (ramp); col.a = s.Alpha; return col; }
struct Input { float2 uv_MainTex; };
void surf (Input IN, inout SurfaceOutput o) { float3 normalMap = tex2D(_MainTex, IN.uv_MainTex);
float4 c; c = pow((_EmissiveColor + _AmbientColor), _MySliderValue);
o.Albedo = c.rgb * normalMap; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }
|