57 lines
1.4 KiB
Plaintext
57 lines
1.4 KiB
Plaintext
import bindless;
|
|
import ibl_common;
|
|
import common_structs;
|
|
|
|
const static float3 trianglePoints[] = {
|
|
float3(-1.0f, -1.0f, 1.0f),
|
|
float3(3.0f, -1.0f, 1.0f),
|
|
float3(-1.0f, 3.0f, 1.0f),
|
|
};
|
|
|
|
[vk::push_constant]
|
|
uniform Block pcb;
|
|
|
|
struct VS_Output
|
|
{
|
|
float4 vertexPosition : SV_Position;
|
|
float3 worldPosition : World_Position;
|
|
};
|
|
|
|
[shader("vertex")]
|
|
VS_Output vsmain(
|
|
uint vertexId : SV_VertexID
|
|
)
|
|
{
|
|
VS_Output stageOutput;
|
|
stageOutput.vertexPosition = float4(trianglePoints[vertexId], 1.0f);
|
|
|
|
float4 clipSpace = mul(float4(trianglePoints[vertexId], 1.0f), pcb.camera[0].invProj);
|
|
float4 worldSpace = mul(clipSpace / clipSpace.wwww, pcb.camera[0].invView);
|
|
stageOutput.worldPosition = worldSpace.xyz;
|
|
|
|
return stageOutput;
|
|
}
|
|
|
|
[shader("fragment")]
|
|
float4 fsmain(float3 worldPosition: World_Position) : SV_Target0
|
|
{
|
|
float3 direction = normalize(worldPosition - pcb.camera[0].position.xyz);
|
|
#ifndef _DEBUG
|
|
float4 color = pcb.lights[0].environment.Sample(direction);
|
|
#else
|
|
float4 color;
|
|
if (pcb.showDiffuse)
|
|
{
|
|
color = pcb.lights[0].diffuseIrradiance.Sample(direction);
|
|
}
|
|
else if (pcb.showPrefilter)
|
|
{
|
|
color = pcb.lights[0].prefilter.Sample(direction);
|
|
}
|
|
else
|
|
{
|
|
color = pcb.lights[0].environment.Sample(direction);
|
|
}
|
|
#endif
|
|
return float4(Uncharted2Tonemap(color.rgb), color.a);
|
|
} |