From d198ec5139b4ecfa2ae23c4bc2bfb41906c0a1d9 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 1 May 2020 12:50:01 +0200 Subject: [PATCH] Use Astyle to format all HLSL renderprogs from now on --- base/renderprogs/AmbientOcclusion_AO.vs.hlsl | 6 +- .../renderprogs/AmbientOcclusion_blur.vs.hlsl | 6 +- .../AmbientOcclusion_minify.vs.hlsl | 6 +- base/renderprogs/BRDF.inc.hlsl | 16 +- .../DeepGBufferRadiosity_blur.ps.hlsl | 96 +- .../DeepGBufferRadiosity_blur.vs.hlsl | 6 +- .../DeepGBufferRadiosity_radiosity.vs.hlsl | 6 +- base/renderprogs/SMAA.inc.hlsl | 1311 +++++++++-------- .../SMAA_blending_weight_calc.ps.hlsl | 22 +- .../SMAA_blending_weight_calc.vs.hlsl | 8 +- base/renderprogs/SMAA_edge_detection.ps.hlsl | 22 +- base/renderprogs/SMAA_edge_detection.vs.hlsl | 10 +- base/renderprogs/SMAA_final.ps.hlsl | 24 +- base/renderprogs/SMAA_final.vs.hlsl | 8 +- base/renderprogs/ambient_lighting.ps.hlsl | 21 +- base/renderprogs/ambient_lighting.vs.hlsl | 45 +- base/renderprogs/ambient_lighting_IBL.vs.hlsl | 45 +- base/renderprogs/bink.ps.hlsl | 11 +- base/renderprogs/bink.vs.hlsl | 9 +- base/renderprogs/bink_gui.ps.hlsl | 9 +- base/renderprogs/bink_gui.vs.hlsl | 9 +- base/renderprogs/blendLight.ps.hlsl | 9 +- base/renderprogs/blendLight.vs.hlsl | 9 +- base/renderprogs/bloodorb1_capture.ps.hlsl | 9 +- base/renderprogs/bloodorb1_capture.vs.hlsl | 11 +- base/renderprogs/bloodorb2_capture.ps.hlsl | 9 +- base/renderprogs/bloodorb2_capture.vs.hlsl | 9 +- base/renderprogs/bloodorb3_capture.ps.hlsl | 9 +- base/renderprogs/bloodorb3_capture.vs.hlsl | 9 +- base/renderprogs/bloodorb_draw.ps.hlsl | 9 +- base/renderprogs/bloodorb_draw.vs.hlsl | 9 +- base/renderprogs/bumpyenvironment.ps.hlsl | 9 +- base/renderprogs/bumpyenvironment.vs.hlsl | 9 +- .../bumpyenvironment_skinned.ps.hlsl | 11 +- .../bumpyenvironment_skinned.vs.hlsl | 41 +- base/renderprogs/color.ps.hlsl | 9 +- base/renderprogs/color.vs.hlsl | 38 +- base/renderprogs/colorProcess.ps.hlsl | 9 +- base/renderprogs/colorProcess.vs.hlsl | 13 +- base/renderprogs/debug_shadowmap.ps.hlsl | 6 +- base/renderprogs/debug_shadowmap.vs.hlsl | 16 +- base/renderprogs/depth.ps.hlsl | 10 +- base/renderprogs/depth.vs.hlsl | 9 +- base/renderprogs/depth_skinned.ps.hlsl | 10 +- base/renderprogs/depth_skinned.vs.hlsl | 41 +- base/renderprogs/enviroSuit.ps.hlsl | 11 +- base/renderprogs/enviroSuit.vs.hlsl | 12 +- base/renderprogs/environment.ps.hlsl | 9 +- base/renderprogs/environment.vs.hlsl | 9 +- base/renderprogs/environment_skinned.ps.hlsl | 9 +- base/renderprogs/environment_skinned.vs.hlsl | 41 +- base/renderprogs/fog.ps.hlsl | 9 +- base/renderprogs/fog.vs.hlsl | 9 +- base/renderprogs/fog_skinned.ps.hlsl | 9 +- base/renderprogs/fog_skinned.vs.hlsl | 41 +- base/renderprogs/fxaa.ps.hlsl | 11 +- base/renderprogs/fxaa.vs.hlsl | 9 +- base/renderprogs/gbuffer.ps.hlsl | 8 +- base/renderprogs/gbuffer.vs.hlsl | 51 +- base/renderprogs/global.inc.hlsl | 53 +- base/renderprogs/gui.ps.hlsl | 9 +- base/renderprogs/gui.vs.hlsl | 9 +- base/renderprogs/hdr_glare_chromatic.ps.hlsl | 62 +- base/renderprogs/hdr_glare_chromatic.vs.hlsl | 9 +- base/renderprogs/heatHazeWithMask.ps.hlsl | 9 +- base/renderprogs/heatHazeWithMask.vs.hlsl | 19 +- .../heatHazeWithMaskAndVertex.ps.hlsl | 9 +- .../heatHazeWithMaskAndVertex.vs.hlsl | 19 +- base/renderprogs/heathaze.ps.hlsl | 9 +- base/renderprogs/heathaze.vs.hlsl | 15 +- base/renderprogs/interaction.ps.hlsl | 56 +- base/renderprogs/interaction.vs.hlsl | 45 +- base/renderprogs/interactionAmbient.ps.hlsl | 13 +- base/renderprogs/interactionAmbient.vs.hlsl | 13 +- .../interactionAmbient_skinned.ps.hlsl | 13 +- .../interactionAmbient_skinned.vs.hlsl | 45 +- base/renderprogs/interactionSM.ps.hlsl | 241 +-- base/renderprogs/interactionSM.vs.hlsl | 57 +- base/renderprogs/motionBlur.ps.hlsl | 24 +- base/renderprogs/motionBlur.vs.hlsl | 9 +- base/renderprogs/postprocess.vs.hlsl | 9 +- base/renderprogs/screen.ps.hlsl | 8 +- base/renderprogs/screen.vs.hlsl | 9 +- base/renderprogs/shadow.ps.hlsl | 10 +- base/renderprogs/shadow.vs.hlsl | 9 +- base/renderprogs/shadowDebug.ps.hlsl | 10 +- base/renderprogs/shadowDebug.vs.hlsl | 9 +- base/renderprogs/shadowDebug_skinned.ps.hlsl | 10 +- base/renderprogs/shadowDebug_skinned.vs.hlsl | 41 +- base/renderprogs/shadow_skinned.ps.hlsl | 10 +- base/renderprogs/shadow_skinned.vs.hlsl | 41 +- base/renderprogs/simpleshade.ps.hlsl | 12 +- base/renderprogs/simpleshade.vs.hlsl | 9 +- base/renderprogs/skinning.inc.hlsl | 39 +- base/renderprogs/skybox.ps.hlsl | 9 +- base/renderprogs/skybox.vs.hlsl | 11 +- base/renderprogs/stereoDeGhost.ps.hlsl | 9 +- base/renderprogs/stereoDeGhost.vs.hlsl | 9 +- base/renderprogs/stereoInterlace.ps.hlsl | 24 +- base/renderprogs/stereoInterlace.vs.hlsl | 9 +- base/renderprogs/stereoWarp.ps.hlsl | 25 +- base/renderprogs/stereoWarp.vs.hlsl | 9 +- base/renderprogs/texture.ps.hlsl | 9 +- base/renderprogs/texture.vs.hlsl | 16 +- base/renderprogs/texture_color.ps.hlsl | 9 +- base/renderprogs/texture_color.vs.hlsl | 16 +- .../renderprogs/texture_color_skinned.ps.hlsl | 9 +- .../renderprogs/texture_color_skinned.vs.hlsl | 48 +- base/renderprogs/texture_color_texgen.ps.hlsl | 12 +- base/renderprogs/texture_color_texgen.vs.hlsl | 11 +- base/renderprogs/tonemap.ps.hlsl | 142 +- base/renderprogs/tonemap.vs.hlsl | 9 +- base/renderprogs/vertex_color.ps.hlsl | 6 +- base/renderprogs/vertex_color.vs.hlsl | 8 +- base/renderprogs/wobblesky.ps.hlsl | 9 +- base/renderprogs/wobblesky.vs.hlsl | 11 +- base/renderprogs/zcullReconstruct.ps.hlsl | 9 +- base/renderprogs/zcullReconstruct.vs.hlsl | 9 +- neo/astyle-code.bat | 7 +- 119 files changed, 2036 insertions(+), 1630 deletions(-) diff --git a/base/renderprogs/AmbientOcclusion_AO.vs.hlsl b/base/renderprogs/AmbientOcclusion_AO.vs.hlsl index 290b37f6..06898657 100644 --- a/base/renderprogs/AmbientOcclusion_AO.vs.hlsl +++ b/base/renderprogs/AmbientOcclusion_AO.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -39,6 +40,7 @@ struct VS_OUT float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { diff --git a/base/renderprogs/AmbientOcclusion_blur.vs.hlsl b/base/renderprogs/AmbientOcclusion_blur.vs.hlsl index 290b37f6..06898657 100644 --- a/base/renderprogs/AmbientOcclusion_blur.vs.hlsl +++ b/base/renderprogs/AmbientOcclusion_blur.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -39,6 +40,7 @@ struct VS_OUT float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { diff --git a/base/renderprogs/AmbientOcclusion_minify.vs.hlsl b/base/renderprogs/AmbientOcclusion_minify.vs.hlsl index 290b37f6..06898657 100644 --- a/base/renderprogs/AmbientOcclusion_minify.vs.hlsl +++ b/base/renderprogs/AmbientOcclusion_minify.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -39,6 +40,7 @@ struct VS_OUT float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { diff --git a/base/renderprogs/BRDF.inc.hlsl b/base/renderprogs/BRDF.inc.hlsl index 7286a669..cd825a29 100644 --- a/base/renderprogs/BRDF.inc.hlsl +++ b/base/renderprogs/BRDF.inc.hlsl @@ -4,7 +4,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 2014-2020 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ half Distribution_GGX( half hdotN, half alpha ) float a2 = alpha * alpha; //float tmp = ( hdotN * hdotN ) * ( a2 - 1.0 ) + 1.0; float tmp = ( hdotN * a2 - hdotN ) * hdotN + 1.0; - + return ( a2 / ( PI * tmp * tmp ) ); } @@ -43,7 +43,7 @@ half Distribution_GGX_Disney( half hdotN, half alphaG ) float a2 = alphaG * alphaG; float tmp = ( hdotN * hdotN ) * ( a2 - 1.0 ) + 1.0; //tmp *= tmp; - + return ( a2 / ( PI * tmp ) ); } @@ -71,7 +71,7 @@ half3 Fresnel_SchlickRoughness( half3 specularColor, half vDotN, half roughness // See Sébastien Lagarde and Charles de Rousiers. 2014. Moving Frostbite to PBR. float ComputeSpecularAO( float vDotN, float ao, float roughness ) { - return clamp( pow( vDotN + ao, exp2( -16.0 * roughness - 1.0) ) - 1.0 + ao, 0.0, 1.0 ); + return clamp( pow( vDotN + ao, exp2( -16.0 * roughness - 1.0 ) ) - 1.0 + ao, 0.0, 1.0 ); } // Visibility term G( l, v, h ) @@ -79,10 +79,10 @@ float ComputeSpecularAO( float vDotN, float ao, float roughness ) float Visibility_Schlick( half vdotN, half ldotN, float alpha ) { float k = alpha * 0.5; - + float schlickL = ( ldotN * ( 1.0 - k ) + k ); float schlickV = ( vdotN * ( 1.0 - k ) + k ); - + return ( 0.25 / ( schlickL * schlickV ) ); //return ( ( schlickL * schlickV ) / ( 4.0 * vdotN * ldotN ) ); } @@ -96,7 +96,7 @@ float Visibility_SmithGGX( half vdotN, half ldotN, float alpha ) float V1 = ldotN + sqrt( alpha + ( 1.0 - alpha ) * ldotN * ldotN ); float V2 = vdotN + sqrt( alpha + ( 1.0 - alpha ) * vdotN * vdotN ); - + // RB: avoid too bright spots return ( 1.0 / max( V1 * V2, 0.15 ) ); } @@ -127,7 +127,7 @@ float3 EnvironmentBRDF( half g, half vdotN, float3 rf0 ) t += float4( 0.0, 0.0, ( 0.015 - 0.75 * 0.04 ) / 0.96, 0.75 ); half a0 = t.x * min( t.y, exp2( -9.28 * vdotN ) ) + t.z; half a1 = t.w; - + return saturate( a0 + rf0 * ( a1 - a0 ) ); } diff --git a/base/renderprogs/DeepGBufferRadiosity_blur.ps.hlsl b/base/renderprogs/DeepGBufferRadiosity_blur.ps.hlsl index 2ad646aa..93049278 100644 --- a/base/renderprogs/DeepGBufferRadiosity_blur.ps.hlsl +++ b/base/renderprogs/DeepGBufferRadiosity_blur.ps.hlsl @@ -22,16 +22,16 @@ uniform sampler2D samp0 : register( s0 ); // view normals uniform sampler2D samp1 : register( s1 ); // view depth uniform sampler2D samp2 : register( s2 ); // view AO - + #define normal_buffer samp0 #define cszBuffer samp1 #define source samp2 - + struct PS_IN { float2 texcoord0 : TEXCOORD0_centroid; }; - + struct PS_OUT { float4 color : COLOR; @@ -87,7 +87,7 @@ struct PS_OUT //uniform int2 axis; #if USE_OCT16 -#include + #include #endif float3 sampleNormal( sampler2D normalBuffer, int2 ssC, int mipLevel ) @@ -113,10 +113,10 @@ float CSZToKey( float z ) float reconstructCSZ( float d ) { //return clipInfo[0] / (clipInfo[1] * d + clipInfo[2]); - + // infinite far perspective matrix return -3.0 / ( -1.0 * d + 1.0 ); - + //d = d * 2.0 - 1.0; //return -rpProjectionMatrixZ.w / ( -rpProjectionMatrixZ.z - d ); } @@ -127,15 +127,15 @@ float3 reconstructCSPosition( float2 S, float z ) P.z = z * 2.0 - 1.0; P.xy = ( S * rpScreenCorrectionFactor.xy ) * 2.0 - 1.0; P.w = 1.0; - + float4 csP; csP.x = dot4( P, rpModelMatrixX ); csP.y = dot4( P, rpModelMatrixY ); csP.z = dot4( P, rpModelMatrixZ ); csP.w = dot4( P, rpModelMatrixW ); - + csP.xyz /= csP.w; - + return csP.xyz; } @@ -153,7 +153,7 @@ float getKey( int2 ssP ) float3 P = reconstructCSPosition( float2( ssP ) + float2( 0.5 ), key ); key = P.z; #endif - + key = clamp( key * ( 1.0 / FAR_PLANE_Z ), 0.0, 1.0 ); return key; } @@ -170,10 +170,10 @@ float3 getPosition( int2 ssP, sampler2D cszBuffer ) { float3 P; P.z = texelFetch( cszBuffer, ssP, 0 ).r; - + // Offset to pixel center P = reconstructCSPosition( float2( ssP ) + float2( 0.5 ), P.z ); - + return P; } @@ -181,43 +181,43 @@ float calculateBilateralWeight( float key, float tapKey, int2 tapLoc, float3 n_C { // range domain (the "bilateral" weight). As depth difference increases, decrease weight. float depthWeight = max( 0.0, 1.0 - ( EDGE_SHARPNESS * 2000.0 ) * abs( tapKey - key ) ); - + float k_normal = 1.0; //40.0; float k_plane = 1.0; //0.5; - + // Prevents blending over creases. float normalWeight = 1.0; //1000.0; float planeWeight = 1.0; - + #if USE_NORMALS float3 tapN_C = sampleNormal( normal_buffer, tapLoc, 0 ); depthWeight = 1.0; - + float normalError = ( 1.0 - dot( tapN_C, n_C ) ) * k_normal; normalWeight = max( 1.0 - EDGE_SHARPNESS * normalError, 0.00 ); - - + + float lowDistanceThreshold2 = 0.001; //0.01; - + //float3 tapC = positionFromKey( tapKey, tapLoc, projInfo ); float3 tapC = getPosition( tapLoc, cszBuffer ); - + // Change in position in camera space float3 dq = C - tapC; - + // How far away is this point from the original sample // in camera space? (Max value is unbounded) float distance2 = dot( dq, dq ); - + // How far off the expected plane (on the perpendicular) is this point? Max value is unbounded. float planeError = max( abs( dot( dq, tapN_C ) ), abs( dot( dq, n_C ) ) ); - + planeWeight = ( distance2 < lowDistanceThreshold2 ) ? 1.0 : pow( max( 0.0, 1.0 - EDGE_SHARPNESS * 2.0 * k_plane * planeError / sqrt( distance2 ) ), 2.0 ); - - + + #endif - + return depthWeight * normalWeight * planeWeight; } @@ -264,11 +264,11 @@ void main( PS_IN fragment, out PS_OUT result ) kernel[6] = 0.036108; #endif //#endif - + int2 ssC = int2( gl_FragCoord.xy ); - + float4 temp = texelFetch( source, ssC, 0 ); - + #if 0 if( fragment.texcoord0.x < 0.75 ) { @@ -276,7 +276,7 @@ void main( PS_IN fragment, out PS_OUT result ) return; } #endif - + #if 0 float key = getKey( ssC ); float3 C = positionFromKey( key, ssC ); @@ -284,27 +284,27 @@ void main( PS_IN fragment, out PS_OUT result ) float3 C = getPosition( ssC, cszBuffer ); float key = CSZToKey( C.z ); #endif - + VALUE_TYPE sum = temp.VALUE_COMPONENTS; - + if( key == 1.0 ) { // Sky pixel (if you aren't using depth keying, disable this test) blurResult = sum; return; } - + // Base weight for falloff. Increase this for more blurriness, // decrease it for better edge discrimination float BASE = kernel[0]; float totalWeight = BASE; sum *= totalWeight; - + float3 n_C; #if USE_NORMALS n_C = sampleNormal( normal_buffer, ssC, 0 ); #endif - + #if MDB_WEIGHTS == 0 for( int r = -R; r <= R; ++r ) { @@ -314,35 +314,35 @@ void main( PS_IN fragment, out PS_OUT result ) { int2 tapLoc = ssC + int2( rpJitterTexScale.xy ) * ( r * SCALE ); temp = texelFetch( source, tapLoc, 0 ); - - + + float tapKey = getKey( tapLoc ); VALUE_TYPE value = temp.VALUE_COMPONENTS; - + // spatial domain: offset kernel tap float weight = 0.3 + kernel[abs( r )]; - + float bilateralWeight = calculateBilateralWeight( key, tapKey, tapLoc, n_C, C ); - + weight *= bilateralWeight; sum += value * weight; totalWeight += weight; } } #else - + float lastBilateralWeight = 9999.0; for( int r = -1; r >= -R; --r ) { int2 tapLoc = ssC + int2( rpJitterTexScale.xy ) * ( r * SCALE ); temp = texelFetch( source, tapLoc, 0 ); float tapKey = getKey( tapLoc ); - + VALUE_TYPE value = temp.VALUE_COMPONENTS; - + // spatial domain: offset kernel tap float weight = 0.3 + kernel[abs( r )]; - + // range domain (the "bilateral" weight). As depth difference increases, decrease weight. float bilateralWeight = calculateBilateralWeight( key, tapKey, tapLoc, n_C, C ); bilateralWeight = min( lastBilateralWeight, bilateralWeight ); @@ -351,7 +351,7 @@ void main( PS_IN fragment, out PS_OUT result ) sum += value * weight; totalWeight += weight; } - + lastBilateralWeight = 9999.0; for( int r = 1; r <= R; ++r ) { @@ -359,10 +359,10 @@ void main( PS_IN fragment, out PS_OUT result ) temp = texelFetch( source, tapLoc, 0 ); float tapKey = getKey( tapLoc ); VALUE_TYPE value = temp.VALUE_COMPONENTS; - + // spatial domain: offset kernel tap float weight = 0.3 + kernel[abs( r )]; - + // range domain (the "bilateral" weight). As depth difference increases, decrease weight. float bilateralWeight = calculateBilateralWeight( key, tapKey, tapLoc, n_C, C ); bilateralWeight = min( lastBilateralWeight, bilateralWeight ); @@ -372,7 +372,7 @@ void main( PS_IN fragment, out PS_OUT result ) totalWeight += weight; } #endif - + const float epsilon = 0.0001; blurResult = sum / ( totalWeight + epsilon ); } diff --git a/base/renderprogs/DeepGBufferRadiosity_blur.vs.hlsl b/base/renderprogs/DeepGBufferRadiosity_blur.vs.hlsl index 290b37f6..06898657 100644 --- a/base/renderprogs/DeepGBufferRadiosity_blur.vs.hlsl +++ b/base/renderprogs/DeepGBufferRadiosity_blur.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -39,6 +40,7 @@ struct VS_OUT float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { diff --git a/base/renderprogs/DeepGBufferRadiosity_radiosity.vs.hlsl b/base/renderprogs/DeepGBufferRadiosity_radiosity.vs.hlsl index 290b37f6..06898657 100644 --- a/base/renderprogs/DeepGBufferRadiosity_radiosity.vs.hlsl +++ b/base/renderprogs/DeepGBufferRadiosity_radiosity.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -39,6 +40,7 @@ struct VS_OUT float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { diff --git a/base/renderprogs/SMAA.inc.hlsl b/base/renderprogs/SMAA.inc.hlsl index 79fc8ac3..14d49890 100644 --- a/base/renderprogs/SMAA.inc.hlsl +++ b/base/renderprogs/SMAA.inc.hlsl @@ -28,14 +28,14 @@ /** - * + * * E N H A N C E D * S U B P I X E L M O R P H O L O G I C A L A N T I A L I A S I N G * * http://www.iryoku.com/smaa/ * * Hi, welcome aboard! - * + * * Here you'll find instructions to get the shader up and running as fast as * possible. * @@ -124,14 +124,14 @@ * this last pass are not possible, the technique will work anyway, but * will perform antialiasing in gamma space. * - * IMPORTANT: for best results the input read for the color/luma edge + * IMPORTANT: for best results the input read for the color/luma edge * detection should *NOT* be sRGB. * * 6. Before including SMAA.h you'll have to setup the render target metrics, * the target and any optional configuration defines. Optionally you can * use a preset. * - * You have the following targets available: + * You have the following targets available: * SMAA_HLSL_3 * SMAA_HLSL_4 * SMAA_HLSL_4_1 @@ -296,25 +296,25 @@ */ #if defined(SMAA_PRESET_LOW) -#define SMAA_THRESHOLD 0.15 -#define SMAA_MAX_SEARCH_STEPS 4 -#define SMAA_DISABLE_DIAG_DETECTION -#define SMAA_DISABLE_CORNER_DETECTION + #define SMAA_THRESHOLD 0.15 + #define SMAA_MAX_SEARCH_STEPS 4 + #define SMAA_DISABLE_DIAG_DETECTION + #define SMAA_DISABLE_CORNER_DETECTION #elif defined(SMAA_PRESET_MEDIUM) -#define SMAA_THRESHOLD 0.1 -#define SMAA_MAX_SEARCH_STEPS 8 -#define SMAA_DISABLE_DIAG_DETECTION -#define SMAA_DISABLE_CORNER_DETECTION + #define SMAA_THRESHOLD 0.1 + #define SMAA_MAX_SEARCH_STEPS 8 + #define SMAA_DISABLE_DIAG_DETECTION + #define SMAA_DISABLE_CORNER_DETECTION #elif defined(SMAA_PRESET_HIGH) -#define SMAA_THRESHOLD 0.1 -#define SMAA_MAX_SEARCH_STEPS 16 -#define SMAA_MAX_SEARCH_STEPS_DIAG 8 -#define SMAA_CORNER_ROUNDING 25 + #define SMAA_THRESHOLD 0.1 + #define SMAA_MAX_SEARCH_STEPS 16 + #define SMAA_MAX_SEARCH_STEPS_DIAG 8 + #define SMAA_CORNER_ROUNDING 25 #elif defined(SMAA_PRESET_ULTRA) -#define SMAA_THRESHOLD 0.05 -#define SMAA_MAX_SEARCH_STEPS 32 -#define SMAA_MAX_SEARCH_STEPS_DIAG 16 -#define SMAA_CORNER_ROUNDING 25 + #define SMAA_THRESHOLD 0.05 + #define SMAA_MAX_SEARCH_STEPS 32 + #define SMAA_MAX_SEARCH_STEPS_DIAG 16 + #define SMAA_CORNER_ROUNDING 25 #endif //----------------------------------------------------------------------------- @@ -323,7 +323,7 @@ /** * SMAA_THRESHOLD specifies the threshold or sensitivity to edges. * Lowering this value you will be able to detect more edges at the expense of - * performance. + * performance. * * Range: [0, 0.5] * 0.1 is a reasonable value, and allows to catch most visible edges. @@ -333,16 +333,16 @@ * contrast edges are properly filtered by just 2x. */ #ifndef SMAA_THRESHOLD -#define SMAA_THRESHOLD 0.1 + #define SMAA_THRESHOLD 0.1 #endif /** * SMAA_DEPTH_THRESHOLD specifies the threshold for depth edge detection. - * + * * Range: depends on the depth range of the scene. */ #ifndef SMAA_DEPTH_THRESHOLD -#define SMAA_DEPTH_THRESHOLD (0.1 * SMAA_THRESHOLD) + #define SMAA_DEPTH_THRESHOLD (0.1 * SMAA_THRESHOLD) #endif /** @@ -356,7 +356,7 @@ * Range: [0, 112] */ #ifndef SMAA_MAX_SEARCH_STEPS -#define SMAA_MAX_SEARCH_STEPS 16 + #define SMAA_MAX_SEARCH_STEPS 16 #endif /** @@ -366,13 +366,13 @@ * * Range: [0, 20] * - * On high-end machines it is cheap (between a 0.8x and 0.9x slower for 16 + * On high-end machines it is cheap (between a 0.8x and 0.9x slower for 16 * steps), but it can have a significant impact on older machines. * * Define SMAA_DISABLE_DIAG_DETECTION to disable diagonal processing. */ #ifndef SMAA_MAX_SEARCH_STEPS_DIAG -#define SMAA_MAX_SEARCH_STEPS_DIAG 8 + #define SMAA_MAX_SEARCH_STEPS_DIAG 8 #endif /** @@ -383,7 +383,7 @@ * Define SMAA_DISABLE_CORNER_DETECTION to disable corner processing. */ #ifndef SMAA_CORNER_ROUNDING -#define SMAA_CORNER_ROUNDING 25 + #define SMAA_CORNER_ROUNDING 25 #endif /** @@ -395,7 +395,7 @@ * perceptually contrast in the other neighbors. */ #ifndef SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR -#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0 + #define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0 #endif /** @@ -408,22 +408,22 @@ * It locally decreases the luma or color threshold if an edge is found in an * additional buffer (so the global threshold can be higher). * - * This method was developed by Playstation EDGE MLAA team, and used in + * This method was developed by Playstation EDGE MLAA team, and used in * Killzone 3, by using the light accumulation buffer. More information here: - * http://iryoku.com/aacourse/downloads/06-MLAA-on-PS3.pptx + * http://iryoku.com/aacourse/downloads/06-MLAA-on-PS3.pptx */ #ifndef SMAA_PREDICATION -#define SMAA_PREDICATION 0 + #define SMAA_PREDICATION 0 #endif /** - * Threshold to be used in the additional predication buffer. + * Threshold to be used in the additional predication buffer. * * Range: depends on the input, so you'll have to find the magic number that * works for you. */ #ifndef SMAA_PREDICATION_THRESHOLD -#define SMAA_PREDICATION_THRESHOLD 0.01 + #define SMAA_PREDICATION_THRESHOLD 0.01 #endif /** @@ -433,7 +433,7 @@ * Range: [1, 5] */ #ifndef SMAA_PREDICATION_SCALE -#define SMAA_PREDICATION_SCALE 2.0 + #define SMAA_PREDICATION_SCALE 2.0 #endif /** @@ -442,7 +442,7 @@ * Range: [0, 1] */ #ifndef SMAA_PREDICATION_STRENGTH -#define SMAA_PREDICATION_STRENGTH 0.4 + #define SMAA_PREDICATION_STRENGTH 0.4 #endif /** @@ -457,7 +457,7 @@ * alternative. */ #ifndef SMAA_REPROJECTION -#define SMAA_REPROJECTION 0 + #define SMAA_REPROJECTION 0 #endif /** @@ -472,7 +472,7 @@ * Range: [0, 80] */ #ifndef SMAA_REPROJECTION_WEIGHT_SCALE -#define SMAA_REPROJECTION_WEIGHT_SCALE 30.0 + #define SMAA_REPROJECTION_WEIGHT_SCALE 30.0 #endif /** @@ -480,29 +480,29 @@ * to be compiled separately. */ #ifndef SMAA_INCLUDE_VS -#define SMAA_INCLUDE_VS 1 + #define SMAA_INCLUDE_VS 1 #endif #ifndef SMAA_INCLUDE_PS -#define SMAA_INCLUDE_PS 1 + #define SMAA_INCLUDE_PS 1 #endif //----------------------------------------------------------------------------- // Texture Access Defines #ifndef SMAA_AREATEX_SELECT -#if defined(SMAA_HLSL_3) -#define SMAA_AREATEX_SELECT(sample) sample.ra -#else -#define SMAA_AREATEX_SELECT(sample) sample.rg -#endif + #if defined(SMAA_HLSL_3) + #define SMAA_AREATEX_SELECT(sample) sample.ra + #else + #define SMAA_AREATEX_SELECT(sample) sample.rg + #endif #endif #ifndef SMAA_SEARCHTEX_SELECT -#define SMAA_SEARCHTEX_SELECT(sample) sample.r + #define SMAA_SEARCHTEX_SELECT(sample) sample.r #endif #ifndef SMAA_DECODE_VELOCITY -#define SMAA_DECODE_VELOCITY(sample) sample.rg + #define SMAA_DECODE_VELOCITY(sample) sample.rg #endif //----------------------------------------------------------------------------- @@ -520,20 +520,20 @@ // Porting Functions #if defined(SMAA_HLSL_3) -#define API_V_DIR(v) v -#define API_V_COORD(v) v -#define API_V_BELOW(v1, v2) v1 > v2 -#define API_V_ABOVE(v1, v2) v1 < v2 -#define SMAATexture2D(tex) sampler2D tex -#define SMAATexturePass2D(tex) tex -#define SMAASampleLevelZero(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) -#define SMAASampleLevelZeroPoint(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) -#define SMAASampleLevelZeroOffset(tex, coord, offset) tex2Dlod(tex, float4(coord + offset * SMAA_RT_METRICS.xy, 0.0, 0.0)) -#define SMAASample(tex, coord) tex2D(tex, coord) -#define SMAASamplePoint(tex, coord) tex2D(tex, coord) -#define SMAASampleOffset(tex, coord, offset) tex2D(tex, coord + offset * SMAA_RT_METRICS.xy) -#define SMAA_FLATTEN [flatten] -#define SMAA_BRANCH [branch] + #define API_V_DIR(v) v + #define API_V_COORD(v) v + #define API_V_BELOW(v1, v2) v1 > v2 + #define API_V_ABOVE(v1, v2) v1 < v2 + #define SMAATexture2D(tex) sampler2D tex + #define SMAATexturePass2D(tex) tex + #define SMAASampleLevelZero(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) + #define SMAASampleLevelZeroPoint(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0)) + #define SMAASampleLevelZeroOffset(tex, coord, offset) tex2Dlod(tex, float4(coord + offset * SMAA_RT_METRICS.xy, 0.0, 0.0)) + #define SMAASample(tex, coord) tex2D(tex, coord) + #define SMAASamplePoint(tex, coord) tex2D(tex, coord) + #define SMAASampleOffset(tex, coord, offset) tex2D(tex, coord + offset * SMAA_RT_METRICS.xy) + #define SMAA_FLATTEN [flatten] + #define SMAA_BRANCH [branch] #endif #if defined(SMAA_HLSL_4) || defined(SMAA_HLSL_4_1) #define API_V_DIR(v) v @@ -555,51 +555,51 @@ SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; Addres #define SMAATexture2DMS2(tex) Texture2DMS tex #define SMAALoad(tex, pos, sample) tex.Load(pos, sample) #if defined(SMAA_HLSL_4_1) -#define SMAAGather(tex, coord) tex.Gather(LinearSampler, coord, 0) + #define SMAAGather(tex, coord) tex.Gather(LinearSampler, coord, 0) #endif #endif #if defined(SMAA_GLSL_3) || defined(SMAA_GLSL_4) -//#define API_V_DIR(v) -(v) -//#define API_V_COORD(v) (1.0 - v) -//#define API_V_BELOW(v1, v2) v1 < v2 -//#define API_V_ABOVE(v1, v2) v1 > v2 + //#define API_V_DIR(v) -(v) + //#define API_V_COORD(v) (1.0 - v) + //#define API_V_BELOW(v1, v2) v1 < v2 + //#define API_V_ABOVE(v1, v2) v1 > v2 -#define API_V_DIR(v) v -#define API_V_COORD(v) v -#define API_V_BELOW(v1, v2) v1 > v2 -#define API_V_ABOVE(v1, v2) v1 < v2 + #define API_V_DIR(v) v + #define API_V_COORD(v) v + #define API_V_BELOW(v1, v2) v1 > v2 + #define API_V_ABOVE(v1, v2) v1 < v2 -#define SMAATexture2D(tex) sampler2D tex -#define SMAATexturePass2D(tex) tex -#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0) -#define SMAASampleLevelZeroPoint(tex, coord) textureLod(tex, coord, 0.0) -#define SMAASampleLevelZeroOffset(tex, coord, offset) textureLodOffset(tex, coord, 0.0, offset) -#define SMAASample(tex, coord) texture(tex, coord) -#define SMAASamplePoint(tex, coord) texture(tex, coord) -#define SMAASampleOffset(tex, coord, offset) texture(tex, coord, offset) -#define SMAA_FLATTEN -#define SMAA_BRANCH -#define lerp(a, b, t) mix(a, b, t) -#define saturate(a) clamp(a, 0.0, 10.0) -#if defined(SMAA_GLSL_4) -#define mad(a, b, c) fma(a, b, c) -#define SMAAGather(tex, coord) textureGather(tex, coord) -#else -#define mad(a, b, c) (a * b + c) -#endif -//#define float2 vec2 -//#define float3 vec3 -//#define float4 vec4 -//#define int2 ivec2 -//#define int3 ivec3 -//#define int4 ivec4 -//#define bool2 bvec2 -//#define bool3 bvec3 -//#define bool4 bvec4 + #define SMAATexture2D(tex) sampler2D tex + #define SMAATexturePass2D(tex) tex + #define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0) + #define SMAASampleLevelZeroPoint(tex, coord) textureLod(tex, coord, 0.0) + #define SMAASampleLevelZeroOffset(tex, coord, offset) textureLodOffset(tex, coord, 0.0, offset) + #define SMAASample(tex, coord) texture(tex, coord) + #define SMAASamplePoint(tex, coord) texture(tex, coord) + #define SMAASampleOffset(tex, coord, offset) texture(tex, coord, offset) + #define SMAA_FLATTEN + #define SMAA_BRANCH + #define lerp(a, b, t) mix(a, b, t) + #define saturate(a) clamp(a, 0.0, 10.0) + #if defined(SMAA_GLSL_4) + #define mad(a, b, c) fma(a, b, c) + #define SMAAGather(tex, coord) textureGather(tex, coord) + #else + #define mad(a, b, c) (a * b + c) + #endif + //#define float2 vec2 + //#define float3 vec3 + //#define float4 vec4 + //#define int2 ivec2 + //#define int3 ivec3 + //#define int4 ivec4 + //#define bool2 bvec2 + //#define bool3 bvec3 + //#define bool4 bvec4 #endif #if !defined(SMAA_HLSL_3) && !defined(SMAA_HLSL_4) && !defined(SMAA_HLSL_4_1) && !defined(SMAA_GLSL_3) && !defined(SMAA_GLSL_4) && !defined(SMAA_CUSTOM_SL) -#error you must define the shading language: SMAA_HLSL_*, SMAA_GLSL_* or SMAA_CUSTOM_SL + #error you must define the shading language: SMAA_HLSL_*, SMAA_GLSL_* or SMAA_CUSTOM_SL #endif //----------------------------------------------------------------------------- @@ -608,42 +608,52 @@ SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; Addres /** * Gathers current pixel, and the top-left neighbors. */ -float3 SMAAGatherNeighbours(float2 texcoord, - float4 offset[3], - SMAATexture2D(tex)) { - #ifdef SMAAGather - return SMAAGather(tex, texcoord + SMAA_RT_METRICS.xy * float2(-0.5, -0.5)).grb; - #else - float P = SMAASamplePoint(tex, texcoord).r; - float Pleft = SMAASamplePoint(tex, offset[0].xy).r; - float Ptop = SMAASamplePoint(tex, offset[0].zw).r; - return float3(P, Pleft, Ptop); - #endif +float3 SMAAGatherNeighbours( float2 texcoord, + float4 offset[3], + SMAATexture2D( tex ) ) +{ +#ifdef SMAAGather + return SMAAGather( tex, texcoord + SMAA_RT_METRICS.xy * float2( -0.5, -0.5 ) ).grb; +#else + float P = SMAASamplePoint( tex, texcoord ).r; + float Pleft = SMAASamplePoint( tex, offset[0].xy ).r; + float Ptop = SMAASamplePoint( tex, offset[0].zw ).r; + return float3( P, Pleft, Ptop ); +#endif } /** * Adjusts the threshold by means of predication. */ -float2 SMAACalculatePredicatedThreshold(float2 texcoord, - float4 offset[3], - SMAATexture2D(predicationTex)) { - float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(predicationTex)); - float2 delta = abs(neighbours.xx - neighbours.yz); - float2 edges = step(SMAA_PREDICATION_THRESHOLD, delta); - return SMAA_PREDICATION_SCALE * SMAA_THRESHOLD * (1.0 - SMAA_PREDICATION_STRENGTH * edges); +float2 SMAACalculatePredicatedThreshold( float2 texcoord, + float4 offset[3], + SMAATexture2D( predicationTex ) ) +{ + float3 neighbours = SMAAGatherNeighbours( texcoord, offset, SMAATexturePass2D( predicationTex ) ); + float2 delta = abs( neighbours.xx - neighbours.yz ); + float2 edges = step( SMAA_PREDICATION_THRESHOLD, delta ); + return SMAA_PREDICATION_SCALE * SMAA_THRESHOLD * ( 1.0 - SMAA_PREDICATION_STRENGTH * edges ); } /** * Conditional move: */ -void SMAAMovc(bool2 cond, inout float2 variable, float2 value) { - SMAA_FLATTEN if (cond.x) variable.x = value.x; - SMAA_FLATTEN if (cond.y) variable.y = value.y; +void SMAAMovc( bool2 cond, inout float2 variable, float2 value ) +{ + SMAA_FLATTEN if( cond.x ) + { + variable.x = value.x; + } + SMAA_FLATTEN if( cond.y ) + { + variable.y = value.y; + } } -void SMAAMovc(bool4 cond, inout float4 variable, float4 value) { - SMAAMovc(cond.xy, variable.xy, value.xy); - SMAAMovc(cond.zw, variable.zw, value.zw); +void SMAAMovc( bool4 cond, inout float4 variable, float4 value ) +{ + SMAAMovc( cond.xy, variable.xy, value.xy ); + SMAAMovc( cond.zw, variable.zw, value.zw ); } @@ -654,37 +664,40 @@ void SMAAMovc(bool4 cond, inout float4 variable, float4 value) { /** * Edge Detection Vertex Shader */ -void SMAAEdgeDetectionVS(float2 texcoord, - out float4 offset[3]) { - offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-1.0, 0.0, 0.0, API_V_DIR(-1.0)), texcoord.xyxy); - offset[1] = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, API_V_DIR(1.0)), texcoord.xyxy); - offset[2] = mad(SMAA_RT_METRICS.xyxy, float4(-2.0, 0.0, 0.0, API_V_DIR(-2.0)), texcoord.xyxy); +void SMAAEdgeDetectionVS( float2 texcoord, + out float4 offset[3] ) +{ + offset[0] = mad( SMAA_RT_METRICS.xyxy, float4( -1.0, 0.0, 0.0, API_V_DIR( -1.0 ) ), texcoord.xyxy ); + offset[1] = mad( SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, API_V_DIR( 1.0 ) ), texcoord.xyxy ); + offset[2] = mad( SMAA_RT_METRICS.xyxy, float4( -2.0, 0.0, 0.0, API_V_DIR( -2.0 ) ), texcoord.xyxy ); } /** * Blend Weight Calculation Vertex Shader */ -void SMAABlendingWeightCalculationVS(float2 texcoord, - out float2 pixcoord, - out float4 offset[3]) { - pixcoord = texcoord * SMAA_RT_METRICS.zw; +void SMAABlendingWeightCalculationVS( float2 texcoord, + out float2 pixcoord, + out float4 offset[3] ) +{ + pixcoord = texcoord * SMAA_RT_METRICS.zw; - // We will use these offsets for the searches later on (see @PSEUDO_GATHER4): - offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-0.25, API_V_DIR(-0.125), 1.25, API_V_DIR(-0.125)), texcoord.xyxy); - offset[1] = mad(SMAA_RT_METRICS.xyxy, float4(-0.125, API_V_DIR(-0.25), -0.125, API_V_DIR(1.25)), texcoord.xyxy); + // We will use these offsets for the searches later on (see @PSEUDO_GATHER4): + offset[0] = mad( SMAA_RT_METRICS.xyxy, float4( -0.25, API_V_DIR( -0.125 ), 1.25, API_V_DIR( -0.125 ) ), texcoord.xyxy ); + offset[1] = mad( SMAA_RT_METRICS.xyxy, float4( -0.125, API_V_DIR( -0.25 ), -0.125, API_V_DIR( 1.25 ) ), texcoord.xyxy ); - // And these for the searches, they indicate the ends of the loops: - offset[2] = mad(SMAA_RT_METRICS.xxyy, - float4(-2.0, 2.0, API_V_DIR(-2.0), API_V_DIR(2.0)) * float(SMAA_MAX_SEARCH_STEPS), - float4(offset[0].xz, offset[1].yw)); + // And these for the searches, they indicate the ends of the loops: + offset[2] = mad( SMAA_RT_METRICS.xxyy, + float4( -2.0, 2.0, API_V_DIR( -2.0 ), API_V_DIR( 2.0 ) ) * float( SMAA_MAX_SEARCH_STEPS ), + float4( offset[0].xz, offset[1].yw ) ); } /** * Neighborhood Blending Vertex Shader */ -void SMAANeighborhoodBlendingVS(float2 texcoord, - out float4 offset) { - offset = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, API_V_DIR(1.0)), texcoord.xyxy); +void SMAANeighborhoodBlendingVS( float2 texcoord, + out float4 offset ) +{ + offset = mad( SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0, API_V_DIR( 1.0 ) ), texcoord.xyxy ); } #endif // SMAA_INCLUDE_VS @@ -698,57 +711,60 @@ void SMAANeighborhoodBlendingVS(float2 texcoord, * IMPORTANT NOTICE: luma edge detection requires gamma-corrected colors, and * thus 'colorTex' should be a non-sRGB texture. */ -float2 SMAALumaEdgeDetectionPS(float2 texcoord, - float4 offset[3], - SMAATexture2D(colorTex) - #if SMAA_PREDICATION - , SMAATexture2D(predicationTex) - #endif - ) { - // Calculate the threshold: - #if SMAA_PREDICATION - float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, SMAATexturePass2D(predicationTex)); - #else - float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD); - #endif +float2 SMAALumaEdgeDetectionPS( float2 texcoord, + float4 offset[3], + SMAATexture2D( colorTex ) +#if SMAA_PREDICATION + , SMAATexture2D( predicationTex ) +#endif + ) +{ + // Calculate the threshold: +#if SMAA_PREDICATION + float2 threshold = SMAACalculatePredicatedThreshold( texcoord, offset, SMAATexturePass2D( predicationTex ) ); +#else + float2 threshold = float2( SMAA_THRESHOLD, SMAA_THRESHOLD ); +#endif - // Calculate lumas: - float3 weights = float3(0.2126, 0.7152, 0.0722); - float L = dot(SMAASamplePoint(colorTex, texcoord).rgb, weights); + // Calculate lumas: + float3 weights = float3( 0.2126, 0.7152, 0.0722 ); + float L = dot( SMAASamplePoint( colorTex, texcoord ).rgb, weights ); - float Lleft = dot(SMAASamplePoint(colorTex, offset[0].xy).rgb, weights); - float Ltop = dot(SMAASamplePoint(colorTex, offset[0].zw).rgb, weights); + float Lleft = dot( SMAASamplePoint( colorTex, offset[0].xy ).rgb, weights ); + float Ltop = dot( SMAASamplePoint( colorTex, offset[0].zw ).rgb, weights ); - // We do the usual threshold: - float4 delta; - delta.xy = abs(L - float2(Lleft, Ltop)); - float2 edges = step(threshold, delta.xy); + // We do the usual threshold: + float4 delta; + delta.xy = abs( L - float2( Lleft, Ltop ) ); + float2 edges = step( threshold, delta.xy ); - // Then discard if there is no edge: - if (dot(edges, float2(1.0, 1.0)) == 0.0) - discard; + // Then discard if there is no edge: + if( dot( edges, float2( 1.0, 1.0 ) ) == 0.0 ) + { + discard; + } - // Calculate right and bottom deltas: - float Lright = dot(SMAASamplePoint(colorTex, offset[1].xy).rgb, weights); - float Lbottom = dot(SMAASamplePoint(colorTex, offset[1].zw).rgb, weights); - delta.zw = abs(L - float2(Lright, Lbottom)); + // Calculate right and bottom deltas: + float Lright = dot( SMAASamplePoint( colorTex, offset[1].xy ).rgb, weights ); + float Lbottom = dot( SMAASamplePoint( colorTex, offset[1].zw ).rgb, weights ); + delta.zw = abs( L - float2( Lright, Lbottom ) ); - // Calculate the maximum delta in the direct neighborhood: - float2 maxDelta = max(delta.xy, delta.zw); + // Calculate the maximum delta in the direct neighborhood: + float2 maxDelta = max( delta.xy, delta.zw ); - // Calculate left-left and top-top deltas: - float Lleftleft = dot(SMAASamplePoint(colorTex, offset[2].xy).rgb, weights); - float Ltoptop = dot(SMAASamplePoint(colorTex, offset[2].zw).rgb, weights); - delta.zw = abs(float2(Lleft, Ltop) - float2(Lleftleft, Ltoptop)); + // Calculate left-left and top-top deltas: + float Lleftleft = dot( SMAASamplePoint( colorTex, offset[2].xy ).rgb, weights ); + float Ltoptop = dot( SMAASamplePoint( colorTex, offset[2].zw ).rgb, weights ); + delta.zw = abs( float2( Lleft, Ltop ) - float2( Lleftleft, Ltoptop ) ); - // Calculate the final maximum delta: - maxDelta = max(maxDelta.xy, delta.zw); - float finalDelta = max(maxDelta.x, maxDelta.y); + // Calculate the final maximum delta: + maxDelta = max( maxDelta.xy, delta.zw ); + float finalDelta = max( maxDelta.x, maxDelta.y ); - // Local contrast adaptation: - edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy); + // Local contrast adaptation: + edges.xy *= step( finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy ); - return edges; + return edges; } /** @@ -757,84 +773,90 @@ float2 SMAALumaEdgeDetectionPS(float2 texcoord, * IMPORTANT NOTICE: color edge detection requires gamma-corrected colors, and * thus 'colorTex' should be a non-sRGB texture. */ -float2 SMAAColorEdgeDetectionPS(float2 texcoord, - float4 offset[3], - SMAATexture2D(colorTex) - #if SMAA_PREDICATION - , SMAATexture2D(predicationTex) - #endif - ) { - // Calculate the threshold: - #if SMAA_PREDICATION - float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, predicationTex); - #else - float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD); - #endif +float2 SMAAColorEdgeDetectionPS( float2 texcoord, + float4 offset[3], + SMAATexture2D( colorTex ) +#if SMAA_PREDICATION + , SMAATexture2D( predicationTex ) +#endif + ) +{ + // Calculate the threshold: +#if SMAA_PREDICATION + float2 threshold = SMAACalculatePredicatedThreshold( texcoord, offset, predicationTex ); +#else + float2 threshold = float2( SMAA_THRESHOLD, SMAA_THRESHOLD ); +#endif - // Calculate color deltas: - float4 delta; - float3 C = SMAASamplePoint(colorTex, texcoord).rgb; + // Calculate color deltas: + float4 delta; + float3 C = SMAASamplePoint( colorTex, texcoord ).rgb; - float3 Cleft = SMAASamplePoint(colorTex, offset[0].xy).rgb; - float3 t = abs(C - Cleft); - delta.x = max(max(t.r, t.g), t.b); + float3 Cleft = SMAASamplePoint( colorTex, offset[0].xy ).rgb; + float3 t = abs( C - Cleft ); + delta.x = max( max( t.r, t.g ), t.b ); - float3 Ctop = SMAASamplePoint(colorTex, offset[0].zw).rgb; - t = abs(C - Ctop); - delta.y = max(max(t.r, t.g), t.b); + float3 Ctop = SMAASamplePoint( colorTex, offset[0].zw ).rgb; + t = abs( C - Ctop ); + delta.y = max( max( t.r, t.g ), t.b ); - // We do the usual threshold: - float2 edges = step(threshold, delta.xy); + // We do the usual threshold: + float2 edges = step( threshold, delta.xy ); - // Then discard if there is no edge: - if (dot(edges, float2(1.0, 1.0)) == 0.0) - discard; + // Then discard if there is no edge: + if( dot( edges, float2( 1.0, 1.0 ) ) == 0.0 ) + { + discard; + } - // Calculate right and bottom deltas: - float3 Cright = SMAASamplePoint(colorTex, offset[1].xy).rgb; - t = abs(C - Cright); - delta.z = max(max(t.r, t.g), t.b); + // Calculate right and bottom deltas: + float3 Cright = SMAASamplePoint( colorTex, offset[1].xy ).rgb; + t = abs( C - Cright ); + delta.z = max( max( t.r, t.g ), t.b ); - float3 Cbottom = SMAASamplePoint(colorTex, offset[1].zw).rgb; - t = abs(C - Cbottom); - delta.w = max(max(t.r, t.g), t.b); + float3 Cbottom = SMAASamplePoint( colorTex, offset[1].zw ).rgb; + t = abs( C - Cbottom ); + delta.w = max( max( t.r, t.g ), t.b ); - // Calculate the maximum delta in the direct neighborhood: - float2 maxDelta = max(delta.xy, delta.zw); + // Calculate the maximum delta in the direct neighborhood: + float2 maxDelta = max( delta.xy, delta.zw ); - // Calculate left-left and top-top deltas: - float3 Cleftleft = SMAASamplePoint(colorTex, offset[2].xy).rgb; - t = abs(C - Cleftleft); - delta.z = max(max(t.r, t.g), t.b); + // Calculate left-left and top-top deltas: + float3 Cleftleft = SMAASamplePoint( colorTex, offset[2].xy ).rgb; + t = abs( C - Cleftleft ); + delta.z = max( max( t.r, t.g ), t.b ); - float3 Ctoptop = SMAASamplePoint(colorTex, offset[2].zw).rgb; - t = abs(C - Ctoptop); - delta.w = max(max(t.r, t.g), t.b); + float3 Ctoptop = SMAASamplePoint( colorTex, offset[2].zw ).rgb; + t = abs( C - Ctoptop ); + delta.w = max( max( t.r, t.g ), t.b ); - // Calculate the final maximum delta: - maxDelta = max(maxDelta.xy, delta.zw); - float finalDelta = max(maxDelta.x, maxDelta.y); + // Calculate the final maximum delta: + maxDelta = max( maxDelta.xy, delta.zw ); + float finalDelta = max( maxDelta.x, maxDelta.y ); - // Local contrast adaptation: - edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy); + // Local contrast adaptation: + edges.xy *= step( finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy ); - return edges; + return edges; } /** * Depth Edge Detection */ -float2 SMAADepthEdgeDetectionPS(float2 texcoord, - float4 offset[3], - SMAATexture2D(depthTex)) { - float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(depthTex)); - float2 delta = abs(neighbours.xx - float2(neighbours.y, neighbours.z)); - float2 edges = step(SMAA_DEPTH_THRESHOLD, delta); +float2 SMAADepthEdgeDetectionPS( float2 texcoord, + float4 offset[3], + SMAATexture2D( depthTex ) ) +{ + float3 neighbours = SMAAGatherNeighbours( texcoord, offset, SMAATexturePass2D( depthTex ) ); + float2 delta = abs( neighbours.xx - float2( neighbours.y, neighbours.z ) ); + float2 edges = step( SMAA_DEPTH_THRESHOLD, delta ); - if (dot(edges, float2(1.0, 1.0)) == 0.0) - discard; + if( dot( edges, float2( 1.0, 1.0 ) ) == 0.0 ) + { + discard; + } - return edges; + return edges; } //----------------------------------------------------------------------------- @@ -845,159 +867,177 @@ float2 SMAADepthEdgeDetectionPS(float2 texcoord, /** * Allows to decode two binary values from a bilinear-filtered access. */ -float2 SMAADecodeDiagBilinearAccess(float2 e) { - // Bilinear access for fetching 'e' have a 0.25 offset, and we are - // interested in the R and G edges: - // - // +---G---+-------+ - // | x o R x | - // +-------+-------+ - // - // Then, if one of these edge is enabled: - // Red: (0.75 * X + 0.25 * 1) => 0.25 or 1.0 - // Green: (0.75 * 1 + 0.25 * X) => 0.75 or 1.0 - // - // This function will unpack the values (mad + mul + round): - // wolframalpha.com: round(x * abs(5 * x - 5 * 0.75)) plot 0 to 1 - e.r = e.r * abs(5.0 * e.r - 5.0 * 0.75); - return round(e); +float2 SMAADecodeDiagBilinearAccess( float2 e ) +{ + // Bilinear access for fetching 'e' have a 0.25 offset, and we are + // interested in the R and G edges: + // + // +---G---+-------+ + // | x o R x | + // +-------+-------+ + // + // Then, if one of these edge is enabled: + // Red: (0.75 * X + 0.25 * 1) => 0.25 or 1.0 + // Green: (0.75 * 1 + 0.25 * X) => 0.75 or 1.0 + // + // This function will unpack the values (mad + mul + round): + // wolframalpha.com: round(x * abs(5 * x - 5 * 0.75)) plot 0 to 1 + e.r = e.r * abs( 5.0 * e.r - 5.0 * 0.75 ); + return round( e ); } -float4 SMAADecodeDiagBilinearAccess(float4 e) { - e.rb = e.rb * abs(5.0 * e.rb - 5.0 * 0.75); - return round(e); +float4 SMAADecodeDiagBilinearAccess( float4 e ) +{ + e.rb = e.rb * abs( 5.0 * e.rb - 5.0 * 0.75 ); + return round( e ); } /** * These functions allows to perform diagonal pattern searches. */ -float2 SMAASearchDiag1(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) { - dir.y = API_V_DIR(dir.y); - float4 coord = float4(texcoord, -1.0, 1.0); - float3 t = float3(SMAA_RT_METRICS.xy, 1.0); - while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && - coord.w > 0.9) { - coord.xyz = mad(t, float3(dir, 1.0), coord.xyz); - e = SMAASampleLevelZero(edgesTex, coord.xy).rg; - coord.w = dot(e, float2(0.5, 0.5)); - } - return coord.zw; +float2 SMAASearchDiag1( SMAATexture2D( edgesTex ), float2 texcoord, float2 dir, out float2 e ) +{ + dir.y = API_V_DIR( dir.y ); + float4 coord = float4( texcoord, -1.0, 1.0 ); + float3 t = float3( SMAA_RT_METRICS.xy, 1.0 ); + while( coord.z < float( SMAA_MAX_SEARCH_STEPS_DIAG - 1 ) && + coord.w > 0.9 ) + { + coord.xyz = mad( t, float3( dir, 1.0 ), coord.xyz ); + e = SMAASampleLevelZero( edgesTex, coord.xy ).rg; + coord.w = dot( e, float2( 0.5, 0.5 ) ); + } + return coord.zw; } -float2 SMAASearchDiag2(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) { - dir.y = API_V_DIR(dir.y); - float4 coord = float4(texcoord, -1.0, 1.0); - coord.x += 0.25 * SMAA_RT_METRICS.x; // See @SearchDiag2Optimization - float3 t = float3(SMAA_RT_METRICS.xy, 1.0); - while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) && - coord.w > 0.9) { - coord.xyz = mad(t, float3(dir, 1.0), coord.xyz); +float2 SMAASearchDiag2( SMAATexture2D( edgesTex ), float2 texcoord, float2 dir, out float2 e ) +{ + dir.y = API_V_DIR( dir.y ); + float4 coord = float4( texcoord, -1.0, 1.0 ); + coord.x += 0.25 * SMAA_RT_METRICS.x; // See @SearchDiag2Optimization + float3 t = float3( SMAA_RT_METRICS.xy, 1.0 ); + while( coord.z < float( SMAA_MAX_SEARCH_STEPS_DIAG - 1 ) && + coord.w > 0.9 ) + { + coord.xyz = mad( t, float3( dir, 1.0 ), coord.xyz ); - // @SearchDiag2Optimization - // Fetch both edges at once using bilinear filtering: - e = SMAASampleLevelZero(edgesTex, coord.xy).rg; - e = SMAADecodeDiagBilinearAccess(e); + // @SearchDiag2Optimization + // Fetch both edges at once using bilinear filtering: + e = SMAASampleLevelZero( edgesTex, coord.xy ).rg; + e = SMAADecodeDiagBilinearAccess( e ); - // Non-optimized version: - // e.g = SMAASampleLevelZero(edgesTex, coord.xy).g; - // e.r = SMAASampleLevelZeroOffset(edgesTex, coord.xy, int2(1, 0)).r; + // Non-optimized version: + // e.g = SMAASampleLevelZero(edgesTex, coord.xy).g; + // e.r = SMAASampleLevelZeroOffset(edgesTex, coord.xy, int2(1, 0)).r; - coord.w = dot(e, float2(0.5, 0.5)); - } - return coord.zw; + coord.w = dot( e, float2( 0.5, 0.5 ) ); + } + return coord.zw; } -/** +/** * Similar to SMAAArea, this calculates the area corresponding to a certain * diagonal distance and crossing edges 'e'. */ -float2 SMAAAreaDiag(SMAATexture2D(areaTex), float2 dist, float2 e, float offset) { - float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE_DIAG, SMAA_AREATEX_MAX_DISTANCE_DIAG), e, dist); +float2 SMAAAreaDiag( SMAATexture2D( areaTex ), float2 dist, float2 e, float offset ) +{ + float2 texcoord = mad( float2( SMAA_AREATEX_MAX_DISTANCE_DIAG, SMAA_AREATEX_MAX_DISTANCE_DIAG ), e, dist ); - // We do a scale and bias for mapping to texel space: - texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE); + // We do a scale and bias for mapping to texel space: + texcoord = mad( SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE ); - // Diagonal areas are on the second half of the texture: - texcoord.x += 0.5; + // Diagonal areas are on the second half of the texture: + texcoord.x += 0.5; - // Move to proper place, according to the subpixel offset: - texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset; + // Move to proper place, according to the subpixel offset: + texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset; - texcoord.y = API_V_COORD(texcoord.y); + texcoord.y = API_V_COORD( texcoord.y ); - // Do it! - return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord)); + // Do it! + return SMAA_AREATEX_SELECT( SMAASampleLevelZero( areaTex, texcoord ) ); } /** * This searches for diagonal patterns and returns the corresponding weights. */ -float2 SMAACalculateDiagWeights(SMAATexture2D(edgesTex), SMAATexture2D(areaTex), float2 texcoord, float2 e, float4 subsampleIndices) { - float2 weights = float2(0.0, 0.0); +float2 SMAACalculateDiagWeights( SMAATexture2D( edgesTex ), SMAATexture2D( areaTex ), float2 texcoord, float2 e, float4 subsampleIndices ) +{ + float2 weights = float2( 0.0, 0.0 ); - // Search for the line ends: - float4 d; - float2 end; - if (e.r > 0.0) { - d.xz = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0, 1.0), end); - d.x += float(end.y > 0.9); - } else - d.xz = float2(0.0, 0.0); - d.yw = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, -1.0), end); + // Search for the line ends: + float4 d; + float2 end; + if( e.r > 0.0 ) + { + d.xz = SMAASearchDiag1( SMAATexturePass2D( edgesTex ), texcoord, float2( -1.0, 1.0 ), end ); + d.x += float( end.y > 0.9 ); + } + else + { + d.xz = float2( 0.0, 0.0 ); + } + d.yw = SMAASearchDiag1( SMAATexturePass2D( edgesTex ), texcoord, float2( 1.0, -1.0 ), end ); - SMAA_BRANCH - if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 - // Fetch the crossing edges: - float4 coords = mad(float4(-d.x + 0.25, API_V_DIR(d.x), d.y, API_V_DIR(-d.y - 0.25)), SMAA_RT_METRICS.xyxy, texcoord.xyxy); - float4 c; - c.xy = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).rg; - c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).rg; - c.yxwz = SMAADecodeDiagBilinearAccess(c.xyzw); + SMAA_BRANCH + if( d.x + d.y > 2.0 ) // d.x + d.y + 1 > 3 + { + // Fetch the crossing edges: + float4 coords = mad( float4( -d.x + 0.25, API_V_DIR( d.x ), d.y, API_V_DIR( -d.y - 0.25 ) ), SMAA_RT_METRICS.xyxy, texcoord.xyxy ); + float4 c; + c.xy = SMAASampleLevelZeroOffset( edgesTex, coords.xy, int2( -1, 0 ) ).rg; + c.zw = SMAASampleLevelZeroOffset( edgesTex, coords.zw, int2( 1, 0 ) ).rg; + c.yxwz = SMAADecodeDiagBilinearAccess( c.xyzw ); - // Non-optimized version: - // float4 coords = mad(float4(-d.x, d.x, d.y, -d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy); - // float4 c; - // c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).g; - // c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, 0)).r; - // c.z = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).g; - // c.w = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, -1)).r; + // Non-optimized version: + // float4 coords = mad(float4(-d.x, d.x, d.y, -d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy); + // float4 c; + // c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).g; + // c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, 0)).r; + // c.z = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).g; + // c.w = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, -1)).r; - // Merge crossing edges at each side into a single value: - float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw); + // Merge crossing edges at each side into a single value: + float2 cc = mad( float2( 2.0, 2.0 ), c.xz, c.yw ); - // Remove the crossing edge if we didn't found the end of the line: - SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0)); + // Remove the crossing edge if we didn't found the end of the line: + SMAAMovc( bool2( step( 0.9, d.zw ) ), cc, float2( 0.0, 0.0 ) ); - // Fetch the areas for this line: - weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.z); - } + // Fetch the areas for this line: + weights += SMAAAreaDiag( SMAATexturePass2D( areaTex ), d.xy, cc, subsampleIndices.z ); + } - // Search for the line ends: - d.xz = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0, -1.0), end); - if (SMAASampleLevelZeroOffset(edgesTex, texcoord, int2(1, 0)).r > 0.0) { - d.yw = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, 1.0), end); - d.y += float(end.y > 0.9); - } else - d.yw = float2(0.0, 0.0); + // Search for the line ends: + d.xz = SMAASearchDiag2( SMAATexturePass2D( edgesTex ), texcoord, float2( -1.0, -1.0 ), end ); + if( SMAASampleLevelZeroOffset( edgesTex, texcoord, int2( 1, 0 ) ).r > 0.0 ) + { + d.yw = SMAASearchDiag2( SMAATexturePass2D( edgesTex ), texcoord, float2( 1.0, 1.0 ), end ); + d.y += float( end.y > 0.9 ); + } + else + { + d.yw = float2( 0.0, 0.0 ); + } - SMAA_BRANCH - if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 - // Fetch the crossing edges: - float4 coords = mad(float4(-d.x, API_V_DIR(-d.x), d.y, API_V_DIR(d.y)), SMAA_RT_METRICS.xyxy, texcoord.xyxy); - float4 c; - c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1, 0)).g; - c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, API_V_DIR(-1))).r; - c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, 0)).gr; - float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw); + SMAA_BRANCH + if( d.x + d.y > 2.0 ) // d.x + d.y + 1 > 3 + { + // Fetch the crossing edges: + float4 coords = mad( float4( -d.x, API_V_DIR( -d.x ), d.y, API_V_DIR( d.y ) ), SMAA_RT_METRICS.xyxy, texcoord.xyxy ); + float4 c; + c.x = SMAASampleLevelZeroOffset( edgesTex, coords.xy, int2( -1, 0 ) ).g; + c.y = SMAASampleLevelZeroOffset( edgesTex, coords.xy, int2( 0, API_V_DIR( -1 ) ) ).r; + c.zw = SMAASampleLevelZeroOffset( edgesTex, coords.zw, int2( 1, 0 ) ).gr; + float2 cc = mad( float2( 2.0, 2.0 ), c.xz, c.yw ); - // Remove the crossing edge if we didn't found the end of the line: - SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0)); + // Remove the crossing edge if we didn't found the end of the line: + SMAAMovc( bool2( step( 0.9, d.zw ) ), cc, float2( 0.0, 0.0 ) ); - // Fetch the areas for this line: - weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.w).gr; - } + // Fetch the areas for this line: + weights += SMAAAreaDiag( SMAATexturePass2D( areaTex ), d.xy, cc, subsampleIndices.w ).gr; + } - return weights; + return weights; } #endif @@ -1006,375 +1046,400 @@ float2 SMAACalculateDiagWeights(SMAATexture2D(edgesTex), SMAATexture2D(areaTex), /** * This allows to determine how much length should we add in the last step - * of the searches. It takes the bilinearly interpolated edge (see + * of the searches. It takes the bilinearly interpolated edge (see * @PSEUDO_GATHER4), and adds 0, 1 or 2, depending on which edges and * crossing edges are active. */ -float SMAASearchLength(SMAATexture2D(searchTex), float2 e, float offset) { - // The texture is flipped vertically, with left and right cases taking half - // of the space horizontally: - float2 scale = SMAA_SEARCHTEX_SIZE * float2(0.5, -1.0); - float2 bias = SMAA_SEARCHTEX_SIZE * float2(offset, 1.0); +float SMAASearchLength( SMAATexture2D( searchTex ), float2 e, float offset ) +{ + // The texture is flipped vertically, with left and right cases taking half + // of the space horizontally: + float2 scale = SMAA_SEARCHTEX_SIZE * float2( 0.5, -1.0 ); + float2 bias = SMAA_SEARCHTEX_SIZE * float2( offset, 1.0 ); - // Scale and bias to access texel centers: - scale += float2(-1.0, 1.0); - bias += float2( 0.5, -0.5); + // Scale and bias to access texel centers: + scale += float2( -1.0, 1.0 ); + bias += float2( 0.5, -0.5 ); - // Convert from pixel coordinates to texcoords: - // (We use SMAA_SEARCHTEX_PACKED_SIZE because the texture is cropped) - scale *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; - bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; + // Convert from pixel coordinates to texcoords: + // (We use SMAA_SEARCHTEX_PACKED_SIZE because the texture is cropped) + scale *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; + bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE; - float2 coord = mad(scale, e, bias); - coord.y = API_V_COORD(coord.y); + float2 coord = mad( scale, e, bias ); + coord.y = API_V_COORD( coord.y ); - // Lookup the search texture: - return SMAA_SEARCHTEX_SELECT(SMAASampleLevelZero(searchTex, coord)); + // Lookup the search texture: + return SMAA_SEARCHTEX_SELECT( SMAASampleLevelZero( searchTex, coord ) ); } /** * Horizontal/vertical search functions for the 2nd pass. */ -float SMAASearchXLeft(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { - /** - * @PSEUDO_GATHER4 - * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to - * sample between edge, thus fetching four edges in a row. - * Sampling with different offsets in each direction allows to disambiguate - * which edges are active from the four fetched ones. - */ - float2 e = float2(0.0, 1.0); - while (texcoord.x > end && - e.g > 0.8281 && // Is there some edge not activated? - e.r == 0.0) { // Or is there a crossing edge that breaks the line? - e = SMAASampleLevelZero(edgesTex, texcoord).rg; - texcoord = mad(-float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); - } +float SMAASearchXLeft( SMAATexture2D( edgesTex ), SMAATexture2D( searchTex ), float2 texcoord, float end ) +{ + /** + * @PSEUDO_GATHER4 + * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to + * sample between edge, thus fetching four edges in a row. + * Sampling with different offsets in each direction allows to disambiguate + * which edges are active from the four fetched ones. + */ + float2 e = float2( 0.0, 1.0 ); + while( texcoord.x > end && + e.g > 0.8281 && // Is there some edge not activated? + e.r == 0.0 ) // Or is there a crossing edge that breaks the line? + { + e = SMAASampleLevelZero( edgesTex, texcoord ).rg; + texcoord = mad( -float2( 2.0, 0.0 ), SMAA_RT_METRICS.xy, texcoord ); + } - float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0), 3.25); - return mad(SMAA_RT_METRICS.x, offset, texcoord.x); + float offset = mad( -( 255.0 / 127.0 ), SMAASearchLength( SMAATexturePass2D( searchTex ), e, 0.0 ), 3.25 ); + return mad( SMAA_RT_METRICS.x, offset, texcoord.x ); - // Non-optimized version: - // We correct the previous (-0.25, -0.125) offset we applied: - // texcoord.x += 0.25 * SMAA_RT_METRICS.x; + // Non-optimized version: + // We correct the previous (-0.25, -0.125) offset we applied: + // texcoord.x += 0.25 * SMAA_RT_METRICS.x; - // The searches are bias by 1, so adjust the coords accordingly: - // texcoord.x += SMAA_RT_METRICS.x; + // The searches are bias by 1, so adjust the coords accordingly: + // texcoord.x += SMAA_RT_METRICS.x; - // Disambiguate the length added by the last step: - // texcoord.x += 2.0 * SMAA_RT_METRICS.x; // Undo last step - // texcoord.x -= SMAA_RT_METRICS.x * (255.0 / 127.0) * SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0); - // return mad(SMAA_RT_METRICS.x, offset, texcoord.x); + // Disambiguate the length added by the last step: + // texcoord.x += 2.0 * SMAA_RT_METRICS.x; // Undo last step + // texcoord.x -= SMAA_RT_METRICS.x * (255.0 / 127.0) * SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0); + // return mad(SMAA_RT_METRICS.x, offset, texcoord.x); } -float SMAASearchXRight(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { - float2 e = float2(0.0, 1.0); - while (texcoord.x < end && - e.g > 0.8281 && // Is there some edge not activated? - e.r == 0.0) { // Or is there a crossing edge that breaks the line? - e = SMAASampleLevelZero(edgesTex, texcoord).rg; - texcoord = mad(float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord); - } - float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.5), 3.25); - return mad(-SMAA_RT_METRICS.x, offset, texcoord.x); +float SMAASearchXRight( SMAATexture2D( edgesTex ), SMAATexture2D( searchTex ), float2 texcoord, float end ) +{ + float2 e = float2( 0.0, 1.0 ); + while( texcoord.x < end && + e.g > 0.8281 && // Is there some edge not activated? + e.r == 0.0 ) // Or is there a crossing edge that breaks the line? + { + e = SMAASampleLevelZero( edgesTex, texcoord ).rg; + texcoord = mad( float2( 2.0, 0.0 ), SMAA_RT_METRICS.xy, texcoord ); + } + float offset = mad( -( 255.0 / 127.0 ), SMAASearchLength( SMAATexturePass2D( searchTex ), e, 0.5 ), 3.25 ); + return mad( -SMAA_RT_METRICS.x, offset, texcoord.x ); } -float SMAASearchYUp(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { - float2 e = float2(1.0, 0.0); - while (API_V_BELOW(texcoord.y, end) && - e.r > 0.8281 && // Is there some edge not activated? - e.g == 0.0) { // Or is there a crossing edge that breaks the line? - e = SMAASampleLevelZero(edgesTex, texcoord).rg; - texcoord = mad(-float2(0.0, API_V_DIR(2.0)), SMAA_RT_METRICS.xy, texcoord); - } - float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.0), 3.25); - return mad(SMAA_RT_METRICS.y, API_V_DIR(offset), texcoord.y); +float SMAASearchYUp( SMAATexture2D( edgesTex ), SMAATexture2D( searchTex ), float2 texcoord, float end ) +{ + float2 e = float2( 1.0, 0.0 ); + while( API_V_BELOW( texcoord.y, end ) && + e.r > 0.8281 && // Is there some edge not activated? + e.g == 0.0 ) // Or is there a crossing edge that breaks the line? + { + e = SMAASampleLevelZero( edgesTex, texcoord ).rg; + texcoord = mad( -float2( 0.0, API_V_DIR( 2.0 ) ), SMAA_RT_METRICS.xy, texcoord ); + } + float offset = mad( -( 255.0 / 127.0 ), SMAASearchLength( SMAATexturePass2D( searchTex ), e.gr, 0.0 ), 3.25 ); + return mad( SMAA_RT_METRICS.y, API_V_DIR( offset ), texcoord.y ); } -float SMAASearchYDown(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) { - float2 e = float2(1.0, 0.0); - while (API_V_ABOVE(texcoord.y, end) && - e.r > 0.8281 && // Is there some edge not activated? - e.g == 0.0) { // Or is there a crossing edge that breaks the line? - e = SMAASampleLevelZero(edgesTex, texcoord).rg; - texcoord = mad(float2(0.0, API_V_DIR(2.0)), SMAA_RT_METRICS.xy, texcoord); - } - float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.5), 3.25); - return mad(-SMAA_RT_METRICS.y, API_V_DIR(offset), texcoord.y); +float SMAASearchYDown( SMAATexture2D( edgesTex ), SMAATexture2D( searchTex ), float2 texcoord, float end ) +{ + float2 e = float2( 1.0, 0.0 ); + while( API_V_ABOVE( texcoord.y, end ) && + e.r > 0.8281 && // Is there some edge not activated? + e.g == 0.0 ) // Or is there a crossing edge that breaks the line? + { + e = SMAASampleLevelZero( edgesTex, texcoord ).rg; + texcoord = mad( float2( 0.0, API_V_DIR( 2.0 ) ), SMAA_RT_METRICS.xy, texcoord ); + } + float offset = mad( -( 255.0 / 127.0 ), SMAASearchLength( SMAATexturePass2D( searchTex ), e.gr, 0.5 ), 3.25 ); + return mad( -SMAA_RT_METRICS.y, API_V_DIR( offset ), texcoord.y ); } -/** +/** * Ok, we have the distance and both crossing edges. So, what are the areas * at each side of current edge? */ -float2 SMAAArea(SMAATexture2D(areaTex), float2 dist, float e1, float e2, float offset) { - // Rounding prevents precision errors of bilinear filtering: - float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE, SMAA_AREATEX_MAX_DISTANCE), round(4.0 * float2(e1, e2)), dist); - - // We do a scale and bias for mapping to texel space: - texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE); +float2 SMAAArea( SMAATexture2D( areaTex ), float2 dist, float e1, float e2, float offset ) +{ + // Rounding prevents precision errors of bilinear filtering: + float2 texcoord = mad( float2( SMAA_AREATEX_MAX_DISTANCE, SMAA_AREATEX_MAX_DISTANCE ), round( 4.0 * float2( e1, e2 ) ), dist ); - // Move to proper place, according to the subpixel offset: - texcoord.y = mad(SMAA_AREATEX_SUBTEX_SIZE, offset, texcoord.y); + // We do a scale and bias for mapping to texel space: + texcoord = mad( SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE ); - texcoord.y = API_V_COORD(texcoord.y); + // Move to proper place, according to the subpixel offset: + texcoord.y = mad( SMAA_AREATEX_SUBTEX_SIZE, offset, texcoord.y ); - // Do it! - return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord)); + texcoord.y = API_V_COORD( texcoord.y ); + + // Do it! + return SMAA_AREATEX_SELECT( SMAASampleLevelZero( areaTex, texcoord ) ); } //----------------------------------------------------------------------------- // Corner Detection Functions -void SMAADetectHorizontalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) { - #if !defined(SMAA_DISABLE_CORNER_DETECTION) - float2 leftRight = step(d.xy, d.yx); - float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight; +void SMAADetectHorizontalCornerPattern( SMAATexture2D( edgesTex ), inout float2 weights, float4 texcoord, float2 d ) +{ +#if !defined(SMAA_DISABLE_CORNER_DETECTION) + float2 leftRight = step( d.xy, d.yx ); + float2 rounding = ( 1.0 - SMAA_CORNER_ROUNDING_NORM ) * leftRight; - rounding /= leftRight.x + leftRight.y; // Reduce blending for pixels in the center of a line. + rounding /= leftRight.x + leftRight.y; // Reduce blending for pixels in the center of a line. - float2 factor = float2(1.0, 1.0); - factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0, API_V_DIR(1))).r; - factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1, API_V_DIR(1))).r; - factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0, API_V_DIR(-2))).r; - factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1, API_V_DIR(-2))).r; + float2 factor = float2( 1.0, 1.0 ); + factor.x -= rounding.x * SMAASampleLevelZeroOffset( edgesTex, texcoord.xy, int2( 0, API_V_DIR( 1 ) ) ).r; + factor.x -= rounding.y * SMAASampleLevelZeroOffset( edgesTex, texcoord.zw, int2( 1, API_V_DIR( 1 ) ) ).r; + factor.y -= rounding.x * SMAASampleLevelZeroOffset( edgesTex, texcoord.xy, int2( 0, API_V_DIR( -2 ) ) ).r; + factor.y -= rounding.y * SMAASampleLevelZeroOffset( edgesTex, texcoord.zw, int2( 1, API_V_DIR( -2 ) ) ).r; - weights *= saturate(factor); - #endif + weights *= saturate( factor ); +#endif } -void SMAADetectVerticalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) { - #if !defined(SMAA_DISABLE_CORNER_DETECTION) - float2 leftRight = step(d.xy, d.yx); - float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight; +void SMAADetectVerticalCornerPattern( SMAATexture2D( edgesTex ), inout float2 weights, float4 texcoord, float2 d ) +{ +#if !defined(SMAA_DISABLE_CORNER_DETECTION) + float2 leftRight = step( d.xy, d.yx ); + float2 rounding = ( 1.0 - SMAA_CORNER_ROUNDING_NORM ) * leftRight; - rounding /= leftRight.x + leftRight.y; + rounding /= leftRight.x + leftRight.y; - float2 factor = float2(1.0, 1.0); - factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2( 1, 0)).g; - factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2( 1, API_V_DIR(1))).g; - factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(-2, 0)).g; - factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(-2, API_V_DIR(1))).g; + float2 factor = float2( 1.0, 1.0 ); + factor.x -= rounding.x * SMAASampleLevelZeroOffset( edgesTex, texcoord.xy, int2( 1, 0 ) ).g; + factor.x -= rounding.y * SMAASampleLevelZeroOffset( edgesTex, texcoord.zw, int2( 1, API_V_DIR( 1 ) ) ).g; + factor.y -= rounding.x * SMAASampleLevelZeroOffset( edgesTex, texcoord.xy, int2( -2, 0 ) ).g; + factor.y -= rounding.y * SMAASampleLevelZeroOffset( edgesTex, texcoord.zw, int2( -2, API_V_DIR( 1 ) ) ).g; - weights *= saturate(factor); - #endif + weights *= saturate( factor ); +#endif } //----------------------------------------------------------------------------- // Blending Weight Calculation Pixel Shader (Second Pass) -float4 SMAABlendingWeightCalculationPS(float2 texcoord, - float2 pixcoord, - float4 offset[3], - SMAATexture2D(edgesTex), - SMAATexture2D(areaTex), - SMAATexture2D(searchTex), - float4 subsampleIndices) { // Just pass zero for SMAA 1x, see @SUBSAMPLE_INDICES. - float4 weights = float4(0.0, 0.0, 0.0, 0.0); +float4 SMAABlendingWeightCalculationPS( float2 texcoord, + float2 pixcoord, + float4 offset[3], + SMAATexture2D( edgesTex ), + SMAATexture2D( areaTex ), + SMAATexture2D( searchTex ), + float4 subsampleIndices ) // Just pass zero for SMAA 1x, see @SUBSAMPLE_INDICES. +{ + float4 weights = float4( 0.0, 0.0, 0.0, 0.0 ); - float2 e = SMAASample(edgesTex, texcoord).rg; + float2 e = SMAASample( edgesTex, texcoord ).rg; - SMAA_BRANCH - if (e.g > 0.0) { // Edge at north - #if !defined(SMAA_DISABLE_DIAG_DETECTION) - // Diagonals have both north and west edges, so searching for them in - // one of the boundaries is enough. - weights.rg = SMAACalculateDiagWeights(SMAATexturePass2D(edgesTex), SMAATexturePass2D(areaTex), texcoord, e, subsampleIndices); + SMAA_BRANCH + if( e.g > 0.0 ) // Edge at north + { +#if !defined(SMAA_DISABLE_DIAG_DETECTION) + // Diagonals have both north and west edges, so searching for them in + // one of the boundaries is enough. + weights.rg = SMAACalculateDiagWeights( SMAATexturePass2D( edgesTex ), SMAATexturePass2D( areaTex ), texcoord, e, subsampleIndices ); - // We give priority to diagonals, so if we find a diagonal we skip - // horizontal/vertical processing. - SMAA_BRANCH - if (weights.r == -weights.g) { // weights.r + weights.g == 0.0 - #endif + // We give priority to diagonals, so if we find a diagonal we skip + // horizontal/vertical processing. + SMAA_BRANCH + if( weights.r == -weights.g ) // weights.r + weights.g == 0.0 + { +#endif - float2 d; + float2 d; - // Find the distance to the left: - float3 coords; - coords.x = SMAASearchXLeft(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].xy, offset[2].x); - coords.y = offset[1].y; // offset[1].y = texcoord.y - 0.25 * SMAA_RT_METRICS.y (@CROSSING_OFFSET) - d.x = coords.x; + // Find the distance to the left: + float3 coords; + coords.x = SMAASearchXLeft( SMAATexturePass2D( edgesTex ), SMAATexturePass2D( searchTex ), offset[0].xy, offset[2].x ); + coords.y = offset[1].y; // offset[1].y = texcoord.y - 0.25 * SMAA_RT_METRICS.y (@CROSSING_OFFSET) + d.x = coords.x; - // Now fetch the left crossing edges, two at a time using bilinear - // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to - // discern what value each edge has: - float e1 = SMAASampleLevelZero(edgesTex, coords.xy).r; + // Now fetch the left crossing edges, two at a time using bilinear + // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to + // discern what value each edge has: + float e1 = SMAASampleLevelZero( edgesTex, coords.xy ).r; - // Find the distance to the right: - coords.z = SMAASearchXRight(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].zw, offset[2].y); - d.y = coords.z; + // Find the distance to the right: + coords.z = SMAASearchXRight( SMAATexturePass2D( edgesTex ), SMAATexturePass2D( searchTex ), offset[0].zw, offset[2].y ); + d.y = coords.z; - // We want the distances to be in pixel units (doing this here allow to - // better interleave arithmetic and memory accesses): - d = abs(round(mad(SMAA_RT_METRICS.zz, d, -pixcoord.xx))); + // We want the distances to be in pixel units (doing this here allow to + // better interleave arithmetic and memory accesses): + d = abs( round( mad( SMAA_RT_METRICS.zz, d, -pixcoord.xx ) ) ); - // SMAAArea below needs a sqrt, as the areas texture is compressed - // quadratically: - float2 sqrt_d = sqrt(d); + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + float2 sqrt_d = sqrt( d ); - // Fetch the right crossing edges: - float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.zy, int2(1, 0)).r; + // Fetch the right crossing edges: + float e2 = SMAASampleLevelZeroOffset( edgesTex, coords.zy, int2( 1, 0 ) ).r; - // Ok, we know how this pattern looks like, now it is time for getting - // the actual area: - weights.rg = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.y); + // Ok, we know how this pattern looks like, now it is time for getting + // the actual area: + weights.rg = SMAAArea( SMAATexturePass2D( areaTex ), sqrt_d, e1, e2, subsampleIndices.y ); - // Fix corners: - coords.y = texcoord.y; - SMAADetectHorizontalCornerPattern(SMAATexturePass2D(edgesTex), weights.rg, coords.xyzy, d); + // Fix corners: + coords.y = texcoord.y; + SMAADetectHorizontalCornerPattern( SMAATexturePass2D( edgesTex ), weights.rg, coords.xyzy, d ); - #if !defined(SMAA_DISABLE_DIAG_DETECTION) - } else - e.r = 0.0; // Skip vertical processing. - #endif - } +#if !defined(SMAA_DISABLE_DIAG_DETECTION) + } + else + { + e.r = 0.0; // Skip vertical processing. + } +#endif + } - SMAA_BRANCH - if (e.r > 0.0) { // Edge at west - float2 d; + SMAA_BRANCH + if( e.r > 0.0 ) // Edge at west + { + float2 d; - // Find the distance to the top: - float3 coords; - coords.y = SMAASearchYUp(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].xy, offset[2].z); - coords.x = offset[0].x; // offset[1].x = texcoord.x - 0.25 * SMAA_RT_METRICS.x; - d.x = coords.y; + // Find the distance to the top: + float3 coords; + coords.y = SMAASearchYUp( SMAATexturePass2D( edgesTex ), SMAATexturePass2D( searchTex ), offset[1].xy, offset[2].z ); + coords.x = offset[0].x; // offset[1].x = texcoord.x - 0.25 * SMAA_RT_METRICS.x; + d.x = coords.y; - // Fetch the top crossing edges: - float e1 = SMAASampleLevelZero(edgesTex, coords.xy).g; + // Fetch the top crossing edges: + float e1 = SMAASampleLevelZero( edgesTex, coords.xy ).g; - // Find the distance to the bottom: - coords.z = SMAASearchYDown(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].zw, offset[2].w); - d.y = coords.z; + // Find the distance to the bottom: + coords.z = SMAASearchYDown( SMAATexturePass2D( edgesTex ), SMAATexturePass2D( searchTex ), offset[1].zw, offset[2].w ); + d.y = coords.z; - // We want the distances to be in pixel units: - d = abs(round(mad(SMAA_RT_METRICS.ww, d, -pixcoord.yy))); + // We want the distances to be in pixel units: + d = abs( round( mad( SMAA_RT_METRICS.ww, d, -pixcoord.yy ) ) ); - // SMAAArea below needs a sqrt, as the areas texture is compressed - // quadratically: - float2 sqrt_d = sqrt(d); + // SMAAArea below needs a sqrt, as the areas texture is compressed + // quadratically: + float2 sqrt_d = sqrt( d ); - // Fetch the bottom crossing edges: - float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.xz, int2(0, API_V_DIR(1))).g; + // Fetch the bottom crossing edges: + float e2 = SMAASampleLevelZeroOffset( edgesTex, coords.xz, int2( 0, API_V_DIR( 1 ) ) ).g; - // Get the area for this direction: - weights.ba = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.x); + // Get the area for this direction: + weights.ba = SMAAArea( SMAATexturePass2D( areaTex ), sqrt_d, e1, e2, subsampleIndices.x ); - // Fix corners: - coords.x = texcoord.x; - SMAADetectVerticalCornerPattern(SMAATexturePass2D(edgesTex), weights.ba, coords.xyxz, d); - } + // Fix corners: + coords.x = texcoord.x; + SMAADetectVerticalCornerPattern( SMAATexturePass2D( edgesTex ), weights.ba, coords.xyxz, d ); + } - return weights; + return weights; } //----------------------------------------------------------------------------- // Neighborhood Blending Pixel Shader (Third Pass) -float4 SMAANeighborhoodBlendingPS(float2 texcoord, - float4 offset, - SMAATexture2D(colorTex), - SMAATexture2D(blendTex) - #if SMAA_REPROJECTION - , SMAATexture2D(velocityTex) - #endif - ) { - // Fetch the blending weights for current pixel: - float4 a; - a.x = SMAASample(blendTex, offset.xy).a; // Right - a.y = SMAASample(blendTex, offset.zw).g; // Top - a.wz = SMAASample(blendTex, texcoord).xz; // Bottom / Left +float4 SMAANeighborhoodBlendingPS( float2 texcoord, + float4 offset, + SMAATexture2D( colorTex ), + SMAATexture2D( blendTex ) +#if SMAA_REPROJECTION + , SMAATexture2D( velocityTex ) +#endif + ) +{ + // Fetch the blending weights for current pixel: + float4 a; + a.x = SMAASample( blendTex, offset.xy ).a; // Right + a.y = SMAASample( blendTex, offset.zw ).g; // Top + a.wz = SMAASample( blendTex, texcoord ).xz; // Bottom / Left - // Is there any blending weight with a value greater than 0.0? - SMAA_BRANCH - if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) { - float4 color = SMAASampleLevelZero(colorTex, texcoord); + // Is there any blending weight with a value greater than 0.0? + SMAA_BRANCH + if( dot( a, float4( 1.0, 1.0, 1.0, 1.0 ) ) < 1e-5 ) + { + float4 color = SMAASampleLevelZero( colorTex, texcoord ); - #if SMAA_REPROJECTION - float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord)); +#if SMAA_REPROJECTION + float2 velocity = SMAA_DECODE_VELOCITY( SMAASampleLevelZero( velocityTex, texcoord ) ); - // Pack velocity into the alpha channel: - color.a = sqrt(5.0 * length(velocity)); - #endif + // Pack velocity into the alpha channel: + color.a = sqrt( 5.0 * length( velocity ) ); +#endif - return color; - } else { - bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical) + return color; + } + else + { + bool h = max( a.x, a.z ) > max( a.y, a.w ); // max(horizontal) > max(vertical) - // Calculate the blending offsets: - float4 blendingOffset = float4(0.0, API_V_DIR(a.y), 0.0, API_V_DIR(a.w)); - float2 blendingWeight = a.yw; - SMAAMovc(bool4(h, h, h, h), blendingOffset, float4(a.x, 0.0, a.z, 0.0)); - SMAAMovc(bool2(h, h), blendingWeight, a.xz); - blendingWeight /= dot(blendingWeight, float2(1.0, 1.0)); + // Calculate the blending offsets: + float4 blendingOffset = float4( 0.0, API_V_DIR( a.y ), 0.0, API_V_DIR( a.w ) ); + float2 blendingWeight = a.yw; + SMAAMovc( bool4( h, h, h, h ), blendingOffset, float4( a.x, 0.0, a.z, 0.0 ) ); + SMAAMovc( bool2( h, h ), blendingWeight, a.xz ); + blendingWeight /= dot( blendingWeight, float2( 1.0, 1.0 ) ); - // Calculate the texture coordinates: - float4 blendingCoord = mad(blendingOffset, float4(SMAA_RT_METRICS.xy, -SMAA_RT_METRICS.xy), texcoord.xyxy); + // Calculate the texture coordinates: + float4 blendingCoord = mad( blendingOffset, float4( SMAA_RT_METRICS.xy, -SMAA_RT_METRICS.xy ), texcoord.xyxy ); - // We exploit bilinear filtering to mix current pixel with the chosen - // neighbor: - float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); - color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); + // We exploit bilinear filtering to mix current pixel with the chosen + // neighbor: + float4 color = blendingWeight.x * SMAASampleLevelZero( colorTex, blendingCoord.xy ); + color += blendingWeight.y * SMAASampleLevelZero( colorTex, blendingCoord.zw ); - #if SMAA_REPROJECTION - // Antialias velocity for proper reprojection in a later stage: - float2 velocity = blendingWeight.x * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.xy)); - velocity += blendingWeight.y * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.zw)); +#if SMAA_REPROJECTION + // Antialias velocity for proper reprojection in a later stage: + float2 velocity = blendingWeight.x * SMAA_DECODE_VELOCITY( SMAASampleLevelZero( velocityTex, blendingCoord.xy ) ); + velocity += blendingWeight.y * SMAA_DECODE_VELOCITY( SMAASampleLevelZero( velocityTex, blendingCoord.zw ) ); - // Pack velocity into the alpha channel: - color.a = sqrt(5.0 * length(velocity)); - #endif + // Pack velocity into the alpha channel: + color.a = sqrt( 5.0 * length( velocity ) ); +#endif - return color; - } + return color; + } } //----------------------------------------------------------------------------- // Temporal Resolve Pixel Shader (Optional Pass) -float4 SMAAResolvePS(float2 texcoord, - SMAATexture2D(currentColorTex), - SMAATexture2D(previousColorTex) - #if SMAA_REPROJECTION - , SMAATexture2D(velocityTex) - #endif - ) { - #if SMAA_REPROJECTION - // Velocity is assumed to be calculated for motion blur, so we need to - // inverse it for reprojection: - float2 velocity = -SMAA_DECODE_VELOCITY(SMAASamplePoint(velocityTex, texcoord).rg); +float4 SMAAResolvePS( float2 texcoord, + SMAATexture2D( currentColorTex ), + SMAATexture2D( previousColorTex ) +#if SMAA_REPROJECTION + , SMAATexture2D( velocityTex ) +#endif + ) +{ +#if SMAA_REPROJECTION + // Velocity is assumed to be calculated for motion blur, so we need to + // inverse it for reprojection: + float2 velocity = -SMAA_DECODE_VELOCITY( SMAASamplePoint( velocityTex, texcoord ).rg ); - // Fetch current pixel: - float4 current = SMAASamplePoint(currentColorTex, texcoord); + // Fetch current pixel: + float4 current = SMAASamplePoint( currentColorTex, texcoord ); - // Reproject current coordinates and fetch previous pixel: - float4 previous = SMAASamplePoint(previousColorTex, texcoord + velocity); + // Reproject current coordinates and fetch previous pixel: + float4 previous = SMAASamplePoint( previousColorTex, texcoord + velocity ); - // Attenuate the previous pixel if the velocity is different: - float delta = abs(current.a * current.a - previous.a * previous.a) / 5.0; - float weight = 0.5 * saturate(1.0 - sqrt(delta) * SMAA_REPROJECTION_WEIGHT_SCALE); + // Attenuate the previous pixel if the velocity is different: + float delta = abs( current.a * current.a - previous.a * previous.a ) / 5.0; + float weight = 0.5 * saturate( 1.0 - sqrt( delta ) * SMAA_REPROJECTION_WEIGHT_SCALE ); - // Blend the pixels according to the calculated weight: - return lerp(current, previous, weight); - #else - // Just blend the pixels: - float4 current = SMAASamplePoint(currentColorTex, texcoord); - float4 previous = SMAASamplePoint(previousColorTex, texcoord); - return lerp(current, previous, 0.5); - #endif + // Blend the pixels according to the calculated weight: + return lerp( current, previous, weight ); +#else + // Just blend the pixels: + float4 current = SMAASamplePoint( currentColorTex, texcoord ); + float4 previous = SMAASamplePoint( previousColorTex, texcoord ); + return lerp( current, previous, 0.5 ); +#endif } //----------------------------------------------------------------------------- // Separate Multisamples Pixel Shader (Optional Pass) #ifdef SMAALoad -void SMAASeparatePS(float4 position, - float2 texcoord, - out float4 target0, - out float4 target1, - SMAATexture2DMS2(colorTexMS)) { - int2 pos = int2(position.xy); - target0 = SMAALoad(colorTexMS, pos, 0); - target1 = SMAALoad(colorTexMS, pos, 1); +void SMAASeparatePS( float4 position, + float2 texcoord, + out float4 target0, + out float4 target1, + SMAATexture2DMS2( colorTexMS ) ) +{ + int2 pos = int2( position.xy ); + target0 = SMAALoad( colorTexMS, pos, 0 ); + target1 = SMAALoad( colorTexMS, pos, 1 ); } #endif diff --git a/base/renderprogs/SMAA_blending_weight_calc.ps.hlsl b/base/renderprogs/SMAA_blending_weight_calc.ps.hlsl index 215366d7..86a20b29 100644 --- a/base/renderprogs/SMAA_blending_weight_calc.ps.hlsl +++ b/base/renderprogs/SMAA_blending_weight_calc.ps.hlsl @@ -38,7 +38,7 @@ If you have questions concerning this license or the applicable additional terms uniform sampler2D samp0 : register(s0); // _smaaEdges uniform sampler2D samp1 : register(s1); // _smaaArea uniform sampler2D samp2 : register(s2); // _smaaSearch - + struct PS_IN { float4 position : VPOS; @@ -48,7 +48,7 @@ struct PS_IN float4 texcoord3 : TEXCOORD3_centroid; float4 texcoord4 : TEXCOORD4_centroid; }; - + struct PS_OUT { float4 color : COLOR; @@ -59,25 +59,25 @@ struct PS_OUT void main( PS_IN fragment, out PS_OUT result ) { float2 texcoord = fragment.texcoord0; - + float4 offset[3]; offset[0] = fragment.texcoord1; offset[1] = fragment.texcoord2; offset[2] = fragment.texcoord3; float2 pixcoord = fragment.texcoord4.st; - + // TODO //float4 subsampleIndices = float4( 1.0, 1.0, 1.0, 0.0 ); float4 subsampleIndices = float4( 0.0, 0.0, 0.0, 0.0 ); - + float4 color = SMAABlendingWeightCalculationPS( texcoord, - pixcoord, - offset, - samp0, - samp1, - samp2, - subsampleIndices ); + pixcoord, + offset, + samp0, + samp1, + samp2, + subsampleIndices ); //color = float4( texcoord.s, texcoord.t, 0.0, 1.0 ); result.color = color; diff --git a/base/renderprogs/SMAA_blending_weight_calc.vs.hlsl b/base/renderprogs/SMAA_blending_weight_calc.vs.hlsl index 073f6bf1..0bb9882d 100644 --- a/base/renderprogs/SMAA_blending_weight_calc.vs.hlsl +++ b/base/renderprogs/SMAA_blending_weight_calc.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms #define SMAA_INCLUDE_PS 0 #include "SMAA.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -51,6 +52,7 @@ struct VS_OUT float4 texcoord3 : TEXCOORD3; float4 texcoord4 : TEXCOORD4; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { @@ -63,7 +65,7 @@ void main( VS_IN vertex, out VS_OUT result ) float4 offset[3]; float2 pixcoord; SMAABlendingWeightCalculationVS( texcoord, pixcoord, offset ); - + result.texcoord1 = offset[0]; result.texcoord2 = offset[1]; result.texcoord3 = offset[2]; diff --git a/base/renderprogs/SMAA_edge_detection.ps.hlsl b/base/renderprogs/SMAA_edge_detection.ps.hlsl index ab1373b1..9801984d 100644 --- a/base/renderprogs/SMAA_edge_detection.ps.hlsl +++ b/base/renderprogs/SMAA_edge_detection.ps.hlsl @@ -36,7 +36,7 @@ If you have questions concerning this license or the applicable additional terms // *INDENT-OFF* uniform sampler2D samp0 : register(s0); // _currentColor uniform sampler2D samp1 : register(s1); // TODO _predictColor - + struct PS_IN { float4 position : VPOS; @@ -45,7 +45,7 @@ struct PS_IN float4 texcoord2 : TEXCOORD2_centroid; float4 texcoord3 : TEXCOORD3_centroid; }; - + struct PS_OUT { float4 color : COLOR; @@ -56,20 +56,20 @@ struct PS_OUT void main( PS_IN fragment, out PS_OUT result ) { float2 tCoords = fragment.texcoord0; - + float4 offset[3]; offset[0] = fragment.texcoord1; offset[1] = fragment.texcoord2; offset[2] = fragment.texcoord3; - + float4 color = float4( 0.0 ); color.rg = SMAALumaEdgeDetectionPS( tCoords, - offset, - samp0 - #if SMAA_PREDICATION - , samp1 - #endif - ); - + offset, + samp0 +#if SMAA_PREDICATION + , samp1 +#endif + ); + result.color = color; } diff --git a/base/renderprogs/SMAA_edge_detection.vs.hlsl b/base/renderprogs/SMAA_edge_detection.vs.hlsl index bd89bc25..ce802173 100644 --- a/base/renderprogs/SMAA_edge_detection.vs.hlsl +++ b/base/renderprogs/SMAA_edge_detection.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms #define SMAA_INCLUDE_PS 0 #include "SMAA.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -50,6 +51,7 @@ struct VS_OUT float4 texcoord2 : TEXCOORD2; float4 texcoord3 : TEXCOORD3; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { @@ -57,12 +59,12 @@ void main( VS_IN vertex, out VS_OUT result ) float2 texcoord = vertex.texcoord; //float2 texcoord = float2( vertex.texcoord.s, 1.0 - vertex.texcoord.t ); - + result.texcoord0 = texcoord; float4 offset[3]; SMAAEdgeDetectionVS( texcoord, offset ); - + result.texcoord1 = offset[0]; result.texcoord2 = offset[1]; result.texcoord3 = offset[2]; diff --git a/base/renderprogs/SMAA_final.ps.hlsl b/base/renderprogs/SMAA_final.ps.hlsl index 11cb7b3c..353dfabb 100644 --- a/base/renderprogs/SMAA_final.ps.hlsl +++ b/base/renderprogs/SMAA_final.ps.hlsl @@ -37,14 +37,14 @@ If you have questions concerning this license or the applicable additional terms uniform sampler2D samp0 : register(s0); // _currentColor uniform sampler2D samp1 : register(s1); // _smaaBlend //uniform sampler2D samp2 : register(s1); // _velocity - + struct PS_IN { float4 position : VPOS; float2 texcoord0 : TEXCOORD0_centroid; float4 texcoord1 : TEXCOORD1_centroid; }; - + struct PS_OUT { float4 color : COLOR; @@ -55,18 +55,18 @@ struct PS_OUT void main( PS_IN fragment, out PS_OUT result ) { float2 texcoord = fragment.texcoord0; - + float4 offset = fragment.texcoord1; - float4 color = SMAANeighborhoodBlendingPS(texcoord, - offset, - samp0, - samp1 - #if SMAA_REPROJECTION - , SMAATexture2D(velocityTex) - #endif - ); - + float4 color = SMAANeighborhoodBlendingPS( texcoord, + offset, + samp0, + samp1 +#if SMAA_REPROJECTION + , SMAATexture2D( velocityTex ) +#endif + ); + //color = tex2D( samp1, texcoord ); //color = float4( samp1 ); result.color = color; diff --git a/base/renderprogs/SMAA_final.vs.hlsl b/base/renderprogs/SMAA_final.vs.hlsl index a24f159b..d63eb676 100644 --- a/base/renderprogs/SMAA_final.vs.hlsl +++ b/base/renderprogs/SMAA_final.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms #define SMAA_INCLUDE_PS 0 #include "SMAA.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -48,6 +49,7 @@ struct VS_OUT float2 texcoord0 : TEXCOORD0; float4 texcoord1 : TEXCOORD1; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { @@ -57,6 +59,6 @@ void main( VS_IN vertex, out VS_OUT result ) float4 offset; SMAANeighborhoodBlendingVS( vertex.texcoord, offset ); - + result.texcoord1 = offset; } \ No newline at end of file diff --git a/base/renderprogs/ambient_lighting.ps.hlsl b/base/renderprogs/ambient_lighting.ps.hlsl index a952a97d..d60ec9f9 100644 --- a/base/renderprogs/ambient_lighting.ps.hlsl +++ b/base/renderprogs/ambient_lighting.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map @@ -50,8 +51,10 @@ struct PS_IN { struct PS_OUT { half4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); // half4 lightFalloff = idtex2Dproj( samp1, fragment.texcoord2 ); // half4 lightProj = idtex2Dproj( samp2, fragment.texcoord3 ); @@ -76,21 +79,21 @@ void main( PS_IN fragment, out PS_OUT result ) { half3 specularContribution = _half3( pow( abs( hDotN ), specularPower ) ); half3 diffuseColor = diffuseMap * ( rpDiffuseModifier.xyz ) * 1.5f; - half3 specularColor = specMap.xyz * specularContribution * ( rpSpecularModifier.xyz ); - + half3 specularColor = specMap.xyz * specularContribution * ( rpSpecularModifier.xyz ); + // RB: http://developer.valvesoftware.com/wiki/Half_Lambert float halfLdotN = dot3( localNormal, lightVector ) * 0.5 + 0.5; halfLdotN *= halfLdotN; - + // traditional very dark Lambert light model used in Doom 3 float ldotN = dot3( localNormal, lightVector ); - + half3 lightColor = sRGBToLinearRGB( rpAmbientColor.rgb ); - + half rim = 1.0f - saturate( hDotN ); half rimPower = 8.0; half3 rimColor = sRGBToLinearRGB( half3( 0.125 ) * 1.2 ) * lightColor * pow( rim, rimPower ); - + //result.color.rgb = localNormal.xyz * 0.5 + 0.5; result.color.xyz = ( ( diffuseColor + specularColor ) * halfLdotN * lightColor + rimColor ) * fragment.color.rgb; //result.color = ( ( diffuseColor + specularColor ) * halfLdotN * lightColor + rimColor ) * fragment.color.rgba; diff --git a/base/renderprogs/ambient_lighting.vs.hlsl b/base/renderprogs/ambient_lighting.vs.hlsl index 1f50bfd7..a1e5e82f 100644 --- a/base/renderprogs/ambient_lighting.vs.hlsl +++ b/base/renderprogs/ambient_lighting.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; #endif +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -53,8 +54,10 @@ struct VS_OUT { float4 texcoord6 : TEXCOORD6; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; float4 vTangent = vertex.tangent * 2.0 - 1.0; @@ -72,25 +75,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 normal; normal.x = dot3( matX, vNormal ); @@ -174,7 +177,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# calculate normalized vector to viewer in R1 float4 toView = normalize( rpLocalViewOrigin - modelPosition ); - + //# add together to become the half angle vector in object space (non-normalized) float4 halfAngleVector = toLight + toView; @@ -193,7 +196,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# generate the vertex color, which can be 1.0, color, or 1.0 - color //# for 1.0 : env[16] = 0, env[17] = 1 //# for color : env[16] = 1, env[17] = 0 - //# for 1.0-color : env[16] = -1, env[17] = 1 + //# for 1.0-color : env[16] = -1, env[17] = 1 result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; #endif } \ No newline at end of file diff --git a/base/renderprogs/ambient_lighting_IBL.vs.hlsl b/base/renderprogs/ambient_lighting_IBL.vs.hlsl index e44f360f..5bfc659c 100644 --- a/base/renderprogs/ambient_lighting_IBL.vs.hlsl +++ b/base/renderprogs/ambient_lighting_IBL.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; #endif +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -53,8 +54,10 @@ struct VS_OUT { float4 texcoord6 : TEXCOORD6; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; float4 vTangent = vertex.tangent * 2.0 - 1.0; @@ -72,25 +75,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 normal; normal.x = dot3( matX, vNormal ); @@ -158,7 +161,7 @@ void main( VS_IN vertex, out VS_OUT result ) { result.texcoord3.x = dot3( toEye, rpModelMatrixX ); result.texcoord3.y = dot3( toEye, rpModelMatrixY ); result.texcoord3.z = dot3( toEye, rpModelMatrixZ ); - + result.texcoord4.x = dot3( tangent, rpModelMatrixX ); result.texcoord5.x = dot3( tangent, rpModelMatrixY ); result.texcoord6.x = dot3( tangent, rpModelMatrixZ ); @@ -180,7 +183,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# generate the vertex color, which can be 1.0, color, or 1.0 - color //# for 1.0 : env[16] = 0, env[17] = 1 //# for color : env[16] = 1, env[17] = 0 - //# for 1.0-color : env[16] = -1, env[17] = 1 + //# for 1.0-color : env[16] = -1, env[17] = 1 result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; #endif } \ No newline at end of file diff --git a/base/renderprogs/bink.ps.hlsl b/base/renderprogs/bink.ps.hlsl index 2213c5da..89cd689a 100644 --- a/base/renderprogs/bink.ps.hlsl +++ b/base/renderprogs/bink.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // Y uniform sampler2D samp1 : register(s1); // Cr uniform sampler2D samp2 : register(s2); // Cb @@ -40,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ const float3 crc = float3( 1.595794678, -0.813476563, 0 ); const float3 crb = float3( 0, -0.391448975, 2.017822266 ); const float3 adj = float3( -0.87065506, 0.529705048f, -1.081668854f ); @@ -58,6 +61,6 @@ void main( PS_IN fragment, out PS_OUT result ) { color.xyz = p; color.w = 1.0; color *= rpColor; - + result.color = sRGBAToLinearRGBA( color ); } \ No newline at end of file diff --git a/base/renderprogs/bink.vs.hlsl b/base/renderprogs/bink.vs.hlsl index 7a1e9a91..8188818b 100644 --- a/base/renderprogs/bink.vs.hlsl +++ b/base/renderprogs/bink.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/bink_gui.ps.hlsl b/base/renderprogs/bink_gui.ps.hlsl index 173d5b03..5a7a3d82 100644 --- a/base/renderprogs/bink_gui.ps.hlsl +++ b/base/renderprogs/bink_gui.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // Y uniform sampler2D samp1 : register(s1); // Cr uniform sampler2D samp2 : register(s2); // Cb @@ -42,8 +43,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ const float3 crc = float3( 1.595794678, -0.813476563, 0 ); const float3 crb = float3( 0, -0.391448975, 2.017822266 ); const float3 adj = float3( -0.87065506, 0.529705048f, -1.081668854f ); diff --git a/base/renderprogs/bink_gui.vs.hlsl b/base/renderprogs/bink_gui.vs.hlsl index 68089b23..f0c0501d 100644 --- a/base/renderprogs/bink_gui.vs.hlsl +++ b/base/renderprogs/bink_gui.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -44,8 +45,10 @@ struct VS_OUT { float4 texcoord1 : TEXCOORD1; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/blendLight.ps.hlsl b/base/renderprogs/blendLight.ps.hlsl index c1f0da31..d2feeb48 100644 --- a/base/renderprogs/blendLight.ps.hlsl +++ b/base/renderprogs/blendLight.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); uniform sampler2D samp1 : register(s1); @@ -40,7 +41,9 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ result.color = idtex2Dproj( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * rpColor; } diff --git a/base/renderprogs/blendLight.vs.hlsl b/base/renderprogs/blendLight.vs.hlsl index 23363752..a8e2c5e8 100644 --- a/base/renderprogs/blendLight.vs.hlsl +++ b/base/renderprogs/blendLight.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -42,8 +43,10 @@ struct VS_OUT { float4 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/bloodorb1_capture.ps.hlsl b/base/renderprogs/bloodorb1_capture.ps.hlsl index 0deb7fcf..04162ae8 100644 --- a/base/renderprogs/bloodorb1_capture.ps.hlsl +++ b/base/renderprogs/bloodorb1_capture.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); //_accum uniform sampler2D samp1 : register(s1); //_currentRender uniform sampler2D samp2 : register(s2); //mask @@ -41,8 +42,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 accumSample = tex2D( samp0, fragment.texcoord0 ); float4 maskSample = tex2D( samp2, fragment.texcoord1 ); diff --git a/base/renderprogs/bloodorb1_capture.vs.hlsl b/base/renderprogs/bloodorb1_capture.vs.hlsl index 104349e4..30b4cf8c 100644 --- a/base/renderprogs/bloodorb1_capture.vs.hlsl +++ b/base/renderprogs/bloodorb1_capture.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform float4 rpUser0 : register( c128 ); //rpCenterScale struct VS_IN { @@ -43,8 +44,10 @@ struct VS_OUT { float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); @@ -54,6 +57,6 @@ void main( VS_IN vertex, out VS_OUT result ) { const float4 centerScale = rpUser0; result.texcoord0 = CenterScale( vertex.texcoord, centerScale.xy ); - // pass through texcoords + // pass through texcoords result.texcoord1 = vertex.texcoord; } \ No newline at end of file diff --git a/base/renderprogs/bloodorb2_capture.ps.hlsl b/base/renderprogs/bloodorb2_capture.ps.hlsl index 82f78227..7b500dd1 100644 --- a/base/renderprogs/bloodorb2_capture.ps.hlsl +++ b/base/renderprogs/bloodorb2_capture.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); //_accum uniform sampler2D samp1 : register(s1); //_currentRender uniform sampler2D samp2 : register(s2); //mask @@ -43,8 +44,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 redTint = float4( 1, 0.98, 0.98, 1 ); float4 accumSample = tex2D( samp0, fragment.texcoord0 ) * redTint; diff --git a/base/renderprogs/bloodorb2_capture.vs.hlsl b/base/renderprogs/bloodorb2_capture.vs.hlsl index 704df4e6..ce677359 100644 --- a/base/renderprogs/bloodorb2_capture.vs.hlsl +++ b/base/renderprogs/bloodorb2_capture.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform float4 rpUser0 : register( c128 ); //rpCenterScaleTex0 uniform float4 rpUser1 : register( c129 ); //rpRotateTex0 uniform float4 rpUser2 : register( c130 ); //rpCenterScaleTex1 @@ -46,8 +47,10 @@ struct VS_OUT { float2 texcoord1 : TEXCOORD1; float2 texcoord2 : TEXCOORD2; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/bloodorb3_capture.ps.hlsl b/base/renderprogs/bloodorb3_capture.ps.hlsl index bf539525..d49d1cf5 100644 --- a/base/renderprogs/bloodorb3_capture.ps.hlsl +++ b/base/renderprogs/bloodorb3_capture.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); //_accum uniform sampler2D samp1 : register(s1); //_currentRender uniform sampler2D samp2 : register(s2); //mask @@ -44,8 +45,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float colorFactor = fragment.texcoord4.x; float4 color0 = float4( 1.0f - colorFactor, 1.0f - colorFactor, 1.0f, 1.0f ); diff --git a/base/renderprogs/bloodorb3_capture.vs.hlsl b/base/renderprogs/bloodorb3_capture.vs.hlsl index b50a92f6..80531a83 100644 --- a/base/renderprogs/bloodorb3_capture.vs.hlsl +++ b/base/renderprogs/bloodorb3_capture.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform float4 rpUser0 : register( c128 ); //rpCenterScaleTex uniform float4 rpUser1 : register( c129 ); //rpRotateTex uniform float4 rpUser2 : register( c130 ); //rpColorFactor @@ -48,8 +49,10 @@ struct VS_OUT { float2 texcoord3 : TEXCOORD3; float2 texcoord4 : TEXCOORD4; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/bloodorb_draw.ps.hlsl b/base/renderprogs/bloodorb_draw.ps.hlsl index b4b1085b..01a9b378 100644 --- a/base/renderprogs/bloodorb_draw.ps.hlsl +++ b/base/renderprogs/bloodorb_draw.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); //_accum uniform sampler2D samp1 : register(s1); //_currentRender uniform sampler2D samp2 : register(s2); //mask @@ -40,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 accumSample = tex2D( samp0, fragment.texcoord0 ); float4 currentRenderSample = tex2D( samp1, fragment.texcoord0 ); diff --git a/base/renderprogs/bloodorb_draw.vs.hlsl b/base/renderprogs/bloodorb_draw.vs.hlsl index a19f8a4f..81561cc1 100644 --- a/base/renderprogs/bloodorb_draw.vs.hlsl +++ b/base/renderprogs/bloodorb_draw.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/bumpyenvironment.ps.hlsl b/base/renderprogs/bumpyenvironment.ps.hlsl index f24b32e8..abcba0f9 100644 --- a/base/renderprogs/bumpyenvironment.ps.hlsl +++ b/base/renderprogs/bumpyenvironment.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map uniform sampler2D samp1 : register(s1); // normal map @@ -45,8 +46,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 bump = tex2D( samp1, fragment.texcoord0 ) * 2.0f - 1.0f; // RB begin diff --git a/base/renderprogs/bumpyenvironment.vs.hlsl b/base/renderprogs/bumpyenvironment.vs.hlsl index 7584fff2..2884bf16 100644 --- a/base/renderprogs/bumpyenvironment.vs.hlsl +++ b/base/renderprogs/bumpyenvironment.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -45,8 +46,10 @@ struct VS_OUT { float3 texcoord4 : TEXCOORD4; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 normal = vertex.normal * 2.0 - 1.0; float4 tangent = vertex.tangent * 2.0 - 1.0; diff --git a/base/renderprogs/bumpyenvironment_skinned.ps.hlsl b/base/renderprogs/bumpyenvironment_skinned.ps.hlsl index 30088499..ab6e566f 100644 --- a/base/renderprogs/bumpyenvironment_skinned.ps.hlsl +++ b/base/renderprogs/bumpyenvironment_skinned.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map uniform sampler2D samp1 : register(s1); // normal map @@ -45,11 +46,13 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 bump = tex2D( samp1, fragment.texcoord0 ) * 2.0f - 1.0f; - + // RB begin float3 localNormal; #if defined(GLES2) diff --git a/base/renderprogs/bumpyenvironment_skinned.vs.hlsl b/base/renderprogs/bumpyenvironment_skinned.vs.hlsl index 5b1cb0c5..0d7de212 100644 --- a/base/renderprogs/bumpyenvironment_skinned.vs.hlsl +++ b/base/renderprogs/bumpyenvironment_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform matrices_ubo { float4 matrices[408]; }; struct VS_IN { @@ -49,8 +50,10 @@ struct VS_OUT { float3 texcoord4 : TEXCOORD4; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; float4 vTangent = vertex.tangent * 2.0 - 1.0; float3 vBinormal = cross( vNormal.xyz, vTangent.xyz ) * vTangent.w; @@ -66,25 +69,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 normal; normal.x = dot3( matX, vNormal ); diff --git a/base/renderprogs/color.ps.hlsl b/base/renderprogs/color.ps.hlsl index 53ea8a17..3251a234 100644 --- a/base/renderprogs/color.ps.hlsl +++ b/base/renderprogs/color.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,12 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = rpColor; } \ No newline at end of file diff --git a/base/renderprogs/color.vs.hlsl b/base/renderprogs/color.vs.hlsl index 1c7a35c4..177605ac 100644 --- a/base/renderprogs/color.vs.hlsl +++ b/base/renderprogs/color.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; #endif +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -45,6 +46,7 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { @@ -60,25 +62,25 @@ void main( VS_IN vertex, out VS_OUT result ) const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float4 modelPosition; modelPosition.x = dot4( matX, vertex.position ); diff --git a/base/renderprogs/colorProcess.ps.hlsl b/base/renderprogs/colorProcess.ps.hlsl index ec5ca995..1f6510a8 100644 --- a/base/renderprogs/colorProcess.ps.hlsl +++ b/base/renderprogs/colorProcess.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN { @@ -39,8 +40,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 src = tex2D( samp0, fragment.texcoord0.xy ); float4 target = fragment.color * dot3( float3( 0.333, 0.333, 0.333 ), src ); result.color = lerp( src, target, fragment.texcoord0.z ); diff --git a/base/renderprogs/colorProcess.vs.hlsl b/base/renderprogs/colorProcess.vs.hlsl index f31a27d9..9844effc 100644 --- a/base/renderprogs/colorProcess.vs.hlsl +++ b/base/renderprogs/colorProcess.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform float4 rpUser0 : register(c128); //rpFraction uniform float4 rpUser1 : register(c129); //rpTargetHue @@ -45,15 +46,17 @@ struct VS_OUT { float4 color : COLOR0; float3 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); result.position.w = dot4( vertex.position, rpMVPmatrixW ); - + result.color = rpUser1; // targetHue - + result.texcoord0.x = vertex.texcoord.x; result.texcoord0.y = 1.0f - vertex.texcoord.y; diff --git a/base/renderprogs/debug_shadowmap.ps.hlsl b/base/renderprogs/debug_shadowmap.ps.hlsl index a0ed63ae..ec330b44 100644 --- a/base/renderprogs/debug_shadowmap.ps.hlsl +++ b/base/renderprogs/debug_shadowmap.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2DArray samp0 : register(s0); struct PS_IN @@ -41,6 +42,7 @@ struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* void main( PS_IN fragment, out PS_OUT result ) { diff --git a/base/renderprogs/debug_shadowmap.vs.hlsl b/base/renderprogs/debug_shadowmap.vs.hlsl index 5b4dacec..d15c952f 100644 --- a/base/renderprogs/debug_shadowmap.vs.hlsl +++ b/base/renderprogs/debug_shadowmap.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,18 +41,23 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); result.position.w = dot4( vertex.position, rpMVPmatrixW ); // compute oldschool texgen or multiply by texture matrix - BRANCH if ( rpTexGen0Enabled.x > 0.0 ) { + BRANCH if( rpTexGen0Enabled.x > 0.0 ) + { result.texcoord0.x = dot4( vertex.position, rpTexGen0S ); result.texcoord0.y = dot4( vertex.position, rpTexGen0T ); - } else { + } + else + { result.texcoord0.x = dot4( vertex.texcoord.xy, rpTextureMatrixS ); result.texcoord0.y = dot4( vertex.texcoord.xy, rpTextureMatrixT ); } diff --git a/base/renderprogs/depth.ps.hlsl b/base/renderprogs/depth.ps.hlsl index 7d1c2dce..26f25047 100644 --- a/base/renderprogs/depth.ps.hlsl +++ b/base/renderprogs/depth.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); + struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = float4( 0.0, 0.0, 0.0, 1.0 ); } \ No newline at end of file diff --git a/base/renderprogs/depth.vs.hlsl b/base/renderprogs/depth.vs.hlsl index bc104075..f57f5d43 100644 --- a/base/renderprogs/depth.vs.hlsl +++ b/base/renderprogs/depth.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; }; @@ -35,8 +36,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/depth_skinned.ps.hlsl b/base/renderprogs/depth_skinned.ps.hlsl index 7d1c2dce..26f25047 100644 --- a/base/renderprogs/depth_skinned.ps.hlsl +++ b/base/renderprogs/depth_skinned.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); + struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = float4( 0.0, 0.0, 0.0, 1.0 ); } \ No newline at end of file diff --git a/base/renderprogs/depth_skinned.vs.hlsl b/base/renderprogs/depth_skinned.vs.hlsl index 99ed115d..30f6ea0c 100644 --- a/base/renderprogs/depth_skinned.vs.hlsl +++ b/base/renderprogs/depth_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -43,8 +44,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ //-------------------------------------------------------------- // GPU transformation of the normal / binormal / bitangent // @@ -56,25 +59,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float4 modelPosition; modelPosition.x = dot4( matX, vertex.position ); diff --git a/base/renderprogs/enviroSuit.ps.hlsl b/base/renderprogs/enviroSuit.ps.hlsl index e8a3e916..061c2356 100644 --- a/base/renderprogs/enviroSuit.ps.hlsl +++ b/base/renderprogs/enviroSuit.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 0 is _current Render uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map @@ -40,11 +41,13 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float2 screenTexCoord = fragment.texcoord; - + // compute warp factor float4 warpFactor = 1.0 - ( tex2D( samp1, screenTexCoord.xy ) * fragment.color ); screenTexCoord -= float2( 0.5, 0.5 ); diff --git a/base/renderprogs/enviroSuit.vs.hlsl b/base/renderprogs/enviroSuit.vs.hlsl index 6b508812..b14a2a64 100644 --- a/base/renderprogs/enviroSuit.vs.hlsl +++ b/base/renderprogs/enviroSuit.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ If you have questions concerning this license or the applicable additional terms // User Renderparms start at 128 as per renderprogs.h +// *INDENT-OFF* uniform float4 rpUser0 : register(c128); // rpScroll uniform float4 rpUser1 : register(c129); // rpDeformMagnitude @@ -46,15 +47,16 @@ struct VS_OUT { float2 texcoord : TEXCOORD0; float4 color : COLOR; }; +// *INDENT-ON* - -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); result.position.w = dot4( vertex.position, rpMVPmatrixW ); - + result.texcoord = vertex.texcoord.xy; const float4 deformMagnitude = rpUser1; diff --git a/base/renderprogs/environment.ps.hlsl b/base/renderprogs/environment.ps.hlsl index 1fe6eb98..12511ff4 100644 --- a/base/renderprogs/environment.ps.hlsl +++ b/base/renderprogs/environment.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map struct PS_IN { @@ -40,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float3 globalNormal = normalize( fragment.texcoord1 ); float3 globalEye = normalize( fragment.texcoord0 ); diff --git a/base/renderprogs/environment.vs.hlsl b/base/renderprogs/environment.vs.hlsl index 14c692e8..931838d1 100644 --- a/base/renderprogs/environment.vs.hlsl +++ b/base/renderprogs/environment.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float4 normal : NORMAL; @@ -40,8 +41,10 @@ struct VS_OUT { float3 texcoord1 : TEXCOORD1; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; diff --git a/base/renderprogs/environment_skinned.ps.hlsl b/base/renderprogs/environment_skinned.ps.hlsl index 1fe6eb98..12511ff4 100644 --- a/base/renderprogs/environment_skinned.ps.hlsl +++ b/base/renderprogs/environment_skinned.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform samplerCUBE samp0 : register(s0); // texture 0 is the cube map struct PS_IN { @@ -40,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float3 globalNormal = normalize( fragment.texcoord1 ); float3 globalEye = normalize( fragment.texcoord0 ); diff --git a/base/renderprogs/environment_skinned.vs.hlsl b/base/renderprogs/environment_skinned.vs.hlsl index 7b7de0f9..02892239 100644 --- a/base/renderprogs/environment_skinned.vs.hlsl +++ b/base/renderprogs/environment_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -46,8 +47,10 @@ struct VS_OUT { float3 texcoord1 : TEXCOORD1; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; //-------------------------------------------------------------- @@ -61,25 +64,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 vNormalSkinned; vNormalSkinned.x = dot3( matX, vNormal ); diff --git a/base/renderprogs/fog.ps.hlsl b/base/renderprogs/fog.ps.hlsl index 6292e65b..30a0370e 100644 --- a/base/renderprogs/fog.ps.hlsl +++ b/base/renderprogs/fog.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); uniform sampler2D samp1 : register(s1); @@ -40,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * sRGBAToLinearRGBA( rpColor ); } diff --git a/base/renderprogs/fog.vs.hlsl b/base/renderprogs/fog.vs.hlsl index 1990525a..47e0302d 100644 --- a/base/renderprogs/fog.vs.hlsl +++ b/base/renderprogs/fog.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -41,8 +42,10 @@ struct VS_OUT { float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/fog_skinned.ps.hlsl b/base/renderprogs/fog_skinned.ps.hlsl index 6292e65b..30a0370e 100644 --- a/base/renderprogs/fog_skinned.ps.hlsl +++ b/base/renderprogs/fog_skinned.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); uniform sampler2D samp1 : register(s1); @@ -40,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ result.color = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * sRGBAToLinearRGBA( rpColor ); } diff --git a/base/renderprogs/fog_skinned.vs.hlsl b/base/renderprogs/fog_skinned.vs.hlsl index 8d0999fa..054a0a3f 100644 --- a/base/renderprogs/fog_skinned.vs.hlsl +++ b/base/renderprogs/fog_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -45,8 +46,10 @@ struct VS_OUT { float2 texcoord0 : TEXCOORD0; float2 texcoord1 : TEXCOORD1; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ //-------------------------------------------------------------- // GPU transformation of the normal / binormal / bitangent // @@ -58,25 +61,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float4 modelPosition; modelPosition.x = dot4( matX, vertex.position ); diff --git a/base/renderprogs/fxaa.ps.hlsl b/base/renderprogs/fxaa.ps.hlsl index e6477b28..7df020fd 100644 --- a/base/renderprogs/fxaa.ps.hlsl +++ b/base/renderprogs/fxaa.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms #define FXAA_EARLY_EXIT 0 #include "Fxaa3_11.h" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); uniform sampler2D samp1 : register(s1); // exponent bias -1 uniform sampler2D samp2 : register(s2); // exponent bias -2 @@ -51,8 +52,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ const float4 FXAAQualityRCPFrame = rpUser0; const float4 FXAAConsoleRcpFrameOpt = rpUser1; @@ -105,6 +108,6 @@ void main( PS_IN fragment, out PS_OUT result ) { fxaaConsoleEdgeThreshold, fxaaConsoleEdgeThresholdMin, fxaaConsole360ConstDir ); - + result.color = colorSample; } \ No newline at end of file diff --git a/base/renderprogs/fxaa.vs.hlsl b/base/renderprogs/fxaa.vs.hlsl index 05a32fea..0687ba0f 100644 --- a/base/renderprogs/fxaa.vs.hlsl +++ b/base/renderprogs/fxaa.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position = vertex.position; result.texcoord0 = vertex.texcoord; } \ No newline at end of file diff --git a/base/renderprogs/gbuffer.ps.hlsl b/base/renderprogs/gbuffer.ps.hlsl index 25fc0a0c..ba03b484 100644 --- a/base/renderprogs/gbuffer.ps.hlsl +++ b/base/renderprogs/gbuffer.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2016 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // normal map struct PS_IN @@ -46,11 +47,12 @@ struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* void main( PS_IN fragment, out PS_OUT result ) { float4 bump = tex2D( samp0, fragment.texcoord0 ) * 2.0f - 1.0f; - + // RB begin float3 localNormal; #if defined(USE_NORMAL_FMT_RGB8) diff --git a/base/renderprogs/gbuffer.vs.hlsl b/base/renderprogs/gbuffer.vs.hlsl index 55d69c1d..1c339b87 100644 --- a/base/renderprogs/gbuffer.vs.hlsl +++ b/base/renderprogs/gbuffer.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2016 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; #endif +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -51,9 +52,11 @@ struct VS_OUT { float3 texcoord4 : TEXCOORD4; float4 color : COLOR0; }; +// *INDENT-ON* + +void main( VS_IN vertex, out VS_OUT result ) +{ -void main( VS_IN vertex, out VS_OUT result ) { - float4 vNormal = vertex.normal * 2.0 - 1.0; float4 vTangent = vertex.tangent * 2.0 - 1.0; float3 vBitangent = cross( vNormal.xyz, vTangent.xyz ) * vTangent.w; @@ -70,25 +73,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 normal; normal.x = dot3( matX, vNormal ); @@ -147,8 +150,8 @@ void main( VS_IN vertex, out VS_OUT result ) { result.texcoord2.z = dot3( normal, rpModelMatrixX ); result.texcoord3.z = dot3( normal, rpModelMatrixY ); - result.texcoord4.z = dot3( normal, rpModelMatrixZ ); - + result.texcoord4.z = dot3( normal, rpModelMatrixZ ); + #else // rotate into view space result.texcoord2.x = dot3( tangent, rpModelViewMatrixX ); @@ -161,7 +164,7 @@ void main( VS_IN vertex, out VS_OUT result ) { result.texcoord2.z = dot3( normal, rpModelViewMatrixX ); result.texcoord3.z = dot3( normal, rpModelViewMatrixY ); - result.texcoord4.z = dot3( normal, rpModelViewMatrixZ ); + result.texcoord4.z = dot3( normal, rpModelViewMatrixZ ); #endif #if defined( USE_GPU_SKINNING ) @@ -173,7 +176,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# generate the vertex color, which can be 1.0, color, or 1.0 - color //# for 1.0 : env[16] = 0, env[17] = 1 //# for color : env[16] = 1, env[17] = 0 - //# for 1.0-color : env[16] = -1, env[17] = 1 + //# for 1.0-color : env[16] = -1, env[17] = 1 result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; #endif } \ No newline at end of file diff --git a/base/renderprogs/global.inc.hlsl b/base/renderprogs/global.inc.hlsl index 3d351e83..39992088 100644 --- a/base/renderprogs/global.inc.hlsl +++ b/base/renderprogs/global.inc.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2020 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ If you have questions concerning this license or the applicable additional terms =========================================================================== */ +// *INDENT-OFF* uniform float4 rpScreenCorrectionFactor : register(c0); uniform float4 rpWindowCoord : register(c1); uniform float4 rpDiffuseModifier : register(c2); @@ -119,9 +120,11 @@ static float dot3( float4 a, float4 b ) { return dot( a.xyz, b.xyz ); } static float dot4( float4 a, float4 b ) { return dot( a, b ); } static float dot4( float2 a, float4 b ) { return dot( float4( a, 0, 1 ), b ); } +// *INDENT-ON* + // RB begin #ifndef PI -#define PI 3.14159265358979323846 + #define PI 3.14159265358979323846 #endif #define DEG2RAD( a ) ( ( a ) * PI / 180.0f ) @@ -174,16 +177,17 @@ half4 LinearRGBToSRGB( half4 rgba ) // ---------------------- // YCoCg Color Conversion // ---------------------- -static const half4 matrixRGB1toCoCg1YX = half4( 0.50, 0.0, -0.50, 0.50196078 ); // Co +static const half4 matrixRGB1toCoCg1YX = half4( 0.50, 0.0, -0.50, 0.50196078 ); // Co static const half4 matrixRGB1toCoCg1YY = half4( -0.25, 0.5, -0.25, 0.50196078 ); // Cg -static const half4 matrixRGB1toCoCg1YZ = half4( 0.0, 0.0, 0.0, 1.0 ); // 1.0 -static const half4 matrixRGB1toCoCg1YW = half4( 0.25, 0.5, 0.25, 0.0 ); // Y +static const half4 matrixRGB1toCoCg1YZ = half4( 0.0, 0.0, 0.0, 1.0 ); // 1.0 +static const half4 matrixRGB1toCoCg1YW = half4( 0.25, 0.5, 0.25, 0.0 ); // Y -static const half4 matrixCoCg1YtoRGB1X = half4( 1.0, -1.0, 0.0, 1.0 ); -static const half4 matrixCoCg1YtoRGB1Y = half4( 0.0, 1.0, -0.50196078, 1.0 ); // -0.5 * 256.0 / 255.0 +static const half4 matrixCoCg1YtoRGB1X = half4( 1.0, -1.0, 0.0, 1.0 ); +static const half4 matrixCoCg1YtoRGB1Y = half4( 0.0, 1.0, -0.50196078, 1.0 ); // -0.5 * 256.0 / 255.0 static const half4 matrixCoCg1YtoRGB1Z = half4( -1.0, -1.0, 1.00392156, 1.0 ); // +1.0 * 256.0 / 255.0 -static half3 ConvertYCoCgToRGB( half4 YCoCg ) { +static half3 ConvertYCoCgToRGB( half4 YCoCg ) +{ half3 rgbColor; YCoCg.z = ( YCoCg.z * 31.875 ) + 1.0; //z = z * 255.0/8.0 + 1.0 @@ -195,7 +199,8 @@ static half3 ConvertYCoCgToRGB( half4 YCoCg ) { return rgbColor; } -static float2 CenterScale( float2 inTC, float2 centerScale ) { +static float2 CenterScale( float2 inTC, float2 centerScale ) +{ float scaleX = centerScale.x; float scaleY = centerScale.y; float4 tc0 = float4( scaleX, 0, 0, 0.5 - ( 0.5f * scaleX ) ); @@ -207,7 +212,8 @@ static float2 CenterScale( float2 inTC, float2 centerScale ) { return finalTC; } -static float2 Rotate2D( float2 inTC, float2 cs ) { +static float2 Rotate2D( float2 inTC, float2 cs ) +{ float sinValue = cs.y; float cosValue = cs.x; @@ -221,8 +227,9 @@ static float2 Rotate2D( float2 inTC, float2 cs ) { } // better noise function available at https://github.com/ashima/webgl-noise -float rand( float2 co ) { - return frac( sin( dot( co.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 ); +float rand( float2 co ) +{ + return frac( sin( dot( co.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 ); } #define square( x ) ( x * x ) @@ -238,13 +245,19 @@ static const half4 LUMINANCE_LINEAR = half4( 0.299, 0.587, 0.144, 0.0 ); #define _float4( x ) float4( x ) #define VPOS WPOS -static float4 idtex2Dproj( sampler2D samp, float4 texCoords ) { return tex2Dproj( samp, texCoords.xyw ); } -static float4 swizzleColor( float4 c ) -{ - return c; - //return sRGBAToLinearRGBA( c ); +static float4 idtex2Dproj( sampler2D samp, float4 texCoords ) +{ + return tex2Dproj( samp, texCoords.xyw ); +} +static float4 swizzleColor( float4 c ) +{ + return c; + //return sRGBAToLinearRGBA( c ); +} +static float2 vposToScreenPosTexCoord( float2 vpos ) +{ + return vpos.xy * rpWindowCoord.xy; } -static float2 vposToScreenPosTexCoord( float2 vpos ) { return vpos.xy * rpWindowCoord.xy; } #define BRANCH #define IFANY @@ -265,7 +278,7 @@ float RemapNoiseTriErp( const float v ) // http://advances.realtimerendering.com/s2014/index.html float InterleavedGradientNoise( float2 uv ) { - + const float3 magic = float3( 0.06711056, 0.00583715, 52.9829189 ); float rnd = fract( magic.z * fract( dot( uv, magic.xy ) ) ); diff --git a/base/renderprogs/gui.ps.hlsl b/base/renderprogs/gui.ps.hlsl index 83f6b727..a3357f0c 100644 --- a/base/renderprogs/gui.ps.hlsl +++ b/base/renderprogs/gui.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN { @@ -40,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 color = ( tex2D( samp0, fragment.texcoord0 ) * fragment.color ) + fragment.texcoord1; result.color.xyz = color.xyz * color.w; result.color.w = color.w; diff --git a/base/renderprogs/gui.vs.hlsl b/base/renderprogs/gui.vs.hlsl index 68089b23..f0c0501d 100644 --- a/base/renderprogs/gui.vs.hlsl +++ b/base/renderprogs/gui.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -44,8 +45,10 @@ struct VS_OUT { float4 texcoord1 : TEXCOORD1; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/hdr_glare_chromatic.ps.hlsl b/base/renderprogs/hdr_glare_chromatic.ps.hlsl index 37cbed1a..c2c3c176 100644 --- a/base/renderprogs/hdr_glare_chromatic.ps.hlsl +++ b/base/renderprogs/hdr_glare_chromatic.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014-2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN @@ -41,6 +42,7 @@ struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* float linterp( float t ) { @@ -65,63 +67,63 @@ float3 spectrumoffset( float t ) void main( PS_IN fragment, out PS_OUT result ) { float2 st = fragment.texcoord0; - + // base color with tone mapping applied float4 color = tex2D( samp0, st ); - - const float gaussFact[9] = float[9](0.13298076, 0.12579441, 0.10648267, 0.08065691, 0.05467002, 0.03315905, 0.01799699, 0.00874063, 0.00379866); - + + const float gaussFact[9] = float[9]( 0.13298076, 0.12579441, 0.10648267, 0.08065691, 0.05467002, 0.03315905, 0.01799699, 0.00874063, 0.00379866 ); + const float3 chromaticOffsets[9] = float3[]( - float3(0.5, 0.5, 0.5), // w - float3(0.8, 0.3, 0.3), + float3( 0.5, 0.5, 0.5 ), // w + float3( 0.8, 0.3, 0.3 ), // float3(1.0, 0.2, 0.2), // r - float3(0.5, 0.2, 0.8), - float3(0.2, 0.2, 1.0), // b - float3(0.2, 0.3, 0.9), - float3(0.2, 0.9, 0.2), // g - float3(0.3, 0.5, 0.3), - float3(0.3, 0.5, 0.3), - float3(0.3, 0.5, 0.3) - //float3(0.3, 0.5, 0.3) - ); - + float3( 0.5, 0.2, 0.8 ), + float3( 0.2, 0.2, 1.0 ), // b + float3( 0.2, 0.3, 0.9 ), + float3( 0.2, 0.9, 0.2 ), // g + float3( 0.3, 0.5, 0.3 ), + float3( 0.3, 0.5, 0.3 ), + float3( 0.3, 0.5, 0.3 ) + //float3(0.3, 0.5, 0.3) + ); + float3 sumColor = float3( 0.0 ); float3 sumSpectrum = float3( 0.0 ); const int tap = 4; const int samples = 9; - + float scale = 13.0; // bloom width const float weightScale = 2.3; // bloom strength - + for( int i = 0; i < samples; i++ ) - { - //float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) ); + { + //float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) ); //float t = log2( float( i ) / ( float( samples ) - 1.0 ) ); //float t = ( float( i ) / ( float( samples ) - 1.0 ) ); - + //float3 so = spectrumoffset( t ); float3 so = chromaticOffsets[ i ]; float4 color = tex2D( samp0, st + float2( float( i ), 0 ) * rpWindowCoord.xy * scale ); - + float weight = gaussFact[ i ]; sumColor += color.rgb * ( so.rgb * weight * weightScale ); } - + #if 1 for( int i = 1; i < samples; i++ ) - { - //float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) ); - + { + //float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) ); + //float3 so = spectrumoffset( t ); float3 so = chromaticOffsets[ i ]; float4 color = tex2D( samp0, st + float2( float( -i ), 0 ) * rpWindowCoord.xy * scale ); - + float weight = gaussFact[ i ]; sumColor += color.rgb * ( so.rgb * weight * weightScale ); } #endif - + result.color = float4( sumColor, 1.0 ); //result.color = float4( sumColor / float(samples), 1.0 ); //result.color = float4( sumColor / sumSpectrum, 1.0 ); diff --git a/base/renderprogs/hdr_glare_chromatic.vs.hlsl b/base/renderprogs/hdr_glare_chromatic.vs.hlsl index d1c94722..38ff6db5 100644 --- a/base/renderprogs/hdr_glare_chromatic.vs.hlsl +++ b/base/renderprogs/hdr_glare_chromatic.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position = vertex.position; //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX ); diff --git a/base/renderprogs/heatHazeWithMask.ps.hlsl b/base/renderprogs/heatHazeWithMask.ps.hlsl index fc52dad1..53db287f 100644 --- a/base/renderprogs/heatHazeWithMask.ps.hlsl +++ b/base/renderprogs/heatHazeWithMask.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 0 is _current Render uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture @@ -42,8 +43,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ // load the distortion map float4 mask = tex2D( samp2, fragment.texcoord0.xy ); diff --git a/base/renderprogs/heatHazeWithMask.vs.hlsl b/base/renderprogs/heatHazeWithMask.vs.hlsl index 1d5e7767..0e5e1615 100644 --- a/base/renderprogs/heatHazeWithMask.vs.hlsl +++ b/base/renderprogs/heatHazeWithMask.vs.hlsl @@ -3,9 +3,9 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2013 Robert Beckebans +Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ uniform matrices_ubo { float4 matrices[408]; }; #endif // RB end +// *INDENT-OFF* uniform float4 rpUser0 : register(c128); // rpScroll uniform float4 rpUser1 : register(c129); // rpDeformMagnitude @@ -53,10 +54,12 @@ struct VS_OUT { float4 texcoord1 : TEXCOORD1; float4 texcoord2 : TEXCOORD2; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ - #include "skinning.inc.hlsl" +#include "skinning.inc.hlsl" // texture 0 takes the texture coordinates unmodified result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 ); @@ -69,12 +72,12 @@ void main( VS_IN vertex, out VS_OUT result ) { float4 vec = float4( 0, 1, 0, 1 ); vec.z = dot4( modelPosition, rpModelViewMatrixZ ); - // magicProjectionAdjust is a magic scalar that scales the projection since we changed from - // using the X axis to the Y axis to calculate R1. It is an approximation to closely match + // magicProjectionAdjust is a magic scalar that scales the projection since we changed from + // using the X axis to the Y axis to calculate R1. It is an approximation to closely match // what the original game did const float magicProjectionAdjust = 0.43f; - float x = dot4 ( vec, rpProjectionMatrixY ) * magicProjectionAdjust; - float w = dot4 ( vec, rpProjectionMatrixW ); + float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust; + float w = dot4( vec, rpProjectionMatrixW ); // don't let the recip get near zero for polygons that cross the view plane w = max( w, 1.0 ); diff --git a/base/renderprogs/heatHazeWithMaskAndVertex.ps.hlsl b/base/renderprogs/heatHazeWithMaskAndVertex.ps.hlsl index 7031b5e9..c4f58130 100644 --- a/base/renderprogs/heatHazeWithMaskAndVertex.ps.hlsl +++ b/base/renderprogs/heatHazeWithMaskAndVertex.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 0 is _current Render uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture @@ -43,8 +44,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ // load the distortion map float4 mask = tex2D( samp2, fragment.texcoord0.xy ); diff --git a/base/renderprogs/heatHazeWithMaskAndVertex.vs.hlsl b/base/renderprogs/heatHazeWithMaskAndVertex.vs.hlsl index a77add42..c965b849 100644 --- a/base/renderprogs/heatHazeWithMaskAndVertex.vs.hlsl +++ b/base/renderprogs/heatHazeWithMaskAndVertex.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2013 Robert Beckebans +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ uniform matrices_ubo { float4 matrices[408]; }; #endif // RB end +// *INDENT-OFF* uniform float4 rpUser0 : register(c128); // rpScroll uniform float4 rpUser1 : register(c129); // rpDeformMagnitude @@ -54,10 +55,12 @@ struct VS_OUT { float4 texcoord2 : TEXCOORD2; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ - #include "skinning.inc.hlsl" +#include "skinning.inc.hlsl" // texture 0 takes the texture coordinates unmodified result.texcoord0 = float4( vertex.texcoord, 0 , 0 ); @@ -70,11 +73,11 @@ void main( VS_IN vertex, out VS_OUT result ) { float4 vec = float4( 0, 1, 0, 1 ); vec.z = dot4( modelPosition, rpModelViewMatrixZ ); - // magicProjectionAdjust is a magic scalar that scales the projection since we changed from - // using the X axis to the Y axis to calculate x. It is an approximation to closely match + // magicProjectionAdjust is a magic scalar that scales the projection since we changed from + // using the X axis to the Y axis to calculate x. It is an approximation to closely match // what the original game did const float magicProjectionAdjust = 0.43f; - float x = dot4 ( vec, rpProjectionMatrixY ) * magicProjectionAdjust; + float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust; float w = dot4( vec, rpProjectionMatrixW ); // don't let the recip get near zero for polygons that cross the view plane diff --git a/base/renderprogs/heathaze.ps.hlsl b/base/renderprogs/heathaze.ps.hlsl index 5bb15ccb..41c7add3 100644 --- a/base/renderprogs/heathaze.ps.hlsl +++ b/base/renderprogs/heathaze.ps.hlsl @@ -3,9 +3,9 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -Copyright (C) 2013-2014 Robert Beckebans +Copyright (C) 2013-2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 0 is _current Render uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map @@ -41,8 +42,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ // load the filtered normal map and convert to -1 to 1 range float4 bumpMap = ( tex2D( samp1, fragment.texcoord0.xy ) * 2.0f ) - 1.0f; diff --git a/base/renderprogs/heathaze.vs.hlsl b/base/renderprogs/heathaze.vs.hlsl index 36ec9656..dd00de1d 100644 --- a/base/renderprogs/heathaze.vs.hlsl +++ b/base/renderprogs/heathaze.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms // User Renderparms start at 128 as per renderprogs.h +// *INDENT-OFF* uniform float4 rpUser0 : register(c128); // rpScroll uniform float4 rpUser1 : register(c129); // rpDeformMagnitude @@ -54,10 +55,12 @@ struct VS_OUT { float4 texcoord0 : TEXCOORD0; float4 texcoord1 : TEXCOORD1; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ - #include "skinning.inc.hlsl" +#include "skinning.inc.hlsl" //texture 0 takes the texture coordinates and adds a scroll const float4 textureScroll = rpUser0; @@ -67,8 +70,8 @@ void main( VS_IN vertex, out VS_OUT result ) { float4 vec = float4( 0, 1, 0, 1 ); vec.z = dot4( modelPosition, rpModelViewMatrixZ ); // this is the modelview matrix - // magicProjectionAdjust is a magic scalar that scales the projection since we changed from - // using the X axis to the Y axis to calculate x. It is an approximation to closely match + // magicProjectionAdjust is a magic scalar that scales the projection since we changed from + // using the X axis to the Y axis to calculate x. It is an approximation to closely match // what the original game did const float magicProjectionAdjust = 0.43f; float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust; diff --git a/base/renderprogs/interaction.ps.hlsl b/base/renderprogs/interaction.ps.hlsl index c5c776dc..2f43d497 100644 --- a/base/renderprogs/interaction.ps.hlsl +++ b/base/renderprogs/interaction.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2020 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" #include "BRDF.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map @@ -53,12 +54,13 @@ struct PS_OUT { half4 color : COLOR; }; +// *INDENT-ON* void main( PS_IN fragment, out PS_OUT result ) { half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); half4 lightFalloff = ( idtex2Dproj( samp3, fragment.texcoord2 ) ); - half4 lightProj = ( idtex2Dproj( samp4, fragment.texcoord3 ) ); + half4 lightProj = ( idtex2Dproj( samp4, fragment.texcoord3 ) ); half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy ); half4 specMapSRGB = tex2D( samp1, fragment.texcoord5.xy ); half4 specMap = sRGBAToLinearRGBA( specMapSRGB ); @@ -77,7 +79,7 @@ void main( PS_IN fragment, out PS_OUT result ) // RB end localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) ); localNormal = normalize( localNormal ); - + // traditional very dark Lambert light model used in Doom 3 half ldotN = saturate( dot3( localNormal, lightVector ) ); @@ -97,7 +99,7 @@ void main( PS_IN fragment, out PS_OUT result ) half hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 ); #if 1 - + #if defined( USE_PBR ) const half metallic = specMapSRGB.g; const half roughness = specMapSRGB.r; @@ -105,84 +107,84 @@ void main( PS_IN fragment, out PS_OUT result ) // the vast majority of real-world materials (anything not metal or gems) have F(0°) // values in a very narrow range (~0.02 - 0.08) - + // approximate non-metals with linear RGB 0.04 which is 0.08 * 0.5 (default in UE4) const half3 dielectricColor = half3( 0.04 ); - + // derive diffuse and specular from albedo(m) base color const half3 baseColor = diffuseMap; - + half3 diffuseColor = baseColor * ( 1.0 - metallic ); half3 specularColor = lerp( dielectricColor, baseColor, metallic ); #else // HACK calculate roughness from D3 gloss maps float Y = dot( LUMINANCE_SRGB.rgb, specMapSRGB.rgb ); - + //const float glossiness = clamp( 1.0 - specMapSRGB.r, 0.0, 0.98 ); const float glossiness = clamp( pow( Y, 1.0 / 2.0 ), 0.0, 0.98 ); - + const float roughness = 1.0 - glossiness; - + half3 diffuseColor = diffuseMap; - half3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat + half3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat #endif - + // RB: compensate r_lightScale 3 and the division of Pi //lambert *= 1.3; - + // rpDiffuseModifier contains light color multiplier half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );// * rpDiffuseModifier.xyz; - + half vdotN = clamp( dot3( viewVector, localNormal ), 0.0, 1.0 ); half vdotH = clamp( dot3( viewVector, halfAngleVector ), 0.0, 1.0 ); half ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 ); - + // compensate r_lightScale 3 * 2 half3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5; - + // cheap approximation by ARM with only one division // http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf // page 26 - + float rr = roughness * roughness; float rrrr = rr * rr; - + // disney GGX float D = ( hdotN * hdotN ) * ( rrrr - 1.0 ) + 1.0; float VFapprox = ( ldotH * ldotH ) * ( roughness + 0.5 ); half3 specularBRDF = ( rrrr / ( 4.0 * PI * D * D * VFapprox ) ) * ldotN * reflectColor; //specularBRDF = half3( 0.0 ); - + #if 0 result.color = float4( _half3( VFapprox ), 1.0 ); return; #endif - + // see http://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/ //lambert /= PI; - + //half3 diffuseColor = mix( diffuseMap, F0, metal ) * rpDiffuseModifier.xyz; half3 diffuseBRDF = diffuseColor * lambert * sRGBToLinearRGB( rpDiffuseModifier.xyz ); - + result.color.xyz = ( diffuseBRDF + specularBRDF ) * lightColor * fragment.color.rgb; result.color.w = 1.0; - + #else - + /* OLD Blinn Phong */ const half specularPower = 10.0f; - + // RB: added abs half3 specularContribution = _half3( pow( hdotN, specularPower ) ); half3 diffuseColor = diffuseMap * sRGBToLinearRGB( rpDiffuseModifier.xyz ); half3 specularColor = specMap.xyz * specularContribution * sRGBToLinearRGB( rpSpecularModifier.xyz ); half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz ); - + /* half rim = 1.0f - saturate( hdotN ); half rimPower = 16.0f; diff --git a/base/renderprogs/interaction.vs.hlsl b/base/renderprogs/interaction.vs.hlsl index 8b2b05a1..7fd920a2 100644 --- a/base/renderprogs/interaction.vs.hlsl +++ b/base/renderprogs/interaction.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; #endif +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -53,8 +54,10 @@ struct VS_OUT { float4 texcoord6 : TEXCOORD6; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; float4 vTangent = vertex.tangent * 2.0 - 1.0; @@ -72,25 +75,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 normal; normal.x = dot3( matX, vNormal ); @@ -173,7 +176,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# calculate normalized vector to viewer in R1 float4 toView = normalize( rpLocalViewOrigin - modelPosition ); - + //# put into texture space result.texcoord6.x = dot3( tangent, toView ); result.texcoord6.y = dot3( bitangent, toView ); @@ -189,7 +192,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# generate the vertex color, which can be 1.0, color, or 1.0 - color //# for 1.0 : env[16] = 0, env[17] = 1 //# for color : env[16] = 1, env[17] = 0 - //# for 1.0-color : env[16] = -1, env[17] = 1 + //# for 1.0-color : env[16] = -1, env[17] = 1 result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; #endif } \ No newline at end of file diff --git a/base/renderprogs/interactionAmbient.ps.hlsl b/base/renderprogs/interactionAmbient.ps.hlsl index a66e5b45..3734b42e 100644 --- a/base/renderprogs/interactionAmbient.ps.hlsl +++ b/base/renderprogs/interactionAmbient.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map @@ -48,8 +49,10 @@ struct PS_IN { struct PS_OUT { half4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); half4 lightFalloff = idtex2Dproj( samp3, fragment.texcoord2 ); half4 lightProj = idtex2Dproj( samp4, fragment.texcoord3 ); @@ -70,7 +73,7 @@ void main( PS_IN fragment, out PS_OUT result ) { // RB end localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) ); localNormal = normalize( localNormal ); - + // traditional very dark Lambert light model used in Doom 3 half ldotN = saturate( dot3( localNormal, lightVector ) ); @@ -83,7 +86,7 @@ void main( PS_IN fragment, out PS_OUT result ) { #else half lambert = ldotN; #endif - + const half specularPower = 10.0f; half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal ); // RB: added abs diff --git a/base/renderprogs/interactionAmbient.vs.hlsl b/base/renderprogs/interactionAmbient.vs.hlsl index 238e0b46..87b213f9 100644 --- a/base/renderprogs/interactionAmbient.vs.hlsl +++ b/base/renderprogs/interactionAmbient.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -46,8 +47,10 @@ struct VS_OUT { float4 texcoord6 : TEXCOORD6; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 normal = vertex.normal * 2.0 - 1.0; float4 tangent = vertex.tangent * 2.0 - 1.0; @@ -95,7 +98,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# calculate normalized vector to viewer in R1 float4 toView = normalize( rpLocalViewOrigin - vertex.position ); - + //# add together to become the half angle vector in object space (non-normalized) float4 halfAngleVector = toLight + toView; @@ -108,6 +111,6 @@ void main( VS_IN vertex, out VS_OUT result ) { //# generate the vertex color, which can be 1.0, color, or 1.0 - color //# for 1.0 : env[16] = 0, env[17] = 1 //# for color : env[16] = 1, env[17] = 0 - //# for 1.0-color : env[16] = -1, env[17] = 1 + //# for 1.0-color : env[16] = -1, env[17] = 1 result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; } \ No newline at end of file diff --git a/base/renderprogs/interactionAmbient_skinned.ps.hlsl b/base/renderprogs/interactionAmbient_skinned.ps.hlsl index 22baf1e3..0872015e 100644 --- a/base/renderprogs/interactionAmbient_skinned.ps.hlsl +++ b/base/renderprogs/interactionAmbient_skinned.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map @@ -49,8 +50,10 @@ struct PS_IN { struct PS_OUT { half4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); half4 lightFalloff = idtex2Dproj( samp3, fragment.texcoord2 ); half4 lightProj = idtex2Dproj( samp4, fragment.texcoord3 ); @@ -71,7 +74,7 @@ void main( PS_IN fragment, out PS_OUT result ) { // RB end localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) ); localNormal = normalize( localNormal ); - + // traditional very dark Lambert light model used in Doom 3 half ldotN = saturate( dot3( localNormal, lightVector ) ); @@ -84,7 +87,7 @@ void main( PS_IN fragment, out PS_OUT result ) { #else half lambert = ldotN; #endif - + const half specularPower = 10.0f; half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal ); // RB: added abs diff --git a/base/renderprogs/interactionAmbient_skinned.vs.hlsl b/base/renderprogs/interactionAmbient_skinned.vs.hlsl index 3cd4bc21..df7ad214 100644 --- a/base/renderprogs/interactionAmbient_skinned.vs.hlsl +++ b/base/renderprogs/interactionAmbient_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -50,8 +51,10 @@ struct VS_OUT { float4 texcoord6 : TEXCOORD6; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; float4 vTangent = vertex.tangent * 2.0 - 1.0; @@ -68,25 +71,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 normal; normal.x = dot3( matX, vNormal ); @@ -154,7 +157,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# calculate normalized vector to viewer in R1 float4 toView = normalize( rpLocalViewOrigin - modelPosition ); - + //# add together to become the half angle vector in object space (non-normalized) float4 halfAngleVector = toLight + toView; @@ -167,6 +170,6 @@ void main( VS_IN vertex, out VS_OUT result ) { //# generate the vertex color, which can be 1.0, color, or 1.0 - color //# for 1.0 : env[16] = 0, env[17] = 1 //# for color : env[16] = 1, env[17] = 0 - //# for 1.0-color : env[16] = -1, env[17] = 1 + //# for 1.0-color : env[16] = -1, env[17] = 1 result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; } \ No newline at end of file diff --git a/base/renderprogs/interactionSM.ps.hlsl b/base/renderprogs/interactionSM.ps.hlsl index 07aa95d9..d11d9fef 100644 --- a/base/renderprogs/interactionSM.ps.hlsl +++ b/base/renderprogs/interactionSM.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2020 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" #include "BRDF.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface normal map uniform sampler2D samp1 : register(s1); // texture 3 is the per-surface specular or roughness/metallic/AO mixer map uniform sampler2D samp2 : register(s2); // texture 2 is the per-surface baseColor map @@ -58,26 +59,26 @@ struct PS_OUT { half4 color : COLOR; }; - +// *INDENT-ON* float BlueNoise( float2 n, float x ) { - float noise = tex2D( samp6, ( n.xy / 256.0 ) ).r; - - noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x ); - - noise = RemapNoiseTriErp( noise ); - - //noise = noise * 2.0 - 1.0; - - return noise; + float noise = tex2D( samp6, ( n.xy / 256.0 ) ).r; + + noise = fract( noise + 0.61803398875 * rpJitterTexOffset.z * x ); + + noise = RemapNoiseTriErp( noise ); + + //noise = noise * 2.0 - 1.0; + + return noise; } void main( PS_IN fragment, out PS_OUT result ) { half4 bumpMap = tex2D( samp0, fragment.texcoord1.xy ); half4 lightFalloff = ( idtex2Dproj( samp3, fragment.texcoord2 ) ); - half4 lightProj = ( idtex2Dproj( samp4, fragment.texcoord3 ) ); + half4 lightProj = ( idtex2Dproj( samp4, fragment.texcoord3 ) ); half4 YCoCG = tex2D( samp2, fragment.texcoord4.xy ); half4 specMapSRGB = tex2D( samp1, fragment.texcoord5.xy ); half4 specMap = sRGBAToLinearRGBA( specMapSRGB ); @@ -96,7 +97,7 @@ void main( PS_IN fragment, out PS_OUT result ) // RB end localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) ); localNormal = normalize( localNormal ); - + // traditional very dark Lambert light model used in Doom 3 half ldotN = saturate( dot3( localNormal, lightVector ) ); @@ -116,10 +117,10 @@ void main( PS_IN fragment, out PS_OUT result ) // shadow mapping // int shadowIndex = 0; - + #if defined( LIGHT_POINT ) float3 toLightGlobal = normalize( fragment.texcoord8.xyz ); - + float axis[6]; axis[0] = -toLightGlobal.x; axis[1] = toLightGlobal.x; @@ -139,9 +140,9 @@ void main( PS_IN fragment, out PS_OUT result ) #endif // #if defined( POINTLIGHT ) #if defined( LIGHT_PARALLEL ) - + float viewZ = -fragment.texcoord9.z; - + shadowIndex = 4; for( int i = 0; i < 4; i++ ) { @@ -152,7 +153,7 @@ void main( PS_IN fragment, out PS_OUT result ) } } #endif - + #if 0 if( shadowIndex == 0 ) { @@ -178,33 +179,33 @@ void main( PS_IN fragment, out PS_OUT result ) { result.color = float4( 0.0, 1.0, 1.0, 1.0 ); } - + //result.color.xyz *= lightColor; return; #endif - + float4 shadowMatrixX = rpShadowMatrices[ int ( shadowIndex * 4 + 0 ) ]; float4 shadowMatrixY = rpShadowMatrices[ int ( shadowIndex * 4 + 1 ) ]; float4 shadowMatrixZ = rpShadowMatrices[ int ( shadowIndex * 4 + 2 ) ]; float4 shadowMatrixW = rpShadowMatrices[ int ( shadowIndex * 4 + 3 ) ]; - + float4 modelPosition = float4( fragment.texcoord7.xyz, 1.0 ); float4 shadowTexcoord; shadowTexcoord.x = dot4( modelPosition, shadowMatrixX ); shadowTexcoord.y = dot4( modelPosition, shadowMatrixY ); shadowTexcoord.z = dot4( modelPosition, shadowMatrixZ ); shadowTexcoord.w = dot4( modelPosition, shadowMatrixW ); - + //float bias = 0.005 * tan( acos( ldotN ) ); //bias = clamp( bias, 0, 0.01 ); float bias = 0.001; - + shadowTexcoord.xyz /= shadowTexcoord.w; - + shadowTexcoord.z = shadowTexcoord.z * rpScreenCorrectionFactor.w; //shadowTexcoord.z = shadowTexcoord.z * 0.999991; //shadowTexcoord.z = shadowTexcoord.z - bias; - shadowTexcoord.w = float(shadowIndex); + shadowTexcoord.w = float( shadowIndex ); #if 0 result.color.xyz = float3( shadowTexcoord.z, shadowTexcoord.z, shadowTexcoord.z ); @@ -213,126 +214,126 @@ void main( PS_IN fragment, out PS_OUT result ) #endif // multiple taps - + #if 0 float4 base = shadowTexcoord; - + base.xy += rpJitterTexScale.xy * -0.5; - + float shadow = 0.0; - + //float stepSize = 1.0 / 16.0; float numSamples = 16; float stepSize = 1.0 / numSamples; - + float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset; for( float i = 0.0; i < numSamples; i += 1.0 ) { float4 jitter = base + tex2D( samp6, jitterTC.xy ) * rpJitterTexScale; jitter.zw = shadowTexcoord.zw; - + shadow += texture( samp5, jitter.xywz ); jitterTC.x += stepSize; } - + shadow *= stepSize; #elif 0 - + const float2 poissonDisk[12] = float2[]( - float2(0.6111618, 0.1050905), - float2(0.1088336, 0.1127091), - float2(0.3030421, -0.6292974), - float2(0.4090526, 0.6716492), - float2(-0.1608387, -0.3867823), - float2(0.7685862, -0.6118501), - float2(-0.1935026, -0.856501), - float2(-0.4028573, 0.07754025), - float2(-0.6411021, -0.4748057), - float2(-0.1314865, 0.8404058), - float2(-0.7005203, 0.4596822), - float2(-0.9713828, -0.06329931) ); - + float2( 0.6111618, 0.1050905 ), + float2( 0.1088336, 0.1127091 ), + float2( 0.3030421, -0.6292974 ), + float2( 0.4090526, 0.6716492 ), + float2( -0.1608387, -0.3867823 ), + float2( 0.7685862, -0.6118501 ), + float2( -0.1935026, -0.856501 ), + float2( -0.4028573, 0.07754025 ), + float2( -0.6411021, -0.4748057 ), + float2( -0.1314865, 0.8404058 ), + float2( -0.7005203, 0.4596822 ), + float2( -0.9713828, -0.06329931 ) ); + float shadow = 0.0; - + // RB: casting a float to int and using it as index can really kill the performance ... float numSamples = 12.0; //int(rpScreenCorrectionFactor.w); float stepSize = 1.0 / numSamples; - + float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset; float4 random = tex2D( samp6, jitterTC.xy ) * PI; //float4 random = fragment.position; - + float2 rot; rot.x = cos( random.x ); rot.y = sin( random.x ); - + float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale.x; - for( int i = 0; i < 12; i++ ) - { - float2 jitter = poissonDisk[i]; + for( int i = 0; i < 12; i++ ) + { + float2 jitter = poissonDisk[i]; float2 jitterRotated; jitterRotated.x = jitter.x * rot.x - jitter.y * rot.y; jitterRotated.y = jitter.x * rot.y + jitter.y * rot.x; - + float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w ); - - shadow += texture( samp5, shadowTexcoordJittered.xywz); - } - shadow *= stepSize; + shadow += texture( samp5, shadowTexcoordJittered.xywz ); + } + + shadow *= stepSize; + + +#elif 1 + + const float2 poissonDisk[12] = float2[]( + float2( 0.6111618, 0.1050905 ), + float2( 0.1088336, 0.1127091 ), + float2( 0.3030421, -0.6292974 ), + float2( 0.4090526, 0.6716492 ), + float2( -0.1608387, -0.3867823 ), + float2( 0.7685862, -0.6118501 ), + float2( -0.1935026, -0.856501 ), + float2( -0.4028573, 0.07754025 ), + float2( -0.6411021, -0.4748057 ), + float2( -0.1314865, 0.8404058 ), + float2( -0.7005203, 0.4596822 ), + float2( -0.9713828, -0.06329931 ) ); - - #elif 1 - - const float2 poissonDisk[12] = float2[]( - float2(0.6111618, 0.1050905), - float2(0.1088336, 0.1127091), - float2(0.3030421, -0.6292974), - float2(0.4090526, 0.6716492), - float2(-0.1608387, -0.3867823), - float2(0.7685862, -0.6118501), - float2(-0.1935026, -0.856501), - float2(-0.4028573, 0.07754025), - float2(-0.6411021, -0.4748057), - float2(-0.1314865, 0.8404058), - float2(-0.7005203, 0.4596822), - float2(-0.9713828, -0.06329931) ); - float shadow = 0.0; - + // RB: casting a float to int and using it as index can really kill the performance ... float numSamples = 6.0; //int(rpScreenCorrectionFactor.w); float stepSize = 1.0 / numSamples; - + //float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset; //float random = tex2D( samp6, jitterTC.xy ).x; - - float random = BlueNoise( fragment.position.xy * 1.0, 100.0 ); - - //float random = InterleavedGradientNoise( fragment.position.xy ); - - random *= PI; - + + float random = BlueNoise( fragment.position.xy * 1.0, 100.0 ); + + //float random = InterleavedGradientNoise( fragment.position.xy ); + + random *= PI; + float2 rot; rot.x = cos( random ); rot.y = sin( random ); - + float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale.x; - for( int i = 0; i < 6; i++ ) - { - float2 jitter = poissonDisk[i]; + for( int i = 0; i < 6; i++ ) + { + float2 jitter = poissonDisk[i]; float2 jitterRotated; jitterRotated.x = jitter.x * rot.x - jitter.y * rot.y; jitterRotated.y = jitter.x * rot.y + jitter.y * rot.x; - - float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w ); - - shadow += texture( samp5, shadowTexcoordJittered.xywz); - } - shadow *= stepSize; - + float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w ); + + shadow += texture( samp5, shadowTexcoordJittered.xywz ); + } + + shadow *= stepSize; + #else float shadow = texture( samp5, shadowTexcoord.xywz ); @@ -343,7 +344,7 @@ void main( PS_IN fragment, out PS_OUT result ) half hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 ); #if 1 - + #if defined( USE_PBR ) const half metallic = specMapSRGB.g; const half roughness = specMapSRGB.r; @@ -351,85 +352,85 @@ void main( PS_IN fragment, out PS_OUT result ) // the vast majority of real-world materials (anything not metal or gems) have F(0°) // values in a very narrow range (~0.02 - 0.08) - + // approximate non-metals with linear RGB 0.04 which is 0.08 * 0.5 (default in UE4) const half3 dielectricColor = half3( 0.04 ); - + // derive diffuse and specular from albedo(m) base color const half3 baseColor = diffuseMap; - + half3 diffuseColor = baseColor * ( 1.0 - metallic ); half3 specularColor = lerp( dielectricColor, baseColor, metallic ); #else // HACK calculate roughness from D3 gloss maps float Y = dot( LUMINANCE_SRGB.rgb, specMapSRGB.rgb ); - + //const float glossiness = clamp( 1.0 - specMapSRGB.r, 0.0, 0.98 ); const float glossiness = clamp( pow( Y, 1.0 / 2.0 ), 0.0, 0.98 ); - + const float roughness = 1.0 - glossiness; - + half3 diffuseColor = diffuseMap; half3 specularColor = specMapSRGB.rgb; // RB: should be linear but it looks too flat #endif - - //diffuseColor = half3( 1.0 ); - + + //diffuseColor = half3( 1.0 ); + // RB: compensate r_lightScale 3 and the division of Pi //lambert *= 1.3; - + // rpDiffuseModifier contains light color multiplier half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz );// * rpDiffuseModifier.xyz; - + half vdotN = clamp( dot3( viewVector, localNormal ), 0.0, 1.0 ); half vdotH = clamp( dot3( viewVector, halfAngleVector ), 0.0, 1.0 ); half ldotH = clamp( dot3( lightVector, halfAngleVector ), 0.0, 1.0 ); - + // compensate r_lightScale 3 * 2 half3 reflectColor = specularColor * rpSpecularModifier.rgb * 1.0;// * 0.5; - + // cheap approximation by ARM with only one division // http://community.arm.com/servlet/JiveServlet/download/96891546-19496/siggraph2015-mmg-renaldas-slides.pdf // page 26 - + float rr = roughness * roughness; float rrrr = rr * rr; - + // disney GGX float D = ( hdotN * hdotN ) * ( rrrr - 1.0 ) + 1.0; float VFapprox = ( ldotH * ldotH ) * ( roughness + 0.5 ); half3 specularBRDF = ( rrrr / ( 4.0 * PI * D * D * VFapprox ) ) * ldotN * reflectColor; //specularBRDF = half3( 0.0 ); - + #if 0 result.color = float4( _half3( VFapprox ), 1.0 ); return; #endif - + // see http://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/ //lambert /= PI; - + //half3 diffuseColor = mix( diffuseMap, F0, metal ) * rpDiffuseModifier.xyz; half3 diffuseBRDF = diffuseColor * lambert * sRGBToLinearRGB( rpDiffuseModifier.xyz ); - + result.color.xyz = ( diffuseBRDF + specularBRDF ) * lightColor * fragment.color.rgb * shadow; result.color.w = 1.0; - + #else - + /* OLD Blinn Phong */ const half specularPower = 10.0f; - + // RB: added abs half3 specularContribution = _half3( pow( hdotN, specularPower ) ); half3 diffuseColor = diffuseMap * sRGBToLinearRGB( rpDiffuseModifier.xyz ); half3 specularColor = specMap.xyz * specularContribution * sRGBToLinearRGB( rpSpecularModifier.xyz ); half3 lightColor = sRGBToLinearRGB( lightProj.xyz * lightFalloff.xyz ); - + /* half rim = 1.0f - saturate( hdotN ); half rimPower = 16.0f; diff --git a/base/renderprogs/interactionSM.vs.hlsl b/base/renderprogs/interactionSM.vs.hlsl index 37dcf2a1..7747510d 100644 --- a/base/renderprogs/interactionSM.vs.hlsl +++ b/base/renderprogs/interactionSM.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; #endif +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -56,8 +57,10 @@ struct VS_OUT { float4 texcoord9 : TEXCOORD9; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vNormal = vertex.normal * 2.0 - 1.0; float4 vTangent = vertex.tangent * 2.0 - 1.0; @@ -75,25 +78,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float3 normal; normal.x = dot3( matX, vNormal ); @@ -176,31 +179,31 @@ void main( VS_IN vertex, out VS_OUT result ) { //# calculate normalized vector to viewer in R1 float4 toView = normalize( rpLocalViewOrigin - modelPosition ); - + //# put into texture space result.texcoord6.x = dot3( tangent, toView ); result.texcoord6.y = dot3( bitangent, toView ); result.texcoord6.z = dot3( normal, toView ); result.texcoord6.w = 1.0f; - + result.texcoord7 = modelPosition; - + float4 worldPosition; worldPosition.x = dot4( modelPosition, rpModelMatrixX ); worldPosition.y = dot4( modelPosition, rpModelMatrixY ); worldPosition.z = dot4( modelPosition, rpModelMatrixZ ); worldPosition.w = dot4( modelPosition, rpModelMatrixW ); - + float4 toLightGlobal = rpGlobalLightOrigin - worldPosition; - + result.texcoord8 = toLightGlobal; - + float4 viewPosition; viewPosition.x = dot4( modelPosition, rpModelViewMatrixX ); viewPosition.y = dot4( modelPosition, rpModelViewMatrixY ); viewPosition.z = dot4( modelPosition, rpModelViewMatrixZ ); viewPosition.w = dot4( modelPosition, rpModelViewMatrixW ); - + result.texcoord9 = viewPosition; #if defined( USE_GPU_SKINNING ) @@ -212,7 +215,7 @@ void main( VS_IN vertex, out VS_OUT result ) { //# generate the vertex color, which can be 1.0, color, or 1.0 - color //# for 1.0 : env[16] = 0, env[17] = 1 //# for color : env[16] = 1, env[17] = 0 - //# for 1.0-color : env[16] = -1, env[17] = 1 + //# for 1.0-color : env[16] = -1, env[17] = 1 result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; #endif } \ No newline at end of file diff --git a/base/renderprogs/motionBlur.ps.hlsl b/base/renderprogs/motionBlur.ps.hlsl index dc47a62d..40d1be0b 100644 --- a/base/renderprogs/motionBlur.ps.hlsl +++ b/base/renderprogs/motionBlur.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // view color uniform sampler2D samp1 : register(s1); // view depth @@ -39,16 +40,20 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ #if 0 - if ( fragment.texcoord0.x < 0.5 ) { - // only draw on half the screen for comparison - discard; - } + if( fragment.texcoord0.x < 0.5 ) + { + // only draw on half the screen for comparison + discard; + } #endif // don't motion blur the hands, which were drawn with alpha = 0 - if ( tex2D( samp0, fragment.texcoord0 ).w == 0.0 ) { + if( tex2D( samp0, fragment.texcoord0 ).w == 0.0 ) + { discard; } @@ -80,7 +85,8 @@ void main( PS_IN fragment, out PS_OUT result ) { float goodSamples = 0.0; float samples = rpOverbright.x; - for ( float i = 0.0 ; i < samples ; i = i + 1.0 ) { + for( float i = 0.0 ; i < samples ; i = i + 1.0 ) + { float2 pos = fragment.texcoord0 + delta * ( ( i / ( samples - 1.0 ) ) - 0.5 ); float4 color = tex2D( samp0, pos ); // only take the values that are not part of the weapon diff --git a/base/renderprogs/motionBlur.vs.hlsl b/base/renderprogs/motionBlur.vs.hlsl index 3d5c28af..5810eb11 100644 --- a/base/renderprogs/motionBlur.vs.hlsl +++ b/base/renderprogs/motionBlur.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -37,8 +38,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position = vertex.position; result.texcoord0 = vertex.texcoord; } \ No newline at end of file diff --git a/base/renderprogs/postprocess.vs.hlsl b/base/renderprogs/postprocess.vs.hlsl index d1c94722..38ff6db5 100644 --- a/base/renderprogs/postprocess.vs.hlsl +++ b/base/renderprogs/postprocess.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position = vertex.position; //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX ); diff --git a/base/renderprogs/screen.ps.hlsl b/base/renderprogs/screen.ps.hlsl index 2093ebd0..d6544af7 100644 --- a/base/renderprogs/screen.ps.hlsl +++ b/base/renderprogs/screen.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN @@ -41,11 +42,12 @@ struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* void main( PS_IN fragment, out PS_OUT result ) { float2 tCoords = fragment.texcoord0; - + float4 color = tex2D( samp0, tCoords ); result.color = color; } diff --git a/base/renderprogs/screen.vs.hlsl b/base/renderprogs/screen.vs.hlsl index d1c94722..38ff6db5 100644 --- a/base/renderprogs/screen.vs.hlsl +++ b/base/renderprogs/screen.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position = vertex.position; //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX ); diff --git a/base/renderprogs/shadow.ps.hlsl b/base/renderprogs/shadow.ps.hlsl index 46fa6b1d..3251a234 100644 --- a/base/renderprogs/shadow.ps.hlsl +++ b/base/renderprogs/shadow.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); + struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = rpColor; } \ No newline at end of file diff --git a/base/renderprogs/shadow.vs.hlsl b/base/renderprogs/shadow.vs.hlsl index 122f9cf5..58aed0dd 100644 --- a/base/renderprogs/shadow.vs.hlsl +++ b/base/renderprogs/shadow.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; }; @@ -35,8 +36,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vPos = vertex.position - rpLocalLightOrigin; vPos = ( vPos.wwww * rpLocalLightOrigin ) + vPos; diff --git a/base/renderprogs/shadowDebug.ps.hlsl b/base/renderprogs/shadowDebug.ps.hlsl index 46fa6b1d..3251a234 100644 --- a/base/renderprogs/shadowDebug.ps.hlsl +++ b/base/renderprogs/shadowDebug.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); + struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = rpColor; } \ No newline at end of file diff --git a/base/renderprogs/shadowDebug.vs.hlsl b/base/renderprogs/shadowDebug.vs.hlsl index 122f9cf5..58aed0dd 100644 --- a/base/renderprogs/shadowDebug.vs.hlsl +++ b/base/renderprogs/shadowDebug.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; }; @@ -35,8 +36,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 vPos = vertex.position - rpLocalLightOrigin; vPos = ( vPos.wwww * rpLocalLightOrigin ) + vPos; diff --git a/base/renderprogs/shadowDebug_skinned.ps.hlsl b/base/renderprogs/shadowDebug_skinned.ps.hlsl index 46fa6b1d..3251a234 100644 --- a/base/renderprogs/shadowDebug_skinned.ps.hlsl +++ b/base/renderprogs/shadowDebug_skinned.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); + struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = rpColor; } \ No newline at end of file diff --git a/base/renderprogs/shadowDebug_skinned.vs.hlsl b/base/renderprogs/shadowDebug_skinned.vs.hlsl index c5ecead0..78653b28 100644 --- a/base/renderprogs/shadowDebug_skinned.vs.hlsl +++ b/base/renderprogs/shadowDebug_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float4 color : COLOR0; @@ -40,8 +41,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ //-------------------------------------------------------------- // GPU transformation of the normal / binormal / bitangent // @@ -53,25 +56,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float4 vertexPosition = vertex.position; vertexPosition.w = 1.0; diff --git a/base/renderprogs/shadow_skinned.ps.hlsl b/base/renderprogs/shadow_skinned.ps.hlsl index 46fa6b1d..3251a234 100644 --- a/base/renderprogs/shadow_skinned.ps.hlsl +++ b/base/renderprogs/shadow_skinned.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,11 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); + struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = rpColor; } \ No newline at end of file diff --git a/base/renderprogs/shadow_skinned.vs.hlsl b/base/renderprogs/shadow_skinned.vs.hlsl index d125a6dd..a6c73ea4 100644 --- a/base/renderprogs/shadow_skinned.vs.hlsl +++ b/base/renderprogs/shadow_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Coypright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform matrices_ubo { float4 matrices[408]; }; struct VS_IN { @@ -40,8 +41,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ //-------------------------------------------------------------- // GPU transformation of the normal / binormal / bitangent // @@ -53,25 +56,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float4 vertexPosition = vertex.position; vertexPosition.w = 1.0; diff --git a/base/renderprogs/simpleshade.ps.hlsl b/base/renderprogs/simpleshade.ps.hlsl index f14e74d6..7129cbee 100644 --- a/base/renderprogs/simpleshade.ps.hlsl +++ b/base/renderprogs/simpleshade.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,9 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* +uniform sampler2D samp0 : register(s0); + struct PS_IN { float4 position : VPOS; float4 texcoord0 : TEXCOORD0_centroid; @@ -36,8 +39,7 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; - -uniform sampler2D samp0 : register(s0); +// *INDENT-OFF* static float2 screenPosToTexcoord( float2 pos, float4 bias_scale ) { return ( pos * bias_scale.zw + bias_scale.xy ); } @@ -45,7 +47,7 @@ void main( PS_IN fragment, out PS_OUT result ) { const float renderWidth = 1280.0f; const float renderHeight = 720.0f; const float4 positionToViewTexture = float4( 0.5f / renderWidth, 0.5f / renderHeight, 1.0f / renderWidth, 1.0f / renderHeight ); - + float interpolatedZOverW = ( 1.0 - ( fragment.texcoord0.z / fragment.texcoord0.w ) ); float3 pos; diff --git a/base/renderprogs/simpleshade.vs.hlsl b/base/renderprogs/simpleshade.vs.hlsl index 9da67447..e0d60bf2 100644 --- a/base/renderprogs/simpleshade.vs.hlsl +++ b/base/renderprogs/simpleshade.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float4 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ float4 position; position.x = dot4( vertex.position, rpMVPmatrixX ); position.y = dot4( vertex.position, rpMVPmatrixY ); diff --git a/base/renderprogs/skinning.inc.hlsl b/base/renderprogs/skinning.inc.hlsl index 2b0add2a..c048e774 100644 --- a/base/renderprogs/skinning.inc.hlsl +++ b/base/renderprogs/skinning.inc.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013-2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,8 @@ float4 modelPosition = vertex.position; // RB: no GPU skinning with ES 2.0 #if defined(USE_GPU_SKINNING) -BRANCH if ( rpEnableSkinning.x > 0.0 ) { +BRANCH if( rpEnableSkinning.x > 0.0 ) +{ //-------------------------------------------------------------- // GPU transformation of the normal / binormal / bitangent // @@ -43,25 +44,25 @@ BRANCH if ( rpEnableSkinning.x > 0.0 ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; modelPosition.x = dot4( matX, vertex.position ); modelPosition.y = dot4( matY, vertex.position ); diff --git a/base/renderprogs/skybox.ps.hlsl b/base/renderprogs/skybox.ps.hlsl index 6c99001d..18fdd1fa 100644 --- a/base/renderprogs/skybox.ps.hlsl +++ b/base/renderprogs/skybox.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform samplerCUBE samp0 : register(s0); struct PS_IN { @@ -39,7 +40,9 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ result.color = sRGBAToLinearRGBA( texCUBE( samp0, fragment.texcoord0 ) ) * fragment.color; } diff --git a/base/renderprogs/skybox.vs.hlsl b/base/renderprogs/skybox.vs.hlsl index b728c7a6..4db0dc39 100644 --- a/base/renderprogs/skybox.vs.hlsl +++ b/base/renderprogs/skybox.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -41,14 +42,16 @@ struct VS_OUT { float3 texcoord0 : TEXCOORD0; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); result.position.w = dot4( vertex.position, rpMVPmatrixW ); result.texcoord0 = vertex.position.xyz - rpLocalViewOrigin.xyz; - + result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; } diff --git a/base/renderprogs/stereoDeGhost.ps.hlsl b/base/renderprogs/stereoDeGhost.ps.hlsl index 53ea8a17..3251a234 100644 --- a/base/renderprogs/stereoDeGhost.ps.hlsl +++ b/base/renderprogs/stereoDeGhost.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,12 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.color = rpColor; } \ No newline at end of file diff --git a/base/renderprogs/stereoDeGhost.vs.hlsl b/base/renderprogs/stereoDeGhost.vs.hlsl index 785665a1..5ba29f16 100644 --- a/base/renderprogs/stereoDeGhost.vs.hlsl +++ b/base/renderprogs/stereoDeGhost.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -39,8 +40,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/stereoInterlace.ps.hlsl b/base/renderprogs/stereoInterlace.ps.hlsl index cbe5c96b..405a3e02 100644 --- a/base/renderprogs/stereoInterlace.ps.hlsl +++ b/base/renderprogs/stereoInterlace.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); uniform sampler2D samp1 : register(s1); @@ -38,12 +39,17 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { - // texcoords will run from 0 to 1 across the entire screen - if ( fract( fragment.position.y * 0.5 ) < 0.5 ) { - result.color = tex2D( samp0, vec2( fragment.texcoord0 ) ); - } else { - result.color = tex2D( samp1, vec2( fragment.texcoord0 ) ); - } +void main( PS_IN fragment, out PS_OUT result ) +{ + // texcoords will run from 0 to 1 across the entire screen + if( fract( fragment.position.y * 0.5 ) < 0.5 ) + { + result.color = tex2D( samp0, vec2( fragment.texcoord0 ) ); + } + else + { + result.color = tex2D( samp1, vec2( fragment.texcoord0 ) ); + } } \ No newline at end of file diff --git a/base/renderprogs/stereoInterlace.vs.hlsl b/base/renderprogs/stereoInterlace.vs.hlsl index a16ced75..f51f67c3 100644 --- a/base/renderprogs/stereoInterlace.vs.hlsl +++ b/base/renderprogs/stereoInterlace.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -37,8 +38,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/stereoWarp.ps.hlsl b/base/renderprogs/stereoWarp.ps.hlsl index 0484a317..90dccf37 100644 --- a/base/renderprogs/stereoWarp.ps.hlsl +++ b/base/renderprogs/stereoWarp.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ the optics. */ +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN { @@ -46,12 +47,14 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { - const float screenWarp_range = 1.45; +void main( PS_IN fragment, out PS_OUT result ) +{ + const float screenWarp_range = 1.45; - const vec2 warpCenter = vec2( 0.5, 0.5 ); - vec2 centeredTexcoord = fragment.texcoord0.xy - warpCenter; + const vec2 warpCenter = vec2( 0.5, 0.5 ); + vec2 centeredTexcoord = fragment.texcoord0.xy - warpCenter; float radialLength = length( centeredTexcoord ); vec2 radialDir = normalize( centeredTexcoord ); @@ -61,14 +64,14 @@ void main( PS_IN fragment, out PS_OUT result ) { float scaledRadialLength = radialLength * range; float tanScaled = tan( scaledRadialLength ); - float rescaleValue = tan( 0.5 * range ); + float rescaleValue = tan( 0.5 * range ); - // If radialLength was 0.5, we want rescaled to also come out - // as 0.5, so the edges of the rendered image are at the edges - // of the warped image. + // If radialLength was 0.5, we want rescaled to also come out + // as 0.5, so the edges of the rendered image are at the edges + // of the warped image. float rescaled = tanScaled / rescaleValue; - vec2 warped = warpCenter + vec2( 0.5, 0.5 ) * radialDir * rescaled; + vec2 warped = warpCenter + vec2( 0.5, 0.5 ) * radialDir * rescaled; result.color = tex2D( samp0, warped ); } diff --git a/base/renderprogs/stereoWarp.vs.hlsl b/base/renderprogs/stereoWarp.vs.hlsl index 480e2d63..ebaec269 100644 --- a/base/renderprogs/stereoWarp.vs.hlsl +++ b/base/renderprogs/stereoWarp.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float4 texcoord : TEXCOORD0; @@ -37,8 +38,10 @@ struct VS_OUT { float4 position : POSITION; float4 texcoord0: TEXCOORD0; // 0 to 1 box }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); diff --git a/base/renderprogs/texture.ps.hlsl b/base/renderprogs/texture.ps.hlsl index 01d0f922..9c301df2 100644 --- a/base/renderprogs/texture.ps.hlsl +++ b/base/renderprogs/texture.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN { @@ -38,8 +39,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ result.color = tex2D( samp0, fragment.texcoord0 ) * rpColor; //result.color = textureLod( samp0, fragment.texcoord0, 2.0 ) * rpColor; //result.color = float4( 0.0, 1.0, 0.0, 1.0 ) * rpColor; diff --git a/base/renderprogs/texture.vs.hlsl b/base/renderprogs/texture.vs.hlsl index 5b4dacec..d15c952f 100644 --- a/base/renderprogs/texture.vs.hlsl +++ b/base/renderprogs/texture.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,18 +41,23 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); result.position.w = dot4( vertex.position, rpMVPmatrixW ); // compute oldschool texgen or multiply by texture matrix - BRANCH if ( rpTexGen0Enabled.x > 0.0 ) { + BRANCH if( rpTexGen0Enabled.x > 0.0 ) + { result.texcoord0.x = dot4( vertex.position, rpTexGen0S ); result.texcoord0.y = dot4( vertex.position, rpTexGen0T ); - } else { + } + else + { result.texcoord0.x = dot4( vertex.texcoord.xy, rpTextureMatrixS ); result.texcoord0.y = dot4( vertex.texcoord.xy, rpTextureMatrixT ); } diff --git a/base/renderprogs/texture_color.ps.hlsl b/base/renderprogs/texture_color.ps.hlsl index babb68c4..f946e43b 100644 --- a/base/renderprogs/texture_color.ps.hlsl +++ b/base/renderprogs/texture_color.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN { @@ -39,8 +40,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 color = tex2D( samp0, fragment.texcoord0 ) * fragment.color; clip( color.a - rpAlphaTest.x ); result.color = sRGBAToLinearRGBA( color ); diff --git a/base/renderprogs/texture_color.vs.hlsl b/base/renderprogs/texture_color.vs.hlsl index a41b7908..75a83d6c 100644 --- a/base/renderprogs/texture_color.vs.hlsl +++ b/base/renderprogs/texture_color.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -41,18 +42,23 @@ struct VS_OUT { float2 texcoord0 : TEXCOORD0; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); result.position.w = dot4( vertex.position, rpMVPmatrixW ); // compute oldschool texgen or multiply by texture matrix - BRANCH if ( rpTexGen0Enabled.x > 0.0 ) { + BRANCH if( rpTexGen0Enabled.x > 0.0 ) + { result.texcoord0.x = dot4( vertex.position, rpTexGen0S ); result.texcoord0.y = dot4( vertex.position, rpTexGen0T ); - } else { + } + else + { result.texcoord0.x = dot4( vertex.texcoord.xy, rpTextureMatrixS ); result.texcoord0.y = dot4( vertex.texcoord.xy, rpTextureMatrixT ); } diff --git a/base/renderprogs/texture_color_skinned.ps.hlsl b/base/renderprogs/texture_color_skinned.ps.hlsl index babb68c4..f946e43b 100644 --- a/base/renderprogs/texture_color_skinned.ps.hlsl +++ b/base/renderprogs/texture_color_skinned.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN { @@ -39,8 +40,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ float4 color = tex2D( samp0, fragment.texcoord0 ) * fragment.color; clip( color.a - rpAlphaTest.x ); result.color = sRGBAToLinearRGBA( color ); diff --git a/base/renderprogs/texture_color_skinned.vs.hlsl b/base/renderprogs/texture_color_skinned.vs.hlsl index 570e0b1f..efd15a0a 100644 --- a/base/renderprogs/texture_color_skinned.vs.hlsl +++ b/base/renderprogs/texture_color_skinned.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2014 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ If you have questions concerning this license or the applicable additional terms uniform matrices_ubo { float4 matrices[408]; }; +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -45,8 +46,10 @@ struct VS_OUT { float2 texcoord0 : TEXCOORD0; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ //-------------------------------------------------------------- // GPU transformation of the normal / binormal / bitangent // @@ -58,25 +61,25 @@ void main( VS_IN vertex, out VS_OUT result ) { const float w3 = vertex.color2.w; float4 matX, matY, matZ; // must be float4 for vec4 - int joint = int(vertex.color.x * 255.1 * 3.0); - matX = matrices[int(joint+0)] * w0; - matY = matrices[int(joint+1)] * w0; - matZ = matrices[int(joint+2)] * w0; + int joint = int( vertex.color.x * 255.1 * 3.0 ); + matX = matrices[int( joint + 0 )] * w0; + matY = matrices[int( joint + 1 )] * w0; + matZ = matrices[int( joint + 2 )] * w0; - joint = int(vertex.color.y * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w1; - matY += matrices[int(joint+1)] * w1; - matZ += matrices[int(joint+2)] * w1; + joint = int( vertex.color.y * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w1; + matY += matrices[int( joint + 1 )] * w1; + matZ += matrices[int( joint + 2 )] * w1; - joint = int(vertex.color.z * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w2; - matY += matrices[int(joint+1)] * w2; - matZ += matrices[int(joint+2)] * w2; + joint = int( vertex.color.z * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w2; + matY += matrices[int( joint + 1 )] * w2; + matZ += matrices[int( joint + 2 )] * w2; - joint = int(vertex.color.w * 255.1 * 3.0); - matX += matrices[int(joint+0)] * w3; - matY += matrices[int(joint+1)] * w3; - matZ += matrices[int(joint+2)] * w3; + joint = int( vertex.color.w * 255.1 * 3.0 ); + matX += matrices[int( joint + 0 )] * w3; + matY += matrices[int( joint + 1 )] * w3; + matZ += matrices[int( joint + 2 )] * w3; float4 modelPosition; modelPosition.x = dot4( matX, vertex.position ); @@ -90,10 +93,13 @@ void main( VS_IN vertex, out VS_OUT result ) { result.position.w = dot4( modelPosition, rpMVPmatrixW ); // compute oldschool texgen or multiply by texture matrix - BRANCH if ( rpTexGen0Enabled.x > 0.0 ) { + BRANCH if( rpTexGen0Enabled.x > 0.0 ) + { result.texcoord0.x = dot4( modelPosition, rpTexGen0S ); result.texcoord0.y = dot4( modelPosition, rpTexGen0T ); - } else { + } + else + { result.texcoord0.x = dot4( vertex.texcoord.xy, rpTextureMatrixS ); result.texcoord0.y = dot4( vertex.texcoord.xy, rpTextureMatrixT ); } diff --git a/base/renderprogs/texture_color_texgen.ps.hlsl b/base/renderprogs/texture_color_texgen.ps.hlsl index a95853cb..d6aa1906 100644 --- a/base/renderprogs/texture_color_texgen.ps.hlsl +++ b/base/renderprogs/texture_color_texgen.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,8 +28,10 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" -uniform sampler2D samp0 : register(s0); +uniform sampler2D samp0 : +register( s0 ); +// *INDENT-OFF* struct PS_IN { float4 position : VPOS; float4 texcoord0 : TEXCOORD0_centroid; @@ -39,8 +41,10 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ // we always do a projective texture lookup so that we can support texgen // materials without a separate shader. Basic materials will have texture diff --git a/base/renderprogs/texture_color_texgen.vs.hlsl b/base/renderprogs/texture_color_texgen.vs.hlsl index 425dae96..f1ae40f6 100644 --- a/base/renderprogs/texture_color_texgen.vs.hlsl +++ b/base/renderprogs/texture_color_texgen.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -41,8 +42,10 @@ struct VS_OUT { float4 texcoord0 : TEXCOORD0; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); @@ -53,7 +56,7 @@ void main( VS_IN vertex, out VS_OUT result ) { tc0.y = dot4( vertex.position, rpTexGen0T ); tc0.z = 0.0f; - tc0.w = dot4( vertex.position, rpTexGen0Q ); + tc0.w = dot4( vertex.position, rpTexGen0Q ); // multiply the texture matrix in result.texcoord0.x = dot4( tc0, rpTextureMatrixS ); diff --git a/base/renderprogs/tonemap.ps.hlsl b/base/renderprogs/tonemap.ps.hlsl index d23f705f..94be7b43 100644 --- a/base/renderprogs/tonemap.ps.hlsl +++ b/base/renderprogs/tonemap.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2009-2015 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); // texture 0 is _currentRender uniform sampler2D samp1 : register(s1); // texture 1 is heatmap @@ -42,9 +43,8 @@ struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* - - float3 Uncharted2Tonemap( float3 x ) { float A = 0.22; // shoulder strength @@ -61,62 +61,62 @@ float3 Uncharted2Tonemap( float3 x ) // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ float3 ACESFilm( float3 x ) { - float a = 2.51; - float b = 0.03; - float c = 2.43; - float d = 0.59; - float e = 0.14; - return saturate( ( x * ( a * x + b ) ) / ( x * ( c * x + d ) + e ) ); + float a = 2.51; + float b = 0.03; + float c = 2.43; + float d = 0.59; + float e = 0.14; + return saturate( ( x * ( a * x + b ) ) / ( x * ( c * x + d ) + e ) ); } void main( PS_IN fragment, out PS_OUT result ) { float2 tCoords = fragment.texcoord0; - + #if defined(BRIGHTPASS_FILTER) // multiply with 4 because the FBO is only 1/4th of the screen resolution tCoords *= float2( 4.0, 4.0 ); #endif - + float4 color = tex2D( samp0, tCoords ); - + // get the luminance of the current pixel float Y = dot( LUMINANCE_SRGB, color ); const float hdrGamma = 2.2; float gamma = hdrGamma; - + #if 0 // convert from sRGB to linear RGB color.r = pow( color.r, gamma ); color.g = pow( color.g, gamma ); color.b = pow( color.b, gamma ); #endif - + #if defined(BRIGHTPASS) - if(Y < 0.1) + if( Y < 0.1 ) { //discard; result.color = float4( 0.0, 0.0, 0.0, 1.0 ); return; } #endif - + float hdrKey = rpScreenCorrectionFactor.x; float hdrAverageLuminance = rpScreenCorrectionFactor.y; float hdrMaxLuminance = rpScreenCorrectionFactor.z; - + // calculate the relative luminance float Yr = ( hdrKey * Y ) / hdrAverageLuminance; float Ymax = hdrMaxLuminance; #define OPERATOR 2 - + #if OPERATOR == 0 // advanced Reinhard operator, artistically desirable to burn out bright areas //float L = Yr * ( 1.0 + Yr / ( Ymax * Ymax ) ) / ( 1.0 + Yr ); - + // exponential tone mapper that is very similar to the Uncharted one // very good in keeping the colors natural float L = 1.0 - exp( -Yr ); @@ -129,44 +129,44 @@ void main( PS_IN fragment, out PS_OUT result ) float exposure = 1.0; float L = ( 1.0 - exp( -Yr * exposure ) ); color.rgb *= L; - + // Kodak filmic tone mappping, includes gamma correction //float3 rgb = max( float3( 0 ), color.rgb - float3( 0.004 ) ); //color.rgb = rgb * ( float3( 0.5 ) + 6.2 * rgb ) / ( float3( 0.06 ) + rgb * ( float3( 1.7 ) + 6.2 * rgb ) ); - + // http://iwasbeingirony.blogspot.de/2010/04/approximating-film-with-tonemapping.html //const float cutoff = 0.025; //color.rgb += ( cutoff * 2.0 - color.rgb ) * saturate( cutoff * 2 - color.rgb ) * ( 0.25 / cutoff ) - cutoff; //color.rgb = color.rgb * ( float3( 0.5 ) + 6.2 * color.rgb ) / ( float3( 0.06 ) + color.rgb * ( float3( 1.7 ) + 6.2 * color.rgb ) ); - + #elif OPERATOR == 2 // can be in range [-4.0 .. 4.0] //float exposureOffset = rpScreenCorrectionFactor.w; - + float avgLuminance = max( hdrAverageLuminance, 0.001 ); float linearExposure = ( hdrKey / avgLuminance ); float exposure = log2( max( linearExposure, 0.0001 ) ); - + //exposure = -2.0; float3 exposedColor = exp2( exposure ) * color.rgb; - + color.rgb = ACESFilm( exposedColor ); - + #elif OPERATOR == 3 // can be in range [-4.0 .. 4.0] float exposure = rpScreenCorrectionFactor.w; - + // exposure curves ranges from 0.0625 to 16.0 float3 exposedColor = exp2( exposure ) * color.rgb; //float3 exposedColor = exposure * color.rgb; - + float3 curr = ACESFilm( exposedColor ); - + float3 whiteScale = 1.0 / ACESFilm( float3( Ymax ) ); color.rgb = curr * whiteScale; - + #elif OPERATOR == 4 // Uncharted 2 tone mapping based on Kodak film curve @@ -174,29 +174,29 @@ void main( PS_IN fragment, out PS_OUT result ) //float exposure = Yr * 1.0; float exposure = rpScreenCorrectionFactor.w; float3 exposedColor = exposure * color.rgb; - + float3 curr = Uncharted2Tonemap( exposedColor ); - + float3 whiteScale = 1.0 / Uncharted2Tonemap( float3( Ymax ) ); color.rgb = curr * whiteScale; #endif - + #if defined(BRIGHTPASS) // adjust contrast //L = pow( L, 1.32 ); - + const half hdrContrastThreshold = rpOverbright.x; const half hdrContrastOffset = rpOverbright.y; - + //float T = max( ( Yr * ( 1.0 + Yr / ( Ymax * Ymax * 2.0 ) ) ) - hdrContrastThreshold, 0.0 ); //float T = max( 1.0 - exp( -Yr ) - hdrContrastThreshold, 0.0 ); float T = max( Yr - hdrContrastThreshold, 0.0 ); - + float B = T > 0.0 ? T / ( hdrContrastOffset + T ) : T; - + color.rgb *= clamp( B, 0.0, 1.0 ); #endif - + #if 1 // convert from linear RGB to sRGB @@ -206,43 +206,43 @@ void main( PS_IN fragment, out PS_OUT result ) color.g = pow( color.g, gamma ); color.b = pow( color.b, gamma ); #endif - + #if defined(HDR_DEBUG) // https://google.github.io/filament/Filament.md.html#figure_luminanceviz - - const float3 debugColors[16] = float3[]( - float3(0.0, 0.0, 0.0), // black - float3(0.0, 0.0, 0.1647), // darkest blue - float3(0.0, 0.0, 0.3647), // darker blue - float3(0.0, 0.0, 0.6647), // dark blue - float3(0.0, 0.0, 0.9647), // blue - float3(0.0, 0.9255, 0.9255), // cyan - float3(0.0, 0.5647, 0.0), // dark green - float3(0.0, 0.7843, 0.0), // green - float3(1.0, 1.0, 0.0), // yellow - float3(0.90588, 0.75294, 0.0), // yellow-orange - float3(1.0, 0.5647, 0.0), // orange - float3(1.0, 0.0, 0.0), // bright red - float3(0.8392, 0.0, 0.0), // red - float3(1.0, 0.0, 1.0), // magenta - float3(0.6, 0.3333, 0.7882), // purple - float3(1.0, 1.0, 1.0) // white - ); - - // The 5th color in the array (cyan) represents middle gray (18%) - // Every stop above or below middle gray causes a color shift - float v = log2( Y / 0.18 ); - v = clamp( v + 5.0, 0.0, 15.0 ); - int index = int( floor( v ) ); - - color.rgb = lerp( debugColors[index], debugColors[ min(15, index + 1) ], fract( v ) ); - - //color = tex2D( samp1, float2( L, 0.0 ) ); - //color = tex2D( samp1, float2( dot( LUMINANCE_SRGB, color ), 0.0 ) ); + + const float3 debugColors[16] = float3[]( + float3( 0.0, 0.0, 0.0 ), // black + float3( 0.0, 0.0, 0.1647 ), // darkest blue + float3( 0.0, 0.0, 0.3647 ), // darker blue + float3( 0.0, 0.0, 0.6647 ), // dark blue + float3( 0.0, 0.0, 0.9647 ), // blue + float3( 0.0, 0.9255, 0.9255 ), // cyan + float3( 0.0, 0.5647, 0.0 ), // dark green + float3( 0.0, 0.7843, 0.0 ), // green + float3( 1.0, 1.0, 0.0 ), // yellow + float3( 0.90588, 0.75294, 0.0 ), // yellow-orange + float3( 1.0, 0.5647, 0.0 ), // orange + float3( 1.0, 0.0, 0.0 ), // bright red + float3( 0.8392, 0.0, 0.0 ), // red + float3( 1.0, 0.0, 1.0 ), // magenta + float3( 0.6, 0.3333, 0.7882 ), // purple + float3( 1.0, 1.0, 1.0 ) // white + ); + + // The 5th color in the array (cyan) represents middle gray (18%) + // Every stop above or below middle gray causes a color shift + float v = log2( Y / 0.18 ); + v = clamp( v + 5.0, 0.0, 15.0 ); + int index = int( floor( v ) ); + + color.rgb = lerp( debugColors[index], debugColors[ min( 15, index + 1 ) ], fract( v ) ); + + //color = tex2D( samp1, float2( L, 0.0 ) ); + //color = tex2D( samp1, float2( dot( LUMINANCE_SRGB, color ), 0.0 ) ); #endif result.color = color; - + #if 0 result.color = float4( L, L, L, 1.0 ); #endif diff --git a/base/renderprogs/tonemap.vs.hlsl b/base/renderprogs/tonemap.vs.hlsl index d1c94722..38ff6db5 100644 --- a/base/renderprogs/tonemap.vs.hlsl +++ b/base/renderprogs/tonemap.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -40,8 +41,10 @@ struct VS_OUT { float4 position : POSITION; float2 texcoord0 : TEXCOORD0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position = vertex.position; //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX ); diff --git a/base/renderprogs/vertex_color.ps.hlsl b/base/renderprogs/vertex_color.ps.hlsl index 70392e72..39b8620a 100644 --- a/base/renderprogs/vertex_color.ps.hlsl +++ b/base/renderprogs/vertex_color.ps.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform sampler2D samp0 : register(s0); struct PS_IN @@ -40,6 +41,7 @@ struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* void main( PS_IN fragment, out PS_OUT result ) { diff --git a/base/renderprogs/vertex_color.vs.hlsl b/base/renderprogs/vertex_color.vs.hlsl index 6cb95bb9..8fe784ee 100644 --- a/base/renderprogs/vertex_color.vs.hlsl +++ b/base/renderprogs/vertex_color.vs.hlsl @@ -2,10 +2,10 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 2013 Robert Beckebans -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; @@ -43,6 +44,7 @@ struct VS_OUT float4 position : POSITION; float4 color : COLOR0; }; +// *INDENT-ON* void main( VS_IN vertex, out VS_OUT result ) { @@ -50,6 +52,6 @@ void main( VS_IN vertex, out VS_OUT result ) result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); result.position.w = dot4( vertex.position, rpMVPmatrixW ); - + result.color = swizzleColor( vertex.color ); } \ No newline at end of file diff --git a/base/renderprogs/wobblesky.ps.hlsl b/base/renderprogs/wobblesky.ps.hlsl index 6c99001d..18fdd1fa 100644 --- a/base/renderprogs/wobblesky.ps.hlsl +++ b/base/renderprogs/wobblesky.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* uniform samplerCUBE samp0 : register(s0); struct PS_IN { @@ -39,7 +40,9 @@ struct PS_IN { struct PS_OUT { float4 color : COLOR; }; +// *INDENT-ON* -void main( PS_IN fragment, out PS_OUT result ) { +void main( PS_IN fragment, out PS_OUT result ) +{ result.color = sRGBAToLinearRGBA( texCUBE( samp0, fragment.texcoord0 ) ) * fragment.color; } diff --git a/base/renderprogs/wobblesky.vs.hlsl b/base/renderprogs/wobblesky.vs.hlsl index 797ee2b2..d0d72137 100644 --- a/base/renderprogs/wobblesky.vs.hlsl +++ b/base/renderprogs/wobblesky.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; float2 texcoord : TEXCOORD0; @@ -41,8 +42,10 @@ struct VS_OUT { float3 texcoord0 : TEXCOORD0; float4 color : COLOR0; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position.x = dot4( vertex.position, rpMVPmatrixX ); result.position.y = dot4( vertex.position, rpMVPmatrixY ); result.position.z = dot4( vertex.position, rpMVPmatrixZ ); @@ -52,6 +55,6 @@ void main( VS_IN vertex, out VS_OUT result ) { result.texcoord0.x = dot3( t0, rpWobbleSkyX ); result.texcoord0.y = dot3( t0, rpWobbleSkyY ); result.texcoord0.z = dot3( t0, rpWobbleSkyZ ); - + result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd; } diff --git a/base/renderprogs/zcullReconstruct.ps.hlsl b/base/renderprogs/zcullReconstruct.ps.hlsl index 4a950399..8194481b 100644 --- a/base/renderprogs/zcullReconstruct.ps.hlsl +++ b/base/renderprogs/zcullReconstruct.ps.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,12 +28,15 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct PS_OUT { float depth : DEPTH; float4 color : COLOR; }; +// *INDENT-ON* -void main( out PS_OUT result ) { +void main( out PS_OUT result ) +{ result.depth = 1; result.color = float4( 0.0, 0.0, 0.0, 0.0 ); } \ No newline at end of file diff --git a/base/renderprogs/zcullReconstruct.vs.hlsl b/base/renderprogs/zcullReconstruct.vs.hlsl index e46efd76..ea5e5534 100644 --- a/base/renderprogs/zcullReconstruct.vs.hlsl +++ b/base/renderprogs/zcullReconstruct.vs.hlsl @@ -2,9 +2,9 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. -This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). +This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc.hlsl" +// *INDENT-OFF* struct VS_IN { float4 position : POSITION; }; @@ -35,8 +36,10 @@ struct VS_IN { struct VS_OUT { float4 position : POSITION; }; +// *INDENT-ON* -void main( VS_IN vertex, out VS_OUT result ) { +void main( VS_IN vertex, out VS_OUT result ) +{ result.position = vertex.position; result.position.z = -1.0; } \ No newline at end of file diff --git a/neo/astyle-code.bat b/neo/astyle-code.bat index fb27417d..d4f5218a 100644 --- a/neo/astyle-code.bat +++ b/neo/astyle-code.bat @@ -4,11 +4,6 @@ astyle.exe -v --formatted --options=astyle-options.ini --exclude="libs" --exclud astyle.exe -v --formatted --options=astyle-options.ini --recursive libs/imgui/*.h astyle.exe -v --formatted --options=astyle-options.ini --recursive libs/imgui/*.cpp -astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/ambient_lighting_IBL.ps.hlsl -astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/postprocess.ps.hlsl -astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/AmbientOcclusion_AO.ps.hlsl -astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/AmbientOcclusion_blur.ps.hlsl -astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/AmbientOcclusion_minify.ps.hlsl -astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/DeepGBufferRadiosity_radiosity.ps.hlsl +astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/*.hlsl pause \ No newline at end of file