3
\$\begingroup\$

So I was making a water shader in unity and well it looked fine in the scene view but as soon as I went into the game view the refraction texture basically flipped up 180 degrees and made it look like the water was reflective. The problem with this is that it breaks the transparency of the shader.


Scene View (how it should look): Scene View

Game View (how it does look): Game View

Shader: (I can't post more than 2 images)

Part of the shader:

float4 Lerp2=lerp(Tex2D2,float4( 0.0, 0.0, 0.0, 0.0 ),_Refraction.xxxx);
float4 Subtract0=Lerp2 - _RefractionCorrection.xxxx;
float4 Add2=((IN.screenPos.xy/IN.screenPos.w).xyxy) + Subtract0;
float4 Tex2D0=tex2D(_GrabTexture,Add2.xy);
\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

Have you tried flipping it back in the shader?

float4 Tex2D0=tex2D(_GrabTexture, float2(Add2.x, 1.0-Add2.y));
\$\endgroup\$
2
  • \$\begingroup\$ Well it makes it work in game view but messes up the scene view, but that's the only solution I have at the moment so thanks anyway. \$\endgroup\$ Sep 2, 2015 at 15:48
  • 2
    \$\begingroup\$ @ThomasMathieson Check this Unity documentation on platform-specific rendering differences: in some cases, Unity will use inconsistent vertical orientations for RenderTextures. There's a suggested code snippet in there to catch these cases and flip your lookups only when needed. \$\endgroup\$
    – DMGregory
    Nov 3, 2015 at 13:34
0
\$\begingroup\$

This is a shot in the dark. Check the scene output for different rendering path options for the main camera. My distortion shader acted weird for deferred rendering, got no clue why. It got fixed for forward rendering path.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .