Shader based on depth with orthographic camera
Hi !
I noticed that shaders for water edge blending, foam effects or any script that rests on detecting shores, did not work with orthographic camera. Through research, I figured out that it is likely to be a depth buffer problem or something but I haven't found any solution yet... Is there any way to get foam effects using an orthographic camera ?
To be more specific, these shaders tend to use this kind of functions to determine where is the shore (in other words, where the water mesh does intersect something else) :
float sceneZ = (LinearEyeDepth(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.ref)).r));
float objectZ = i.ref.z;
float intensityFactor = 1 - saturate((sceneZ - objectZ) / _FoamStrength);
(from here : https://drive.google.com/file/d/0B4LJksp0Jr1rNnFkdGhlZmZDdVU/view)
or
half depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.screenPos));
depth = LinearEyeDepth(depth);
edgeBlendFactors = saturate(_InvFadeParemeter * (depth-i.screenPos.w));
edgeBlendFactors.y = 1.0-edgeBlendFactors.y;
[...]
baseColor.a = edgeBlendFactors.x;
(from the Water4 asset)
And these particular lines of code seem not to work with orthographic cameras, since the buffer does not behave the same way, at least I guess. So I'm desperately looking for a mean to "detect" shores anyway.
I hope i've been clear enough. Many thanks !
Your answer
![](https://koobas.hobune.stream/wayback/20220612102445im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why does my mirror not reflect my water shader? 0 Answers
Water Shader Issue 0 Answers
Problem with an Outline shader's depth 0 Answers
Shader Graph low poly water normals 1 Answer
Water shader change 0 Answers