Download

UE4.26.1, Hololens 2 - Can't write linear mask with Scene Capture 2D

Hello everyone,

[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.
Screenshots attached.

Gradient image is a completely straight plane in editor / VR Preview:

](filedata/fetch?id=1870843&d=1615603166)

Gradient image has a slight bend on Hololens 2:

](filedata/fetch?id=1870842&d=1615603166)

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):
terrain_intention.jpg](filedata/fetch?id=1870844&d=1615603241)

Update:
By setting RT and all samplers to “Data” and using Canvas functions to copy the gradient over, it seems I am able to sample linear values from the render target.
It seems that “Render material to Render Target” applied a curve. (midway point was 0.7 vs expected 0.5 … now it’s 0.49 which is close enough.)

However, it seems that the Scene Capture 2D still applies non-linear data when I try to render the mesh. Will try to update the first post to reflect. :slight_smile: