Prismatic Shader
by on June 14, 2016 in Uncategorized

Here’s the results of my Prismatic Shader:

I wanted it to reflect kind of like rainbows in gasoline. It’s not perfect but I think it’s pretty nice!

[sourcecode language="csharp"]
Shader "Custom/Prismatic" {
 Properties {
 _Color ("Color", Color) = (1,1,1,1)
 _MainTex ("Albedo (RGB)", 2D) = "white" {}
 _Glossiness ("Smoothness", Range(0,1)) = 0.5
 _Emission("Emission", Range(0,3)) = 0.0
 _Metallic ("Metallic", Range(0,1)) = 0.0
 _Cube("Cubemap", CUBE) = "" {}
 }
 SubShader {
 Tags { "RenderType"="Opaque" }
 LOD 200
 
 CGPROGRAM
 #pragma surface surf Standard fullforwardshadows

 #pragma target 3.0

 sampler2D _MainTex;
 sampler2D _RampTex;

 struct Input {
 float2 uv_MainTex;
 float3 worldRefl;
 };
 half _Emission;
 half _Glossiness;
 half _Metallic;
 half _Shifter;
 fixed4 _Color;

 float3 _CamPosition;
 samplerCUBE _Cube;

 void surf (Input IN, inout SurfaceOutputStandard o) {
 float3 n = WorldNormalVector(IN, o.Normal);
 fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
 
 o.Albedo = c.rgb * (n);// *_WorldSpaceCameraPos);

 o.Metallic = _Metallic;
 o.Smoothness = _Glossiness;
 o.Alpha = c.a;
 o.Albedo *= abs(n);
 o.Emission = texCUBE(_Cube, IN.worldRefl).rgb * _Emission * (n * _WorldSpaceCameraPos);
 }
 ENDCG
 } 
 FallBack "Diffuse"
}

[/sourcecode]

 

Leave a Reply

2014 Prismic Studios LLC © ALL RIGHTS RESERVED. Gnomes vs. Fairies TM