I’m playing with custom render pipeline, which is quite simple at the moment. First, I render scene with MRT shader, which outputs 2 textures: color and custom data. Then DrawSkybox() into color tex. And finally Blit() from color tex to CameraTarget with post fx shader, which uses data tex. All shader code is written on HLSL and I’m using Core RP Library. To this moment I never had an issue with flipped picture, but I knew it could happen.
So, today I was rewriting some code. The only meaningful thing I did was changing declaration of render textures. I changed this:
buffer.GetTemporaryRT(colorTexID, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.Default);
to this:
RenderTextureDescriptor basicTexDesc = new RenderTextureDescriptor()
{
dimension = TextureDimension.Tex2D,
graphicsFormat = GraphicsFormat.R8G8B8A8_UNorm,
width = camera.pixelWidth,
height = camera.pixelHeight,
depthBufferBits = 0,
msaaSamples = 1,
sRGB = false,
useMipMap = false,
autoGenerateMips = false
};
buffer.GetTemporaryRT(colorTexID, basicTexDesc, FilterMode.Point);
After that change the render flipped upside down. So I went to dedicated manual page and began to try different stuff they suggest. I believe I only need to adjust post fx shader, right? So, adding this to Vertex program doesn’t do anything:
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
output.uv.y = 1-output.uv.y;
#endif
This fixed an issue, but ONLY in editor window, in game view it remains flipped:
float u = input.uv.x;
float v = (_ProjectionParams.x > 0) ? input.uv.y : 1 - input.uv.y;
output.uv = float2(u, v);
What am I doing wrong?