Hi, is it possible to make a 180° rotation to the screenPos vector?
I have the reflexion of my object but I want my reflexion not to be inverted so I figured to multiply the screenPos vector (the on I use as a coordinate for my _GrabTexture) by a 2x2 180° rotation matrix (-1,0,0,-1) and when I do that, the reflexion just disapear…
OUT.viewDirWorldReflect = -WorldSpaceViewDir(v.vertex); //<–flipped texture coordinate for reflection in a vertex fragment
and then;
float3 reflectionVec = normalize(reflect(IN.viewDirWorldReflect ,worldNormal));
Thanks for the reply but I don’t understand in which part of my code I should use the reflectionVec because it’s a float3 and I need a float2 as a coordinate for my _GrabTexture UV!
oh sorry i was thinking you would use a cube texture for reflection.
For the grabpass texture, you can check the example for refractive glass shader which comes with unity pro.
They use somethin like the following to flip the texture: #if UNITY_UV_STARTS_AT_TOP
float scale = -1.0; #else
float scale = 1.0; #endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
o.uvgrab.zw = o.vertex.zw;
I found the shader you mentionned and followed the creation of the uvgrab coordinates step by step. However, when I switch my screenPos for the uvgrab coordinates, my reflection is not visible on the screen…
In Fact, I’d just like to reverse upside down my ScreenPos coordinates beceause I managed to display my reflection of my mesh on the wave with the screenPos coordinate, but I’d like to reverse these to actually project a second projection on the wave in order to see my mesh when he is behind it! Here is a low res (sorry) to explain better!
I tried multiple Math thing to the screenPos vector4 (including multiplication by rotation matrix) but in vain…) so if someone knows how to do it, please let me know! :]
Maybe before and/or after multiplying my rotation matrix I have to multiply a translation matrix in order to rotate it with the pivot in the center, maybe that’s why my texture disappear when rotating?