imagination XD

realizing dream

[Shader] Reflective Transparent / Water-like Unity Indie

Leave a comment

This is what I promised. Sorry for being late, I’m kinda busy recently. I made this shader by merging between Transparent>Diffuse and Reflective>Diffuse. But I haven’t done with Normal Mapped Specular. My Unity kinda hates me, everytime I add Normal Map to this shader Unity Yells “Too many texture interpolators would be used for ForwardBase pass!” or “_ReflectColor no Properties!”. Perhaps you can do it yourself.

NOTE : I didn’t copy this script from internet. I just merge Unity’s Transparent>Diffuse and Reflective>Diffuse. So, if you are saying that I copy your script like that movie script I was made in 2012 and you found in 2014, go f*** yourself… By the way, this script ALREADY Exist on Nitro Racer XD on Epic Living Room track. I just made a lot of modification from Nitro Racer XD.

Shader name in Unity is “Glass Reflective_N”, and this is the preview / how to use the shader.

Ref_BLWater Ref_Full Ref_BLRef Ref_MStUnity - Untitled - RT - PC, Mac & Linux Standalone_4

Want More Realistic ?

If you want more realistic, you could add UVMover (Moving main texture’s offset from script * Time.deltaTime), and Realtime Reflection INDIE. Adding some Caustic effects or Underwater effects or Normal Map or Specular Shininess. You can also use this shader for a glass…

Glass Reflective_N

Shader name is a little bit ironic isn’t it ? It says N for Normal Map support, but this shader couldn’t support Normal Map. Alright here’s the shader.

Shader "Glass Reflective_N" {
 Properties {
 _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
 _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
 //_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {}
 //_BumpMap ("Normalmap", 2D) = "bump" {}
 _Cube ("Reflection Cubemap", Cube) = "black" { TexGen CubeReflect }
 }
 SubShader {
 Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
 Blend SrcAlpha OneMinusSrcAlpha
 //Pass {
 // Color [_Color]
 // SetTexture [_MainTex] {
 // combine texture * primary
 // }
 // }
 LOD 300
 
 CGPROGRAM
 //#pragma surface surf BlinnPhong decal:add nolightmap
 #pragma surface surf BlinnPhong alpha
 //#pragma target 3.0
 sampler2D _MainTex;
 //sampler2D _BumpMap;
 samplerCUBE _Cube;
 //half _Shininess;
 
 fixed4 _ReflectColor;
 fixed4 _Color;
 
 struct Input {
 float3 worldRefl;
 float2 uv_MainTex;
 //float2 uv_BumpMap;
 INTERNAL_DATA
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
 fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
 //o.Albedo = 1;
 //o.Gloss = 0;
 o.Albedo = tex.rgb * _Color.rgb;
 o.Gloss = tex.a;
 //o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
 
 //o.Specular = _Shininess;
 float3 worldRefl = WorldReflectionVector (IN, o.Normal);
 fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);
 reflcol *= tex.a;
 o.Emission = reflcol.rgb * _ReflectColor.rgb;
 //o.Alpha = reflcol.a * _ReflectColor.a;
 o.Alpha = tex.a * _Color.a;
 
 }
 ENDCG
 }
 FallBack "Transparent/VertexLit"
}

 

Advertisements

Author: IMGVERTEX

Started making games since 13 year old. 3D CGI Weeaboo | VFX Otaku | Anime Researcher | Indie Game Dev | VR Chuunibyou

FEED ME

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s