[UPDATE: I am now able to sample linear values from the Render Target, but the Scene Capture 2D is spitting out sRGB values into my Render Target.]
I am trying to interactively displace a terrain using a 2D render target texture. This involves two 128x128 R32F render targets, a scene capture 2D, and a shader that picks the minimum between its depth and what is stored in the “front” buffer.
This works well in editor and VR preview mode, but not on the device. Even with a straight gradient image (not scene capture) the surface is curved; sampling must be multiplied against a curve eg. sRGB.
Gradient image is a completely straight plane in editor / VR Preview:
Gradient image has a slight bend on Hololens 2:
I have tried the following to get around this:
- Tried “Linear Color” and “mask” on texture samplers / images
- Uncheck sRGB on initial heightmap image content
- Uncheck “sRGB” on render targets
- Uncheck tone mapping / gamut curve on the scene capture 2D
- Uncheck everything for post processing on the scene capture 2D and set post blend to 0.0
- Tried “final color (LDR) RGB” on the scene capture; did not render on the device at all
- Tried “Scene Depth” into an R32 texture. It did not have good results on the device
- Use Canvas to copy instead of “render material to render target”; this actually made the copy more accurate
This is driving me absolutely bonkers. In practice, the terrain displacement looks off and magically regrows when you wave your hands over it.
Any thoughts at all are greatly appreciated. Thank you so much!
Here is what I am ultimately going for (VR preview mode):