Skip to content

Commit 0d17f5f

Browse files
committed
shaders: Add GLSL port of shadow shaders.
1 parent c341434 commit 0d17f5f

16 files changed

+415
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
out vec4 SV_Target;
3+
4+
layout(location = TEXCOORD1) in float2 p_shadow_tc0 ; // TEXCOORD1; // Diffuse map for aref
5+
6+
float4 _main ( p_shadow_direct_aref I );
7+
8+
void main()
9+
{
10+
p_shadow_direct_aref I;
11+
I.tc0 = p_shadow_tc0;
12+
13+
SV_Target = _main (I);
14+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
#ifdef SKIN_NONE
5+
layout(location = POSITION) in float4 v_model_P ; // POSITION; // (float,float,float,1)
6+
#else
7+
layout(location = POSITION) in int4 v_model_P ; // POSITION; // (float,float,float,1) - quantized
8+
#endif
9+
#ifdef SKIN_0
10+
layout(location = NORMAL) in float3 v_model_N ; // NORMAL; // (nx,ny,nz)
11+
#else
12+
layout(location = NORMAL) in float4 v_model_N ; // NORMAL; // (nx,ny,nz,index)
13+
#endif
14+
#if defined(SKIN_3) || defined(SKIN_4)
15+
layout(location = TANGENT) in float4 v_model_T ; // TANGENT; // (nx,ny,nz,weight0)
16+
layout(location = BINORMAL) in float4 v_model_B ; // BINORMAL; // (nx,ny,nz,weight1)
17+
#else
18+
layout(location = TANGENT) in float3 v_model_T ; // TANGENT; // (nx,ny,nz)
19+
layout(location = BINORMAL) in float3 v_model_B ; // BINORMAL; // (nx,ny,nz)
20+
#endif
21+
#ifdef SKIN_NONE
22+
layout(location = TEXCOORD0) in float2 v_model_tc ; // TEXCOORD0; // (u,v)
23+
#elif defined(SKIN_2) || defined(SKIN_3)
24+
layout(location = TEXCOORD0) in int4 v_model_tc ; // TEXCOORD0; // (u,v)
25+
#else
26+
layout(location = TEXCOORD0) in int2 v_model_tc ; // TEXCOORD0; // (u,v)
27+
#endif
28+
#ifdef SKIN_4
29+
layout(location = TEXCOORD1) in float4 v_model_ind ; // (x=m-index0, y=m-index1, z=m-index2, w=m-index3)
30+
#endif
31+
32+
v2p_shadow_direct _main( v_model I );
33+
34+
void main()
35+
{
36+
#ifdef SKIN_NONE
37+
v_model I;
38+
#endif
39+
#ifdef SKIN_0
40+
v_model_skinned_0 I;
41+
#endif
42+
#ifdef SKIN_1
43+
v_model_skinned_1 I;
44+
#endif
45+
#ifdef SKIN_2
46+
v_model_skinned_2 I;
47+
#endif
48+
#ifdef SKIN_3
49+
v_model_skinned_3 I;
50+
#endif
51+
#ifdef SKIN_4
52+
v_model_skinned_4 I;
53+
I.ind = v_model_ind;
54+
#endif
55+
56+
I.P = v_model_P;
57+
I.N = v_model_N;
58+
I.T = v_model_T;
59+
I.B = v_model_B;
60+
I.tc = v_model_tc;
61+
62+
v2p_shadow_direct O;
63+
#ifdef SKIN_NONE
64+
O = _main(I);
65+
#endif
66+
#ifdef SKIN_0
67+
O = _main(skinning_0(I));
68+
#endif
69+
#ifdef SKIN_1
70+
O = _main(skinning_1(I));
71+
#endif
72+
#ifdef SKIN_2
73+
O = _main(skinning_2(I));
74+
#endif
75+
#ifdef SKIN_3
76+
O = _main(skinning_3(I));
77+
#endif
78+
#ifdef SKIN_4
79+
O = _main(skinning_4(I));
80+
#endif
81+
82+
gl_Position = O.hpos;
83+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
#ifdef SKIN_NONE
5+
layout(location = POSITION) in float4 v_model_P ; // POSITION; // (float,float,float,1)
6+
#else
7+
layout(location = POSITION) in int4 v_model_P ; // POSITION; // (float,float,float,1) - quantized
8+
#endif
9+
#ifdef SKIN_0
10+
layout(location = NORMAL) in float3 v_model_N ; // NORMAL; // (nx,ny,nz)
11+
#else
12+
layout(location = NORMAL) in float4 v_model_N ; // NORMAL; // (nx,ny,nz,index)
13+
#endif
14+
#if defined(SKIN_3) || defined(SKIN_4)
15+
layout(location = TANGENT) in float4 v_model_T ; // TANGENT; // (nx,ny,nz,weight0)
16+
layout(location = BINORMAL) in float4 v_model_B ; // BINORMAL; // (nx,ny,nz,weight1)
17+
#else
18+
layout(location = TANGENT) in float3 v_model_T ; // TANGENT; // (nx,ny,nz)
19+
layout(location = BINORMAL) in float3 v_model_B ; // BINORMAL; // (nx,ny,nz)
20+
#endif
21+
#ifdef SKIN_NONE
22+
layout(location = TEXCOORD0) in float2 v_model_tc ; // TEXCOORD0; // (u,v)
23+
#elif defined(SKIN_2) || defined(SKIN_3)
24+
layout(location = TEXCOORD0) in int4 v_model_tc ; // TEXCOORD0; // (u,v)
25+
#else
26+
layout(location = TEXCOORD0) in int2 v_model_tc ; // TEXCOORD0; // (u,v)
27+
#endif
28+
#ifdef SKIN_4
29+
layout(location = TEXCOORD1) in float4 v_model_ind ; // (x=m-index0, y=m-index1, z=m-index2, w=m-index3)
30+
#endif
31+
32+
layout(location = TEXCOORD1) out float2 v2p_shadow_tc0 ; // TEXCOORD1; // Diffuse map for aref
33+
34+
v2p_shadow_direct_aref _main( v_model I );
35+
36+
void main()
37+
{
38+
#ifdef SKIN_NONE
39+
v_model I;
40+
#endif
41+
#ifdef SKIN_0
42+
v_model_skinned_0 I;
43+
#endif
44+
#ifdef SKIN_1
45+
v_model_skinned_1 I;
46+
#endif
47+
#ifdef SKIN_2
48+
v_model_skinned_2 I;
49+
#endif
50+
#ifdef SKIN_3
51+
v_model_skinned_3 I;
52+
#endif
53+
#ifdef SKIN_4
54+
v_model_skinned_4 I;
55+
I.ind = v_model_ind;
56+
#endif
57+
58+
I.P = v_model_P;
59+
I.N = v_model_N;
60+
I.T = v_model_T;
61+
I.B = v_model_B;
62+
I.tc = v_model_tc;
63+
64+
v2p_shadow_direct_aref O;
65+
#ifdef SKIN_NONE
66+
O = _main(I);
67+
#endif
68+
#ifdef SKIN_0
69+
O = _main(skinning_0(I));
70+
#endif
71+
#ifdef SKIN_1
72+
O = _main(skinning_1(I));
73+
#endif
74+
#ifdef SKIN_2
75+
O = _main(skinning_2(I));
76+
#endif
77+
#ifdef SKIN_3
78+
O = _main(skinning_3(I));
79+
#endif
80+
#ifdef SKIN_4
81+
O = _main(skinning_4(I));
82+
#endif
83+
84+
v2p_shadow_tc0 = O.tc0;
85+
gl_Position = O.hpos;
86+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
struct a2v
5+
{
6+
// float4 tc0; // TEXCOORD0; // Texture coordinates
7+
float4 P; // POSITION; // Object-space position
8+
};
9+
10+
layout(location = POSITION) in float4 v_shadow_P ; // POSITION; // Object-space position
11+
12+
v2p_shadow_direct _main ( a2v I );
13+
14+
void main()
15+
{
16+
a2v I;
17+
I.P = v_shadow_P;
18+
19+
v2p_shadow_direct O = _main (I);
20+
21+
gl_Position = O.HPos;
22+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
struct a2v
5+
{
6+
float4 P ; // POSITION; // Object-space position
7+
int2 tc0 ; // TEXCOORD0; // Texture coordinates
8+
};
9+
10+
layout(location = NORMAL) in float4 v_static_Nh ; // NORMAL; // (nx,ny,nz,hemi occlusion)
11+
layout(location = TANGENT) in float4 v_static_T ; // TANGENT; // tangent
12+
layout(location = BINORMAL) in float4 v_static_B ; // BINORMAL; // binormal
13+
layout(location = TEXCOORD0) in int2 v_static_tc ; // TEXCOORD0; // (u,v)
14+
#ifdef USE_LM_HEMI
15+
layout(location = TEXCOORD1) in int2 v_static_lmh ; // TEXCOORD1; // (lmu,lmv)
16+
#endif
17+
layout(location = POSITION) in float4 v_static_P ; // POSITION; // (float,float,float,1)
18+
19+
layout(location = TEXCOORD1) out float2 v2p_shadow_tc0 ; // TEXCOORD1; // Diffuse map for aref
20+
21+
v2p_shadow_direct_aref _main ( v_static I );
22+
23+
void main()
24+
{
25+
v_static I;
26+
I.Nh = v_static_Nh;
27+
I.T = v_static_T;
28+
I.B = v_static_B;
29+
I.tc = v_static_tc;
30+
#ifdef USE_LM_HEMI
31+
I.lmh = v_static_lmh;
32+
#endif
33+
I.P = v_static_P;
34+
35+
v2p_shadow_direct_aref O = _main (I);
36+
37+
v2p_shadow_tc0 = O.tc0;
38+
gl_Position = O.HPos;
39+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
layout(location = POSITION) in float4 v_tree_P ; // POSITION; // (float,float,float,1)
5+
layout(location = NORMAL) in float4 v_tree_Nh ; // NORMAL; // (nx,ny,nz)
6+
layout(location = TANGENT) in float3 v_tree_T ; // TANGENT; // tangent
7+
layout(location = BINORMAL) in float3 v_tree_B ; // BINORMAL; // binormal
8+
layout(location = TEXCOORD0) in int4 v_tree_tc ; // TEXCOORD0; // (u,v,frac,???)
9+
10+
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
11+
layout(location = TEXCOORD0) out float4 v2p_flat_tcdh ; // TEXCOORD0; // Texture coordinates, w=sun_occlusion
12+
#else
13+
layout(location = TEXCOORD0) out float2 v2p_flat_tcdh ; // TEXCOORD0; // Texture coordinates
14+
#endif
15+
layout(location = TEXCOORD1) out float4 v2p_flat_position; // TEXCOORD1; // position + hemi
16+
layout(location = TEXCOORD2) out float3 v2p_flat_N ; // TEXCOORD2; // Eye-space normal (for lighting)
17+
#ifdef USE_TDETAIL
18+
layout(location = TEXCOORD3) out float2 v2p_flat_tcdbump; // TEXCOORD3; // d-bump
19+
#endif
20+
#ifdef USE_LM_HEMI
21+
layout(location = TEXCOORD4) out float2 v2p_flat_lmh ; // TEXCOORD4; // lm-hemi
22+
#endif
23+
24+
#ifdef USE_AREF
25+
v2p_shadow_direct_aref _main ( v_shadow_direct_aref I );
26+
#else // USE_AREF
27+
v2p_shadow_direct _main ( v_shadow_direct I );
28+
#endif // USE_AREF
29+
30+
void main()
31+
{
32+
v_tree I;
33+
I.P = v_tree_P;
34+
I.Nh = v_tree_Nh;
35+
I.T = v_tree_T;
36+
I.B = v_tree_B;
37+
I.tc = v_tree_tc;
38+
39+
#ifdef USE_AREF
40+
v2p_shadow_direct_aref O = _main (I);
41+
v2p_shadow_tc0 = O.tc0;
42+
#else // USE_AREF
43+
v2p_shadow_direct O = _main (I);
44+
#endif // USE_AREF
45+
46+
gl_Position = O.hpos;
47+
}
278 Bytes
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "common.h"
2+
#include "iostructs\v_shadow.h"
3+
4+
//////////////////////////////////////////////////////////////////////////////////////////
5+
// Vertex
6+
v2p_shadow_direct _main ( a2v I )
7+
{
8+
v2p_shadow_direct O;
9+
10+
O.hpos = mul (m_WVP, I.P );
11+
#ifndef USE_HWSMAP
12+
O.depth = O.hpos.z;
13+
#endif
14+
return O;
15+
}
480 Bytes
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "common.h"
2+
#include "iostructs\v_shadow_aref.h"
3+
4+
//////////////////////////////////////////////////////////////////////////////////////////
5+
// Vertex
6+
v2p_shadow_direct_aref _main ( v_static I )
7+
{
8+
v2p_shadow_direct_aref O;
9+
O.hpos = mul (m_WVP, I.P );
10+
O.tc0 = unpack_tc_base (I.tc,I.T.w,I.B.w ); // copy tc
11+
#ifndef USE_HWSMAP
12+
O.depth = O.hpos.z;
13+
#endif
14+
return O;
15+
}

0 commit comments

Comments
 (0)