{"id":589,"date":"2012-02-12T03:53:54","date_gmt":"2012-02-12T00:53:54","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=589"},"modified":"2013-08-15T22:23:21","modified_gmt":"2013-08-15T19:23:21","slug":"fake-water-shader-refraction","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/02\/12\/fake-water-shader-refraction\/","title":{"rendered":"Fake Water Shader"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver4\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"590\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/12\/fake-water-shader-refraction\/mfakeriverrefractionreflection1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mFakeRiverRefractionReflection1.jpg?fit=680%2C388&amp;ssl=1\" data-orig-size=\"680,388\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"mFakeRiverRefractionReflection1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mFakeRiverRefractionReflection1.jpg?fit=680%2C388&amp;ssl=1\" class=\"alignnone size-full wp-image-590\" title=\"mFakeRiverRefractionReflection1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mFakeRiverRefractionReflection1.jpg?resize=680%2C388\" width=\"680\" height=\"388\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mFakeRiverRefractionReflection1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mFakeRiverRefractionReflection1.jpg?resize=300%2C171&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Testing &#8220;fake&#8221; water shader &amp; trying to make a nice looking river scene (with unity free version..)<\/p>\n<p><strong>Webplayer(s):<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver4\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver4\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver4\/<\/a> (*7mb)<br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/<\/a><\/p>\n<p><strong>Current &#8220;features&#8221;:<\/strong><\/p>\n<ul>\n<li>Terrain textures &amp; stones are from: <a title=\"http:\/\/u3d.as\/content\/forst\/advanced-terrain-shaders-v2\/2Bo\" href=\"http:\/\/u3d.as\/content\/forst\/advanced-terrain-shaders-v2\/2Bo\" target=\"_blank\">Advanced Terrain Shaders v2<\/a><\/li>\n<li>Terrain modeled with heightmap, imported to Unity with <a title=\"http:\/\/forum.unity3d.com\/threads\/91018-mTerrain-(3dsMax-mesh-to-Unity-terrain)\" href=\"http:\/\/forum.unity3d.com\/threads\/91018-mTerrain-(3dsMax-mesh-to-Unity-terrain)\" target=\"_blank\">mTerrain<\/a><\/li>\n<li>Unity Terrain + normal\u00a0 flat mesh plane for the river<\/li>\n<li>Custom &#8220;water&#8221; shader: Kind of fake reflection\/refraction look by using 2 textures (*image#2)<\/li>\n<li>UV anim + Weird Waves &#8220;DepthBlur&#8221; or Refraction (?)<\/li>\n<li>Problem: Cannot see through the water at all..<\/li>\n<\/ul>\n<p><strong>Ideas \/ Todo\/ItWontWork:<\/strong><\/p>\n<ul>\n<li>Perlin noise for the waves?<\/li>\n<li>Normal \/ Vertex Bump\/Displacement?<\/li>\n<li>Extra Texture layers (one more thin surface fx? more visible river bottom texture?)<\/li>\n<li>Cubemap reflection?<\/li>\n<li>Distance Blur?<\/li>\n<li>Interactive object-on-water fx? (water texture color based on object distance? animated ripples coming out from the object?)<\/li>\n<li>Sides should have slower speed +\u00a0 less sky reflection + more ground color (transparency?)<\/li>\n<li>Add particles for water splashing (but a rock on the river?)<\/li>\n<li>Fake vignetting with unity free version? (screen sized plane, with vignette texture, drawn on top of everything?)<\/li>\n<li>Fake Caustics with caustics map?, heres a nice <a title=\"http:\/\/www.dualheights.se\/caustics\/#images\" href=\"http:\/\/www.dualheights.se\/caustics\/#images\" target=\"_blank\">Caustics Generator<\/a><\/li>\n<\/ul>\n<h2><strong>Download source:<\/strong><\/h2>\n<p><a title=\"Download Source\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=222&amp;uid=un1t3c0d5r\" target=\"_blank\">FakeWaterShader.unityPackage<\/a><\/p>\n<p>&#8212;<\/p>\n<p>(below)<strong> Image#2<\/strong> : Current water shader with 2 textures (12.02.2012)<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"596\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/12\/fake-water-shader-refraction\/fakewatershader1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader1.jpg?fit=680%2C391&amp;ssl=1\" data-orig-size=\"680,391\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"FakeWaterShader1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader1.jpg?fit=680%2C391&amp;ssl=1\" class=\"alignnone size-full wp-image-596\" title=\"FakeWaterShader1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader1.jpg?resize=680%2C391\" width=\"680\" height=\"391\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader1.jpg?resize=300%2C172&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&#8212;<\/p>\n<p>(below)<strong> Image#3<\/strong>: Had to redo the shader.. couldnt make it work with 1 sided planes.. Now using 2 sided box.<br \/>\nStarting to get some see thru effects, just need to animated it and add the surface blurring again.<br \/>\nMade a quick cut on the terrain..doesnt look so nice (see the edges of the terrain near river), but enough for a quick test..<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"603\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/12\/fake-water-shader-refraction\/fakewatershader2\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader2.jpg?fit=680%2C404&amp;ssl=1\" data-orig-size=\"680,404\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"FakeWaterShader2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader2.jpg?fit=680%2C404&amp;ssl=1\" class=\"alignnone size-full wp-image-603\" title=\"FakeWaterShader2\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader2.jpg?resize=680%2C404\" width=\"680\" height=\"404\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader2.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader2.jpg?resize=300%2C178&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&#8212;<\/p>\n<p>(below)<strong> Image#4:<\/strong> Notes<br \/>\n&#8211; Added Foam map (currently not moving and it looks like the river has thin ice and the water is flowing under it..)<br \/>\n&#8211; Added Cubemap reflection (not strong enough?..have to try fix that &amp; need to find better cubemaps..<br \/>\n&#8211; Problems adding vertex waves, but actually rivers dont have &#8220;sea waves&#8221;.. have to try with moving normals..(?)<br \/>\n&#8211; Idea: Create Foam around objects (based on distance?..but then cannot have many objects to do that inside shader?)<br \/>\n&#8211; Added <a title=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver4\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver4\/\" target=\"_blank\">webplayer <\/a>of this version (without the foam)<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"606\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/12\/fake-water-shader-refraction\/fakewatershaderfoam3\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3.jpg?fit=680%2C428&amp;ssl=1\" data-orig-size=\"680,428\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"FakeWaterShaderFoam3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3.jpg?fit=680%2C428&amp;ssl=1\" class=\"alignnone size-full wp-image-606\" title=\"FakeWaterShaderFoam3\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3.jpg?resize=680%2C428\" width=\"680\" height=\"428\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3.jpg?resize=300%2C188&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&#8212;<\/p>\n<p>(below)<strong> Image#5<\/strong> : Current water shader with 4 textures (13.02.2012)<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"611\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/12\/fake-water-shader-refraction\/fakewatershaderfoam3shader\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3Shader.jpg?fit=680%2C380&amp;ssl=1\" data-orig-size=\"680,380\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"FakeWaterShaderFoam3Shader\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3Shader.jpg?fit=680%2C380&amp;ssl=1\" class=\"alignnone size-full wp-image-611\" title=\"FakeWaterShaderFoam3Shader\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3Shader.jpg?resize=680%2C380\" width=\"680\" height=\"380\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3Shader.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShaderFoam3Shader.jpg?resize=300%2C167&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>&#8212;<\/p>\n<p>(below)<strong> Image#6<\/strong><\/p>\n<p>&#8211; Water is more transparent now (Transparency is based on normals)<br \/>\n&#8211;\u00a0 Got few highlights on the water, just by doubling some color values, not sure how(?) (still would need more &#8220;fake light highlights&#8221;)<br \/>\n&#8211; Tried speedMask texture (middle of the river flowed faster than the sides..but that caused texture stretching problems)<br \/>\n&#8211; Foam map failed with speedMask texture (strecthing)<br \/>\n&#8211; Tried &#8220;BlinnPhong&#8221;, but that killed Cubemap..(?) so back to &#8220;Lambert&#8221;<br \/>\n&#8211; In the image there are few stones in the water, looks ok thru the water also<br \/>\n&#8211; Maybe needs extra highlight map, middle depth map (some junk flowing inside water..)<br \/>\n&#8211; Stone should have foam around it.. (failed to get distance to stone in shader, trying again later..)<br \/>\n&#8211; Added <a title=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/\" target=\"_blank\">webplayer<\/a><\/p>\n<p><a title=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"616\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/12\/fake-water-shader-refraction\/fakewatershader3\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader3.jpg?fit=680%2C367&amp;ssl=1\" data-orig-size=\"680,367\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"FakeWaterShader3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader3.jpg?fit=680%2C367&amp;ssl=1\" class=\"alignnone size-full wp-image-616\" title=\"FakeWaterShader3\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader3.jpg?resize=680%2C367\" width=\"680\" height=\"367\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader3.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/FakeWaterShader3.jpg?resize=300%2C161&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Testing &#8220;fake&#8221; water shader &amp; trying to make a nice looking river scene (with unity free version..) Webplayer(s): http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver4\/ (*7mb) http:\/\/unitycoder.com\/upload\/demos\/mFakeRiver5\/ Current &#8220;features&#8221;: Terrain textures &amp; stones are from: Advanced Terrain Shaders v2 Terrain modeled with heightmap, imported to Unity with mTerrain Unity Terrain + [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":590,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[7,165,166,164,14,167,168,60],"class_list":["post-589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-fake","tag-reflection","tag-refraction","tag-river","tag-shader","tag-skyrim","tag-terrain","tag-water"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mFakeRiverRefractionReflection1.jpg?fit=680%2C388&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-9v","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=589"}],"version-history":[{"count":30,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/589\/revisions"}],"predecessor-version":[{"id":2324,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/589\/revisions\/2324"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/590"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}