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);

Have you tried flipping it back in the shader?

float4 Tex2D0=tex2D(_GrabTexture, float2(Add2.x, 1.0-Add2.y));
  • 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. – Thomas Mathieson Sep 2 '15 at 15:48
  • 2
    @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. – DMGregory Nov 3 '15 at 13:34

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.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.