mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-24 04:41:10 +00:00
93 lines
1.9 KiB
HLSL
93 lines
1.9 KiB
HLSL
// 3D world rendering shader
|
|
// Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
// Vertex input data
|
|
struct VertexData
|
|
{
|
|
float3 pos : POSITION;
|
|
float4 color : COLOR0;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
// Pixel input data
|
|
struct PixelData
|
|
{
|
|
float4 pos : POSITION;
|
|
float4 color : COLOR0;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
// Modulation color
|
|
float4 modulatecolor;
|
|
|
|
// Matrix for final transformation
|
|
float4x4 worldviewproj;
|
|
|
|
// Texture input
|
|
texture texture1;
|
|
|
|
// Filter settings
|
|
dword minfiltersettings;
|
|
dword magfiltersettings;
|
|
|
|
// Texture sampler settings
|
|
sampler2D texturesamp = sampler_state
|
|
{
|
|
Texture = <texture1>;
|
|
MagFilter = magfiltersettings;
|
|
MinFilter = minfiltersettings;
|
|
MipFilter = magfiltersettings;
|
|
AddressU = Wrap;
|
|
AddressV = Wrap;
|
|
MipMapLodBias = 0.0f;
|
|
};
|
|
|
|
// Vertex shader
|
|
PixelData vs_main(VertexData vd)
|
|
{
|
|
PixelData pd;
|
|
|
|
// Fill pixel data input
|
|
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
|
|
pd.color = vd.color;
|
|
pd.uv = vd.uv;
|
|
|
|
// Return result
|
|
return pd;
|
|
}
|
|
|
|
// Normal pixel shader
|
|
float4 ps_main(PixelData pd) : COLOR
|
|
{
|
|
float4 tcolor = tex2D(texturesamp, pd.uv);
|
|
|
|
// Blend texture color, vertex color and modulation color
|
|
return tcolor * pd.color * modulatecolor;
|
|
}
|
|
|
|
// Full-bright pixel shader
|
|
float4 ps_fullbright(PixelData pd) : COLOR
|
|
{
|
|
float4 tcolor = tex2D(texturesamp, pd.uv);
|
|
|
|
// Blend texture color and modulation color
|
|
return tcolor * modulatecolor;
|
|
}
|
|
|
|
// Technique for shader model 2.0
|
|
technique SM20
|
|
{
|
|
// Normal
|
|
pass p0
|
|
{
|
|
VertexShader = compile vs_2_0 vs_main();
|
|
PixelShader = compile ps_2_0 ps_main();
|
|
}
|
|
|
|
// Full brightness mode
|
|
pass p1
|
|
{
|
|
VertexShader = compile vs_2_0 vs_main();
|
|
PixelShader = compile ps_2_0 ps_fullbright();
|
|
}
|
|
}
|