Skip to content

Commit

Permalink
shaders: Add GLSL port of particle shaders.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Mar 7, 2016
1 parent e64f1a7 commit 36ad95d
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 0 deletions.
35 changes: 35 additions & 0 deletions res/gamedata/shaders/gl/iostructs/p_particle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

out vec4 SV_Target;
in vec4 gl_FragCoord;

struct v2p
{
float2 tc0 ; // TEXCOORD0;
float4 c ; // COLOR0;

// Igor: for additional depth dest
#ifdef USE_SOFT_PARTICLES
float4 tctexgen ; // TEXCOORD1;
#endif // USE_SOFT_PARTICLES

float4 hpos ; // SV_Position;
};

layout(location = TEXCOORD0) in float2 p_particle_tc ; // TEXCOORD0;
layout(location = COLOR0) in float4 p_particle_c ; // COLOR0;
#ifdef USE_SOFT_PARTICLES
layout(location = TEXCOORD1) in float4 p_particle_tctexgen; // TEXCOORD1;
#endif // USE_SOFT_PARTICLES

float4 _main ( v2p I );

void main()
{
v2p I;
I.tc0 = p_particle_tc;
I.c = p_particle_c;
I.tctexgen = p_particle_tctexgen;
I.hpos = gl_FragCoord;

SV_Target = _main (I);
}
49 changes: 49 additions & 0 deletions res/gamedata/shaders/gl/iostructs/v_particle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

out gl_PerVertex { vec4 gl_Position; };

struct vv
{
float4 P ; // POSITION;
float2 tc ; // TEXCOORD0;
float4 c ; // COLOR0;
};

struct v2p
{
float2 tc ; // TEXCOORD0;
float4 c ; // COLOR0;

// Igor: for additional depth dest
#ifdef USE_SOFT_PARTICLES
float4 tctexgen ; // TEXCOORD1;
#endif // USE_SOFT_PARTICLES

float4 hpos ; // SV_Position;
};

layout(location = POSITION) in float4 v_particle_P ; // POSITION;
layout(location = TEXCOORD0) in float2 v_particle_tc ; // TEXCOORD0;
layout(location = COLOR) in float4 v_particle_c ; // COLOR;

layout(location = TEXCOORD0) out float2 v2p_particle_tc ; // TEXCOORD0;
layout(location = COLOR0) out float4 v2p_particle_c ; // COLOR0;
#ifdef USE_SOFT_PARTICLES
layout(location = TEXCOORD1) out float4 v2p_particle_tctexgen; // TEXCOORD1;
#endif // USE_SOFT_PARTICLES

v2p _main ( vv I );

void main()
{
vv I;
I.P = v_particle_P;
I.tc = v_particle_tc;
I.c = v_particle_c;

v2p O = _main (I);

v2p_particle_tc = O.tc;
v2p_particle_c = O.c;
v2p_particle_tctexgen = O.tctexgen;
gl_Position = O.hpos;
}
15 changes: 15 additions & 0 deletions res/gamedata/shaders/gl/particle-clip.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "common.h"
#include "iostructs\v_particle.h"

v2p _main (vv v)
{
v2p o;

o.hpos = mul (m_WVP, v.P); // xform, input in world coords
o.hpos.z = abs (o.hpos.z);
o.hpos.w = abs (o.hpos.w);
o.tc = v.tc; // copy tc
o.c = v.c; // copy color

return o;
}
Binary file added res/gamedata/shaders/gl/particle.ps
Binary file not shown.
22 changes: 22 additions & 0 deletions res/gamedata/shaders/gl/particle.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "common.h"
#include "iostructs\v_particle.h"

uniform float4x4 mVPTexgen;

v2p _main (vv v)
{
v2p o;

o.hpos = mul (m_WVP, v.P); // xform, input in world coords
// o.hpos = mul (m_VP, v.P); // xform, input in world coords
o.tc = v.tc; // copy tc
o.c = unpack_D3DCOLOR(v.c); // copy color

// Igor: for additional depth dest
#ifdef USE_SOFT_PARTICLES
o.tctexgen = mul( mVPTexgen, v.P);
o.tctexgen.z = o.hpos.z;
#endif // USE_SOFT_PARTICLES

return o;
}
Binary file added res/gamedata/shaders/gl/particle_alphaonly.ps
Binary file not shown.
Binary file added res/gamedata/shaders/gl/particle_distort.ps
Binary file not shown.
Binary file added res/gamedata/shaders/gl/particle_distort_hard.ps
Binary file not shown.
Binary file added res/gamedata/shaders/gl/particle_hard.ps
Binary file not shown.
Binary file added res/gamedata/shaders/gl/particle_s-aadd.ps
Binary file not shown.
Binary file added res/gamedata/shaders/gl/particle_s-add.ps
Binary file not shown.
Binary file added res/gamedata/shaders/gl/particle_s-blend.ps
Binary file not shown.

0 comments on commit 36ad95d

Please sign in to comment.