Files
GP1-DirectX/project/resources/PosCol3D.fx
2024-12-11 18:53:17 +01:00

87 lines
2.0 KiB
HLSL

float4x4 gWorldViewProj : WorldViewProjection;
texture2D gDiffuseMap : DiffuseMap;
//Input output
struct VS_INPUT{
float3 Position : POSITION;
float3 Color: COLOR;
float2 TexCoord: TEXCOORD;
};
struct VS_OUTPUT{
float4 Position : SV_POSITION;
float3 Color: COLOR;
float2 TexCoord: TEXCOORD;
};
//----------------------
// SamplerState
//----------------------
SamplerState samPoint
{
Filter = MIN_MAG_MIP_POINT;
Addressu = Wrap; //or Mirror, Clamp, Border
AddressV = Wrap; //or Mirror, Clamp, Border
};
SamplerState samLinear
{
Filter = MIN_MAG_MIP_LINEAR;
Addressu = Wrap; //or Mirror, Clamp, Border
AddressV = Wrap; //or Mirror, Clamp, Border
};
SamplerState samAnisotropic
{
Filter = ANISOTROPIC;
Addressu = Wrap; //or Mirror, Clamp, Border
AddressV = Wrap; //or Mirror, Clamp, Border
};
//Vertex shader
VS_OUTPUT VS(VS_INPUT input){
VS_OUTPUT output = (VS_OUTPUT)0;
output.Position = mul(float4(input.Position, 1.f), gWorldViewProj);
output.Color = input.Color;
output.TexCoord = input.TexCoord;
return output;
}
float4 PS_point(VS_OUTPUT input) : SV_TARGET{
return gDiffuseMap.Sample(samPoint, input.TexCoord);
}
float4 PS_linear(VS_OUTPUT input) : SV_TARGET{
return gDiffuseMap.Sample(samLinear, input.TexCoord);
}
float4 PS_anisotropic(VS_OUTPUT input) : SV_TARGET{
return gDiffuseMap.Sample(samAnisotropic, input.TexCoord);
}
technique11 PointTechnique{
pass P0 {
SetVertexShader( CompileShader( vs_5_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_5_0, PS_point() ) );
}
}
technique11 LinearTechnique {
pass P0 {
SetVertexShader( CompileShader( vs_5_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_5_0, PS_linear() ) );
}
}
technique11 AnisotropicTechnique {
pass P0 {
SetVertexShader( CompileShader( vs_5_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_5_0, PS_anisotropic() ) );
}
}