Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast Stereo Rendering for VR #877

Open
RobertBeckebans opened this issue Apr 13, 2024 · 0 comments
Open

Fast Stereo Rendering for VR #877

RobertBeckebans opened this issue Apr 13, 2024 · 0 comments

Comments

@RobertBeckebans
Copy link
Owner

From https://docs.google.com/presentation/d/19x9XDjUvkW_9gsfsMQzt3hZbRNziVsoCEHOn4AercAc/edit#slide=id.g5791d9ed1_015

  1. Use a combined stereo rendertarget with has the size for both eyes. If the res is 2160x2160 it would be 4320x2160.
  2. Form a combined frustum of both eye frustums for culling in the renderer frontend
  3. Only emit 1 3D view and iterate it only once
  4. Use instancing for each drawcall and use InstanceID to offset it between the left or the right eye "fake" stereo rendertarget
  5. Use Shader clipping instead of the Scissor mechanism to avoid leaking meshes into the other eye rendertarget

This probably needs a rewrite of all vertex shaders but it's worth the effort.

Pseudocode:

Matrix WorldToEyeClipMatrix[2] // computed from SDK
Vector4 EyeClipEdge[2]={(-1,0,0,1), (1,0,0,1)}
float EyeOffsetScale[2]={0.5,-0.5}

uint eyeIndex = instanceID & 1   // use low bit as eye index.

Vector4 clipPos = worldPos * WorldToEyeClipMatrix[eyeIndex]
cullDistanceOut.x = clipDistanceOut.x = clipPos · EyeClipEdge[eyeIndex]

clipPos.x *= 0.5; // shrink to half of the screen
clipPos.x += EyeOffsetScale[eyeIndex] * clipPos.w; // scoot left or right.
clipPositionOut = clipPos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant