Skip to content

Commit

Permalink
shaders: Fix shader compilation errors in GLSL ports.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Mar 22, 2016
1 parent 4fe8459 commit a42ae5e
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 13 deletions.
3 changes: 3 additions & 0 deletions res/gamedata/shaders/gl/common_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ float3 calc_model_lq_lighting( float3 norm_w )
}

float3 unpack_normal( float3 v ) { return 2*v-1; }
float3 unpack_normal( float4 v ) { return 2*v.xyz-1; }
float3 unpack_bx2( float3 v ) { return 2*v-1; }
float3 unpack_bx2( float4 v ) { return 2*v.xyz-1; }
float3 unpack_bx4( float3 v ) { return 4*v-2; } //!reduce the amount of stretching from 4*v-2 and increase precision
float3 unpack_bx4( float4 v ) { return 4*v.xyz-2; }
float2 unpack_tc_lmap( float2 tc ) { return tc*(1.f/32768.f); } // [-1 .. +1 ]
float4 unpack_color( float4 c ) { return c.bgra; }
float4 unpack_D3DCOLOR( float4 c ) { return c.bgra; }
Expand Down
8 changes: 6 additions & 2 deletions res/gamedata/shaders/gl/deffer_base_bump.vs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common.h"
#include "iostructs\v_static_bumped.h"

#include "iostructs\v_static_bump.h"
#line 4 1
v2p_bumped _main( v_in I )
{
// I.color.rgb = I.color.bgr; // Swizzle to compensate DX9/DX10 format mismatch
Expand All @@ -12,7 +12,11 @@ v2p_bumped _main( v_in I )
v2p_bumped O;
float3 Pe = mul (m_WV, w_pos );
O.hpos = mul (m_WVP, w_pos );
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
O.tcdh = float4 (tc.xyyy );
#else
O.tcdh = float2 (tc.xyyy );
#endif
O.position = float4 (Pe, hemi );
// O.position = float4 (O.hpos.xyz, hemi );

Expand Down
8 changes: 6 additions & 2 deletions res/gamedata/shaders/gl/deffer_base_flat.vs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common.h"
#include "iostructs\v_static_flat.h"

#line 4 1
v2p_flat _main ( v_in I )
{
I.Nh = unpack_D3DCOLOR(I.Nh);
Expand All @@ -15,7 +15,11 @@ v2p_flat _main ( v_in I )
float3 Pe = mul( m_WV, I.P );

float2 tc = unpack_tc_base( I.tc, I.T.w, I.B.w); // copy tc
O.tcdh = float4( tc.xyyy );
#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
O.tcdh = float4( tc.xyyy );
#else
O.tcdh = float2( tc.xyyy );
#endif
O.position = float4( Pe, I.Nh.w );

#if defined(USE_R2_STATIC_SUN) && !defined(USE_LM_HEMI)
Expand Down
5 changes: 5 additions & 0 deletions res/gamedata/shaders/gl/deffer_tree_bump.vs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ v2p_bumped _main (v_tree I)
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
O.tcdh = float2 (tc.xyyy );
#endif
O.hpos = mul (m_VP, w_pos );
O.position = float4 (Pe, hemi );

Expand Down
4 changes: 2 additions & 2 deletions res/gamedata/shaders/gl/hud_crosshair.vs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "common_iostructs.h"
//#include "common.h"
#include "iostructs\v2p_TL0uv.h"
//include "common.h"
#include "iostructs\v_TL0uv.h"

uniform float4 screen_res; // Screen resolution (x-Width,y-Height, zw - 1/resolution)

Expand Down
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/iostructs/v_shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ void main()

v2p_shadow_direct O = _main (I);

gl_Position = O.HPos;
gl_Position = O.hpos;
}
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/iostructs/v_shadow_aref.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ void main()
v2p_shadow_direct_aref O = _main (I);

v2p_shadow_tc0 = O.tc0;
gl_Position = O.HPos;
gl_Position = O.hpos;
}
1 change: 1 addition & 0 deletions res/gamedata/shaders/gl/iostructs/v_volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ void main()
#ifdef USE_SJITTER
v2p_volume_tcJ = O.tcJ;
#endif
gl_Position = O.hpos;
}
10 changes: 5 additions & 5 deletions res/gamedata/shaders/gl/sload.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

#ifdef MSAA_ALPHATEST_DX10_1
#if MSAA_SAMPLES == 2
static const float2 MSAAOffsets[2] = { float2(4,4), float2(-4,-4) };
const float2 MSAAOffsets[2] = { float2(4,4), float2(-4,-4) };
#endif
#if MSAA_SAMPLES == 4
static const float2 MSAAOffsets[4] = { float2(-2,-6), float2(6,-2), float2(-6,2), float2(2,6) };
const float2 MSAAOffsets[4] = { float2(-2,-6), float2(6,-2), float2(-6,2), float2(2,6) };
#endif
#if MSAA_SAMPLES == 8
static const float2 MSAAOffsets[8] = { float2(1,-3), float2(-1,3), float2(5,1), float2(-3,-5),
const float2 MSAAOffsets[8] = { float2(1,-3), float2(-1,3), float2(5,1), float2(-3,-5),
float2(-5,5), float2(-7,-1), float2(3,7), float2(7,-7) };
#endif
#endif // MSAA_ALPHATEST_DX10_1
Expand All @@ -35,8 +35,8 @@ float4 tbase( float2 tc )

#if defined(ALLOW_STEEPPARALLAX) && defined(USE_STEEPPARALLAX)

static const float fParallaxStartFade = 8.0f;
static const float fParallaxStopFade = 12.0f;
const float fParallaxStartFade = 8.0f;
const float fParallaxStopFade = 12.0f;

void UpdateTC( inout p_bumped I )
{
Expand Down

0 comments on commit a42ae5e

Please sign in to comment.