16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 13:59:19 +02:00

add depth prepass in preparation for moving from deferred back to forward renderer

This commit is contained in:
Wls50
2025-11-23 09:19:44 +01:00
committed by Hirek
parent 915e4c769e
commit 593a8a288f
10 changed files with 201 additions and 53 deletions

View File

@@ -7,6 +7,12 @@ struct VertexInput {
float4 m_Tangent : Tangent;
};
#ifdef PREPASS
struct VertexOutput {
float2 m_TexCoord : TexCoord;
float4 m_PositionSV : SV_Position;
};
#else
struct VertexOutput {
float3 m_Position : Position;
float3 m_Normal : Normal;
@@ -16,6 +22,7 @@ struct VertexOutput {
float4 m_PositionCS : PositionCS;
float4 m_HistoryPositionCS : HistoryPositionCS;
};
#endif
cbuffer VertexConstants : register(b0) {
float4x4 g_JitteredProjection;
@@ -29,14 +36,17 @@ VertexOutput main(in VertexInput vs_in) {
VertexOutput result;
float4x3 model_view = GetModelView();
float4x3 model_view_history = GetModelViewHistory();
result.m_Position = mul(float4(vs_in.m_Position, 1.), model_view).xyz;
result.m_Normal = mul(float4(vs_in.m_Normal, 0.), model_view).xyz;
float3 view_space_position = mul(float4(vs_in.m_Position, 1.), model_view).xyz;
result.m_TexCoord = vs_in.m_TexCoord;
result.m_PositionSV = mul(g_JitteredProjection, float4(view_space_position, 1.));
#ifndef PREPASS
result.m_Normal = mul(float4(vs_in.m_Normal, 0.), model_view).xyz;
result.m_Position = view_space_position;
result.m_Tangent.xyz = mul(float4(vs_in.m_Tangent.xyz, 0.), model_view).xyz;
result.m_Tangent.w = vs_in.m_Tangent.w;
result.m_PositionSV = mul(g_JitteredProjection, float4(result.m_Position, 1.));
result.m_PositionCS = mul(g_Projection, float4(result.m_Position, 1.));
float3 history_position = mul(float4(vs_in.m_Position, 1.), model_view_history);
result.m_HistoryPositionCS = mul(g_ProjectionHistory, float4(history_position, 1.));
#endif
return result;
}