Skip to content

Commit

Permalink
shaders: Add GLSL port of shadow shaders.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Mar 13, 2016
1 parent c341434 commit 0d17f5f
Show file tree
Hide file tree
Showing 16 changed files with 415 additions and 0 deletions.
14 changes: 14 additions & 0 deletions res/gamedata/shaders/gl/iostructs/p_shadow_aref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

out vec4 SV_Target;

layout(location = TEXCOORD1) in float2 p_shadow_tc0 ; // TEXCOORD1; // Diffuse map for aref

float4 _main ( p_shadow_direct_aref I );

void main()
{
p_shadow_direct_aref I;
I.tc0 = p_shadow_tc0;

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

out gl_PerVertex { vec4 gl_Position; };

#ifdef SKIN_NONE
layout(location = POSITION) in float4 v_model_P ; // POSITION; // (float,float,float,1)
#else
layout(location = POSITION) in int4 v_model_P ; // POSITION; // (float,float,float,1) - quantized
#endif
#ifdef SKIN_0
layout(location = NORMAL) in float3 v_model_N ; // NORMAL; // (nx,ny,nz)
#else
layout(location = NORMAL) in float4 v_model_N ; // NORMAL; // (nx,ny,nz,index)
#endif
#if defined(SKIN_3) || defined(SKIN_4)
layout(location = TANGENT) in float4 v_model_T ; // TANGENT; // (nx,ny,nz,weight0)
layout(location = BINORMAL) in float4 v_model_B ; // BINORMAL; // (nx,ny,nz,weight1)
#else
layout(location = TANGENT) in float3 v_model_T ; // TANGENT; // (nx,ny,nz)
layout(location = BINORMAL) in float3 v_model_B ; // BINORMAL; // (nx,ny,nz)
#endif
#ifdef SKIN_NONE
layout(location = TEXCOORD0) in float2 v_model_tc ; // TEXCOORD0; // (u,v)
#elif defined(SKIN_2) || defined(SKIN_3)
layout(location = TEXCOORD0) in int4 v_model_tc ; // TEXCOORD0; // (u,v)
#else
layout(location = TEXCOORD0) in int2 v_model_tc ; // TEXCOORD0; // (u,v)
#endif
#ifdef SKIN_4
layout(location = TEXCOORD1) in float4 v_model_ind ; // (x=m-index0, y=m-index1, z=m-index2, w=m-index3)
#endif

v2p_shadow_direct _main( v_model I );

void main()
{
#ifdef SKIN_NONE
v_model I;
#endif
#ifdef SKIN_0
v_model_skinned_0 I;
#endif
#ifdef SKIN_1
v_model_skinned_1 I;
#endif
#ifdef SKIN_2
v_model_skinned_2 I;
#endif
#ifdef SKIN_3
v_model_skinned_3 I;
#endif
#ifdef SKIN_4
v_model_skinned_4 I;
I.ind = v_model_ind;
#endif

I.P = v_model_P;
I.N = v_model_N;
I.T = v_model_T;
I.B = v_model_B;
I.tc = v_model_tc;

v2p_shadow_direct O;
#ifdef SKIN_NONE
O = _main(I);
#endif
#ifdef SKIN_0
O = _main(skinning_0(I));
#endif
#ifdef SKIN_1
O = _main(skinning_1(I));
#endif
#ifdef SKIN_2
O = _main(skinning_2(I));
#endif
#ifdef SKIN_3
O = _main(skinning_3(I));
#endif
#ifdef SKIN_4
O = _main(skinning_4(I));
#endif

gl_Position = O.hpos;
}
86 changes: 86 additions & 0 deletions res/gamedata/shaders/gl/iostructs/v_model_shadow_aref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

out gl_PerVertex { vec4 gl_Position; };

#ifdef SKIN_NONE
layout(location = POSITION) in float4 v_model_P ; // POSITION; // (float,float,float,1)
#else
layout(location = POSITION) in int4 v_model_P ; // POSITION; // (float,float,float,1) - quantized
#endif
#ifdef SKIN_0
layout(location = NORMAL) in float3 v_model_N ; // NORMAL; // (nx,ny,nz)
#else
layout(location = NORMAL) in float4 v_model_N ; // NORMAL; // (nx,ny,nz,index)
#endif
#if defined(SKIN_3) || defined(SKIN_4)
layout(location = TANGENT) in float4 v_model_T ; // TANGENT; // (nx,ny,nz,weight0)
layout(location = BINORMAL) in float4 v_model_B ; // BINORMAL; // (nx,ny,nz,weight1)
#else
layout(location = TANGENT) in float3 v_model_T ; // TANGENT; // (nx,ny,nz)
layout(location = BINORMAL) in float3 v_model_B ; // BINORMAL; // (nx,ny,nz)
#endif
#ifdef SKIN_NONE
layout(location = TEXCOORD0) in float2 v_model_tc ; // TEXCOORD0; // (u,v)
#elif defined(SKIN_2) || defined(SKIN_3)
layout(location = TEXCOORD0) in int4 v_model_tc ; // TEXCOORD0; // (u,v)
#else
layout(location = TEXCOORD0) in int2 v_model_tc ; // TEXCOORD0; // (u,v)
#endif
#ifdef SKIN_4
layout(location = TEXCOORD1) in float4 v_model_ind ; // (x=m-index0, y=m-index1, z=m-index2, w=m-index3)
#endif

layout(location = TEXCOORD1) out float2 v2p_shadow_tc0 ; // TEXCOORD1; // Diffuse map for aref

v2p_shadow_direct_aref _main( v_model I );

void main()
{
#ifdef SKIN_NONE
v_model I;
#endif
#ifdef SKIN_0
v_model_skinned_0 I;
#endif
#ifdef SKIN_1
v_model_skinned_1 I;
#endif
#ifdef SKIN_2
v_model_skinned_2 I;
#endif
#ifdef SKIN_3
v_model_skinned_3 I;
#endif
#ifdef SKIN_4
v_model_skinned_4 I;
I.ind = v_model_ind;
#endif

I.P = v_model_P;
I.N = v_model_N;
I.T = v_model_T;
I.B = v_model_B;
I.tc = v_model_tc;

v2p_shadow_direct_aref O;
#ifdef SKIN_NONE
O = _main(I);
#endif
#ifdef SKIN_0
O = _main(skinning_0(I));
#endif
#ifdef SKIN_1
O = _main(skinning_1(I));
#endif
#ifdef SKIN_2
O = _main(skinning_2(I));
#endif
#ifdef SKIN_3
O = _main(skinning_3(I));
#endif
#ifdef SKIN_4
O = _main(skinning_4(I));
#endif

v2p_shadow_tc0 = O.tc0;
gl_Position = O.hpos;
}
22 changes: 22 additions & 0 deletions res/gamedata/shaders/gl/iostructs/v_shadow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

out gl_PerVertex { vec4 gl_Position; };

struct a2v
{
// float4 tc0; // TEXCOORD0; // Texture coordinates
float4 P; // POSITION; // Object-space position
};

layout(location = POSITION) in float4 v_shadow_P ; // POSITION; // Object-space position

v2p_shadow_direct _main ( a2v I );

void main()
{
a2v I;
I.P = v_shadow_P;

v2p_shadow_direct O = _main (I);

gl_Position = O.HPos;
}
39 changes: 39 additions & 0 deletions res/gamedata/shaders/gl/iostructs/v_shadow_aref.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

out gl_PerVertex { vec4 gl_Position; };

struct a2v
{
float4 P ; // POSITION; // Object-space position
int2 tc0 ; // TEXCOORD0; // Texture coordinates
};

layout(location = NORMAL) in float4 v_static_Nh ; // NORMAL; // (nx,ny,nz,hemi occlusion)
layout(location = TANGENT) in float4 v_static_T ; // TANGENT; // tangent
layout(location = BINORMAL) in float4 v_static_B ; // BINORMAL; // binormal
layout(location = TEXCOORD0) in int2 v_static_tc ; // TEXCOORD0; // (u,v)
#ifdef USE_LM_HEMI
layout(location = TEXCOORD1) in int2 v_static_lmh ; // TEXCOORD1; // (lmu,lmv)
#endif
layout(location = POSITION) in float4 v_static_P ; // POSITION; // (float,float,float,1)

layout(location = TEXCOORD1) out float2 v2p_shadow_tc0 ; // TEXCOORD1; // Diffuse map for aref

v2p_shadow_direct_aref _main ( v_static I );

void main()
{
v_static I;
I.Nh = v_static_Nh;
I.T = v_static_T;
I.B = v_static_B;
I.tc = v_static_tc;
#ifdef USE_LM_HEMI
I.lmh = v_static_lmh;
#endif
I.P = v_static_P;

v2p_shadow_direct_aref O = _main (I);

v2p_shadow_tc0 = O.tc0;
gl_Position = O.HPos;
}
47 changes: 47 additions & 0 deletions res/gamedata/shaders/gl/iostructs/v_tree_shadow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

out gl_PerVertex { vec4 gl_Position; };

layout(location = POSITION) in float4 v_tree_P ; // POSITION; // (float,float,float,1)
layout(location = NORMAL) in float4 v_tree_Nh ; // NORMAL; // (nx,ny,nz)
layout(location = TANGENT) in float3 v_tree_T ; // TANGENT; // tangent
layout(location = BINORMAL) in float3 v_tree_B ; // BINORMAL; // binormal
layout(location = TEXCOORD0) in int4 v_tree_tc ; // TEXCOORD0; // (u,v,frac,???)

#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
layout(location = TEXCOORD0) out float4 v2p_flat_tcdh ; // TEXCOORD0; // Texture coordinates, w=sun_occlusion
#else
layout(location = TEXCOORD0) out float2 v2p_flat_tcdh ; // TEXCOORD0; // Texture coordinates
#endif
layout(location = TEXCOORD1) out float4 v2p_flat_position; // TEXCOORD1; // position + hemi
layout(location = TEXCOORD2) out float3 v2p_flat_N ; // TEXCOORD2; // Eye-space normal (for lighting)
#ifdef USE_TDETAIL
layout(location = TEXCOORD3) out float2 v2p_flat_tcdbump; // TEXCOORD3; // d-bump
#endif
#ifdef USE_LM_HEMI
layout(location = TEXCOORD4) out float2 v2p_flat_lmh ; // TEXCOORD4; // lm-hemi
#endif

#ifdef USE_AREF
v2p_shadow_direct_aref _main ( v_shadow_direct_aref I );
#else // USE_AREF
v2p_shadow_direct _main ( v_shadow_direct I );
#endif // USE_AREF

void main()
{
v_tree I;
I.P = v_tree_P;
I.Nh = v_tree_Nh;
I.T = v_tree_T;
I.B = v_tree_B;
I.tc = v_tree_tc;

#ifdef USE_AREF
v2p_shadow_direct_aref O = _main (I);
v2p_shadow_tc0 = O.tc0;
#else // USE_AREF
v2p_shadow_direct O = _main (I);
#endif // USE_AREF

gl_Position = O.hpos;
}
Binary file added res/gamedata/shaders/gl/shadow_direct_base.ps
Binary file not shown.
15 changes: 15 additions & 0 deletions res/gamedata/shaders/gl/shadow_direct_base.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "common.h"
#include "iostructs\v_shadow.h"

//////////////////////////////////////////////////////////////////////////////////////////
// Vertex
v2p_shadow_direct _main ( a2v I )
{
v2p_shadow_direct O;

O.hpos = mul (m_WVP, I.P );
#ifndef USE_HWSMAP
O.depth = O.hpos.z;
#endif
return O;
}
Binary file added res/gamedata/shaders/gl/shadow_direct_base_aref.ps
Binary file not shown.
15 changes: 15 additions & 0 deletions res/gamedata/shaders/gl/shadow_direct_base_aref.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "common.h"
#include "iostructs\v_shadow_aref.h"

//////////////////////////////////////////////////////////////////////////////////////////
// Vertex
v2p_shadow_direct_aref _main ( v_static I )
{
v2p_shadow_direct_aref O;
O.hpos = mul (m_WVP, I.P );
O.tc0 = unpack_tc_base (I.tc,I.T.w,I.B.w ); // copy tc
#ifndef USE_HWSMAP
O.depth = O.hpos.z;
#endif
return O;
}
17 changes: 17 additions & 0 deletions res/gamedata/shaders/gl/shadow_direct_model.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "common.h"
#include "skin.h"
#include "iostructs\v_model_shadow.h"

//////////////////////////////////////////////////////////////////////////////////////////
// Vertex
v2p_shadow_direct _main( v_model I )
{
v2p_shadow_direct O ;
float4 hpos = mul( m_WVP, I.P );

O.hpos = hpos;
#ifndef USE_HWSMAP
O.depth = O.hpos.z;
#endif
return O ;
}
17 changes: 17 additions & 0 deletions res/gamedata/shaders/gl/shadow_direct_model_aref.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "common.h"
#include "skin.h"
#include "iostructs\v_model_shadow_aref.h"

//////////////////////////////////////////////////////////////////////////////////////////
// Vertex
v2p_shadow_direct_aref _main( v_model I )
{
v2p_shadow_direct_aref O;
float4 hpos = mul (m_WVP, I.P );
O.hpos = hpos;
O.tc0 = I.tc;
#ifndef USE_HWSMAP
O.depth = O.hpos.z;
#endif
return O;
}
Loading

0 comments on commit 0d17f5f

Please sign in to comment.