Skip to content

Commit 36ad95d

Browse files
committed
shaders: Add GLSL port of particle shaders.
1 parent e64f1a7 commit 36ad95d

12 files changed

+121
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
out vec4 SV_Target;
3+
in vec4 gl_FragCoord;
4+
5+
struct v2p
6+
{
7+
float2 tc0 ; // TEXCOORD0;
8+
float4 c ; // COLOR0;
9+
10+
// Igor: for additional depth dest
11+
#ifdef USE_SOFT_PARTICLES
12+
float4 tctexgen ; // TEXCOORD1;
13+
#endif // USE_SOFT_PARTICLES
14+
15+
float4 hpos ; // SV_Position;
16+
};
17+
18+
layout(location = TEXCOORD0) in float2 p_particle_tc ; // TEXCOORD0;
19+
layout(location = COLOR0) in float4 p_particle_c ; // COLOR0;
20+
#ifdef USE_SOFT_PARTICLES
21+
layout(location = TEXCOORD1) in float4 p_particle_tctexgen; // TEXCOORD1;
22+
#endif // USE_SOFT_PARTICLES
23+
24+
float4 _main ( v2p I );
25+
26+
void main()
27+
{
28+
v2p I;
29+
I.tc0 = p_particle_tc;
30+
I.c = p_particle_c;
31+
I.tctexgen = p_particle_tctexgen;
32+
I.hpos = gl_FragCoord;
33+
34+
SV_Target = _main (I);
35+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
out gl_PerVertex { vec4 gl_Position; };
3+
4+
struct vv
5+
{
6+
float4 P ; // POSITION;
7+
float2 tc ; // TEXCOORD0;
8+
float4 c ; // COLOR0;
9+
};
10+
11+
struct v2p
12+
{
13+
float2 tc ; // TEXCOORD0;
14+
float4 c ; // COLOR0;
15+
16+
// Igor: for additional depth dest
17+
#ifdef USE_SOFT_PARTICLES
18+
float4 tctexgen ; // TEXCOORD1;
19+
#endif // USE_SOFT_PARTICLES
20+
21+
float4 hpos ; // SV_Position;
22+
};
23+
24+
layout(location = POSITION) in float4 v_particle_P ; // POSITION;
25+
layout(location = TEXCOORD0) in float2 v_particle_tc ; // TEXCOORD0;
26+
layout(location = COLOR) in float4 v_particle_c ; // COLOR;
27+
28+
layout(location = TEXCOORD0) out float2 v2p_particle_tc ; // TEXCOORD0;
29+
layout(location = COLOR0) out float4 v2p_particle_c ; // COLOR0;
30+
#ifdef USE_SOFT_PARTICLES
31+
layout(location = TEXCOORD1) out float4 v2p_particle_tctexgen; // TEXCOORD1;
32+
#endif // USE_SOFT_PARTICLES
33+
34+
v2p _main ( vv I );
35+
36+
void main()
37+
{
38+
vv I;
39+
I.P = v_particle_P;
40+
I.tc = v_particle_tc;
41+
I.c = v_particle_c;
42+
43+
v2p O = _main (I);
44+
45+
v2p_particle_tc = O.tc;
46+
v2p_particle_c = O.c;
47+
v2p_particle_tctexgen = O.tctexgen;
48+
gl_Position = O.hpos;
49+
}
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_particle.h"
3+
4+
v2p _main (vv v)
5+
{
6+
v2p o;
7+
8+
o.hpos = mul (m_WVP, v.P); // xform, input in world coords
9+
o.hpos.z = abs (o.hpos.z);
10+
o.hpos.w = abs (o.hpos.w);
11+
o.tc = v.tc; // copy tc
12+
o.c = v.c; // copy color
13+
14+
return o;
15+
}

res/gamedata/shaders/gl/particle.ps

1.17 KB
Binary file not shown.

res/gamedata/shaders/gl/particle.vs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "common.h"
2+
#include "iostructs\v_particle.h"
3+
4+
uniform float4x4 mVPTexgen;
5+
6+
v2p _main (vv v)
7+
{
8+
v2p o;
9+
10+
o.hpos = mul (m_WVP, v.P); // xform, input in world coords
11+
// o.hpos = mul (m_VP, v.P); // xform, input in world coords
12+
o.tc = v.tc; // copy tc
13+
o.c = unpack_D3DCOLOR(v.c); // copy color
14+
15+
// Igor: for additional depth dest
16+
#ifdef USE_SOFT_PARTICLES
17+
o.tctexgen = mul( mVPTexgen, v.P);
18+
o.tctexgen.z = o.hpos.z;
19+
#endif // USE_SOFT_PARTICLES
20+
21+
return o;
22+
}
220 Bytes
Binary file not shown.
997 Bytes
Binary file not shown.
32 Bytes
Binary file not shown.
48 Bytes
Binary file not shown.
406 Bytes
Binary file not shown.
388 Bytes
Binary file not shown.
339 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)