DirectXTK12/Src/Shaders/DualTextureEffect.fx

127 строки
2.8 KiB
HLSL

// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// http://go.microsoft.com/fwlink/?LinkID=615561
// http://create.msdn.com/en-US/education/catalog/sample/stock_effects
Texture2D<float4> Texture : register(t0);
Texture2D<float4> Texture2 : register(t1);
sampler Sampler : register(s0);
sampler Sampler2 : register(s1);
cbuffer Parameters : register(b0)
{
float4 DiffuseColor : packoffset(c0);
float3 FogColor : packoffset(c1);
float4 FogVector : packoffset(c2);
float4x4 WorldViewProj : packoffset(c3);
};
#include "Structures.fxh"
#include "RootSig.fxh"
#include "Common.fxh"
// Vertex shader: basic.
[RootSignature(DualTextureRS)]
VSOutputTx2 VSDualTexture(VSInputTx2 vin)
{
VSOutputTx2 vout;
CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
SetCommonVSOutputParams;
vout.TexCoord = vin.TexCoord;
vout.TexCoord2 = vin.TexCoord2;
return vout;
}
// Vertex shader: no fog.
[RootSignature(DualTextureRS)]
VSOutputTx2NoFog VSDualTextureNoFog(VSInputTx2 vin)
{
VSOutputTx2NoFog vout;
CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
SetCommonVSOutputParamsNoFog;
vout.TexCoord = vin.TexCoord;
vout.TexCoord2 = vin.TexCoord2;
return vout;
}
// Vertex shader: vertex color.
[RootSignature(DualTextureRS)]
VSOutputTx2 VSDualTextureVc(VSInputTx2Vc vin)
{
VSOutputTx2 vout;
CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
SetCommonVSOutputParams;
vout.TexCoord = vin.TexCoord;
vout.TexCoord2 = vin.TexCoord2;
vout.Diffuse *= vin.Color;
return vout;
}
// Vertex shader: vertex color, no fog.
[RootSignature(DualTextureRS)]
VSOutputTx2NoFog VSDualTextureVcNoFog(VSInputTx2Vc vin)
{
VSOutputTx2NoFog vout;
CommonVSOutput cout = ComputeCommonVSOutput(vin.Position);
SetCommonVSOutputParamsNoFog;
vout.TexCoord = vin.TexCoord;
vout.TexCoord2 = vin.TexCoord2;
vout.Diffuse *= vin.Color;
return vout;
}
// Pixel shader: basic.
[RootSignature(DualTextureRS)]
float4 PSDualTexture(PSInputTx2 pin) : SV_Target0
{
float4 color = Texture.Sample(Sampler, pin.TexCoord);
float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
color.rgb *= 2;
color *= overlay * pin.Diffuse;
ApplyFog(color, pin.Specular.w);
return color;
}
// Pixel shader: no fog.
[RootSignature(DualTextureRS)]
float4 PSDualTextureNoFog(PSInputTx2NoFog pin) : SV_Target0
{
float4 color = Texture.Sample(Sampler, pin.TexCoord);
float4 overlay = Texture2.Sample(Sampler2, pin.TexCoord2);
color.rgb *= 2;
color *= overlay * pin.Diffuse;
return color;
}