Facepunch / sbox-issues

176 stars 12 forks source link

VR: Graphics.RenderToTexture doesn't work in Renderhooks #2793

Open Adesii opened 1 year ago

Adesii commented 1 year ago

Describe the bug

When i use RenderToTexture in a renderhook (most likely on a CustomSceneObject too) It spams the Console once and then outputs black afterwards in the RenderTarget. When using Camera.Main as the SceneCamera the game just Crashes after compiling is finished.

This issue only occurs in VR. the same Test Project works just fine without VR.

To Reproduce

  1. Open Test project in SteamVR Mode
  2. See a black Sphere in the middle of the platform on Flatgrass
  3. uncomment the Camera.Main example and the game crashes

Test Project : rendertotexturebug.zip

Expected behavior

It should render like in the Non-Vr version.

I wanted to use this to get Portals in VR, and using the Camera.Main for the SceneCamera after offseting it for the eyes since i would assume it would have the VR Settings that the user sees to make the portals seamless.

I wanted to go this approach because ScenePortals just don't really want to Work in VR.

Media/Files

No response

Additional context

Im using a Oculus Rift CV1. don't know if its a hardware issue with my Headset or a general VR issue since i don't have multiple

handsomematt commented 1 year ago

What does it spam the console with?

Does it work with r_stereo_multiview_instancing 0?

Can also test if it's a bug specific to multiview instancing or VR by trying in desktop from the Debug Menu

image

Adesii commented 1 year ago

Right.. i should have probably posted the logs. im quite tired sry lol Log.1085.log

Also Tested it in VR with r_stereo_multiview_instancing 0 and vr_multiview_instancing 0 didn't work

It works fine without VR and with the Stereo Rendering Enabled image

handsomematt commented 1 year ago

Cool that narrows it down a lot, it'll be a few weeks until I can look into this however though sorry

Adesii commented 1 year ago

Its fine. Was just a fun side project i wanted to try to get working. I'll just ignore the portals for now and focus more on getting the mechanics working.