Skip to content

Commit 4bb4295

Browse files
committed
shaders: Add GLSL port of model_def_lq.
1 parent 0d17f5f commit 4bb4295

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
out vec4 SV_Target;
3+
4+
struct v2p
5+
{
6+
float2 tc0; // TEXCOORD0; // base
7+
// float2 tc1; // TEXCOORD1; // lmap
8+
float3 c0; // COLOR0; // sun
9+
};
10+
11+
layout(location = TEXCOORD0) in float2 p_model_tc0 ; // TEXCOORD0; // base
12+
//layout(location = TEXCOORD1) in float2 p_model_tc1 ; // TEXCOORD1; // lmap
13+
layout(location = COLOR0) in float3 p_model_c0 ; // COLOR0; // sun
14+
15+
float4 _main ( v2p I );
16+
17+
void main()
18+
{
19+
v2p I;
20+
I.tc0 = p_model_tc0;
21+
// I.tc1 = p_model_tc1;
22+
I.c0 = p_model_c0;
23+
24+
SV_Target = _main (I);
25+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
struct v2p
5+
{
6+
float2 tc0 ; // TEXCOORD0; // base
7+
float3 c0 ; // COLOR0; // color
8+
float fog ; // FOG;
9+
float4 hpos ; // SV_Position;
10+
};
11+
12+
#ifdef SKIN_NONE
13+
layout(location = POSITION) in float4 v_model_P ; // POSITION; // (float,float,float,1)
14+
#else
15+
layout(location = POSITION) in int4 v_model_P ; // POSITION; // (float,float,float,1) - quantized
16+
#endif
17+
#ifdef SKIN_0
18+
layout(location = NORMAL) in float3 v_model_N ; // NORMAL; // (nx,ny,nz)
19+
#else
20+
layout(location = NORMAL) in float4 v_model_N ; // NORMAL; // (nx,ny,nz,index)
21+
#endif
22+
#if defined(SKIN_3) || defined(SKIN_4)
23+
layout(location = TANGENT) in float4 v_model_T ; // TANGENT; // (nx,ny,nz,weight0)
24+
layout(location = BINORMAL) in float4 v_model_B ; // BINORMAL; // (nx,ny,nz,weight1)
25+
#else
26+
layout(location = TANGENT) in float3 v_model_T ; // TANGENT; // (nx,ny,nz)
27+
layout(location = BINORMAL) in float3 v_model_B ; // BINORMAL; // (nx,ny,nz)
28+
#endif
29+
#ifdef SKIN_NONE
30+
layout(location = TEXCOORD0) in float2 v_model_tc ; // TEXCOORD0; // (u,v)
31+
#elif defined(SKIN_2) || defined(SKIN_3)
32+
layout(location = TEXCOORD0) in int4 v_model_tc ; // TEXCOORD0; // (u,v)
33+
#else
34+
layout(location = TEXCOORD0) in int2 v_model_tc ; // TEXCOORD0; // (u,v)
35+
#endif
36+
#ifdef SKIN_4
37+
layout(location = TEXCOORD1) in float4 v_model_ind ; // (x=m-index0, y=m-index1, z=m-index2, w=m-index3)
38+
#endif
39+
40+
layout(location = TEXCOORD0) out float2 v2p_model_tc0 ; // TEXCOORD0; // base
41+
layout(location = COLOR0) out float3 v2p_model_c0 ; // COLOR0; // color
42+
layout(location = FOG) out float v2p_model_fog ; // FOG;
43+
44+
v2p _main(v_model v);
45+
46+
void main()
47+
{
48+
#ifdef SKIN_NONE
49+
v_model I;
50+
#endif
51+
#ifdef SKIN_0
52+
v_model_skinned_0 I;
53+
#endif
54+
#ifdef SKIN_1
55+
v_model_skinned_1 I;
56+
#endif
57+
#ifdef SKIN_2
58+
v_model_skinned_2 I;
59+
#endif
60+
#ifdef SKIN_3
61+
v_model_skinned_3 I;
62+
#endif
63+
#ifdef SKIN_4
64+
v_model_skinned_4 I;
65+
I.ind = v_model_ind;
66+
#endif
67+
68+
I.P = v_model_P;
69+
I.N = v_model_N;
70+
I.T = v_model_T;
71+
I.B = v_model_B;
72+
I.tc = v_model_tc;
73+
74+
v2p O;
75+
#ifdef SKIN_NONE
76+
O = _main(I);
77+
#endif
78+
#ifdef SKIN_0
79+
O = _main(skinning_0(I));
80+
#endif
81+
#ifdef SKIN_1
82+
O = _main(skinning_1(I));
83+
#endif
84+
#ifdef SKIN_2
85+
O = _main(skinning_2(I));
86+
#endif
87+
#ifdef SKIN_3
88+
O = _main(skinning_3(I));
89+
#endif
90+
#ifdef SKIN_4
91+
O = _main(skinning_4(I));
92+
#endif
93+
94+
v2p_model_tc0 = O.tc0;
95+
v2p_model_c0 = O.c0;
96+
v2p_model_fog = O.fog;
97+
gl_Position = O.hpos;
98+
}
343 Bytes
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "common.h"
2+
#include "skin.h"
3+
#include "iostructs\v_model_def.h"
4+
5+
v2p _main(v_model v)
6+
{
7+
v2p o;
8+
9+
float4 pos = v.P;
10+
float3 pos_w = mul( m_W, pos );
11+
float3 norm_w = normalize( mul( m_W, v.N ) );
12+
13+
o.hpos = mul( m_WVP, pos ); // xform, input in world coords
14+
o.tc0 = v.tc.xy; // copy tc
15+
o.c0 = calc_model_lq_lighting( norm_w );
16+
o.fog = saturate(calc_fogging( float4( pos_w, 1 ) )); // fog, input in world coords
17+
18+
return o;
19+
}

0 commit comments

Comments
 (0)