Fix shaders for reverse z

This commit is contained in:
ExMatics HydrogenC
2024-06-04 09:30:26 +08:00
parent cde3e3d710
commit eab4a8c404
8 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ void RenderView::Prepare(RenderContext& renderContext)
void RenderView::PrepareCache(const RenderContext& renderContext, float width, float height, const Float2& temporalAAJitter, const RenderView* mainView)
{
// The same format used by the Flax common shaders and postFx materials
ViewInfo = Float4(1.0f / Projection.M11, 1.0f / Projection.M22, Far / (Far - Near), (-Far * Near) / (Far - Near) / Far);
ViewInfo = Float4(1.0f / Projection.M11, 1.0f / Projection.M22, Near / (Far - Near), (Far * Near) / (Far - Near) / Far);
ScreenSize = Float4(width, height, 1.0f / width, 1.0f / height);
TemporalAAJitter.Z = TemporalAAJitter.X;
+2 -2
View File
@@ -277,8 +277,8 @@ void DepthOfFieldPass::Render(RenderContext& renderContext, GPUTexture*& frame,
cbData.BokehTargetSize.Y = static_cast<float>(bokehTargetHeight);
// TODO: use projection matrix instead of this far and near stuff?
cbData.ProjectionAB.X = farPlane / (farPlane - nearPlane);
cbData.ProjectionAB.Y = (-farPlane * nearPlane) / (farPlane - nearPlane);
cbData.ProjectionAB.X = nearPlane / (farPlane - nearPlane);
cbData.ProjectionAB.Y = (farPlane * nearPlane) / (farPlane - nearPlane);
auto cb = shader->GetCB(0);
context->UpdateCB(cb, &cbData);
+1 -1
View File
@@ -396,7 +396,7 @@ bool GBufferPass::IsDebugView(ViewMode mode)
void GBufferPass::SetInputs(const RenderView& view, GBufferData& gBuffer)
{
// GBuffer params:
// ViewInfo : x-1/Projection[0,0] y-1/Projection[1,1] z-(Far / (Far - Near) w-(-Far * Near) / (Far - Near) / Far)
// ViewInfo : x-1/Projection[0,0] y-1/Projection[1,1] z-(Near / (Far - Near)) w-((Far * Near) / (Far - Near))
// ScreenSize : x-Width y-Height z-1 / Width w-1 / Height
// ViewPos,ViewFar : x,y,z - world space view position w-Far
// InvViewMatrix : inverse view matrix (4 rows by 4 columns)