Skip to content

Commit

Permalink
shaders: Fix various oversights in GLSL ports.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Mar 24, 2016
1 parent 5ad54e9 commit a1e13c8
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 35 deletions.
5 changes: 4 additions & 1 deletion res/gamedata/shaders/gl/deffer_detail_s_flat.vs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ v2p_flat _main (v_detail v)
O.hpos = Pp;
O.N = mul (m_WV, normalize(norm) );
float3 Pe = mul (m_WV, pos );
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
O.tcdh = float4 ((v.misc * consts).xyyy );
#else
O.tcdh = float2 ((v.misc * consts).xyyy );
#endif

# if defined(USE_R2_STATIC_SUN)
O.tcdh.w = c0.x; // (,,,dir-occlusion)
Expand All @@ -46,4 +50,3 @@ v2p_flat _main (v_detail v)

return O;
}
FXVS;
5 changes: 4 additions & 1 deletion res/gamedata/shaders/gl/deffer_detail_w_flat.vs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ v2p_flat _main (v_detail v)
O.N = mul (m_WV, normalize(norm) );
float3 Pe = mul (m_WV, pos );
// O.tcdh = float4 ((v.misc * consts).xy );
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
O.tcdh = float4 ((v.misc * consts).xyyy );
#else
O.tcdh = float2 ((v.misc * consts).xyyy );
#endif

# if defined(USE_R2_STATIC_SUN)
O.tcdh.w = c0.x; // (,,,dir-occlusion)
Expand All @@ -57,4 +61,3 @@ v2p_flat _main (v_detail v)

return O;
}
FXVS;
Binary file modified res/gamedata/shaders/gl/deffer_impl_flat.ps
Binary file not shown.
5 changes: 2 additions & 3 deletions res/gamedata/shaders/gl/deffer_tree_bump.vs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ v2p_bumped _main (v_tree I)
float3 pos = mul (m_xform, I.P);

//
float base = m_xform._24 ; // take base height from matrix
float base = m_xform._42 ; // take base height from matrix
float dp = calc_cyclic (wave.w+dot(pos,float3(wave)));
float H = pos.y - base ; // height of vertex (scaled, rotated, etc.)
float frac = I.tc.z*consts.x; // fractional (or rigidity)
float inten = H * dp; // intensity
float2 result = calc_xz_wave (wind.xz*inten, frac);
#ifdef USE_TREEWAVE
result = 0;
result = float2(0);
#endif
float4 w_pos = float4(pos.x+result.x, pos.y, pos.z+result.y, 1);
float2 tc = (I.tc * consts).xy;
Expand All @@ -34,7 +34,6 @@ v2p_bumped _main (v_tree I)
// Eye-space pos/normal
v2p_bumped O;
float3 Pe = mul (m_V, w_pos );
O.tcdh = float4 (tc.xyyy );
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
O.tcdh = float4 (tc.xyyy );
#else
Expand Down
8 changes: 6 additions & 2 deletions res/gamedata/shaders/gl/deffer_tree_flat.vs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ v2p_flat _main (v_tree I)
float3 pos = mul (m_xform, I.P);

//
float base = m_xform._24; // take base height from matrix
float base = m_xform._42; // take base height from matrix
float dp = calc_cyclic (wave.w+dot(pos,float3(wave)));
float H = pos.y - base; // height of vertex (scaled, rotated, etc.)
float frac = I.tc.z*consts.x; // fractional (or rigidity)
Expand All @@ -37,7 +37,11 @@ v2p_flat _main (v_tree I)
//float hemi = I.Nh.w;
o.hpos = mul (m_VP, f_pos );
o.N = mul (float3x3(m_xform_v), unpack_bx2(I.Nh) );
o.tcdh = float4 ((I.tc * consts).xyyy );
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
o.tcdh = float4 ((I.tc * consts).xyyy );
#else
o.tcdh = float2 ((I.tc * consts).xyyy );
#endif
o.position = float4 (Pe, hemi );

#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
Expand Down
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/iostructs/p_simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct v2p
float2 tc0 ; // TEXCOORD0; // base
};

layout(location = TEXCOORD0) in float4 p_simple_tc0 ; // TEXCOORD0; // base
layout(location = TEXCOORD0) in float2 p_simple_tc0 ; // TEXCOORD0; // base

float4 _main ( v2p I );

Expand Down
38 changes: 14 additions & 24 deletions res/gamedata/shaders/gl/iostructs/v_tree_shadow.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@

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,???)
layout(location = POSITION) in float4 v_shadow_P ; // POSITION; // (float,float,float,1)
#ifdef USE_AREF
layout(location = TEXCOORD0) in int4 v_shadow_tc ; // TEXCOORD0; // (u,v,frac,???)
#endif // USE_AREF

#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
layout(location = TEXCOORD1) out float2 v2p_shadow_tc0 ; // TEXCOORD1; // Diffuse map for aref
#endif // USE_AREF

#ifdef USE_AREF
v2p_shadow_direct_aref _main ( v_shadow_direct_aref I );
Expand All @@ -29,12 +18,13 @@ v2p_shadow_direct _main ( v_shadow_direct I );

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
v_shadow_direct_aref I;
I.tc = v_shadow_tc;
#else // USE_AREF
v_shadow_direct I;
#endif // USE_AREF
I.P = v_shadow_P;

#ifdef USE_AREF
v2p_shadow_direct_aref O = _main (I);
Expand Down
Binary file modified res/gamedata/shaders/gl/shadow_direct_base.ps
Binary file not shown.
6 changes: 3 additions & 3 deletions res/gamedata/shaders/gl/shadow_direct_tree.vs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ v2p_shadow_direct _main ( v_shadow_direct I )
float3 pos = mul (m_xform , I.P);

//
float base = m_xform._24; // take base height from matrix
float dp = calc_cyclic (wave.w+dot(pos,(float3)wave));
float base = m_xform._42; // take base height from matrix
float dp = calc_cyclic (wave.w+dot(pos,float3(wave)));
float H = pos.y - base; // height of vertex (scaled, rotated, etc.)
float inten = H * dp; // intensity
float2 result;
#ifdef USE_TREEWAVE
result = 0;
result = float2(0);
#else // USE_TREEWAVE
#ifdef USE_AREF
float frac = I.tc.z*consts.x; // fractional (or rigidity)
Expand Down
Binary file modified res/gamedata/shaders/gl/simple.ps
Binary file not shown.

0 comments on commit a1e13c8

Please sign in to comment.