diff --git a/res/gamedata/shaders/gl/accum_emissivel.ps b/res/gamedata/shaders/gl/accum_emissivel.ps new file mode 100644 index 00000000000..cb676e36955 Binary files /dev/null and b/res/gamedata/shaders/gl/accum_emissivel.ps differ diff --git a/res/gamedata/shaders/gl/font2.ps b/res/gamedata/shaders/gl/font2.ps new file mode 100644 index 00000000000..cad75d6974f Binary files /dev/null and b/res/gamedata/shaders/gl/font2.ps differ diff --git a/res/gamedata/shaders/gl/iostructs/p_lmape.h b/res/gamedata/shaders/gl/iostructs/p_lmape.h new file mode 100644 index 00000000000..d1f5ca3e9d2 --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/p_lmape.h @@ -0,0 +1,37 @@ + +out vec4 SV_Target; + +struct v2p +{ + float2 tc0 ; // TEXCOORD0; // base + float2 tc1 ; // TEXCOORD1; // lmap + float2 tc2 ; // TEXCOORD2; // hemi + float3 tc3 ; // TEXCOORD3; // env + float3 c0 ; // COLOR0; + float3 c1 ; // COLOR1; + float fog ; // FOG; +}; + +layout(location = TEXCOORD0) in float2 v2p_lmape_tc0 ; // TEXCOORD0; // base +layout(location = TEXCOORD1) in float2 v2p_lmape_tc1 ; // TEXCOORD1; // lmap +layout(location = TEXCOORD2) in float2 v2p_lmape_tc2 ; // TEXCOORD2; // hemi +layout(location = TEXCOORD3) in float3 v2p_lmape_tc3 ; // TEXCOORD3; // env +layout(location = COLOR0) in float3 v2p_lmape_c0 ; // COLOR0; +layout(location = COLOR1) in float3 v2p_lmape_c1 ; // COLOR1; +layout(location = FOG) in float v2p_lmape_fog ; // FOG; + +float4 _main ( v2p I ); + +void main() +{ + v2p I; + I.tc0 = v2p_lmape_tc0; + I.tc1 = v2p_lmape_tc1; + I.tc2 = v2p_lmape_tc2; + I.tc3 = v2p_lmape_tc3; + I.c0 = v2p_lmape_c0; + I.c1 = v2p_lmape_c1; + I.fog = v2p_lmape_fog; + + SV_Target = _main (I); +} diff --git a/res/gamedata/shaders/gl/iostructs/p_lod.h b/res/gamedata/shaders/gl/iostructs/p_lod.h new file mode 100644 index 00000000000..47e2874e24f --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/p_lod.h @@ -0,0 +1,68 @@ + +out vec4 SV_Target0; +#ifndef ATOC +out vec4 SV_Target1; +#ifndef GBUFFER_OPTIMIZATION +out vec4 SV_Target2; +#endif // GBUFFER_OPTIMIZATION +#ifdef EXTEND_F_DEFFER +out int gl_SampleMask[]; +#endif // EXTEND_F_DEFFER +#ifdef MSAA_ALPHATEST_DX10_1_ATOC +in vec4 gl_FragCoord; +#endif // MSAA_ALPHATEST_DX10_1_ATOC +#endif // #endif + +struct v2p +{ + float3 Pe ; // TEXCOORD0; + float2 tc0 ; // TEXCOORD1; // base0 + float2 tc1 ; // TEXCOORD2; // base1 + float4 af ; // COLOR1; // alpha&factor //skyloader: COLOR1? maybe COLOR0? +}; + +layout(location = TEXCOORD0) in float3 v2p_lod_Pe ; // TEXCOORD0; // base +layout(location = TEXCOORD1) in float2 v2p_lod_tc0 ; // TEXCOORD1; // lmap +layout(location = TEXCOORD2) in float2 v2p_lod_tc1 ; // TEXCOORD2; // hemi +layout(location = COLOR1) in float4 v2p_lod_af ; // COLOR1; + +#ifdef ATOC +float4 _main ( v2p I ); +#else // ATOC +#ifdef MSAA_ALPHATEST_DX10_1_ATOC +f_deffer _main ( v2p I, float4 pos2d ); +#else // MSAA_ALPHATEST_DX10_1_ATOC +f_deffer _main ( v2p I ); +#endif // MSAA_ALPHATEST_DX10_1_ATOC +#endif // ATOC + +void main() +{ + v2p I; + I.Pe = v2p_lod_Pe; + I.tc0 = v2p_lod_tc0; + I.tc1 = v2p_lod_tc1; + I.af = v2p_lod_af; + +#ifdef ATOC + SV_Target = _main (I); +#else // ATOC +#ifdef MSAA_ALPHATEST_DX10_1_ATOC + f_deffer O = _main (I, gl_FragCoord); +#else + f_deffer O = _main (I); +#endif // MSAA_ALPHATEST_DX10_1_ATOC + +#endif // ATOC + + SV_Target0 = O.position; +#ifdef GBUFFER_OPTIMIZATION + SV_Target1 = O.C; +#else + SV_Target1 = O.Ne; + SV_Target2 = O.C; +#endif // GBUFFER_OPTIMIZATION +#ifdef EXTEND_F_DEFFER + gl_SampleMask[0] = O.mask; +#endif +} diff --git a/res/gamedata/shaders/gl/iostructs/p_vert.h b/res/gamedata/shaders/gl/iostructs/p_vert.h new file mode 100644 index 00000000000..05b69f5be46 --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/p_vert.h @@ -0,0 +1,25 @@ + +out vec4 SV_Target; + +struct v2p +{ + float2 Tex0 ; // TEXCOORD0; + float3 c0 ; // COLOR0; // c0=all lighting + float fog ; // FOG; +}; + +layout(location = TEXCOORD0) in float2 v2p_vert_tc ; // TEXCOORD0; +layout(location = COLOR0) in float3 v2p_vert_c ; // COLOR0; // c0=all lighting +layout(location = FOG) in float v2p_vert_fog ; // FOG; + +float4 _main ( v2p I ); + +void main() +{ + v2p I; + I.Tex0 = v2p_vert_tc; + I.c0 = v2p_vert_c; + I.fog = v2p_vert_fog; + + SV_Target = _main (I); +} diff --git a/res/gamedata/shaders/gl/iostructs/p_water.h b/res/gamedata/shaders/gl/iostructs/p_water.h new file mode 100644 index 00000000000..1a01242f257 --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/p_water.h @@ -0,0 +1,63 @@ + +out vec4 SV_Target; +#ifdef GBUFFER_OPTIMIZATION +in vec4 gl_FragCoord; +#endif + +struct v2p +{ + float2 tbase ; // TEXCOORD0; // base + float2 tnorm0 ; // TEXCOORD1; // nm0 + float2 tnorm1 ; // TEXCOORD2; // nm1 + float3 M1 ; // TEXCOORD3; + float3 M2 ; // TEXCOORD4; + float3 M3 ; // TEXCOORD5; + float3 v2point ; // TEXCOORD6; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + float4 tctexgen; // TEXCOORD7; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + float4 c0 ; // COLOR0; + float fog ; // FOG; +}; + +layout(location = TEXCOORD0) in float2 v2p_vert_tbase ; // TEXCOORD0; +layout(location = TEXCOORD1) in float2 v2p_vert_tnorm0 ; // TEXCOORD1; +layout(location = TEXCOORD2) in float2 v2p_vert_tnorm1 ; // TEXCOORD2; +layout(location = TEXCOORD3) in float3 v2p_vert_M1 ; // TEXCOORD3; +layout(location = TEXCOORD4) in float3 v2p_vert_M2 ; // TEXCOORD4; +layout(location = TEXCOORD5) in float3 v2p_vert_M3 ; // TEXCOORD5; +layout(location = TEXCOORD6) in float3 v2p_vert_v2point ; // TEXCOORD6; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +layout(location = TEXCOORD7) in float4 v2p_vert_tctexgen ; // TEXCOORD7; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +layout(location = COLOR0) in float4 v2p_vert_c0 ; // COLOR0; +layout(location = FOG) in float v2p_vert_fog ; // FOG; + +#ifdef GBUFFER_OPTIMIZATION +float4 _main( v2p I, float4 pos2d ); +#else +float4 _main( v2p I ); +#endif + +void main() +{ + v2p I; + + I.tbase = v2p_vert_tbase; + I.tnorm0 = v2p_vert_tnorm0; + I.tnorm1 = v2p_vert_tnorm1; + I.M1 = v2p_vert_M1; + I.M2 = v2p_vert_M2; + I.M3 = v2p_vert_M3; + I.v2point = v2p_vert_v2point; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + I.tctexgen = v2p_vert_tctexgen; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + I.c0 = v2p_vert_c0; + I.fog = v2p_vert_fog; +#ifdef GBUFFER_OPTIMIZATION + SV_Target = _main ( I, gl_FragCoord ); +#else + SV_Target = _main ( I ); +#endif +} diff --git a/res/gamedata/shaders/gl/iostructs/p_waterd.h b/res/gamedata/shaders/gl/iostructs/p_waterd.h new file mode 100644 index 00000000000..4450f99350d --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/p_waterd.h @@ -0,0 +1,33 @@ + +out vec4 SV_Target; + +struct v2p +{ + float2 tbase ; // TEXCOORD0; + float2 tdist0 ; // TEXCOORD1; + float2 tdist1 ; // TEXCOORD2; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + float4 tctexgen; // TEXCOORD3; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +}; + +layout(location = TEXCOORD0) in float2 v2p_vert_tbase ; // TEXCOORD0; +layout(location = TEXCOORD1) in float2 v2p_vert_tdist0 ; // TEXCOORD1; +layout(location = TEXCOORD2) in float2 v2p_vert_tdist1 ; // TEXCOORD2; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +layout(location = TEXCOORD3) in float4 v2p_vert_tctexgen ; // TEXCOORD3; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + +float4 _main ( v2p I ); + +void main() +{ + v2p I; + I.tbase = v2p_vert_tbase; + I.tdist0 = v2p_vert_tdist0; + I.tdist1 = v2p_vert_tdist1; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + I.tctexgen = v2p_vert_tctexgen; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + SV_Target = _main (I); +} diff --git a/res/gamedata/shaders/gl/iostructs/v_lmape.h b/res/gamedata/shaders/gl/iostructs/v_lmape.h new file mode 100644 index 00000000000..30bbd8f05b6 --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/v_lmape.h @@ -0,0 +1,70 @@ + +out gl_PerVertex { vec4 gl_Position; }; + +struct v_static +{ + float4 Nh ; // NORMAL; // (nx,ny,nz,hemi occlusion) + float4 T ; // TANGENT; // tangent + float4 B ; // BINORMAL; // binormal + float2 tc ; // TEXCOORD0; // (u,v) +#ifdef USE_LM_HEMI + float2 lmh ; // TEXCOORD1; // (lmu,lmv) +#endif + float4 P ; // POSITION; // (float,float,float,1) +}; + +struct v2p +{ + float4 hpos ; // SV_Position; + float2 tc0 ; // TEXCOORD0; // base + float2 tc1 ; // TEXCOORD1; // lmap + float2 tc2 ; // TEXCOORD2; // hemi + float3 tc3 ; // TEXCOORD3; // env + float3 c0 ; // COLOR0; + float3 c1 ; // COLOR1; + float fog ; // FOG; +}; + +layout(location = POSITION) in float4 v_static_P ; // POSITION; // (float,float,float,1) +layout(location = NORMAL) in float4 v_static_N ; // 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 float2 v_static_tc ; // TEXCOORD0; // (u,v) +#ifdef USE_LM_HEMI +layout(location = TEXCOORD1) in float2 v_static_lmh ; // TEXCOORD1; // (lmu,lmv) +#endif + + +layout(location = TEXCOORD0) out float2 v2p_lmape_tc0 ; // TEXCOORD0; // base +layout(location = TEXCOORD1) out float2 v2p_lmape_tc1 ; // TEXCOORD1; // lmap +layout(location = TEXCOORD2) out float2 v2p_lmape_tc2 ; // TEXCOORD2; // hemi +layout(location = TEXCOORD3) out float3 v2p_lmape_tc3 ; // TEXCOORD3; // env +layout(location = COLOR0) out float3 v2p_lmape_c0 ; // COLOR0; +layout(location = COLOR1) out float3 v2p_lmape_c1 ; // COLOR1; +layout(location = FOG) out float v2p_lmape_fog ; // FOG; + +v2p _main ( v_static I ); + +void main() +{ + v_static I; + I.P = v_static_P; + I.Nh = v_static_N; + 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 + + v2p O = _main (I); + + v2p_lmape_tc0 = O.tc0; + v2p_lmape_tc1 = O.tc1; + v2p_lmape_tc2 = O.tc2; + v2p_lmape_tc3 = O.tc3; + v2p_lmape_c0 = O.c0; + v2p_lmape_c1 = O.c1; + v2p_lmape_fog = O.fog; + gl_Position = O.hpos; +} diff --git a/res/gamedata/shaders/gl/iostructs/v_lod.h b/res/gamedata/shaders/gl/iostructs/v_lod.h new file mode 100644 index 00000000000..146faac4d2c --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/v_lod.h @@ -0,0 +1,63 @@ + +out gl_PerVertex { vec4 gl_Position; }; + +struct v_lod +{ + float3 pos0 ; // POSITION0; + float3 pos1 ; // POSITION1; + float3 n0 ; // NORMAL0; + float3 n1 ; // NORMAL1; + float2 tc0 ; // TEXCOORD0; + float2 tc1 ; // TEXCOORD1; + float4 rgbh0 ; // TEXCOORD2; // rgb.h + float4 rgbh1 ; // TEXCOORD3; // rgb.h + float4 sun_af ; // COLOR0; // x=sun_0, y=sun_1, z=alpha, w=factor +}; +struct v2p +{ + float4 hpos ; // SV_Position; + float3 Pe ; // TEXCOORD0; + float2 tc0 ; // TEXCOORD1; // base0 + float2 tc1 ; // TEXCOORD2; // base1 + float4 af ; // COLOR1; // alpha&factor //skyloader: COLOR1? maybe COLOR0? +}; + +layout(location = POSITION0) in float3 v_lod_pos0 ; // POSITION0; +layout(location = POSITION1) in float3 v_lod_pos1 ; // POSITION1; +layout(location = NORMAL0) in float3 v_lod_n0 ; // NORMAL0; +layout(location = NORMAL1) in float3 v_lod_n1 ; // NORMAL1; +layout(location = TEXCOORD0) in float2 v_lod_tc0 ; // TEXCOORD0; +layout(location = TEXCOORD1) in float2 v_lod_tc1 ; // TEXCOORD1; +layout(location = TEXCOORD2) in float4 v_lod_rgbh0 ; // TEXCOORD2; // rgb.h +layout(location = TEXCOORD3) in float4 v_lod_rgbh1 ; // TEXCOORD3; // rgb.h +layout(location = COLOR0) in float4 v_lod_sun_af ; // COLOR0; // x=sun_0, y=sun_1, z=alpha, w=factor + + +layout(location = TEXCOORD0) out float3 v2p_lod_Pe ; // TEXCOORD0; // base +layout(location = TEXCOORD1) out float2 v2p_lod_tc0 ; // TEXCOORD1; // lmap +layout(location = TEXCOORD2) out float2 v2p_lod_tc1 ; // TEXCOORD2; // hemi +layout(location = COLOR1) out float4 v2p_lod_af ; // COLOR1; + +v2p _main ( v_lod I ); + +void main() +{ + v_lod I; + I.pos0 = v_lod_pos0; + I.pos1 = v_lod_pos1; + I.n0 = v_lod_n0; + I.n1 = v_lod_n1; + I.tc0 = v_lod_tc0; + I.tc1 = v_lod_tc1; + I.rgbh0 = v_lod_rgbh0; + I.rgbh1 = v_lod_rgbh1; + I.sun_af = v_lod_sun_af; + + v2p O = _main (I); + + v2p_lod_Pe = O.Pe; + v2p_lod_tc0 = O.tc0; + v2p_lod_tc1 = O.tc1; + v2p_lod_af = O.af; + gl_Position = O.hpos; +} diff --git a/res/gamedata/shaders/gl/iostructs/v_vert.h b/res/gamedata/shaders/gl/iostructs/v_vert.h new file mode 100644 index 00000000000..861a6b4425f --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/v_vert.h @@ -0,0 +1,61 @@ + +out gl_PerVertex { vec4 gl_Position; }; + +struct v_static_color +{ + float4 Nh ; // NORMAL; // (nx,ny,nz,hemi occlusion) + float4 T ; // TANGENT; // tangent + float4 B ; // BINORMAL; // binormal + float2 tc ; // TEXCOORD0; // (u,v) +#ifdef USE_LM_HEMI + float2 lmh ; // TEXCOORD1; // (lmu,lmv) +#endif + float4 color ; // COLOR0; // (r,g,b,dir-occlusion) // Swizzle before use!!! + float4 P ; // POSITION; // (float,float,float,1) +}; + +struct v2p +{ + float4 hpos ; // SV_Position; + float2 Tex0 ; // TEXCOORD0; + float3 c0 ; // COLOR0; // c0=all lighting + float fog ; // FOG; +}; + +layout(location = POSITION) in float4 v_static_color_P ; // POSITION; // (float,float,float,1) +layout(location = NORMAL) in float4 v_static_color_N ; // NORMAL; // (nx,ny,nz,hemi occlusion) +layout(location = TANGENT) in float4 v_static_color_T ; // TANGENT; // tangent +layout(location = BINORMAL) in float4 v_static_color_B ; // BINORMAL; // binormal +layout(location = TEXCOORD0) in float2 v_static_color_tc ; // TEXCOORD0; // (u,v) +#ifdef USE_LM_HEMI +layout(location = TEXCOORD1) in float2 v_static_color_lmh ; // TEXCOORD1; // (lmu,lmv) +#endif +layout(location = COLOR0) in float4 v_static_color_c ; // COLOR0; // (r,g,b,dir-occlusion) + + +layout(location = TEXCOORD0) out float2 v2p_vert_tc ; // TEXCOORD0; +layout(location = COLOR0) out float3 v2p_vert_c ; // COLOR0; // c0=all lighting +layout(location = FOG) out float v2p_vert_fog ; // FOG; + +v2p _main ( v_static_color I ); + +void main() +{ + v_static_color I; + I.P = v_static_color_P; + I.Nh = v_static_color_N; + I.T = v_static_color_T; + I.B = v_static_color_B; + I.tc = v_static_color_tc; +#ifdef USE_LM_HEMI + I.lmh = v_static_color_lmh; +#endif + I.color = v_static_color_c; + + v2p O = _main (I); + + v2p_vert_tc = O.Tex0; + v2p_vert_c = O.c0; + v2p_vert_fog = O.fog; + gl_Position = O.hpos; +} diff --git a/res/gamedata/shaders/gl/iostructs/v_water.h b/res/gamedata/shaders/gl/iostructs/v_water.h new file mode 100644 index 00000000000..db36196e33c --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/v_water.h @@ -0,0 +1,77 @@ + +out gl_PerVertex { vec4 gl_Position; }; + +struct v_vert +{ + float4 P ; // POSITION; // (float,float,float,1) + float4 N ; // NORMAL; // (nx,ny,nz,hemi occlusion) + float4 T ; // TANGENT; + float4 B ; // BINORMAL; + float4 color ; // COLOR0; // (r,g,b,dir-occlusion) + float2 uv ; // TEXCOORD0; // (u0,v0) +}; +struct v2p +{ + float4 hpos ; // SV_Position; + float2 tbase ; // TEXCOORD0; // base + float2 tnorm0 ; // TEXCOORD1; // nm0 + float2 tnorm1 ; // TEXCOORD2; // nm1 + float3 M1 ; // TEXCOORD3; + float3 M2 ; // TEXCOORD4; + float3 M3 ; // TEXCOORD5; + float3 v2point ; // TEXCOORD6; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + float4 tctexgen; // TEXCOORD7; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + float4 c0 ; // COLOR0; + float fog ; // FOG; +}; + +layout(location = POSITION) in float4 v_vert_P ; // POSITION; // (float,float,float,1) +layout(location = NORMAL) in float4 v_vert_N ; // NORMAL; // (nx,ny,nz,hemi occlusion) +layout(location = TANGENT) in float4 v_vert_T ; // TANGENT; // tangent +layout(location = BINORMAL) in float4 v_vert_B ; // BINORMAL; // binormal +layout(location = COLOR0) in float4 v_vert_color ; // COLOR0; // (r,g,b,dir-occlusion) +layout(location = TEXCOORD0) in float2 v_vert_uv ; // TEXCOORD0; // (u0,v0) + +layout(location = TEXCOORD0) out float2 v2p_vert_tbase ; // TEXCOORD0; +layout(location = TEXCOORD1) out float2 v2p_vert_tnorm0 ; // TEXCOORD1; +layout(location = TEXCOORD2) out float2 v2p_vert_tnorm1 ; // TEXCOORD2; +layout(location = TEXCOORD3) out float3 v2p_vert_M1 ; // TEXCOORD3; +layout(location = TEXCOORD4) out float3 v2p_vert_M2 ; // TEXCOORD4; +layout(location = TEXCOORD5) out float3 v2p_vert_M3 ; // TEXCOORD5; +layout(location = TEXCOORD6) out float3 v2p_vert_v2point ; // TEXCOORD6; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +layout(location = TEXCOORD7) out float4 v2p_vert_tctexgen ; // TEXCOORD7; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +layout(location = COLOR0) out float4 v2p_vert_c0 ; // COLOR0; +layout(location = FOG) out float v2p_vert_fog ; // FOG; + +v2p _main (v_vert v); + +void main() +{ + v_vert I; + I.P = v_vert_P; + I.N = v_vert_N; + I.T = v_vert_T; + I.B = v_vert_B; + I.color = v_vert_color; + I.uv = v_vert_uv; + + v2p O = _main (I); + + v2p_vert_tbase = O.tbase; + v2p_vert_tnorm0 = O.tnorm0; + v2p_vert_tnorm1 = O.tnorm1; + v2p_vert_M1 = O.M1; + v2p_vert_M2 = O.M2; + v2p_vert_M3 = O.M3; + v2p_vert_v2point= O.v2point; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + v2p_vert_tctexgen = O.tctexgen; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + v2p_vert_c0 = O.c0; + v2p_vert_fog = O.fog; + gl_Position = O.hpos; +} diff --git a/res/gamedata/shaders/gl/iostructs/v_waterd.h b/res/gamedata/shaders/gl/iostructs/v_waterd.h new file mode 100644 index 00000000000..51da1513f64 --- /dev/null +++ b/res/gamedata/shaders/gl/iostructs/v_waterd.h @@ -0,0 +1,59 @@ + +out gl_PerVertex { vec4 gl_Position; }; + +struct v_vert +{ + float4 P ; // POSITION; // (float,float,float,1) + float4 N ; // NORMAL; // (nx,ny,nz,hemi occlusion) + float4 T ; // TANGENT; + float4 B ; // BINORMAL; + float4 color ; // COLOR0; // (r,g,b,dir-occlusion) + int2 uv ; // TEXCOORD0; // (u0,v0) +}; +struct v2p +{ + float4 hpos ; // SV_Position; + float2 tbase ; // TEXCOORD0; + float2 tdist0 ; // TEXCOORD1; + float2 tdist1 ; // TEXCOORD2; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + float4 tctexgen; // TEXCOORD3; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +}; + +layout(location = POSITION) in float4 v_vert_P ; // POSITION; // (float,float,float,1) +layout(location = NORMAL) in float4 v_vert_N ; // NORMAL; // (nx,ny,nz,hemi occlusion) +layout(location = TANGENT) in float4 v_vert_T ; // TANGENT; // tangent +layout(location = BINORMAL) in float4 v_vert_B ; // BINORMAL; // binormal +layout(location = COLOR0) in float4 v_vert_color ; // COLOR0; // (r,g,b,dir-occlusion) +layout(location = TEXCOORD0) in int2 v_vert_uv ; // TEXCOORD0; // (u0,v0) + +layout(location = TEXCOORD0) out float2 v2p_vert_tbase ; // TEXCOORD0; +layout(location = TEXCOORD1) out float2 v2p_vert_tdist0 ; // TEXCOORD1; +layout(location = TEXCOORD2) out float2 v2p_vert_tdist1 ; // TEXCOORD2; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) +layout(location = TEXCOORD3) out float4 v2p_vert_tctexgen ; // TEXCOORD3; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + +v2p _main (v_vert v); + +void main() +{ + v_vert I; + I.P = v_vert_P; + I.N = v_vert_N; + I.T = v_vert_T; + I.B = v_vert_B; + I.color = v_vert_color; + I.uv = v_vert_uv; + + v2p O = _main (I); + + v2p_vert_tbase = O.tbase; + v2p_vert_tdist0 = O.tdist0; + v2p_vert_tdist1 = O.tdist1; +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + v2p_vert_tctexgen = O.tctexgen; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + gl_Position = O.hpos; +} diff --git a/res/gamedata/shaders/gl/lmape.ps b/res/gamedata/shaders/gl/lmape.ps new file mode 100644 index 00000000000..997eb34587f Binary files /dev/null and b/res/gamedata/shaders/gl/lmape.ps differ diff --git a/res/gamedata/shaders/gl/lmape.vs b/res/gamedata/shaders/gl/lmape.vs new file mode 100644 index 00000000000..9c1183a3ad8 --- /dev/null +++ b/res/gamedata/shaders/gl/lmape.vs @@ -0,0 +1,22 @@ +#define USE_LM_HEMI +#include "common.h" +#include "iostructs\v_lmape.h" + +v2p _main(v_static v) +{ + v2p o; + + float3 pos_w = v.P.xyz; + float3 norm_w = normalize(unpack_normal(v.Nh)); + + o.hpos = mul (m_VP, v.P); // xform, input in world coords + o.tc0 = unpack_tc_base (v.tc,v.T.w,v.B.w); // copy tc + o.tc1 = unpack_tc_lmap (v.lmh); // copy tc + o.tc2 = o.tc1; + o.tc3 = calc_reflection (pos_w, norm_w); + o.c0 = v_hemi(norm_w); // just hemisphere + o.c1 = v_sun (norm_w); // sun + o.fog = saturate(calc_fogging (v.P)); // fog, input in world coords + + return o; +} diff --git a/res/gamedata/shaders/gl/lod.ps b/res/gamedata/shaders/gl/lod.ps new file mode 100644 index 00000000000..7272a244d84 Binary files /dev/null and b/res/gamedata/shaders/gl/lod.ps differ diff --git a/res/gamedata/shaders/gl/lod.vs b/res/gamedata/shaders/gl/lod.vs new file mode 100644 index 00000000000..a0a1ef1697f --- /dev/null +++ b/res/gamedata/shaders/gl/lod.vs @@ -0,0 +1,30 @@ +#include "common.h" +#include "iostructs\v_lod.h" + +#define L_SCALE (2.0f*1.55f) +v2p _main ( v_lod I ) +{ + v2p o; + + //I.sun_af.xyz = I.sun_af.zyx; // skyloader: is unpack_D3DCOLOR needed here? + //I.rgbh0.xyz = I.rgbh0.zyx; + //I.rgbh1.xyz = I.rgbh1.zyx; + + // lerp pos + float factor = I.sun_af.w; + float4 pos = float4 (lerp(I.pos0,I.pos1,factor), 1.f); + + float h = lerp (I.rgbh0.w,I.rgbh1.w,factor)*L_SCALE; + + o.hpos = mul (m_VP, pos); // xform, input in world coords + o.Pe = mul (m_V, pos); + + // replicate TCs + o.tc0 = I.tc0; + o.tc1 = I.tc1; + + // calc normal & lighting + o.af = float4 (h,h,I.sun_af.z,factor); + return o; +} + diff --git a/res/gamedata/shaders/gl/model_distort.vs b/res/gamedata/shaders/gl/model_distort.vs new file mode 100644 index 00000000000..34e29e481c5 --- /dev/null +++ b/res/gamedata/shaders/gl/model_distort.vs @@ -0,0 +1,19 @@ +#include "common.h" +#include "skin.h" +#include "iostructs\v_model_distort.h" + +vf _main (v_model v) +{ + vf o; + + o.hpos = mul (m_WVP, v.P); // xform, input in world coords + o.tc0 = v.tc.xy; // copy tc + + // 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)); + o.c0 = float4 (fade); + + return o; +} diff --git a/res/gamedata/shaders/gl/model_distort4glass.vs b/res/gamedata/shaders/gl/model_distort4glass.vs index c2fef6e6ada..84856055452 100644 --- a/res/gamedata/shaders/gl/model_distort4glass.vs +++ b/res/gamedata/shaders/gl/model_distort4glass.vs @@ -2,18 +2,18 @@ #include "skin.h" #include "iostructs\v_model_distort.h" -vf _main (v_model v) +vf _main (v_model v) { - vf o; + vf o; - o.hpos = mul (m_WVP, v.P); // xform, input in world coords - o.tc0 = v.tc.xy; // copy tc + o.hpos = mul (m_WVP, v.P); // xform, input in world coords + o.tc0 = v.tc.xy; // copy tc - // calculate fade - float3 dir_v = normalize (mul(m_WV,v.P)); - float3 norm_v = normalize (mul(m_WV,v.N)); - float fade = 0.9*abs (dot(dir_v,norm_v)); - o.c0 = float4(fade); + // calculate fade + float3 dir_v = normalize (mul(m_WV,v.P)); + float3 norm_v = normalize (mul(m_WV,v.N)); + float fade = 0.9f*abs (dot(dir_v,norm_v)); + o.c0 = float4 (fade); - return o; + return o; } diff --git a/res/gamedata/shaders/gl/shared/common.h b/res/gamedata/shaders/gl/shared/common.h index 22bb089ed2b..465aa88f628 100644 --- a/res/gamedata/shaders/gl/shared/common.h +++ b/res/gamedata/shaders/gl/shared/common.h @@ -58,10 +58,14 @@ void sincos(float x, out float s, out float c) { s = sin(x); c = cos(x); } #define COLOR2 2 #define POSITION 3 #define POSITIONT 3 +#define POSITION0 3 +#define POSITION1 4 #define TANGENT 4 #define NORMAL 5 +#define NORMAL0 5 +#define NORMAL1 6 #define BINORMAL 6 -#define FOG 7 +#define FOG 7 #define TEXCOORD0 8 #define TEXCOORD1 9 #define TEXCOORD2 10 diff --git a/res/gamedata/shaders/gl/vert.ps b/res/gamedata/shaders/gl/vert.ps new file mode 100644 index 00000000000..d96a45cc689 Binary files /dev/null and b/res/gamedata/shaders/gl/vert.ps differ diff --git a/res/gamedata/shaders/gl/vert.vs b/res/gamedata/shaders/gl/vert.vs new file mode 100644 index 00000000000..cb6f9947846 --- /dev/null +++ b/res/gamedata/shaders/gl/vert.vs @@ -0,0 +1,21 @@ +#include "common.h" +#include "iostructs\v_vert.h" + +v2p _main (v_static_color v) +{ + v2p o; + + float3 N = unpack_normal (v.Nh.xyz); + o.hpos = mul (m_VP, v.P); // xform, input in world coords + o.Tex0 = unpack_tc_base (v.tc,v.T.w,v.B.w); // copy tc + + float3 L_rgb = v.color.bgr; // precalculated RGB lighting + float3 L_hemi = v_hemi(N)*v.Nh.w; // hemisphere + float3 L_sun = v_sun(N)*v.color.w; // sun + float3 L_final = L_rgb + L_hemi + L_sun + L_ambient.rgb; + + o.c0 = L_final; + o.fog = saturate(calc_fogging (v.P)); // fog, input in world coords + + return o; +} diff --git a/res/gamedata/shaders/gl/water.ps b/res/gamedata/shaders/gl/water.ps new file mode 100644 index 00000000000..561c12aacd8 Binary files /dev/null and b/res/gamedata/shaders/gl/water.ps differ diff --git a/res/gamedata/shaders/gl/water.vs b/res/gamedata/shaders/gl/water.vs new file mode 100644 index 00000000000..c7eef1bed99 --- /dev/null +++ b/res/gamedata/shaders/gl/water.vs @@ -0,0 +1,67 @@ +#include "common.h" +#include "shared\waterconfig.h" +#include "shared\watermove.h" +#include "iostructs\v_water.h" + +uniform float4x4 m_texgen; + +v2p _main (v_vert v) +{ + //v.N = unpack_D3DCOLOR(v.N); + //v.T = unpack_D3DCOLOR(v.T); + //v.B = unpack_D3DCOLOR(v.B); + //v.color = unpack_D3DCOLOR(v.color); + + v2p o; + + float4 P = v.P; // world + float3 NN = unpack_normal(v.N); + P = watermove(P); + + o.v2point = P.xyz-eye_position; + o.tbase = unpack_tc_base (v.uv,v.T.w,v.B.w); // copy tc + o.tnorm0 = watermove_tc (o.tbase*W_DISTORT_BASE_TILE_0, P.xz, W_DISTORT_AMP_0); + o.tnorm1 = watermove_tc (o.tbase*W_DISTORT_BASE_TILE_1, P.xz, W_DISTORT_AMP_1); + + // Calculate the 3x3 transform from tangent space to eye-space + // TangentToEyeSpace = object2eye * tangent2object + // = object2eye * transpose(object2tangent) (since the inverse of a rotation is its transpose) + float3 N = unpack_bx4(v.N); // just scale (assume normal in the -.5f, .5f) + float3 T = unpack_bx4(v.T); // + float3 B = unpack_bx4(v.B); // + float3x3 xform = mul (float3x3(m_W), float3x3( + T.x,B.x,N.x, + T.y,B.y,N.y, + T.z,B.z,N.z + )); + // 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] + // ...... [ 0 2 0 0] + // ...... [ 0 0 2 0] + // ...... [-1 -1 -1 1] + // issue: strange, but it's slower :( + // issue: interpolators? dp4? VS limited? black magic? + + // Feed this transform to pixel shader + o.M1 = xform[0]; + o.M2 = xform[1]; + o.M3 = xform[2]; + + float3 L_rgb = v.color.rgb; // precalculated RGB lighting + float3 L_hemi = v_hemi(N)*v.N.w; // hemisphere + float3 L_sun = v_sun(N)*v.color.w; // sun + float3 L_final = L_rgb + L_hemi + L_sun + L_ambient.rgb; + + o.hpos = mul (m_VP, P); // xform, input in world coords + o.fog = saturate (calc_fogging(v.P)); + o.c0 = float4 (L_final, 1.f); + +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + o.tctexgen = mul (m_texgen, P); + float3 Pe = mul (m_V, P).xyz; + o.tctexgen.z = Pe.z; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + + return o; +} \ No newline at end of file diff --git a/res/gamedata/shaders/gl/water_soft.ps b/res/gamedata/shaders/gl/water_soft.ps new file mode 100644 index 00000000000..3ae7e813ba5 Binary files /dev/null and b/res/gamedata/shaders/gl/water_soft.ps differ diff --git a/res/gamedata/shaders/gl/water_soft.vs b/res/gamedata/shaders/gl/water_soft.vs new file mode 100644 index 00000000000..925157ec739 --- /dev/null +++ b/res/gamedata/shaders/gl/water_soft.vs @@ -0,0 +1,2 @@ +//#define NEED_SOFT_WATER // skyloader: temporarily disabled +#include "water.vs" \ No newline at end of file diff --git a/res/gamedata/shaders/gl/waterd.ps b/res/gamedata/shaders/gl/waterd.ps new file mode 100644 index 00000000000..e20b116f39c Binary files /dev/null and b/res/gamedata/shaders/gl/waterd.ps differ diff --git a/res/gamedata/shaders/gl/waterd.vs b/res/gamedata/shaders/gl/waterd.vs new file mode 100644 index 00000000000..49d8af8ae43 --- /dev/null +++ b/res/gamedata/shaders/gl/waterd.vs @@ -0,0 +1,33 @@ +#include "common.h" +#include "shared\waterconfig.h" +#include "shared\watermove.h" +#include "iostructs\v_waterd.h" + +uniform float4x4 m_texgen; + +v2p _main (v_vert v) +{ + v.N = unpack_D3DCOLOR(v.N); + v.T = unpack_D3DCOLOR(v.T); + v.B = unpack_D3DCOLOR(v.B); + v.color = unpack_D3DCOLOR(v.color); + + v2p o; + + float4 P = v.P; + float3 N = unpack_normal (v.N); + P = watermove (P); + + o.tbase = unpack_tc_base (v.uv,v.T.w,v.B.w); // copy tc + o.tdist0 = watermove_tc (o.tbase*W_DISTORT_BASE_TILE_0, P.xz, W_DISTORT_AMP_0); + o.tdist1 = watermove_tc (o.tbase*W_DISTORT_BASE_TILE_1, P.xz, W_DISTORT_AMP_1); + o.hpos = mul (m_VP, P); // xform, input in world coords + +#if defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + o.tctexgen = mul (m_texgen, P); + float3 Pe = mul (m_V, P); + o.tctexgen.z = Pe.z; +#endif // defined(USE_SOFT_WATER) && defined(NEED_SOFT_WATER) + + return o; +} diff --git a/res/gamedata/shaders/gl/waterd_soft.ps b/res/gamedata/shaders/gl/waterd_soft.ps new file mode 100644 index 00000000000..6aa1a4edbcf Binary files /dev/null and b/res/gamedata/shaders/gl/waterd_soft.ps differ diff --git a/res/gamedata/shaders/gl/waterd_soft.vs b/res/gamedata/shaders/gl/waterd_soft.vs new file mode 100644 index 00000000000..4371ee34157 --- /dev/null +++ b/res/gamedata/shaders/gl/waterd_soft.vs @@ -0,0 +1,2 @@ +//#define NEED_SOFT_WATER // skyloader: temporarily disabled +#include "waterd.vs" \ No newline at end of file