20
2014
Beach Sand Water (shader)
Quick test for beach shader..
Inspiration from this topic: http://forum.unity3d.com/threads/229473-Wet-beach-texture
Info:
– Nothing much happening there, beach has moving mask to change color
– Water plane has moving vertices and quite basic normal mapped transparent shader
– Transparency glitches here & there.. (goes out of sync from moving?)
– Made sand normal map with this : ) normalmapmaker
Webplayer:
http://unitycoder.com/upload/demos/BeachSandWaterShader1/ (~3.7mb)
Sand texture:
http://hhh316.deviantart.com/art/Seamless-desert-sand-texture-183159331
—
Water shader (quite broken)
Shader "UnityCoder/SeaBeachTest1" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} // _Perturb ("Perturb", 2D) = "black" {} _Mask ("Mask", 2D) = "black" {} _BumpMap ("Normal map", 2D) = "bump" {} _BumpMap2 ("Normal map2", 2D) = "bump" {} } SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 300 CGPROGRAM #pragma surface surf BlinnPhong alpha vertex:vert sampler2D _MainTex; sampler2D _Mask; //sampler2D _Perturb; sampler2D _BumpMap; sampler2D _BumpMap2; fixed4 _Color; half _Shininess; struct Input { float2 uv_MainTex; float2 uv_Mask; //float3 worldPos; }; void vert (inout appdata_full v) { v.vertex.z += (_SinTime.y*0.5f-0.5f)*10; } void surf (Input IN, inout SurfaceOutput o) { fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); float2 pan = float2(0,(_SinTime.y*0.5f-0.5f)); fixed4 norm1 = tex2D(_BumpMap, IN.uv_MainTex+pan*0.2f); fixed4 norm2 = tex2D(_BumpMap2, IN.uv_MainTex+pan*0.22f); fixed water = tex2D(_Mask, IN.uv_Mask).a; o.Albedo = tex.rgb * _Color.rgb; o.Gloss = tex.a; o.Alpha = ((1-_SinTime.y)*(tex.a*2 * _Color.a))-(1-water); o.Specular = tex.r*_Shininess; o.Normal = UnpackNormal(lerp(norm1,norm2,tex.r)); } ENDCG } Fallback "Transparent/VertexLit" }
Beach shader (quite broken)
Shader "UnityCoder/BeachSandTest1" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _CutOff ("CutOff", Range (0.0, 1)) = 0.5 _MainTex ("Base (RGB)", 2D) = "white" {} _BumpMap ("Normal map", 2D) = "bump" {} _SpecMap ("Specular map", 2D) = "black" {} _Mask ("Mask", 2D) = "black" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 400 CGPROGRAM #pragma surface surf BlinnPhong #pragma exclude_renderers flash #pragma target 3.0 sampler2D _MainTex; sampler2D _BumpMap; sampler2D _SpecMap; sampler2D _Mask; fixed4 _Color; fixed _CutOff; half _Shininess; struct Input { float2 uv_MainTex; float2 uv_Mask; }; void surf (Input IN, inout SurfaceOutput o) { float2 pan = float2(0,_SinTime.y*0.5f-0.5f); fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); // fixed wet = clamp(tex2D(_Mask, IN.uv_Mask+pan).r,0,0.5f); //,0,_CutOff)*2; fixed wet = tex2D(_Mask, IN.uv_Mask+pan).r; //fixed wet = tex2D(_Mask, IN.uv_Mask).r; // fixed4 specTex = tex2D(_SpecMap, IN.uv_MainTex+pan); fixed4 specTex = tex2D(_SpecMap, IN.uv_MainTex); fixed4 specTex2 = tex2D(_SpecMap, IN.uv_MainTex+pan*0.2f); float4 norm1 = tex2D(_BumpMap, IN.uv_MainTex); float4 norm2 = tex2D(_BumpMap, IN.uv_MainTex+pan*2); fixed4 tex2 = tex2D(_MainTex, IN.uv_MainTex+pan); //fixed3 c = tex.rgb; fixed3 cc = lerp(tex.rgb,tex2.rgb*0.2f,wet*_CutOff); float g = clamp(lerp(specTex2.r,0,cc.r),0,1); float g2 = clamp(lerp(specTex.r,specTex2.r,wet),0,1); o.Albedo = cc; o.Gloss = g; //o.Emission = g*10; o.Alpha = 1; //tex.a * _Color.a; o.Specular = g2;//*_Shininess;// * specTex.g * wet; o.Normal = UnpackNormal(lerp(norm1,norm2,g)); } ENDCG } FallBack "Specular" }
Related Posts
2 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
nice sea shader images here:
http://forum.unity3d.com/threads/229118-Visualization-of-Earth-s-beauty-Dev-Diary
added shader sources (not really useful, quite broken)