Skip to content

Commit dfe5389

Browse files
committed
shaders: Add G-Buffer support to GLSL ports.
1 parent c47e38c commit dfe5389

14 files changed

+18
-18
lines changed
12 Bytes
Binary file not shown.

res/gamedata/shaders/gl/common_functions.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ f_deffer pack_gbuffer( float4 norm, float4 pos, float4 col, uint imask )
214214
res.Ne = norm;
215215
res.C = col;
216216
#else
217-
res.position = float4( gbuf_pack_normal( norm ), pos.z, gbuf_pack_hemi_mtl( norm.w, pos.w ) );
217+
res.position = float4( gbuf_pack_normal( norm.xyz ), pos.z, gbuf_pack_hemi_mtl( norm.w, pos.w ) );
218218
res.C = col;
219219
#endif
220220

@@ -226,14 +226,14 @@ f_deffer pack_gbuffer( float4 norm, float4 pos, float4 col, uint imask )
226226
}
227227

228228
#ifdef GBUFFER_OPTIMIZATION
229-
gbuffer_data gbuffer_load_data( float2 tc, float2 pos2d, int iSample )
229+
gbuffer_data gbuffer_load_data( float2 tc, float4 pos2d, uint iSample )
230230
{
231231
gbuffer_data gbd;
232232

233233
gbd.P = float3(0,0,0);
234234
gbd.hemi = 0;
235235
gbd.mtl = 0;
236-
gbd.C = 0;
236+
gbd.C = float3(0,0,0);
237237
gbd.N = float3(0,0,0);
238238

239239
#ifndef USE_MSAA
@@ -250,7 +250,7 @@ gbuffer_data gbuffer_load_data( float2 tc, float2 pos2d, int iSample )
250250
// righttop = ( tan(fHorzFOV/2), tan(fVertFOV/2), 1 )
251251
// leftbottom = ( -tan(fHorzFOV/2), -tan(fVertFOV/2), 1 )
252252
// rightbottom = ( tan(fHorzFOV/2), -tan(fVertFOV/2), 1 )
253-
gbd.P = float3( P.z * ( pos2d * pos_decompression_params.zw - pos_decompression_params.xy ), P.z );
253+
gbd.P = float3( P.z * ( pos2d.xy * pos_decompression_params.zw - pos_decompression_params.xy ), P.z );
254254

255255
// reconstruct N
256256
gbd.N = gbuf_unpack_normal( P.xy );
@@ -273,21 +273,21 @@ gbuffer_data gbuffer_load_data( float2 tc, float2 pos2d, int iSample )
273273
return gbd;
274274
}
275275

276-
gbuffer_data gbuffer_load_data( float2 tc, float2 pos2d )
276+
gbuffer_data gbuffer_load_data( float2 tc, float4 pos2d )
277277
{
278278
return gbuffer_load_data( tc, pos2d, 0 );
279279
}
280280

281-
gbuffer_data gbuffer_load_data_offset( float2 tc, float2 OffsetTC, float2 pos2d )
281+
gbuffer_data gbuffer_load_data_offset( float2 tc, float2 OffsetTC, float4 pos2d )
282282
{
283-
float2 delta = ( ( OffsetTC - tc ) * pos_decompression_params2.xy );
283+
float4 delta = float4( ( OffsetTC - tc ) * pos_decompression_params2.xy, 0, 0 );
284284

285285
return gbuffer_load_data( OffsetTC, pos2d + delta, 0 );
286286
}
287287

288-
gbuffer_data gbuffer_load_data_offset( float2 tc, float2 OffsetTC, float2 pos2d, uint iSample )
288+
gbuffer_data gbuffer_load_data_offset( float2 tc, float2 OffsetTC, float4 pos2d, uint iSample )
289289
{
290-
float2 delta = ( ( OffsetTC - tc ) * pos_decompression_params2.xy );
290+
float4 delta = float4( ( OffsetTC - tc ) * pos_decompression_params2.xy, 0, 0 );
291291

292292
return gbuffer_load_data( OffsetTC, pos2d + delta, iSample );
293293
}

res/gamedata/shaders/gl/deffer_base_bump.vs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "common.h"
22
#include "iostructs\v_static_bump.h"
3-
#line 4 1
3+
44
v2p_bumped _main( v_in I )
55
{
66
// I.color.rgb = I.color.bgr; // Swizzle to compensate DX9/DX10 format mismatch

res/gamedata/shaders/gl/deffer_base_flat.vs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "common.h"
22
#include "iostructs\v_static_flat.h"
3-
#line 4 1
3+
44
v2p_flat _main ( v_in I )
55
{
66
I.Nh = unpack_D3DCOLOR(I.Nh);
-11 Bytes
Binary file not shown.

res/gamedata/shaders/gl/deffer_model_bump.vs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ v2p_bumped _main( v_model I )
2525
float3 Nw = mul (float3x3(m_W), float3(I.N));
2626
float3 hc_pos = float3(hemi_cube_pos_faces);
2727
float3 hc_neg = float3(hemi_cube_neg_faces);
28-
float3 hc_mixed= mix(hc_pos, hc_neg, lessThan(Nw, float3(0)));
28+
float3 hc_mixed= mask(lessThan(Nw, float3(0)), hc_neg, hc_pos);
2929
float hemi_val= dot( hc_mixed, abs(Nw) );
3030
hemi_val = saturate(hemi_val);
3131

res/gamedata/shaders/gl/deffer_model_flat.vs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ v2p_flat _main( v_model I )
2222
float3 Nw = mul (float3x3(m_W), float3(I.N));
2323
float3 hc_pos = float3(hemi_cube_pos_faces);
2424
float3 hc_neg = float3(hemi_cube_neg_faces);
25-
float3 hc_mixed= mix(hc_pos, hc_neg, lessThan(Nw, float3(0)));
25+
float3 hc_mixed= mask(lessThan(Nw, float3(0)), hc_neg, hc_pos);
2626
float hemi_val= dot( hc_mixed, abs(Nw) );
2727
hemi_val = saturate(hemi_val);
2828

res/gamedata/shaders/gl/iostructs/p_TL_sun.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ void main()
3030
I.Tex0 = p_TL_Tex0;
3131
I.Color = p_TL_Color;
3232

33-
SV_Target = _main (I);
3433
#ifdef MSAA_OPTIMIZATION
3534
#ifdef GBUFFER_OPTIMIZATION
3635
SV_Target = _main ( I, gl_FragCoord, gl_SampleID );
8 Bytes
Binary file not shown.
18 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)