Skip to content

Commit

Permalink
OpenGL: some changes in shaders for ATI video cards (Thanks Tron for …
Browse files Browse the repository at this point in the history
…his advice)
  • Loading branch information
SkyLoaderr committed Nov 27, 2018
1 parent 738ef6e commit 23e9a2c
Show file tree
Hide file tree
Showing 61 changed files with 137 additions and 138 deletions.
Binary file modified res/gamedata/shaders/gl/accum_base.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/accum_sun.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/accum_sun_far.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/accum_sun_mask.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/accum_sun_near.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/accum_volumetric.ps
Binary file not shown.
8 changes: 4 additions & 4 deletions res/gamedata/shaders/gl/accum_volumetric.vs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ v2p _main ( float3 P )
o.lightToPos = vPos.xyz - Ldynamic_pos.xyz;
o.vPos = vPos.xyz;

// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0f;
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0f*2;
o.fDensity = 1.0f/40.0f;
// o.fDensity = 1.0f/20.0f;
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0;
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0*2.0;
o.fDensity = 1.0/40.0;
// o.fDensity = 1.0/20.0;

for (int i=0; i<3; ++i)
{
Expand Down
Binary file modified res/gamedata/shaders/gl/accum_volumetric_sun.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/bloom_build.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/bloom_luminance_2.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/bloom_luminance_3.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/combine_1.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/combine_1.vs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
v2p _main ( _in I )
{
v2p O;
O.hpos = float4 (I.P.x, -I.P.y, 0, 1);
O.hpos = float4 (I.P.x, -I.P.y, 0.0, 1.0);
float scale = texelFetch(s_tonemap,int2(0,0),0).x;
O.tc0 = float4 (I.P.zw, scale, scale);
O.tcJ = I.tcJ;
Expand Down
Binary file modified res/gamedata/shaders/gl/combine_2_aa.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// #define USE_SUPER_SPECULAR

#ifdef USE_R2_STATIC_SUN
# define xmaterial float(1.0f/4.fs)
# define xmaterial float(1.0/4.0)
#else
# define xmaterial float(L_material.w)
#endif
Expand Down
22 changes: 11 additions & 11 deletions res/gamedata/shaders/gl/common_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

//////////////////////////////////////////////////////////////////////////////////////////
// Defines //
#define def_gloss float(2.f /255.f)
#define def_aref float(200.f/255.f)
#define def_dbumph float(0.333f)
#define def_virtualh float(0.05f) // 5cm
#define def_distort float(0.05f) // we get -0.5 .. 0.5 range, this is -512 .. 512 for 1024, so scale it
#define def_hdr float(9.f) // hight luminance range float(3.h)
#define def_hdr_clip float(0.75f) //
#define def_gloss float(2.0/255.0)
#define def_aref float(200.0/255.0)
#define def_dbumph float(0.333)
#define def_virtualh float(0.05) // 5cm
#define def_distort float(0.05) // we get -0.5 .. 0.5 range, this is -512 .. 512 for 1024, so scale it
#define def_hdr float(9.0) // hight luminance range float(3.h)
#define def_hdr_clip float(0.75) //

#define LUMINANCE_VECTOR float3(0.3f, 0.38f, 0.22f)
#define LUMINANCE_VECTOR float3(0.3, 0.38, 0.22)

//////////////////////////////////////////////////////////////////////////////////////////
#ifndef SMAP_size
#define SMAP_size 1024
#define SMAP_size 1024.0
#endif
#define PARALLAX_H 0.02
#define parallax float2(PARALLAX_H, -PARALLAX_H/2)
#define PARALLAX_H 0.02
#define parallax float2(PARALLAX_H, -PARALLAX_H/2)
//////////////////////////////////////////////////////////////////////////////////////////

#endif // common_defines_h_included
16 changes: 8 additions & 8 deletions res/gamedata/shaders/gl/common_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ float Contrast(float Input, float ContrastPower)
{
//piecewise contrast function
bool IsAboveHalf = Input > 0.5 ;
float ToRaise = saturate(2*(IsAboveHalf ? 1-Input : Input));
float ToRaise = saturate(2*(IsAboveHalf ? (1.0 - Input) : Input));
float Output = 0.5*pow(ToRaise, ContrastPower);
Output = IsAboveHalf ? 1-Output : Output;
Output = IsAboveHalf ? (1.0 - Output) : Output;
return Output;
}

Expand All @@ -21,7 +21,7 @@ void tonemap( out float4 low, out float4 high, float3 rgb, float scale)
const float fWhiteIntensitySQR = fWhiteIntensity*fWhiteIntensity;

// low = (rgb/(rgb + 1)).xyzz;
low = ( (rgb*(1+rgb/fWhiteIntensitySQR)) / (rgb+1) ).xyzz;
low = ( (rgb*(1.0+rgb/fWhiteIntensitySQR)) / (rgb+1.0) ).xyzz;

high = rgb.xyzz/def_hdr; // 8x dynamic range

Expand All @@ -35,7 +35,7 @@ void tonemap( out float4 low, out float4 high, float3 rgb, float scale)

float4 combine_bloom( float3 low, float4 high)
{
return float4( low + high.rgb*high.a, 1.f );
return float4( low + high.rgb*high.a, 1.0 );
}

float calc_fogging( float4 w_pos )
Expand All @@ -45,7 +45,7 @@ float calc_fogging( float4 w_pos )

float2 unpack_tc_base( float2 tc, float du, float dv )
{
return (tc.xy + float2 (du,dv))*(32.f/32768.f); //!Increase from 32bit to 64bit floating point
return (tc.xy + float2 (du,dv))*(32.0/32768.0); //!Increase from 32bit to 64bit floating point
}

float3 calc_sun_r1( float3 norm_w )
Expand All @@ -55,7 +55,7 @@ float3 calc_sun_r1( float3 norm_w )

float3 calc_model_hemi_r1( float3 norm_w )
{
return max(0,norm_w.y)*L_hemi_color.rgb;
return max(0.0,norm_w.y)*L_hemi_color.rgb;
}

float3 calc_model_lq_lighting( float3 norm_w )
Expand All @@ -69,7 +69,7 @@ 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 ]
float2 unpack_tc_lmap( float2 tc ) { return tc*(1.0/32768.0); } // [-1 .. +1 ]
float4 unpack_color( float4 c ) { return c.bgra; }
float4 unpack_D3DCOLOR( float4 c ) { return c.bgra; }
float3 unpack_D3DCOLOR( float3 c ) { return c.bgr; }
Expand All @@ -78,7 +78,7 @@ float3 p_hemi( float2 tc )
{
// float3 t_lmh = tex2D (s_hemi, tc);
// float3 t_lmh = s_hemi.Sample( smp_rtlinear, tc);
// return dot(t_lmh,1.f/4.f);
// return dot(t_lmh,1.0/4.0);
float4 t_lmh = tex2D (s_hemi, tc);
return float3(t_lmh.a);
}
Expand Down
Binary file modified res/gamedata/shaders/gl/deffer_base_aref_bump.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/deffer_base_aref_flat.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/deffer_base_bump.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/deffer_base_flat.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/deffer_impl_flat.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/deffer_model_bump.vs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ v2p_bumped _main( v_model I )
float3 N = I.N; // just scale (assume normal in the -.5f, .5f)
float3 T = I.T; //
float3 B = I.B; //
float3x3 xform = mul (float3x3(m_WV), float3x3(2.f*T,2.f*B,2.f*N));
float3x3 xform = mul (float3x3(m_WV), float3x3(2.0*T,2.0*B,2.0*N));
// The pixel shader operates on the bump-map in [0..1] range
// Remap this range in the matrix, anyway we are pixel-shader limited :)
// ...... [ 2 0 0 0]
Expand Down
Binary file modified res/gamedata/shaders/gl/deffer_particle.ps
Binary file not shown.
35 changes: 17 additions & 18 deletions res/gamedata/shaders/gl/dof.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ float DOFFactor(float depth)
}


//#define MAXCOF 5.f
#define MAXCOF 7.f
#define EPSDEPTHDOF 0.0001f
#define MAXCOF 7.0
#define EPSDEPTHDOF 0.0001
float3 dof(float2 center)
{
// Scale tap offsets based on render target size
Expand All @@ -46,31 +45,31 @@ float3 dof(float2 center)

//float blur = 1;
// const amount of blur: define controlled
//float2 scale = float2 (.5f / 1024.f, .5f / 768.f) * MAXCOF * blur;
//float2 scale = float2 (0.5 / 1024.0, 0.5 / 768.0) * MAXCOF * blur;
// const amount of blur: engine controlled
float2 scale = float2 (.5f / 1024.f, .5f / 768.f) * (dof_kernel.z * blur);
float2 scale = float2 (0.5 / 1024.0, 0.5 / 768.0) * (dof_kernel.z * blur);
// amount of blur varies according to resolution
// but kernel size in pixels is fixed.
// float2 scale = dof_kernel.xy * blur;

// poisson
float2 o [12];
o[0] = float2(-0.326212f , -0.405810f)*scale;
o[1] = float2(-0.840144f , -0.073580f)*scale;
o[2] = float2(-0.695914f , 0.457137f)*scale;
o[3] = float2(-0.203345f , 0.620716f)*scale;
o[4] = float2( 0.962340f , -0.194983f)*scale;
o[5] = float2( 0.473434f , -0.480026f)*scale;
o[6] = float2( 0.519456f , 0.767022f)*scale;
o[7] = float2( 0.185461f , -0.893124f)*scale;
o[8] = float2( 0.507431f , 0.064425f)*scale;
o[9] = float2( 0.896420f , 0.412458f)*scale;
o[10] = float2(-0.321940f , -0.932615f)*scale;
o[11] = float2(-0.791559f , -0.597710f)*scale;
o[0] = float2(-0.326212, -0.405810)*scale;
o[1] = float2(-0.840144, -0.073580)*scale;
o[2] = float2(-0.695914, 0.457137)*scale;
o[3] = float2(-0.203345, 0.620716)*scale;
o[4] = float2( 0.962340, -0.194983)*scale;
o[5] = float2( 0.473434, -0.480026)*scale;
o[6] = float2( 0.519456, 0.767022)*scale;
o[7] = float2( 0.185461, -0.893124)*scale;
o[8] = float2( 0.507431, 0.064425)*scale;
o[9] = float2( 0.896420, 0.412458)*scale;
o[10] = float2(-0.321940, -0.932615)*scale;
o[11] = float2(-0.791559, -0.597710)*scale;

// sample
float3 sum = tex2D(s_image,center).rgb;
float contrib = 1.f;
float contrib = 1.0;

for (int i=0; i<12; i++)
{
Expand Down
Binary file modified res/gamedata/shaders/gl/font2.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/lmape.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/lod.ps
Binary file not shown.
6 changes: 3 additions & 3 deletions res/gamedata/shaders/gl/model_def_lq.vs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ v2p _main(v_model v)
float3 pos_w = mul( m_W, pos );
float3 norm_w = normalize( mul( m_W, v.N ) );

o.hpos = mul( m_WVP, pos ); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
o.hpos = mul( m_WVP, pos ); // xform, input in world coords
o.tc0 = v.tc.xy; // copy tc
o.c0 = calc_model_lq_lighting( norm_w );
o.fog = saturate(calc_fogging( float4( pos_w, 1 ) )); // fog, input in world coords
o.fog = saturate(calc_fogging( float4( pos_w, 1.0 ) )); // fog, input in world coords

return o;
}
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/model_distort.vs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ vf _main (v_model v)
// calculate fade
float3 dir_v = normalize (mul(m_WV,v.P));
float3 norm_v = normalize (mul(m_WV,v.N));
float fade = 1.f-abs (dot(dir_v,norm_v));
float fade = 1.0-abs (dot(dir_v,norm_v));
o.c0 = float4 (fade);

return o;
Expand Down
Binary file modified res/gamedata/shaders/gl/model_env_lq.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/portal.vs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ v2p _main (v_vert v)
o.fog = saturate(o.fog);
o.c.rgb = lerp(fog_color.rgb, o.c.rgb, o.fog);

// float scale = tex2Dlod (s_tonemap,float4(.5,.5,.5,.5)).x ;
// float scale = tex2Dlod (s_tonemap,float4(0.5,0.5,0.5,0.5)).x ;
// float scale = s_tonemap.Load(int3(0,0,0)).x;
// float scale = s_tonemap.Load(int3(1,1,0)).x;
float scale = texelFetch(s_tonemap,int2(0,0),0).x;
Expand Down
Binary file modified res/gamedata/shaders/gl/postprocess.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/rain_apply_gloss.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/rain_apply_normal.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/rain_layer.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/rain_patch_normal.ps
Binary file not shown.
Binary file modified res/gamedata/shaders/gl/rain_patch_normal_new.ps
Binary file not shown.
16 changes: 8 additions & 8 deletions res/gamedata/shaders/gl/shadow.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ float shadow_hw( float4 tc )
float s2 = sample_hw_pcf( tc, float4( -1, +1, 0, 0) );
float s3 = sample_hw_pcf( tc, float4( +1, +1, 0, 0) );

return (s0+s1+s2+s3)/4.f;
return (s0+s1+s2+s3)/4.0;
}

#if SUN_QUALITY>=4
Expand Down Expand Up @@ -654,7 +654,7 @@ float4 test (float4 tc, float2 offset)
f.z = test (tc,-J0.xy+float2( k1, 0)).z;
f.w = test (tc,-J0.wz+float2( 0, k1)).x;
half res = ( r.x + r.y + r.z + r.w + f.x + f.y + f.z + f.w )*1.f/(4.f + 4.f );
half res = ( r.x + r.y + r.z + r.w + f.x + f.y + f.z + f.w )*1.0/(4.0 + 4.0 );
return res;
}*/
half shadowtest_sun (float4 tc, float4 tcJ) // jittered sampling
Expand All @@ -675,7 +675,7 @@ half shadowtest_sun (float4 tc, float4 tcJ) // jittered sampling
r.z = test (tc,-J0.xy+half2(-k, k)).z;
r.w = test (tc,-J0.wz+half2( k, k)).x;

return dot(r,float4(1.f/4.f));
return dot(r,float4(1.0/4.0));
}

half shadow_high (float4 tc) // jittered sampling
Expand All @@ -686,7 +686,7 @@ half shadow_high (float4 tc) // jittered sampling
float2 tc_J = frac(tc.xy/tc.w*SMAP_size/4.0f )*.5f;
float4 J0 = tex2D (jitter0,tc_J)*scale;

const float k = 1.f/float(SMAP_size);
const float k = 1.0/float(SMAP_size);
half4 r;
r.x = test (tc,J0.xy+half2(-k,-k)).x;
r.y = test (tc,J0.wz+half2( k,-k)).y;
Expand All @@ -703,7 +703,7 @@ half shadow_high (float4 tc) // jittered sampling
r1.z = test (tc,-2*J0.xy+half2( k1, 0)).z;
r1.w = test (tc,-2*J0.wz+half2( 0, k1)).x;

return ( r.x + r.y + r.z + r.w + r1.x + r1.y + r1.z + r1.w )*1.f/8.f;
return ( r.x + r.y + r.z + r.w + r1.x + r1.y + r1.z + r1.w )*1.0/8.0;
}

float shadow( float4 tc )
Expand Down Expand Up @@ -779,7 +779,7 @@ float shadowtest (float4 tc, float4 tcJ) // jittered sampling
r.z = test (tc,J1.xy).z;
r.w = test (tc,J1.wz).x;

return dot(r,float4(1.f/4.f));
return dot(r,float4(1.0/4.0));
}

float shadow_rain (float4 tc, float2 tcJ) // jittered sampling
Expand All @@ -804,7 +804,7 @@ float shadow_rain (float4 tc, float2 tcJ) // jittered sampling
// r.z = test (tc,J0.yz).z;
// r.w = test (tc,J0.xw).x;

return dot(r,float4(1.f/4.f));
return dot(r,float4(1.0/4.0));
}

//////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -816,7 +816,7 @@ float sunmask( float4 P )
return tex2D( s_lmap, tc ).w; // A8
}
#else
float sunmask( float4 P ) { return 1.f; } //
float sunmask( float4 P ) { return 1.0; } //
#endif
//////////////////////////////////////////////////////////////////////////////////////////
uniform float4x4 m_shadow;
Expand Down
Binary file modified res/gamedata/shaders/gl/shadow_direct_base.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion res/gamedata/shaders/gl/shadow_direct_tree.vs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ v2p_shadow_direct _main ( v_shadow_direct I )
float inten = H * dp; // intensity
float2 result;
#ifdef USE_TREEWAVE
result = float2(0);
result = float2(0.0, 0.0);
#else // USE_TREEWAVE
#ifdef USE_AREF
float frac = I.tc.z*consts.x; // fractional (or rigidity)
Expand Down
10 changes: 5 additions & 5 deletions res/gamedata/shaders/gl/shared/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ void sincos(float x, out float s, out float c) { s = sin(x); c = cos(x); }

float calc_cyclic (float x)
{
float phase = 1/(2*3.141592653589f);
float sqrt2 = 1.4142136f;
float sqrt2m2 = 2.8284271f;
float phase = 1/(2*3.141592653589);
float sqrt2 = 1.4142136;
float sqrt2m2 = 2.8284271;
float f = sqrt2m2*frac(x)-sqrt2; // [-sqrt2 .. +sqrt2] !No changes made, but this controls the grass wave (which is violent if I must say)
return f*f - 1.f; // [-1 .. +1]
return f*f - 1.0; // [-1 .. +1]
}

float2 calc_xz_wave (float2 dir2D, float frac)
{
// Beizer
float2 ctrl_A = float2(0.f, 0.f );
float2 ctrl_A = float2(0.0, 0.0 );
float2 ctrl_B = float2(dir2D.x, dir2D.y );
return lerp (ctrl_A, ctrl_B, frac); //!This calculates tree wave. No changes made
}
Expand Down
Loading

0 comments on commit 23e9a2c

Please sign in to comment.