Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

d3d11 error / i wanna make it RimLightShader

$
0
0
Hi All :-) Please answer me. answer me. I was studied about RimLighting with Unity5. This is error message. Shader error in 'Custom/Rim_light': constructors only defined for numeric base types at line 44 (on d3d11) Compiling Vertex program] and next is code(copied https://youtu.be/QRINA875mI8 ). // Shader "Custom/Rim_light" { Properties { _Color ("Color", Color) = (1.0,1.0,1.0,1.0) _SpecColor ("specular Color", Color) = (1.0,1.0,1.0,1.0) _Shininess ("Shininess", float) = 10 _RimColor ("Rim Color", Color) = (1.0,1.0,1.0,1.0) _RimPower ("Rim Power", Range(0.1,10.0))=3.0 } SubShader { Pass{ Tags { "LightMode"="ForwardBase" } CGPROGRAM #pragma vertex vert #pragma fragment frag //user defined variables uniform float4 _Color; uniform float4 _SpecColor; uniform float4 _RimColor; uniform float _Shininess; uniform float _RimPower; //unity defined var uniform float4 _LightColor0; //Base input structs struct vertexInput { float4 vertex : POSITION; float3 normal : NORMAL; }; struct vertexOutput{ float4 pos : SV_POSITION; float4 posWorld : TEXCOORD; float3 normalDir : TEXCOORD1; }; // vertex function vertexOutput vert(vertexInput v){ vertexOutput o; o.posWorld = mul(_Object2World, v.vertex); o.normalDir = normalize(mul(float4(v.normal, 0.0), _World2Object).xyz); o.pos = mul(UNITY_MATRIX_MVP, v.vertex); **return 0;** } //fragment function float4 frag(vertexOutput i) : COLOR { float3 normalDirection = i.normalDir; float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); float3 lightDirection = normalize(_WorldSpaceCameraPos0.xyz); float atten = 1.0; //light float3 diffuseReflection = atten * _LightColor0.xyz * _Color.xyz * saturate(dot(normalDirection, lightDirection)); float3 specularReflection = atten * _LightColor0.xyz * _SpecColor.xyz * saturate(dot(normalDirection, lightDirection)) * pow(saturate(dot(reflect(-lightDirection, normalDirection), viewDirection)), _Shininess); //Rim Lighting //float rim = 1-saturate(dot(normalize(viewDirection, normalDirection); //float rimLighting = atten * _LightColor0.xyz * _RimColor * saturate(dot(nomalDirection, lightDirection))*pow(rim, _RimPower); //float3 lightFinal = rimLighting + diffuseReflection + specularReflection; float rimlighting = 1-saturate(dot(viewDirection, normalDirection)); float3 lightFinal = rimLighting; return float4(lightFinal * _Color.xyz, 1.0); } ENDCG } } }

Viewing all articles
Browse latest Browse all 1875

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>