fna-workbench

fna-workbench Git Source Tree


Root/src/Graphics/Effect/StockEffects/HLSL/DualTextureEffect.fx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//-----------------------------------------------------------------------------
// DualTextureEffect.fx
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
 
#include "Macros.fxh"
 
 
DECLARE_TEXTURE(Texture, 0);
DECLARE_TEXTURE(Texture2, 1);
 
 
BEGIN_CONSTANTS
 
    float4 DiffuseColor     _vs(c0) _cb(c0);
    float3 FogColor         _ps(c0) _cb(c1);
    float4 FogVector        _vs(c5) _cb(c2);
 
MATRIX_CONSTANTS
 
    float4x4 WorldViewProj  _vs(c1) _cb(c0);
 
END_CONSTANTS
 
 
#include "Structures.fxh"
#include "Common.fxh"
 
 
// Vertex shader: basic.
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.
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.
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.
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.
float4 PSDualTexture(PSInputTx2 pin) : SV_Target0
{
    float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord);
    float4 overlay = SAMPLE_TEXTURE(Texture2, pin.TexCoord2);
 
    color.rgb *= 2;   
    color *= overlay * pin.Diffuse;
     
    ApplyFog(color, pin.Specular.w);
     
    return color;
}
 
 
// Pixel shader: no fog.
float4 PSDualTextureNoFog(PSInputTx2NoFog pin) : SV_Target0
{
    float4 color = SAMPLE_TEXTURE(Texture, pin.TexCoord);
    float4 overlay = SAMPLE_TEXTURE(Texture2, pin.TexCoord2);
     
    color.rgb *= 2;   
    color *= overlay * pin.Diffuse;
     
    return color;
}
 
 
VertexShader VSArray[4] =
{
    compile vs_2_0 VSDualTexture(),
    compile vs_2_0 VSDualTextureNoFog(),
    compile vs_2_0 VSDualTextureVc(),
    compile vs_2_0 VSDualTextureVcNoFog(),
};
 
 
PixelShader PSArray[2] =
{
    compile ps_2_0 PSDualTexture(),
    compile ps_2_0 PSDualTextureNoFog(),
};
 
 
int PSIndices[4] =
{
    0,      // basic
    1,      // no fog
    0,      // vertex color
    1,      // vertex color, no fog
};
 
 
int ShaderIndex = 0;
 
 
Technique DualTextureEffect
{
    Pass
    {
        VertexShader = (VSArray[ShaderIndex]);
        PixelShader  = (PSArray[PSIndices[ShaderIndex]]);
    }
}

Archive Download this file

Branches

Number of commits:
Page rendered in 0.10746s using 11 queries.