-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shaders: Implement particle shaders.
- Loading branch information
Showing
14 changed files
with
105 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
struct v2p | ||
{ | ||
float2 tc0; // base | ||
half4 c; // color | ||
// Igor: for additional depth dest | ||
#ifdef USE_SOFT_PARTICLES | ||
float4 tctexgen; | ||
#endif // USE_SOFT_PARTICLES | ||
float fog; | ||
}; | ||
|
||
layout(location = TEXCOORD0) in vec2 tc0; // base | ||
layout(location = COLOR0) in vec4 c0; // color | ||
#ifdef USE_SOFT_PARTICLES | ||
layout(location = TEXCOORD1) in vec4 tctexgen; | ||
#endif // USE_SOFT_PARTICLES | ||
layout(location = FOG) in float fog; | ||
|
||
layout(location = COLOR0) out vec4 C; | ||
|
||
half4 _main( v2p I ); | ||
|
||
void main() | ||
{ | ||
v2p I; | ||
I.tc0 = tc0; | ||
I.c = c0; | ||
I.tctexgen = tctexgen; | ||
I.fog = fog; | ||
|
||
C = _main(I); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
out gl_PerVertex { vec4 gl_Position; }; | ||
|
||
struct vv | ||
{ | ||
float4 P; | ||
float2 tc; | ||
float4 c; | ||
}; | ||
struct vf | ||
{ | ||
float4 hpos; | ||
float2 tc; | ||
float4 c; | ||
|
||
// Igor: for additional depth dest | ||
#ifdef USE_SOFT_PARTICLES | ||
float4 tctexgen; | ||
#endif // USE_SOFT_PARTICLES | ||
}; | ||
|
||
layout(location = POSITION) in float4 P; | ||
layout(location = TEXCOORD0) in float2 tc; | ||
layout(location = COLOR0) in float4 c; | ||
|
||
layout(location = TEXCOORD0) out vec2 tc0; // base | ||
layout(location = COLOR0) out vec4 c0; // color | ||
#ifdef USE_SOFT_PARTICLES | ||
layout(location = TEXCOORD1) out vec4 tctexgen; | ||
#endif // USE_SOFT_PARTICLES | ||
layout(location = FOG) out float fog; | ||
|
||
vf _main( vv v ); | ||
|
||
void main() | ||
{ | ||
vv I; | ||
I.P = P; | ||
I.tc = tc; | ||
I.c = c; | ||
|
||
vf O; | ||
O = _main(I); | ||
|
||
tc0 = O.tc; | ||
c0 = O.c; | ||
#ifdef USE_SOFT_PARTICLES | ||
tctexgen = O.tctexgen; | ||
#endif // USE_SOFT_PARTICLES | ||
gl_Position = O.hpos; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
#include "common.h" | ||
#include "iostructs/v_particle.h" | ||
|
||
out gl_PerVertex { vec4 gl_Position; }; | ||
|
||
layout(location = 0) in vec4 P; | ||
layout(location = 1) in vec2 tc; | ||
layout(location = 2) in vec4 c; | ||
|
||
layout(location = 0) out vec2 tc0; | ||
layout(location = 1) out vec4 c0; | ||
|
||
void main () | ||
vf _main (vv v) | ||
{ | ||
float4 hpos = mul (m_WVP, P); // xform, input in world coords | ||
hpos.z = abs (hpos.z); | ||
hpos.w = abs (hpos.w); | ||
tc0 = tc; // copy tc | ||
c0 = c; // copy color | ||
vf 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 | ||
|
||
gl_Position = hpos; | ||
return o; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,20 @@ | ||
#include "common.h" | ||
#include "iostructs/v_particle.h" | ||
|
||
out gl_PerVertex { vec4 gl_Position; }; | ||
|
||
layout(location = 0) in vec4 P; | ||
layout(location = 1) in vec2 tc; | ||
layout(location = 2) in vec4 c; | ||
|
||
layout(location = 0) out vec2 tc0; | ||
layout(location = 1) out vec4 c0; | ||
// Igor: for additional depth dest | ||
#ifdef USE_SOFT_PARTICLES | ||
layout(location = 2) out vec4 tctexgen; | ||
#endif // USE_SOFT_PARTICLES | ||
|
||
//uniform float4x4 mVPTexgen; | ||
|
||
void main () | ||
vf _main (vv v) | ||
{ | ||
float4 hpos = mul (m_WVP, P); // xform, input in world coords | ||
// float4 hpos = mul (m_VP, P); // xform, input in world coords | ||
tc0 = tc; // copy tc | ||
c0 = unpack_D3DCOLOR(c); // copy color | ||
vf 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 = v.c; // copy color | ||
|
||
// Igor: for additional depth dest | ||
#ifdef USE_SOFT_PARTICLES | ||
tctexgen = mul( mVPTexgen, P); | ||
tctexgen.z = hpos.z; | ||
o.tctexgen = mul( mVPTexgen, v.P); | ||
o.tctexgen.z = o.hpos.z; | ||
#endif // USE_SOFT_PARTICLES | ||
|
||
gl_Position = hpos; | ||
return o; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.