mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
59 lines
1.7 KiB
HLSL
59 lines
1.7 KiB
HLSL
#pragma pack_matrix(column_major)
|
|
|
|
struct VertexInput {
|
|
float3 m_Position : Position;
|
|
float3 m_Normal : Normal;
|
|
float2 m_TexCoord : TexCoord;
|
|
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;
|
|
float2 m_TexCoord : TexCoord;
|
|
float4 m_Tangent : Tangent;
|
|
float4 m_PositionSV : SV_Position;
|
|
float4 m_PositionCS : PositionCS;
|
|
float4 m_HistoryPositionCS : HistoryPositionCS;
|
|
};
|
|
#endif
|
|
|
|
cbuffer VertexConstants : register(b0) {
|
|
float4x4 g_JitteredProjection;
|
|
float4x4 g_Projection;
|
|
float4x4 g_ProjectionHistory;
|
|
};
|
|
|
|
#include "manul/draw_constants.hlsli"
|
|
|
|
#ifdef NO_JITTER
|
|
#define PROJECTION g_Projection
|
|
#else
|
|
#define PROJECTION g_JitteredProjection
|
|
#endif
|
|
|
|
VertexOutput main(in VertexInput vs_in) {
|
|
VertexOutput result;
|
|
float4x3 model_view = GetModelView();
|
|
float4x3 model_view_history = GetModelViewHistory();
|
|
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(PROJECTION, 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_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;
|
|
}
|