project-aster/samples/03_model_render/shader/background.vs.hlsl

32 lines
749 B
HLSL

#include "graphics_structs.hlsli"
struct VS_Input
{
uint VertexIndex : SV_VertexID;
};
struct VS_Output
{
float4 VertexPosition : SV_Position;
float3 WorldPosition : POSITION;
};
VS_Output main(VS_Input StageInput)
{
float3 Points[] =
{
float3(-1.0f, -1.0f, 1.0f),
float3(3.0f, -1.0f, 1.0f),
float3(-1.0f, 3.0f, 1.0f),
};
VS_Output StageOutput;
StageOutput.VertexPosition = float4(Points[StageInput.VertexIndex], 1.0f);
float4 ClipSpace = mul(Camera.InvProjection, float4(Points[StageInput.VertexIndex], 1.0f));
float4 WorldSpace = mul(Camera.InvView, ClipSpace / ClipSpace.wwww);
StageOutput.WorldPosition = WorldSpace.xyz;
return StageOutput;
}