2023-01-29 18:58:59 +01:00
|
|
|
import Common;
|
|
|
|
|
|
|
|
|
|
struct VertexShaderInput
|
|
|
|
|
{
|
|
|
|
|
float3 position;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VertexShaderOutput
|
|
|
|
|
{
|
|
|
|
|
float4 clipPos : SV_Position;
|
|
|
|
|
float3 texCoords;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[[vk::push_constant]]
|
|
|
|
|
ConstantBuffer<float4x4> transformMatrix;
|
|
|
|
|
|
|
|
|
|
[shader("vertex")]
|
2023-02-01 22:13:04 +01:00
|
|
|
VertexShaderOutput vertexMain(
|
2023-01-29 18:58:59 +01:00
|
|
|
VertexShaderInput input)
|
|
|
|
|
{
|
2023-02-01 22:13:04 +01:00
|
|
|
VertexShaderOutput output;
|
|
|
|
|
float3x3 cameraRotation = float3x3(gViewParams.viewMatrix);
|
|
|
|
|
float4 worldPos = float4(mul(cameraRotation, input.position), 1.0f);
|
|
|
|
|
//clip(dot(worldPos, clipPlane));
|
|
|
|
|
output.clipPos = mul(gViewParams.projectionMatrix, worldPos);
|
|
|
|
|
output.texCoords = normalize(input.position);
|
2023-01-29 18:58:59 +01:00
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[[vk::push_constant]]
|
2023-02-01 22:13:04 +01:00
|
|
|
ConstantBuffer<float4> fogBlend;
|
2023-01-29 18:58:59 +01:00
|
|
|
|
2023-02-01 22:13:04 +01:00
|
|
|
layout(set = 0, binding = 1)
|
|
|
|
|
TextureCube cubeMap;
|
|
|
|
|
layout(set = 0, binding = 2)
|
|
|
|
|
TextureCube cubeMap2;
|
|
|
|
|
layout(set = 0, binding = 3)
|
2023-01-29 18:58:59 +01:00
|
|
|
SamplerState sampler;
|
|
|
|
|
|
2023-02-01 22:13:04 +01:00
|
|
|
static const float lowerLimit = 0.0;
|
|
|
|
|
static const float upperLimit = 0.1;
|
2023-01-29 18:58:59 +01:00
|
|
|
|
2023-02-01 22:13:04 +01:00
|
|
|
[shader("fragment")]
|
|
|
|
|
float4 fragmentMain(
|
|
|
|
|
VertexShaderOutput output) : SV_Target
|
2023-01-29 18:58:59 +01:00
|
|
|
{
|
|
|
|
|
float4 texture1 = cubeMap.Sample(sampler, output.texCoords);
|
|
|
|
|
float4 texture2 = cubeMap2.Sample(sampler, output.texCoords);
|
2023-02-01 22:13:04 +01:00
|
|
|
float4 finalColor = lerp(texture1, texture2, fogBlend.w);
|
2023-01-29 18:58:59 +01:00
|
|
|
|
2023-02-01 22:13:04 +01:00
|
|
|
float factor = (output.texCoords.y - lowerLimit) / (upperLimit - lowerLimit);
|
2023-01-29 18:58:59 +01:00
|
|
|
factor = clamp(factor, 0.0, 1.0);
|
2023-02-01 22:13:04 +01:00
|
|
|
return lerp(float4(fogBlend.xyz, 1), finalColor, factor);
|
2023-01-29 18:58:59 +01:00
|
|
|
}
|