mirror of
https://git.stillkill.net/MinecraftLeak/MinecraftLegends.git
synced 2026-10-22 13:22:20 +01:00
37 lines
989 B
Plaintext
37 lines
989 B
Plaintext
#include "ShaderConstantsGNM.h"
|
|
|
|
struct PS_Input {
|
|
float4 position : S_POSITION;
|
|
float2 uv : TEXCOORD_0;
|
|
float4 color : COLOR;
|
|
float4 worldPosition : TEXCOORD_1;
|
|
float4 fogColor : FOG_COLOR;
|
|
};
|
|
|
|
float4 main( in PS_Input PSInput ) : S_TARGET_OUTPUT
|
|
{
|
|
float4 outputColor = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
|
|
|
outputColor.a *= PSInput.color.a;
|
|
|
|
float2 uv = PSInput.worldPosition.xz;
|
|
float4 occlusionTexture = TEXTURE_1.Sample(TextureSampler1, uv);
|
|
|
|
// clamp the uvs
|
|
if (uv.x >= 0.0f && uv.x <= 1.0f &&
|
|
uv.y >= 0.0f && uv.y <= 1.0f &&
|
|
PSInput.worldPosition.y < occlusionTexture.a) {
|
|
outputColor.a = 0.0f;
|
|
}
|
|
|
|
float mixAmount = saturate((PSInput.worldPosition.y - occlusionTexture.a)*10.0f);
|
|
float3 lighting = lerp(occlusionTexture.rgb, PSInput.color.rgb, mixAmount);
|
|
outputColor.rgb *= lighting.rgb;
|
|
|
|
//apply fog
|
|
outputColor.rgb = lerp(outputColor.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a);
|
|
|
|
return outputColor;
|
|
}
|
|
|