mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
Merge branch 'SMAA' into HDR-linearRGB
Conflicts: base/renderprogs/global.inc neo/renderer/RenderProgs_GLSL.cpp neo/renderer/RenderProgs_embedded.h
This commit is contained in:
commit
195f8082b8
32 changed files with 18160 additions and 69 deletions
11
README.txt
11
README.txt
|
@ -301,13 +301,22 @@ __________________________________________
|
|||
- Changed light interaction shaders to use Half-Lambert lighting like in Half-Life 2 to
|
||||
make the game less dark. https://developer.valvesoftware.com/wiki/Half_Lambert
|
||||
|
||||
- True 64 bit HDR lighting with adaptive tone mapping
|
||||
|
||||
The used Reinhard operator adds a bit more contrast to the game and gives it a harder look.
|
||||
|
||||
- Filmic post process effects like Technicolor color grading and film grain
|
||||
|
||||
___________________________________________________
|
||||
|
||||
9) CONSOLE VARIABLES
|
||||
__________________________________________
|
||||
|
||||
r_useShadowMapping 1 - Use soft shadow mapping instead of hard stencil shadows
|
||||
r_useShadowMapping [0 or 1] - Use soft shadow mapping instead of hard stencil shadows
|
||||
|
||||
r_useHDR [0 or 1] - Use High Dynamic Range lighting with adaptive tone mapping
|
||||
|
||||
r_useFilmicPostProcessEffects [0 or 1] - Apply several post process effects to mimic a filmic look"
|
||||
|
||||
|
||||
___________________________________________________
|
||||
|
|
|
@ -12,6 +12,20 @@ Thank you for downloading RBDOOM-3-BFG.
|
|||
|
||||
|
||||
|
||||
_______________________________________
|
||||
|
||||
TBD - RBDOOM-3-BFG 1.1.0
|
||||
_______________________________
|
||||
|
||||
- True 64 bit HDR lighting with adaptive tone mapping
|
||||
|
||||
- Filmic post process effects like Technicolor color grading and film grain
|
||||
|
||||
- Fixed issues with Mesa drivers and allowed them to use shadow mapping
|
||||
|
||||
- Defaulted fs_resourceLoadPriority to 0 so it is not necessary anymore to specify when running a modification
|
||||
|
||||
|
||||
_______________________________________
|
||||
|
||||
7 March 2015 - RBDOOM-3-BFG 1.0.3
|
||||
|
|
1382
base/renderprogs/SMAA.inc
Normal file
1382
base/renderprogs/SMAA.inc
Normal file
File diff suppressed because it is too large
Load diff
83
base/renderprogs/SMAA_blending_weight_calc.pixel
Normal file
83
base/renderprogs/SMAA_blending_weight_calc.pixel
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
#define SMAA_INCLUDE_VS 0
|
||||
#define SMAA_INCLUDE_PS 1
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); // _smaaEdges
|
||||
uniform sampler2D samp1 : register(s1); // _smaaArea
|
||||
uniform sampler2D samp2 : register(s2); // _smaaSearch
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 position : VPOS;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
float4 texcoord3 : TEXCOORD3_centroid;
|
||||
float4 texcoord4 : TEXCOORD4_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT
|
||||
{
|
||||
float4 color : COLOR;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
||||
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 );
|
||||
|
||||
//color = float4( texcoord.s, texcoord.t, 0.0, 1.0 );
|
||||
result.color = color;
|
||||
}
|
72
base/renderprogs/SMAA_blending_weight_calc.vertex
Normal file
72
base/renderprogs/SMAA_blending_weight_calc.vertex
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
#define SMAA_INCLUDE_VS 1
|
||||
#define SMAA_INCLUDE_PS 0
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
struct VS_IN
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_OUT
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
float4 texcoord3 : TEXCOORD3;
|
||||
float4 texcoord4 : TEXCOORD4;
|
||||
};
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
result.position = vertex.position;
|
||||
|
||||
float2 texcoord = vertex.texcoord;
|
||||
//float2 texcoord = float2( vertex.texcoord.s, 1.0 - vertex.texcoord.t );
|
||||
result.texcoord0 = texcoord;
|
||||
|
||||
float4 offset[3];
|
||||
float2 pixcoord;
|
||||
SMAABlendingWeightCalculationVS( texcoord, pixcoord, offset );
|
||||
|
||||
result.texcoord1 = offset[0];
|
||||
result.texcoord2 = offset[1];
|
||||
result.texcoord3 = offset[2];
|
||||
|
||||
result.texcoord4.st = pixcoord;
|
||||
}
|
75
base/renderprogs/SMAA_edge_detection.pixel
Normal file
75
base/renderprogs/SMAA_edge_detection.pixel
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
#define SMAA_INCLUDE_VS 0
|
||||
#define SMAA_INCLUDE_PS 1
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); // _currentColor
|
||||
uniform sampler2D samp1 : register(s1); // TODO _predictColor
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 position : VPOS;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
float4 texcoord3 : TEXCOORD3_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT
|
||||
{
|
||||
float4 color : COLOR;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
result.color = color;
|
||||
}
|
69
base/renderprogs/SMAA_edge_detection.vertex
Normal file
69
base/renderprogs/SMAA_edge_detection.vertex
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
#define SMAA_INCLUDE_VS 1
|
||||
#define SMAA_INCLUDE_PS 0
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
struct VS_IN
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_OUT
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
float4 texcoord3 : TEXCOORD3;
|
||||
};
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
result.position = vertex.position;
|
||||
|
||||
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];
|
||||
}
|
73
base/renderprogs/SMAA_final.pixel
Normal file
73
base/renderprogs/SMAA_final.pixel
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
#define SMAA_INCLUDE_VS 0
|
||||
#define SMAA_INCLUDE_PS 1
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
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;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
//color = tex2D( samp1, texcoord );
|
||||
//color = float4( samp1 );
|
||||
result.color = color;
|
||||
}
|
62
base/renderprogs/SMAA_final.vertex
Normal file
62
base/renderprogs/SMAA_final.vertex
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
#define SMAA_INCLUDE_VS 1
|
||||
#define SMAA_INCLUDE_PS 0
|
||||
#include "renderprogs/SMAA.inc"
|
||||
|
||||
struct VS_IN
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_OUT
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
result.position = vertex.position;
|
||||
|
||||
result.texcoord0 = vertex.texcoord;
|
||||
|
||||
float4 offset;
|
||||
SMAANeighborhoodBlendingVS( vertex.texcoord, offset );
|
||||
|
||||
result.texcoord1 = offset;
|
||||
}
|
|
@ -3,8 +3,11 @@ return
|
|||
-- includes
|
||||
"global.inc",
|
||||
"skinning.inc",
|
||||
"SMAA.inc",
|
||||
|
||||
-- shaders
|
||||
"ambient_lighting.pixel",
|
||||
"ambient_lighting.vertex",
|
||||
"bink.pixel",
|
||||
"bink.vertex",
|
||||
"bink_gui.pixel",
|
||||
|
@ -33,39 +36,42 @@ return
|
|||
"depth.vertex",
|
||||
"depth_skinned.pixel",
|
||||
"depth_skinned.vertex",
|
||||
"enviroSuit.pixel",
|
||||
"enviroSuit.vertex",
|
||||
"environment.pixel",
|
||||
"environment.vertex",
|
||||
"environment_skinned.pixel",
|
||||
"environment_skinned.vertex",
|
||||
"enviroSuit.pixel",
|
||||
"enviroSuit.vertex",
|
||||
"fog.pixel",
|
||||
"fog.vertex",
|
||||
"fog_skinned.pixel",
|
||||
"fog_skinned.vertex",
|
||||
"fxaa.pixel",
|
||||
"fxaa.vertex",
|
||||
"global.inc",
|
||||
"gui.pixel",
|
||||
"gui.vertex",
|
||||
"heathaze.pixel",
|
||||
"heathaze.vertex",
|
||||
"hdr_glare_chromatic.pixel",
|
||||
"hdr_glare_chromatic.vertex",
|
||||
"heatHazeWithMask.pixel",
|
||||
"heatHazeWithMask.vertex",
|
||||
"heatHazeWithMaskAndVertex.pixel",
|
||||
"heatHazeWithMaskAndVertex.vertex",
|
||||
"heathaze.pixel",
|
||||
"heathaze.vertex",
|
||||
"interaction.pixel",
|
||||
"interaction.vertex",
|
||||
"interactionSM.pixel",
|
||||
"interactionSM.vertex",
|
||||
"interactionAmbient.pixel",
|
||||
"interactionAmbient.vertex",
|
||||
"interactionAmbient_skinned.pixel",
|
||||
"interactionAmbient_skinned.vertex",
|
||||
"interactionSM.pixel",
|
||||
"interactionSM.vertex",
|
||||
"motionBlur.pixel",
|
||||
"motionBlur.vertex",
|
||||
"postprocess.pixel",
|
||||
"postprocess.vertex",
|
||||
"screen.pixel",
|
||||
"screen.vertex",
|
||||
"shadow.pixel",
|
||||
"shadow.vertex",
|
||||
"shadowDebug.pixel",
|
||||
|
@ -76,7 +82,6 @@ return
|
|||
"shadow_skinned.vertex",
|
||||
"simpleshade.pixel",
|
||||
"simpleshade.vertex",
|
||||
"skinning.inc",
|
||||
"skybox.pixel",
|
||||
"skybox.vertex",
|
||||
"stereoDeGhost.pixel",
|
||||
|
@ -93,6 +98,8 @@ return
|
|||
"texture_color_skinned.vertex",
|
||||
"texture_color_texgen.pixel",
|
||||
"texture_color_texgen.vertex",
|
||||
"tonemap.pixel",
|
||||
"tonemap.vertex",
|
||||
"vertex_color.pixel",
|
||||
"vertex_color.vertex",
|
||||
"wobblesky.pixel",
|
||||
|
|
97
base/renderprogs/ambient_lighting.pixel
Normal file
97
base/renderprogs/ambient_lighting.pixel
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
uniform sampler2D samp0 : register(s0); // texture 1 is the per-surface bump map
|
||||
uniform sampler2D samp1 : register(s1); // texture 2 is the light falloff texture
|
||||
uniform sampler2D samp2 : register(s2); // texture 3 is the light projection texture
|
||||
uniform sampler2D samp3 : register(s3); // texture 4 is the per-surface diffuse map
|
||||
uniform sampler2D samp4 : register(s4); // texture 5 is the per-surface specular map
|
||||
|
||||
struct PS_IN {
|
||||
half4 position : VPOS;
|
||||
half4 texcoord0 : TEXCOORD0_centroid;
|
||||
half4 texcoord1 : TEXCOORD1_centroid;
|
||||
// half4 texcoord2 : TEXCOORD2_centroid;
|
||||
// half4 texcoord3 : TEXCOORD3_centroid;
|
||||
half4 texcoord4 : TEXCOORD4_centroid;
|
||||
half4 texcoord5 : TEXCOORD5_centroid;
|
||||
half4 texcoord6 : TEXCOORD6_centroid;
|
||||
half4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
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 );
|
||||
half4 YCoCG = tex2D( samp3, fragment.texcoord4.xy );
|
||||
half4 specMap = tex2D( samp4, fragment.texcoord5.xy );
|
||||
|
||||
half3 lightVector = normalize( fragment.texcoord0.xyz );
|
||||
half3 diffuseMap = ConvertYCoCgToRGB( YCoCG );
|
||||
|
||||
half3 localNormal;
|
||||
#if defined(USE_NORMAL_FMT_RGB8)
|
||||
localNormal.xy = bumpMap.rg - 0.5;
|
||||
#else
|
||||
localNormal.xy = bumpMap.wy - 0.5;
|
||||
#endif
|
||||
localNormal.z = sqrt( abs( dot( localNormal.xy, localNormal.xy ) - 0.25 ) );
|
||||
localNormal = normalize( localNormal );
|
||||
|
||||
const half specularPower = 10.0f;
|
||||
half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );
|
||||
// RB: added abs
|
||||
half3 specularContribution = _half3( pow( abs( hDotN ), specularPower ) );
|
||||
|
||||
half3 diffuseColor = diffuseMap * rpDiffuseModifier.xyz * 1.5f;
|
||||
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 = rpAmbientColor.rgb;
|
||||
|
||||
half rim = 1.0f - saturate( hDotN );
|
||||
half rimPower = 8.0;
|
||||
half3 rimColor = 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.w = 1.0;
|
||||
}
|
199
base/renderprogs/ambient_lighting.vertex
Normal file
199
base/renderprogs/ambient_lighting.vertex
Normal file
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
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").
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
#if defined( USE_GPU_SKINNING )
|
||||
uniform matrices_ubo { float4 matrices[408]; };
|
||||
#endif
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 color : COLOR0;
|
||||
float4 color2 : COLOR1;
|
||||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
// float4 texcoord2 : TEXCOORD2;
|
||||
// float4 texcoord3 : TEXCOORD3;
|
||||
float4 texcoord4 : TEXCOORD4;
|
||||
float4 texcoord5 : TEXCOORD5;
|
||||
float4 texcoord6 : TEXCOORD6;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
#if defined( USE_GPU_SKINNING )
|
||||
//--------------------------------------------------------------
|
||||
// GPU transformation of the normal / tangent / bitangent
|
||||
//
|
||||
// multiplying with 255.1 give us the same result and is faster than floor( w * 255 + 0.5 )
|
||||
//--------------------------------------------------------------
|
||||
const float w0 = vertex.color2.x;
|
||||
const float w1 = vertex.color2.y;
|
||||
const float w2 = vertex.color2.z;
|
||||
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;
|
||||
|
||||
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.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 );
|
||||
normal.y = dot3( matY, vNormal );
|
||||
normal.z = dot3( matZ, vNormal );
|
||||
normal = normalize( normal );
|
||||
|
||||
float3 tangent;
|
||||
tangent.x = dot3( matX, vTangent );
|
||||
tangent.y = dot3( matY, vTangent );
|
||||
tangent.z = dot3( matZ, vTangent );
|
||||
tangent = normalize( tangent );
|
||||
|
||||
float3 bitangent;
|
||||
bitangent.x = dot3( matX, vBitangent );
|
||||
bitangent.y = dot3( matY, vBitangent );
|
||||
bitangent.z = dot3( matZ, vBitangent );
|
||||
bitangent = normalize( bitangent );
|
||||
|
||||
float4 modelPosition;
|
||||
modelPosition.x = dot4( matX, vertex.position );
|
||||
modelPosition.y = dot4( matY, vertex.position );
|
||||
modelPosition.z = dot4( matZ, vertex.position );
|
||||
modelPosition.w = 1.0;
|
||||
|
||||
#else
|
||||
float4 modelPosition = vertex.position;
|
||||
float3 normal = vNormal.xyz;
|
||||
float3 tangent = vTangent.xyz;
|
||||
float3 bitangent = vBitangent.xyz;
|
||||
#endif
|
||||
|
||||
result.position.x = dot4( modelPosition, rpMVPmatrixX );
|
||||
result.position.y = dot4( modelPosition, rpMVPmatrixY );
|
||||
result.position.z = dot4( modelPosition, rpMVPmatrixZ );
|
||||
result.position.w = dot4( modelPosition, rpMVPmatrixW );
|
||||
|
||||
float4 defaultTexCoord = float4( 0.0f, 0.5f, 0.0f, 1.0f );
|
||||
|
||||
//calculate vector to light
|
||||
//float4 toLight = rpLocalLightOrigin;
|
||||
float4 toLight = normalize( float4( 0.0f, 0.5f, 1.0f, 1.0f ) );
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
//result.texcoord0 is the direction to the light in tangent space
|
||||
result.texcoord0.x = dot3( tangent, toLight );
|
||||
result.texcoord0.y = dot3( bitangent, toLight );
|
||||
result.texcoord0.z = dot3( normal, toLight );
|
||||
result.texcoord0.w = 1.0f;
|
||||
|
||||
//textures 1 takes the base coordinates by the texture matrix
|
||||
result.texcoord1 = defaultTexCoord;
|
||||
result.texcoord1.x = dot4( vertex.texcoord.xy, rpBumpMatrixS );
|
||||
result.texcoord1.y = dot4( vertex.texcoord.xy, rpBumpMatrixT );
|
||||
|
||||
//# texture 2 has one texgen
|
||||
//result.texcoord2 = defaultTexCoord;
|
||||
//result.texcoord2.x = dot4( vertex.position, rpLightFalloffS );
|
||||
|
||||
//# texture 3 has three texgens
|
||||
//result.texcoord3.x = dot4( vertex.position, rpLightProjectionS );
|
||||
//result.texcoord3.y = dot4( vertex.position, rpLightProjectionT );
|
||||
//result.texcoord3.z = 0.0f;
|
||||
//result.texcoord3.w = dot4( vertex.position, rpLightProjectionQ );
|
||||
|
||||
//# textures 4 takes the base coordinates by the texture matrix
|
||||
result.texcoord4 = defaultTexCoord;
|
||||
result.texcoord4.x = dot4( vertex.texcoord.xy, rpDiffuseMatrixS );
|
||||
result.texcoord4.y = dot4( vertex.texcoord.xy, rpDiffuseMatrixT );
|
||||
|
||||
//# textures 5 takes the base coordinates by the texture matrix
|
||||
result.texcoord5 = defaultTexCoord;
|
||||
result.texcoord5.x = dot4( vertex.texcoord.xy, rpSpecularMatrixS );
|
||||
result.texcoord5.y = dot4( vertex.texcoord.xy, rpSpecularMatrixT );
|
||||
|
||||
//# texture 6's texcoords will be the halfangle in texture space
|
||||
|
||||
//# calculate normalized vector to light in R0
|
||||
toLight = normalize( toLight );
|
||||
|
||||
//# 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;
|
||||
|
||||
//# put into texture space
|
||||
result.texcoord6.x = dot3( tangent, halfAngleVector );
|
||||
result.texcoord6.y = dot3( bitangent, halfAngleVector );
|
||||
result.texcoord6.z = dot3( normal, halfAngleVector );
|
||||
result.texcoord6.w = 1.0f;
|
||||
|
||||
#if defined( USE_GPU_SKINNING )
|
||||
// for joint transformation of the tangent space, we use color and
|
||||
// color2 for weighting information, so hopefully there aren't any
|
||||
// effects that need vertex color...
|
||||
result.color = float4( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
#else
|
||||
//# 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
|
||||
result.color = ( swizzleColor( vertex.color ) * rpVertexColorModulate ) + rpVertexColorAdd;
|
||||
#endif
|
||||
}
|
|
@ -226,7 +226,8 @@ float rand( float2 co ) {
|
|||
}
|
||||
|
||||
|
||||
static const half4 LUMINANCE_VECTOR = half4( 0.2125, 0.7154, 0.0721, 0.0 );
|
||||
static const half4 LUMINANCE_SRGB = half4( 0.2125, 0.7154, 0.0721, 0.0 );
|
||||
static const half4 LUMINANCE_LINEAR = half4( 0.299, 0.587, 0.144, 0.0 );
|
||||
#define _half2( x ) half2( x )
|
||||
#define _half3( x ) half3( x )
|
||||
#define _half4( x ) half4( x )
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2014 Robert Beckebans
|
||||
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").
|
||||
|
||||
|
@ -59,28 +59,31 @@ float3 spectrumoffset( float t )
|
|||
float w = linterp( remap( t, 1.0 / 6.0, 5.0 / 6.0 ) );
|
||||
float3 ret = float3( lo, 1.0, hi ) * float3( 1.0 - w, w, 1.0 - w );
|
||||
|
||||
return ret; //pow( ret, float3( 1.0 / 2.2 ) );
|
||||
return ret; // pow( ret, float3( 1.0 / 2.2 ) );
|
||||
}
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
float2 st = fragment.texcoord0;
|
||||
|
||||
// base color with tone mapping and other post processing applied
|
||||
// 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 float3 chromaticOffsets[9] = float3[](
|
||||
float3(0.5, 0.5, 0.5),
|
||||
float3(0.8, 0.3, 0.3 ),
|
||||
float3(1.0, 0.2, 0.2),
|
||||
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),
|
||||
float3(0.2, 0.2, 1.0), // b
|
||||
float3(0.2, 0.3, 0.9),
|
||||
float3(0.2, 0.9, 0.2),
|
||||
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.3, 0.5, 0.3)
|
||||
);
|
||||
|
||||
float3 sumColor = float3( 0.0 );
|
||||
float3 sumSpectrum = float3( 0.0 );
|
||||
|
@ -88,34 +91,34 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
const int tap = 4;
|
||||
const int samples = 9;
|
||||
|
||||
float scale = 13.0;
|
||||
const float weightScale = 3.0;
|
||||
float scale = 13.0; // bloom width
|
||||
const float weightScale = 2.3; // bloom strength
|
||||
|
||||
//for( int i = -tap; i < tap; i++ )
|
||||
for( int i = 0; i < samples; i++ )
|
||||
{
|
||||
float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) );
|
||||
//float t = log( float( 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 = 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 );
|
||||
//sumSpectrum += so.xyz;
|
||||
}
|
||||
|
||||
#if 1
|
||||
for( int i = 0; i < samples; i++ )
|
||||
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 = 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 );
|
||||
//sumSpectrum += so.xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,9 +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
|
||||
|
@ -28,18 +29,130 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "renderprogs/global.inc"
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0);
|
||||
|
||||
struct PS_IN {
|
||||
uniform sampler2D samp1 : register(s1);
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 position : VPOS;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
|
||||
struct PS_OUT
|
||||
{
|
||||
float4 color : COLOR;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result ) {
|
||||
float2 tCoords = fragment.texcoord0;
|
||||
result.color = tex2D( samp0, tCoords );
|
||||
#define USE_TECHNICOLOR 1 // [0 or 1]
|
||||
|
||||
#define Technicolor_Amount 0.5 // [0.00 to 1.00]
|
||||
#define Technicolor_Power 4.0 // [0.00 to 8.00]
|
||||
#define Technicolor_RedNegativeAmount 0.88 // [0.00 to 1.00]
|
||||
#define Technicolor_GreenNegativeAmount 0.88 // [0.00 to 1.00]
|
||||
#define Technicolor_BlueNegativeAmount 0.88 // [0.00 to 1.00]
|
||||
|
||||
#define USE_VIBRANCE 1
|
||||
#define Vibrance 0.5 // [-1.00 to 1.00]
|
||||
#define Vibrance_RGB_Balance float3( 1.0, 1.0, 1.0 )
|
||||
|
||||
#define USE_FILMGRAIN 1
|
||||
|
||||
float3 overlay( float3 a, float3 b )
|
||||
{
|
||||
//return pow( abs( b ), 2.2 ) < 0.5 ? ( 2.0 * a * b ) : float3( 1.0, 1.0, 1.0 ) - float3( 2.0, 2.0, 2.0 ) * ( float3( 1.0, 1.0, 1.0 ) - a ) * ( 1.0 - b );
|
||||
//return abs( b ) < 0.5 ? ( 2.0 * a * b ) : float3( 1.0, 1.0, 1.0 ) - float3( 2.0, 2.0, 2.0 ) * ( float3( 1.0, 1.0, 1.0 ) - a ) * ( 1.0 - b );
|
||||
|
||||
return float3(
|
||||
b.x < 0.5 ? ( 2.0 * a.x * b.x ) : ( 1.0 - 2.0 * ( 1.0 - a.x ) * ( 1.0 - b.x ) ),
|
||||
b.y < 0.5 ? ( 2.0 * a.y * b.y ) : ( 1.0 - 2.0 * ( 1.0 - a.y ) * ( 1.0 - b.y ) ),
|
||||
b.z < 0.5 ? ( 2.0 * a.z * b.z ) : ( 1.0 - 2.0 * ( 1.0 - a.z ) * ( 1.0 - b.z ) ) );
|
||||
}
|
||||
|
||||
|
||||
void TechnicolorPass( inout float4 color )
|
||||
{
|
||||
const float3 cyanFilter = float3( 0.0, 1.30, 1.0 );
|
||||
const float3 magentaFilter = float3( 1.0, 0.0, 1.05 );
|
||||
const float3 yellowFilter = float3( 1.6, 1.6, 0.05 );
|
||||
const float3 redOrangeFilter = float3( 1.05, 0.62, 0.0 );
|
||||
const float3 greenFilter = float3( 0.3, 1.0, 0.0 );
|
||||
|
||||
float2 redNegativeMul = color.rg * ( 1.0 / ( Technicolor_RedNegativeAmount * Technicolor_Power ) );
|
||||
float2 greenNegativeMul = color.rg * ( 1.0 / ( Technicolor_GreenNegativeAmount * Technicolor_Power ) );
|
||||
float2 blueNegativeMul = color.rb * ( 1.0 / ( Technicolor_BlueNegativeAmount * Technicolor_Power ) );
|
||||
|
||||
float redNegative = dot( redOrangeFilter.rg, redNegativeMul );
|
||||
float greenNegative = dot( greenFilter.rg, greenNegativeMul );
|
||||
float blueNegative = dot( magentaFilter.rb, blueNegativeMul );
|
||||
|
||||
float3 redOutput = float3( redNegative ) + cyanFilter;
|
||||
float3 greenOutput = float3( greenNegative ) + magentaFilter;
|
||||
float3 blueOutput = float3( blueNegative ) + yellowFilter;
|
||||
|
||||
float3 result = redOutput * greenOutput * blueOutput;
|
||||
color.rgb = lerp( color.rgb, result, Technicolor_Amount );
|
||||
}
|
||||
|
||||
|
||||
void VibrancePass( inout float4 color )
|
||||
{
|
||||
const float3 vibrance = Vibrance_RGB_Balance * Vibrance;
|
||||
|
||||
float Y = dot( LUMINANCE_SRGB, color );
|
||||
|
||||
float minColor = min( color.r, min( color.g, color.b ) );
|
||||
float maxColor = max( color.r, max( color.g, color.b ) );
|
||||
|
||||
float colorSat = maxColor - minColor;
|
||||
|
||||
color.rgb = lerp( float3( Y ), color.rgb, ( 1.0 + ( vibrance * ( 1.0 - ( sign( vibrance ) * colorSat ) ) ) ) );
|
||||
}
|
||||
|
||||
|
||||
void FilmgrainPass( inout float4 color )
|
||||
{
|
||||
float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;
|
||||
//float4 jitterTC = ( fragment.position * ( 1.0 / 128.0 ) ) + rpJitterTexOffset;
|
||||
//float2 jitterTC = fragment.position.xy * 2.0;
|
||||
//jitterTC.x *= rpWindowCoord.y / rpWindowCoord.x;
|
||||
|
||||
float4 noiseColor = tex2D( samp1, fragment.position.xy + jitterTC.xy );
|
||||
float Y = noiseColor.r;
|
||||
//float Y = dot( LUMINANCE_VECTOR, noiseColor );
|
||||
//noiseColor.rgb = float3( Y, Y, Y );
|
||||
|
||||
float exposureFactor = 1.0;
|
||||
exposureFactor = sqrt( exposureFactor );
|
||||
const float noiseIntensity = 1.7; //rpScreenCorrectionFactor.z;
|
||||
|
||||
float t = lerp( 3.5 * noiseIntensity, 1.13 * noiseIntensity, exposureFactor );
|
||||
color.rgb = overlay( color.rgb, lerp( float3( 0.5 ), noiseColor.rgb, t ) );
|
||||
|
||||
//color.rgb = noiseColor.rgb;
|
||||
//color.rgb = lerp( color.rgb, noiseColor.rgb, 0.3 );
|
||||
}
|
||||
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
float2 tCoords = fragment.texcoord0;
|
||||
|
||||
// base color with tone mapping and other post processing applied
|
||||
float4 color = tex2D( samp0, tCoords );
|
||||
|
||||
#if USE_TECHNICOLOR
|
||||
TechnicolorPass( color );
|
||||
#endif
|
||||
|
||||
#if USE_VIBRANCE
|
||||
VibrancePass( color );
|
||||
#endif
|
||||
|
||||
#if USE_FILMGRAIN
|
||||
FilmgrainPass( color );
|
||||
#endif
|
||||
|
||||
result.color = color;
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ struct PS_OUT
|
|||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
float A = 0.15;
|
||||
float B = 0.50;
|
||||
float C = 0.10;
|
||||
float D = 0.20;
|
||||
float E = 0.02;
|
||||
float F = 0.30;
|
||||
float W = 11.2;
|
||||
float A = 0.22; // shoulder strength
|
||||
float B = 0.3; // linear strength
|
||||
float C = 0.10; // linear angle
|
||||
float D = 0.20; // toe strength
|
||||
float E = 0.01; // toe numerator
|
||||
float F = 0.30; // toe denominator
|
||||
float W = 11.2; // linear white point
|
||||
|
||||
float3 Uncharted2Tonemap( float3 x )
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float4 color = tex2D( samp0, tCoords );
|
||||
|
||||
// get the luminance of the current pixel
|
||||
float Y = dot( LUMINANCE_VECTOR, color );
|
||||
float Y = dot( LUMINANCE_SRGB, color );
|
||||
|
||||
const float hdrGamma = 2.2;
|
||||
float gamma = hdrGamma;
|
||||
|
@ -99,15 +99,33 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float Ymax = hdrMaxLuminance;
|
||||
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
// advanced Reinhard operator, artistically desirable to burn out bright areas
|
||||
float L = Yr * ( 1.0 + Yr / ( Ymax * Ymax ) ) / ( 1.0 + Yr );
|
||||
color.rgb *= L;
|
||||
|
||||
// http://freespace.virgin.net/hugo.elias/graphics/x_posure.htm
|
||||
// exponential tone mapper that is very similar to the Uncharted one
|
||||
// very good in keeping the colors natural
|
||||
//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 ) );
|
||||
|
||||
#else
|
||||
// Uncharted 2 tone mapper but looks weird :(
|
||||
// Uncharted 2 tone mapping based on Kodak film curve
|
||||
|
||||
float exposure = ( hdrKey / hdrAverageLuminance ) * 0.4;
|
||||
//float exposure = ( hdrKey / hdrAverageLuminance ) * 0.2;
|
||||
//float exposure = Yr * 1.0;
|
||||
float exposure = 1.0;
|
||||
float3 exposedColor = exposure * color.rgb;
|
||||
|
||||
float3 curr = Uncharted2Tonemap( exposedColor );
|
||||
|
@ -144,7 +162,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
#if defined(HDR_DEBUG)
|
||||
//color = tex2D( samp1, float2( L, 0.0 ) );
|
||||
color = tex2D( samp1, float2( dot( LUMINANCE_VECTOR, color ), 0.0 ) );
|
||||
color = tex2D( samp1, float2( dot( LUMINANCE_SRGB, color ), 0.0 ) );
|
||||
#endif
|
||||
|
||||
result.color = color;
|
||||
|
|
|
@ -400,6 +400,7 @@ file(GLOB RENDERER_JOBS_STATICSHADOWVOLUME_INCLUDES renderer/jobs/staticshadowvo
|
|||
file(GLOB RENDERER_JOBS_STATICSHADOWVOLUME_SOURCES renderer/jobs/staticshadowvolume/*.cpp)
|
||||
file(GLOB RENDERER_OPENGL_INCLUDES renderer/OpenGL/*.h)
|
||||
file(GLOB RENDERER_OPENGL_SOURCES renderer/OpenGL/*.cpp)
|
||||
file(GLOB RENDERER_SMAA_INCLUDES renderer/SMAA/*.h)
|
||||
|
||||
file(GLOB IRRXML_INCLUDES libs/irrxml/src/*.h)
|
||||
file(GLOB IRRXML_SOURCES libs/irrxml/src/*.cpp)
|
||||
|
@ -988,6 +989,8 @@ source_group("renderer\\jobs\\staticshadowvolume" FILES ${RENDERER_JOBS_STATICSH
|
|||
source_group("renderer\\OpenGL" FILES ${RENDERER_OPENGL_INCLUDES})
|
||||
source_group("renderer\\OpenGL" FILES ${RENDERER_OPENGL_SOURCES})
|
||||
|
||||
source_group("renderer\\SMAA" FILES ${RENDERER_SMAA_INCLUDES})
|
||||
|
||||
source_group("libs\\irrxml" FILES ${IRRXML_INCLUDES})
|
||||
source_group("libs\\irrxml" FILES ${IRRXML_SOURCES})
|
||||
|
||||
|
@ -1150,6 +1153,7 @@ set(RBDOOM3_INCLUDES
|
|||
${RENDERER_JOBS_PRELIGHTSHADOWVOLUME_INCLUDES}
|
||||
${RENDERER_JOBS_STATICSHADOWVOLUME_INCLUDES}
|
||||
${RENDERER_OPENGL_INCLUDES}
|
||||
${RENDERER_SMAA_INCLUDES}
|
||||
#${IRRXML_INCLUDES}
|
||||
${JPEG_INCLUDES}
|
||||
${PNG_INCLUDES}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
astyle.exe -v --formatted --options=astyle-options.ini --exclude="libs" --recursive *.h
|
||||
astyle.exe -v --formatted --options=astyle-options.ini --exclude="libs" --exclude="d3xp/gamesys/SysCvar.cpp" --exclude="d3xp/gamesys/Callbacks.cpp" --exclude="sys/win32/win_cpu.cpp" --exclude="sys/win32/win_main.cpp" --recursive *.cpp
|
||||
astyle.exe -v -Q --options=astyle-options.ini ../base/renderprogs/postprocess.pixel
|
||||
|
||||
pause
|
|
@ -40,7 +40,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
// RB: changed home folder so we don't break the savegame of the original game
|
||||
#define SAVE_PATH "\\id Software\\RBDOOM 3 BFG"
|
||||
|
||||
#define ENGINE_VERSION "RBDOOM 3 BFG 1.0.3" // printed in console
|
||||
#define ENGINE_VERSION "RBDOOM 3 BFG 1.1.0" // printed in console
|
||||
// RB end
|
||||
|
||||
#define BASE_GAMEDIR "base"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2014 Robert Beckebans
|
||||
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").
|
||||
|
||||
|
@ -100,6 +100,7 @@ void Framebuffer::Init()
|
|||
globalFramebuffers.hdrFBO = new Framebuffer( "_hdr", glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
globalFramebuffers.hdrFBO->Bind();
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
if( r_multiSamples.GetBool() )
|
||||
{
|
||||
globalFramebuffers.hdrFBO->AddColorBuffer( GL_RGBA16F, 0, r_multiSamples.GetInteger() );
|
||||
|
@ -109,6 +110,7 @@ void Framebuffer::Init()
|
|||
globalFramebuffers.hdrFBO->AttachImageDepth( GL_TEXTURE_2D_MULTISAMPLE, globalImages->currentDepthImage );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
globalFramebuffers.hdrFBO->AddColorBuffer( GL_RGBA16F, 0 );
|
||||
globalFramebuffers.hdrFBO->AddDepthBuffer( GL_DEPTH24_STENCIL8 );
|
||||
|
@ -120,7 +122,7 @@ void Framebuffer::Init()
|
|||
globalFramebuffers.hdrFBO->Check();
|
||||
|
||||
// HDR no MSAA
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
globalFramebuffers.hdrNonMSAAFBO = new Framebuffer( "_hdrNoMSAA", glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
globalFramebuffers.hdrNonMSAAFBO->Bind();
|
||||
|
||||
|
@ -128,6 +130,7 @@ void Framebuffer::Init()
|
|||
globalFramebuffers.hdrNonMSAAFBO->AttachImage2D( GL_TEXTURE_2D, globalImages->currentRenderHDRImageNoMSAA, 0 );
|
||||
|
||||
globalFramebuffers.hdrNonMSAAFBO->Check();
|
||||
#endif
|
||||
|
||||
// HDR DOWNSCALE
|
||||
|
||||
|
@ -150,6 +153,19 @@ void Framebuffer::Init()
|
|||
globalFramebuffers.bloomRenderFBO[i]->Check();
|
||||
}
|
||||
|
||||
// SMSAA
|
||||
globalFramebuffers.smaaEdgesFBO = new Framebuffer( "_smaaEdges", glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
globalFramebuffers.smaaEdgesFBO->Bind();
|
||||
globalFramebuffers.smaaEdgesFBO->AddColorBuffer( GL_RGBA8, 0 );
|
||||
globalFramebuffers.smaaEdgesFBO->AttachImage2D( GL_TEXTURE_2D, globalImages->smaaEdgesImage, 0 );
|
||||
globalFramebuffers.smaaEdgesFBO->Check();
|
||||
|
||||
globalFramebuffers.smaaBlendFBO = new Framebuffer( "_smaaBlend", glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
globalFramebuffers.smaaBlendFBO->Bind();
|
||||
globalFramebuffers.smaaBlendFBO->AddColorBuffer( GL_RGBA8, 0 );
|
||||
globalFramebuffers.smaaBlendFBO->AttachImage2D( GL_TEXTURE_2D, globalImages->smaaBlendImage, 0 );
|
||||
globalFramebuffers.smaaBlendFBO->Check();
|
||||
|
||||
Unbind();
|
||||
}
|
||||
|
||||
|
@ -163,6 +179,7 @@ void Framebuffer::CheckFramebuffers()
|
|||
globalImages->currentRenderHDRImage->Resize( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
globalImages->currentDepthImage->Resize( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
if( r_multiSamples.GetBool() )
|
||||
{
|
||||
globalImages->currentRenderHDRImageNoMSAA->Resize( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
|
@ -176,6 +193,7 @@ void Framebuffer::CheckFramebuffers()
|
|||
globalFramebuffers.hdrNonMSAAFBO->height = glConfig.nativeScreenHeight;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
globalFramebuffers.hdrFBO->Bind();
|
||||
globalFramebuffers.hdrFBO->AttachImage2D( GL_TEXTURE_2D, globalImages->currentRenderHDRImage, 0 );
|
||||
|
@ -208,6 +226,26 @@ void Framebuffer::CheckFramebuffers()
|
|||
globalFramebuffers.bloomRenderFBO[i]->Check();
|
||||
}
|
||||
|
||||
// SMAA
|
||||
|
||||
globalImages->smaaEdgesImage->Resize( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
|
||||
globalFramebuffers.smaaEdgesFBO->width = glConfig.nativeScreenWidth / 4;
|
||||
globalFramebuffers.smaaEdgesFBO->height = glConfig.nativeScreenHeight / 4;
|
||||
|
||||
globalFramebuffers.smaaEdgesFBO->Bind();
|
||||
globalFramebuffers.smaaEdgesFBO->AttachImage2D( GL_TEXTURE_2D, globalImages->smaaEdgesImage, 0 );
|
||||
globalFramebuffers.smaaEdgesFBO->Check();
|
||||
|
||||
globalImages->smaaBlendImage->Resize( glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
|
||||
globalFramebuffers.smaaBlendFBO->width = glConfig.nativeScreenWidth / 4;
|
||||
globalFramebuffers.smaaBlendFBO->height = glConfig.nativeScreenHeight / 4;
|
||||
|
||||
globalFramebuffers.smaaBlendFBO->Bind();
|
||||
globalFramebuffers.smaaBlendFBO->AttachImage2D( GL_TEXTURE_2D, globalImages->smaaBlendImage, 0 );
|
||||
globalFramebuffers.smaaBlendFBO->Check();
|
||||
|
||||
Unbind();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2014 Robert Beckebans
|
||||
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").
|
||||
|
||||
|
@ -121,10 +121,14 @@ struct globalFramebuffers_t
|
|||
{
|
||||
Framebuffer* shadowFBO[MAX_SHADOWMAP_RESOLUTIONS];
|
||||
Framebuffer* hdrFBO;
|
||||
#if defined(USE_HDR_MSAA)
|
||||
Framebuffer* hdrNonMSAAFBO;
|
||||
#endif
|
||||
// Framebuffer* hdrQuarterFBO;
|
||||
Framebuffer* hdr64FBO;
|
||||
Framebuffer* bloomRenderFBO[MAX_BLOOM_BUFFERS];
|
||||
Framebuffer* smaaEdgesFBO;
|
||||
Framebuffer* smaaBlendFBO;
|
||||
};
|
||||
extern globalFramebuffers_t globalFramebuffers;
|
||||
|
||||
|
|
|
@ -349,14 +349,22 @@ public:
|
|||
idImage* jitterImage1; // shadow jitter
|
||||
idImage* jitterImage4;
|
||||
idImage* jitterImage16;
|
||||
idImage* grainImage1;
|
||||
idImage* randomImage256;
|
||||
idImage* currentRenderHDRImage;
|
||||
#if defined(USE_HDR_MSAA)
|
||||
idImage* currentRenderHDRImageNoMSAA;
|
||||
#endif
|
||||
idImage* currentRenderHDRImageQuarter;
|
||||
idImage* currentRenderHDRImage64;
|
||||
idImage* bloomRender[2];
|
||||
idImage* heatmap5Image;
|
||||
idImage* heatmap7Image;
|
||||
idImage* smaaInputImage;
|
||||
idImage* smaaAreaImage;
|
||||
idImage* smaaSearchImage;
|
||||
idImage* smaaEdgesImage;
|
||||
idImage* smaaBlendImage;
|
||||
// RB end
|
||||
idImage* scratchImage;
|
||||
idImage* scratchImage2;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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-2015 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -32,6 +32,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#include "tr_local.h"
|
||||
#include "SMAA/AreaTex.h"
|
||||
#include "SMAA/SearchTex.h"
|
||||
|
||||
#define DEFAULT_SIZE 16
|
||||
|
||||
|
@ -145,10 +147,27 @@ static void R_RGBA8Image( idImage* image )
|
|||
image->GenerateImage( ( byte* )data, DEFAULT_SIZE, DEFAULT_SIZE, TF_DEFAULT, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
static void R_RGBA8LinearImage( idImage* image )
|
||||
{
|
||||
byte data[DEFAULT_SIZE][DEFAULT_SIZE][4];
|
||||
|
||||
memset( data, 0, sizeof( data ) );
|
||||
data[0][0][0] = 16;
|
||||
data[0][0][1] = 32;
|
||||
data[0][0][2] = 48;
|
||||
data[0][0][3] = 96;
|
||||
|
||||
image->GenerateImage( ( byte* )data, DEFAULT_SIZE, DEFAULT_SIZE, TF_LINEAR, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
static void R_DepthImage( idImage* image )
|
||||
{
|
||||
// RB: NULL data and MSAA support
|
||||
#if defined(USE_HDR_MSAA)
|
||||
int msaaSamples = r_multiSamples.GetInteger();
|
||||
#else
|
||||
int msaaSamples = 0;
|
||||
#endif
|
||||
image->GenerateImage( NULL, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight, TF_NEAREST, TR_CLAMP, TD_DEPTH, msaaSamples );
|
||||
// RB end
|
||||
}
|
||||
|
@ -156,7 +175,11 @@ static void R_DepthImage( idImage* image )
|
|||
// RB begin
|
||||
static void R_HDR_RGBA16FImage_ResNative( idImage* image )
|
||||
{
|
||||
#if defined(USE_HDR_MSAA)
|
||||
int msaaSamples = r_multiSamples.GetInteger();
|
||||
#else
|
||||
int msaaSamples = 0;
|
||||
#endif
|
||||
image->GenerateImage( NULL, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight, TF_NEAREST, TR_CLAMP, TD_RGBA16F, msaaSamples );
|
||||
}
|
||||
|
||||
|
@ -179,6 +202,11 @@ static void R_HDR_RGBA16FImage_Res64( idImage* image )
|
|||
{
|
||||
image->GenerateImage( NULL, 64, 64, TF_NEAREST, TR_CLAMP, TD_RGBA16F );
|
||||
}
|
||||
|
||||
static void R_SMAAImage_ResNative( idImage* image )
|
||||
{
|
||||
image->GenerateImage( NULL, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight, TF_LINEAR, TR_CLAMP, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
// RB end
|
||||
|
||||
static void R_AlphaNotchImage( idImage* image )
|
||||
|
@ -589,6 +617,8 @@ static void R_CreateRandom256Image( idImage* image )
|
|||
image->GenerateImage( ( byte* )data, 256, 256, TF_NEAREST, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void R_CreateHeatmap5ColorsImage( idImage* image )
|
||||
{
|
||||
int x, y;
|
||||
|
@ -690,6 +720,93 @@ static void R_CreateHeatmap7ColorsImage( idImage* image )
|
|||
|
||||
image->GenerateImage( ( byte* )data, FALLOFF_TEXTURE_SIZE, 16, TF_LINEAR, TR_CLAMP, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
static void R_CreateGrainImage1( idImage* image )
|
||||
{
|
||||
const static int GRAIN_SIZE = 128;
|
||||
|
||||
static byte data[GRAIN_SIZE][GRAIN_SIZE][4];
|
||||
|
||||
idRandom2 random( Sys_Milliseconds() );
|
||||
|
||||
for( int i = 0 ; i < GRAIN_SIZE ; i++ )
|
||||
{
|
||||
for( int j = 0 ; j < GRAIN_SIZE ; j++ )
|
||||
{
|
||||
#if 0
|
||||
//int value = 127 - 8 + ( rand() & 15 ); //random.RandomInt( 127 );
|
||||
int value = 127 - 8 + random.RandomInt( 15 );
|
||||
|
||||
data[i][j][0] = value;
|
||||
data[i][j][1] = value;
|
||||
data[i][j][2] = value;
|
||||
data[i][j][3] = 0;
|
||||
#else
|
||||
data[i][j][0] = 127 - 8 + random.RandomInt( 15 );
|
||||
data[i][j][1] = 127 - 8 + random.RandomInt( 15 );
|
||||
data[i][j][2] = 127 - 8 + random.RandomInt( 15 );
|
||||
data[i][j][3] = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
image->GenerateImage( ( byte* )data, GRAIN_SIZE, GRAIN_SIZE, TF_NEAREST, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
static void R_CreateSMAAAreaImage( idImage* image )
|
||||
{
|
||||
static byte data[AREATEX_HEIGHT][AREATEX_WIDTH][4];
|
||||
|
||||
idRandom2 random( Sys_Milliseconds() );
|
||||
|
||||
for( int x = 0; x < AREATEX_WIDTH; x++ )
|
||||
{
|
||||
for( int y = 0; y < AREATEX_HEIGHT; y++ )
|
||||
{
|
||||
#if 0
|
||||
data[AREATEX_HEIGHT - y][x][0] = areaTexBytes[ y * AREATEX_PITCH + x * 2 + 0 ];
|
||||
data[AREATEX_HEIGHT - y][x][1] = areaTexBytes[ y * AREATEX_PITCH + x * 2 + 1 ];
|
||||
data[AREATEX_HEIGHT - y][x][2] = 0;
|
||||
data[AREATEX_HEIGHT - y][x][3] = 1;
|
||||
#else
|
||||
data[y][x][0] = areaTexBytes[ y * AREATEX_PITCH + x * 2 + 0 ];
|
||||
data[y][x][1] = areaTexBytes[ y * AREATEX_PITCH + x * 2 + 1 ];
|
||||
data[y][x][2] = 0;
|
||||
data[y][x][3] = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
image->GenerateImage( ( byte* )data, AREATEX_WIDTH, AREATEX_HEIGHT, TF_LINEAR, TR_CLAMP, TD_LOOKUP_TABLE_RGBA );
|
||||
}
|
||||
|
||||
static void R_CreateSMAASearchImage( idImage* image )
|
||||
{
|
||||
static byte data[SEARCHTEX_HEIGHT][SEARCHTEX_WIDTH][4];
|
||||
|
||||
idRandom2 random( Sys_Milliseconds() );
|
||||
|
||||
for( int x = 0; x < SEARCHTEX_WIDTH; x++ )
|
||||
{
|
||||
for( int y = 0; y < SEARCHTEX_HEIGHT; y++ )
|
||||
{
|
||||
#if 0
|
||||
data[SEARCHTEX_HEIGHT - y][x][0] = searchTexBytes[ y * SEARCHTEX_PITCH + x ];
|
||||
data[SEARCHTEX_HEIGHT - y][x][1] = 0;
|
||||
data[SEARCHTEX_HEIGHT - y][x][2] = 0;
|
||||
data[SEARCHTEX_HEIGHT - y][x][3] = 1;
|
||||
#else
|
||||
data[y][x][0] = searchTexBytes[ y * SEARCHTEX_PITCH + x ];
|
||||
data[y][x][1] = 0;
|
||||
data[y][x][2] = 0;
|
||||
data[y][x][3] = 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
image->GenerateImage( ( byte* )data, SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, TF_LINEAR, TR_CLAMP, TD_LOOKUP_TABLE_MONO );
|
||||
}
|
||||
|
||||
// RB end
|
||||
|
||||
/*
|
||||
|
@ -724,7 +841,9 @@ void idImageManager::CreateIntrinsicImages()
|
|||
randomImage256 = globalImages->ImageFromFunction( "_random256", R_CreateRandom256Image );
|
||||
|
||||
currentRenderHDRImage = globalImages->ImageFromFunction( "_currentRenderHDR", R_HDR_RGBA16FImage_ResNative );
|
||||
#if defined(USE_HDR_MSAA)
|
||||
currentRenderHDRImageNoMSAA = globalImages->ImageFromFunction( "_currentRenderHDRNoMSAA", R_HDR_RGBA16FImage_ResNative_NoMSAA );
|
||||
#endif
|
||||
currentRenderHDRImageQuarter = globalImages->ImageFromFunction( "_currentRenderHDRQuarter", R_HDR_RGBA16FImage_ResQuarter );
|
||||
currentRenderHDRImage64 = globalImages->ImageFromFunction( "_currentRenderHDR64", R_HDR_RGBA16FImage_Res64 );
|
||||
|
||||
|
@ -733,6 +852,16 @@ void idImageManager::CreateIntrinsicImages()
|
|||
|
||||
heatmap5Image = ImageFromFunction( "_heatmap5", R_CreateHeatmap5ColorsImage );
|
||||
heatmap7Image = ImageFromFunction( "_heatmap7", R_CreateHeatmap7ColorsImage );
|
||||
|
||||
grainImage1 = globalImages->ImageFromFunction( "_grain1", R_CreateGrainImage1 );
|
||||
|
||||
smaaInputImage = ImageFromFunction( "_smaaInput", R_RGBA8LinearImage );
|
||||
|
||||
smaaAreaImage = globalImages->ImageFromFunction( "_smaaArea", R_CreateSMAAAreaImage );
|
||||
smaaSearchImage = globalImages->ImageFromFunction( "_smaaSearch", R_CreateSMAASearchImage );
|
||||
|
||||
smaaEdgesImage = globalImages->ImageFromFunction( "_smaaEdges", R_SMAAImage_ResNative );
|
||||
smaaBlendImage = globalImages->ImageFromFunction( "_smaaBlend", R_SMAAImage_ResNative );
|
||||
// RB end
|
||||
|
||||
// scratchImage is used for screen wipes/doublevision etc..
|
||||
|
|
|
@ -730,6 +730,7 @@ void idImage::CopyFramebuffer( int x, int y, int imageWidth, int imageHeight )
|
|||
|
||||
//if( backEnd.glState.currentFramebuffer != NULL && backEnd.glState.currentFramebuffer->IsMultiSampled() )
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
if( globalFramebuffers.hdrFBO->IsMultiSampled() )
|
||||
{
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, globalFramebuffers.hdrFBO->GetFramebuffer() );
|
||||
|
@ -746,6 +747,7 @@ void idImage::CopyFramebuffer( int x, int y, int imageWidth, int imageHeight )
|
|||
globalFramebuffers.hdrFBO->Bind();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glCopyTexImage2D( target, 0, GL_RGBA16F, x, y, imageWidth, imageHeight, 0 );
|
||||
}
|
||||
|
|
|
@ -95,6 +95,8 @@ void idRenderProgManager::Init()
|
|||
// RB begin
|
||||
{ BUILTIN_COLOR_SKINNED, "color", "_skinned", BIT( USE_GPU_SKINNING ), true },
|
||||
{ BUILTIN_VERTEX_COLOR, "vertex_color.vfp", "", 0, false },
|
||||
{ BUILTIN_AMBIENT_LIGHTING, "ambient_lighting", "", 0, false },
|
||||
{ BUILTIN_AMBIENT_LIGHTING_SKINNED, "ambient_lighting", "_skinned", BIT( USE_GPU_SKINNING ), true },
|
||||
// RB end
|
||||
// { BUILTIN_SIMPLESHADE, "simpleshade.vfp", 0, false },
|
||||
{ BUILTIN_TEXTURED, "texture.vfp", 0, false },
|
||||
|
@ -139,6 +141,10 @@ void idRenderProgManager::Init()
|
|||
{ BUILTIN_BRIGHTPASS, "tonemap", "_brightpass", BIT( BRIGHTPASS ), false },
|
||||
{ BUILTIN_HDR_GLARE_CHROMATIC, "hdr_glare_chromatic", "", 0, false },
|
||||
{ BUILTIN_HDR_DEBUG, "tonemap", "_debug", BIT( HDR_DEBUG ), false },
|
||||
|
||||
{ BUILTIN_SMAA_EDGE_DETECTION, "SMAA_edge_detection", "", 0, false },
|
||||
{ BUILTIN_SMAA_BLENDING_WEIGHT_CALCULATION, "SMAA_blending_weight_calc", "", 0, false },
|
||||
{ BUILTIN_SMAA_NEIGHBORHOOD_BLENDING, "SMAA_final", "", 0, false },
|
||||
// RB end
|
||||
{ BUILTIN_STEREO_DEGHOST, "stereoDeGhost.vfp", 0, false },
|
||||
{ BUILTIN_STEREO_WARP, "stereoWarp.vfp", 0, false },
|
||||
|
@ -233,6 +239,7 @@ void idRenderProgManager::Init()
|
|||
vertexShaders[builtinShaders[BUILTIN_SHADOW_DEBUG_SKINNED]].usesJoints = true;
|
||||
vertexShaders[builtinShaders[BUILTIN_FOG_SKINNED]].usesJoints = true;
|
||||
// RB begin
|
||||
vertexShaders[builtinShaders[BUILTIN_AMBIENT_LIGHTING_SKINNED]].usesJoints = true;
|
||||
vertexShaders[builtinShaders[BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED]].usesJoints = true;
|
||||
vertexShaders[builtinShaders[BUILTIN_INTERACTION_SHADOW_MAPPING_POINT_SKINNED]].usesJoints = true;
|
||||
vertexShaders[builtinShaders[BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED]].usesJoints = true;
|
||||
|
|
|
@ -211,6 +211,16 @@ public:
|
|||
{
|
||||
BindShader_Builtin( BUILTIN_VERTEX_COLOR );
|
||||
}
|
||||
|
||||
void BindShader_AmbientLighting()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_AMBIENT_LIGHTING );
|
||||
}
|
||||
|
||||
void BindShader_AmbientLightingSkinned()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_AMBIENT_LIGHTING_SKINNED );
|
||||
}
|
||||
// RB end
|
||||
|
||||
void BindShader_Texture( )
|
||||
|
@ -418,6 +428,21 @@ public:
|
|||
BindShader_Builtin( BUILTIN_HDR_DEBUG );
|
||||
}
|
||||
|
||||
void BindShader_SMAA_EdgeDetection()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_SMAA_EDGE_DETECTION );
|
||||
}
|
||||
|
||||
void BindShader_SMAA_BlendingWeightCalculation()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_SMAA_BLENDING_WEIGHT_CALCULATION );
|
||||
}
|
||||
|
||||
void BindShader_SMAA_NeighborhoodBlending()
|
||||
{
|
||||
BindShader_Builtin( BUILTIN_SMAA_NEIGHBORHOOD_BLENDING );
|
||||
}
|
||||
|
||||
#if 0
|
||||
void BindShader_ZCullReconstruct()
|
||||
{
|
||||
|
@ -490,6 +515,8 @@ protected:
|
|||
// RB begin
|
||||
BUILTIN_COLOR_SKINNED,
|
||||
BUILTIN_VERTEX_COLOR,
|
||||
BUILTIN_AMBIENT_LIGHTING,
|
||||
BUILTIN_AMBIENT_LIGHTING_SKINNED,
|
||||
// RB end
|
||||
BUILTIN_SIMPLESHADE,
|
||||
BUILTIN_TEXTURED,
|
||||
|
@ -532,6 +559,10 @@ protected:
|
|||
BUILTIN_BRIGHTPASS,
|
||||
BUILTIN_HDR_GLARE_CHROMATIC,
|
||||
BUILTIN_HDR_DEBUG,
|
||||
|
||||
BUILTIN_SMAA_EDGE_DETECTION,
|
||||
BUILTIN_SMAA_BLENDING_WEIGHT_CALCULATION,
|
||||
BUILTIN_SMAA_NEIGHBORHOOD_BLENDING,
|
||||
// RB end
|
||||
BUILTIN_STEREO_DEGHOST,
|
||||
BUILTIN_STEREO_WARP,
|
||||
|
|
|
@ -560,6 +560,11 @@ idStr StripDeadCode( const idStr& in, const char* name, const idStrList& compile
|
|||
src.AddDefine( "USE_SRGB" );
|
||||
}
|
||||
|
||||
// SMAA configuration
|
||||
src.AddDefine( "SMAA_GLSL_3" );
|
||||
src.AddDefine( "SMAA_RT_METRICS rpScreenCorrectionFactor " );
|
||||
src.AddDefine( "SMAA_PRESET_HIGH" );
|
||||
|
||||
idList< idCGBlock > blocks;
|
||||
|
||||
blocks.SetNum( 100 );
|
||||
|
|
|
@ -246,16 +246,19 @@ idCVar r_shadowMapSunDepthBiasScale( "r_shadowMapSunDepthBiasScale", "0.999991",
|
|||
|
||||
// RB: HDR parameters
|
||||
idCVar r_useHDR( "r_useHDR", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "use high dynamic range rendering" );
|
||||
idCVar r_hdrMinLuminance( "r_hdrMinLuminance", "0.001", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrMaxLuminance( "r_hdrMaxLuminance", "3000", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrKey( "r_hdrKey", "0.18", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrContrastThreshold( "r_hdrContrastThreshold", "20", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrContrastOffset( "r_hdrContrastOffset", "3", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrGlarePasses( "r_hdrGlarePasses", "4", CVAR_RENDERER | CVAR_INTEGER, "" );
|
||||
idCVar r_hdrDebug( "r_hdrDebug", "0", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrMinLuminance( "r_hdrMinLuminance", "0.05", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrMaxLuminance( "r_hdrMaxLuminance", "300", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrKey( "r_hdrKey", "0.5", CVAR_RENDERER | CVAR_FLOAT, "mid-gray 0.5 in linear RGB space (without gamma curve applied)" );
|
||||
idCVar r_hdrContrastThreshold( "r_hdrContrastThreshold", "13", CVAR_RENDERER | CVAR_FLOAT, "all pixels brighter than this cause HDR bloom glares" );
|
||||
idCVar r_hdrContrastOffset( "r_hdrContrastOffset", "100", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrGlarePasses( "r_hdrGlarePasses", "8", CVAR_RENDERER | CVAR_INTEGER, "how many times the bloom blur is rendered offscreen. number should be even" );
|
||||
idCVar r_hdrDebug( "r_hdrDebug", "0", CVAR_RENDERER | CVAR_FLOAT, "show scene luminance as heat map" );
|
||||
|
||||
idCVar r_ldrContrastThreshold( "r_ldrContrastThreshold", "1.1", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_ldrContrastOffset( "r_ldrContrastOffset", "3", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
|
||||
idCVar r_useFilmicPostProcessEffects( "r_useFilmicPostProcessEffects", "1", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "apply several post process effects to mimic a filmic look" );
|
||||
idCVar r_forceAmbient( "r_forceAmbient", "0.2", CVAR_RENDERER | CVAR_FLOAT, "render additional ambient pass to make the game less dark", 0.0f, 0.4f );
|
||||
// RB end
|
||||
|
||||
const char* fileExten[3] = { "tga", "png", "jpg" };
|
||||
|
|
14981
neo/renderer/SMAA/AreaTex.h
Normal file
14981
neo/renderer/SMAA/AreaTex.h
Normal file
File diff suppressed because it is too large
Load diff
133
neo/renderer/SMAA/SearchTex.h
Normal file
133
neo/renderer/SMAA/SearchTex.h
Normal file
|
@ -0,0 +1,133 @@
|
|||
/**
|
||||
* Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com)
|
||||
* Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com)
|
||||
* Copyright (C) 2013 Belen Masia (bmasia@unizar.es)
|
||||
* Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com)
|
||||
* Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished to
|
||||
* do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software. As clarification, there
|
||||
* is no requirement that the copyright notice and permission be included in
|
||||
* binary distributions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SEARCHTEX_H
|
||||
#define SEARCHTEX_H
|
||||
|
||||
#define SEARCHTEX_WIDTH 64
|
||||
#define SEARCHTEX_HEIGHT 16
|
||||
#define SEARCHTEX_PITCH SEARCHTEX_WIDTH
|
||||
#define SEARCHTEX_SIZE (SEARCHTEX_HEIGHT * SEARCHTEX_PITCH)
|
||||
|
||||
/**
|
||||
* Stored in R8 format. Load it in the following format:
|
||||
* - DX9: D3DFMT_L8
|
||||
* - DX10: DXGI_FORMAT_R8_UNORM
|
||||
*/
|
||||
static const unsigned char searchTexBytes[] =
|
||||
{
|
||||
0xfe, 0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x7f, 0x7f,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00,
|
||||
0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0xfe, 0x7f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xfe,
|
||||
0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f,
|
||||
0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xfe, 0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x7f, 0x7f,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00,
|
||||
0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0xfe, 0x7f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xfe,
|
||||
0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f,
|
||||
0x7f, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x7f,
|
||||
0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f,
|
||||
0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f,
|
||||
0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00,
|
||||
0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x7f,
|
||||
0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f,
|
||||
0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f,
|
||||
0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00,
|
||||
0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
#endif
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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-2015 Robert Beckebans
|
||||
Copyright (C) 2014 Carl Kenner
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
@ -1737,6 +1737,338 @@ static void RB_RenderInteractions( const drawSurf_t* surfList, const viewLight_t
|
|||
renderProgManager.Unbind();
|
||||
}
|
||||
|
||||
// RB begin
|
||||
|
||||
/*
|
||||
=========================================================================================
|
||||
|
||||
AMBIENT PASS RENDERING
|
||||
|
||||
=========================================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
==================
|
||||
RB_AmbientPass
|
||||
==================
|
||||
*/
|
||||
static void RB_AmbientPass( const drawSurf_t* const* drawSurfs, int numDrawSurfs )
|
||||
{
|
||||
if( r_forceAmbient.GetFloat() <= 0 || r_skipAmbient.GetBool() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( numDrawSurfs == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// if we are just doing 2D rendering, no need to fill the depth buffer
|
||||
if( backEnd.viewDef->viewEntitys == NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_FILL_DEPTH_BUFFER );
|
||||
renderLog.OpenBlock( "RB_AmbientPassFast" );
|
||||
|
||||
// RB: not needed
|
||||
// GL_StartDepthPass( backEnd.viewDef->scissor );
|
||||
|
||||
// force MVP change on first surface
|
||||
backEnd.currentSpace = NULL;
|
||||
|
||||
// draw all the subview surfaces, which will already be at the start of the sorted list,
|
||||
// with the general purpose path
|
||||
//GL_State( GLS_DEFAULT );
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHMASK | GLS_DEPTHFUNC_EQUAL );
|
||||
|
||||
const float lightScale = 1.0f; //r_lightScale.GetFloat();
|
||||
const idVec4 lightColor = colorWhite * lightScale;
|
||||
// apply the world-global overbright and the 2x factor for specular
|
||||
const idVec4 diffuseColor = lightColor;
|
||||
const idVec4 specularColor = lightColor * 2.0f;
|
||||
|
||||
// setup renderparms assuming we will be drawing trivial surfaces first
|
||||
RB_SetupForFastPathInteractions( diffuseColor, specularColor );
|
||||
|
||||
for( int i = 0; i < numDrawSurfs; i++ )
|
||||
{
|
||||
const drawSurf_t* drawSurf = drawSurfs[i];
|
||||
const idMaterial* surfaceMaterial = drawSurf->material;
|
||||
|
||||
// translucent surfaces don't put anything in the depth buffer and don't
|
||||
// test against it, which makes them fail the mirror clip plane operation
|
||||
if( surfaceMaterial->Coverage() == MC_TRANSLUCENT )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// get the expressions for conditionals / color / texcoords
|
||||
const float* surfaceRegs = drawSurf->shaderRegisters;
|
||||
|
||||
// if all stages of a material have been conditioned off, don't do anything
|
||||
int stage = 0;
|
||||
for( ; stage < surfaceMaterial->GetNumStages(); stage++ )
|
||||
{
|
||||
const shaderStage_t* pStage = surfaceMaterial->GetStage( stage );
|
||||
// check the stage enable condition
|
||||
if( surfaceRegs[ pStage->conditionRegister ] != 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( stage == surfaceMaterial->GetNumStages() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isWorldModel = ( drawSurf->space->entityDef->parms.origin == vec3_origin );
|
||||
|
||||
//if( isWorldModel )
|
||||
//{
|
||||
// renderProgManager.BindShader_VertexLighting();
|
||||
//}
|
||||
//else
|
||||
{
|
||||
// take lighting from grid
|
||||
if( drawSurf->jointCache )
|
||||
{
|
||||
renderProgManager.BindShader_AmbientLightingSkinned();
|
||||
}
|
||||
else
|
||||
{
|
||||
renderProgManager.BindShader_AmbientLighting();
|
||||
}
|
||||
}
|
||||
|
||||
// change the matrix if needed
|
||||
if( drawSurf->space != backEnd.currentSpace )
|
||||
{
|
||||
backEnd.currentSpace = drawSurf->space;
|
||||
|
||||
RB_SetMVP( drawSurf->space->mvp );
|
||||
|
||||
// tranform the view origin into model local space
|
||||
idVec4 localViewOrigin( 1.0f );
|
||||
R_GlobalPointToLocal( drawSurf->space->modelMatrix, backEnd.viewDef->renderView.vieworg, localViewOrigin.ToVec3() );
|
||||
SetVertexParm( RENDERPARM_LOCALVIEWORIGIN, localViewOrigin.ToFloatPtr() );
|
||||
|
||||
if( !isWorldModel )
|
||||
{
|
||||
// tranform the light direction into model local space
|
||||
idVec3 globalLightDirection( 0.0f, 0.0f, -1.0f ); // HACK
|
||||
idVec4 localLightDirection( 0.0f );
|
||||
R_GlobalVectorToLocal( drawSurf->space->modelMatrix, globalLightDirection, localLightDirection.ToVec3() );
|
||||
|
||||
SetVertexParm( RENDERPARM_LOCALLIGHTORIGIN, localLightDirection.ToFloatPtr() );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if( !isWorldModel )
|
||||
{
|
||||
idVec4 directedColor;
|
||||
directedColor.x = drawSurf->space->gridDirectedLight.x;
|
||||
directedColor.y = drawSurf->space->gridDirectedLight.y;
|
||||
directedColor.z = drawSurf->space->gridDirectedLight.z;
|
||||
directedColor.w = 1;
|
||||
|
||||
idVec4 ambientColor;
|
||||
ambientColor.x = drawSurf->space->gridAmbientLight.x;
|
||||
ambientColor.y = drawSurf->space->gridAmbientLight.y;
|
||||
ambientColor.z = drawSurf->space->gridAmbientLight.z;
|
||||
ambientColor.w = 1;
|
||||
|
||||
renderProgManager.SetRenderParm( RENDERPARM_COLOR, directedColor.ToFloatPtr() );
|
||||
renderProgManager.SetRenderParm( RENDERPARM_AMBIENT_COLOR, ambientColor.ToFloatPtr() );
|
||||
}
|
||||
#else
|
||||
idVec4 ambientColor;
|
||||
float ambientBoost = r_useHDR.GetBool() ? 1.5 : 1.0;
|
||||
ambientColor.x = r_forceAmbient.GetFloat();
|
||||
ambientColor.y = r_forceAmbient.GetFloat();
|
||||
ambientColor.z = r_forceAmbient.GetFloat();
|
||||
ambientColor.w = 1;
|
||||
|
||||
renderProgManager.SetRenderParm( RENDERPARM_AMBIENT_COLOR, ambientColor.ToFloatPtr() );
|
||||
#endif
|
||||
|
||||
/*
|
||||
uint64 surfGLState = 0;
|
||||
|
||||
// set polygon offset if necessary
|
||||
if( surfaceMaterial->TestMaterialFlag( MF_POLYGONOFFSET ) )
|
||||
{
|
||||
surfGLState |= GLS_POLYGON_OFFSET;
|
||||
GL_PolygonOffset( r_offsetFactor.GetFloat(), r_offsetUnits.GetFloat() * surfaceMaterial->GetPolygonOffset() );
|
||||
}
|
||||
|
||||
// subviews will just down-modulate the color buffer
|
||||
idVec4 color;
|
||||
if( surfaceMaterial->GetSort() == SS_SUBVIEW )
|
||||
{
|
||||
surfGLState |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO | GLS_DEPTHFUNC_LESS;
|
||||
color[0] = 1.0f;
|
||||
color[1] = 1.0f;
|
||||
color[2] = 1.0f;
|
||||
color[3] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// others just draw black
|
||||
#if 0
|
||||
color[0] = 0.0f;
|
||||
color[1] = 0.0f;
|
||||
color[2] = 0.0f;
|
||||
color[3] = 1.0f;
|
||||
#else
|
||||
color = colorWhite;
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
// check for the fast path
|
||||
if( surfaceMaterial->GetFastPathBumpImage() && !r_skipInteractionFastPath.GetBool() )
|
||||
{
|
||||
renderLog.OpenBlock( surfaceMaterial->GetName() );
|
||||
|
||||
// texture 0 will be the per-surface bump map
|
||||
GL_SelectTexture( INTERACTION_TEXUNIT_BUMP );
|
||||
surfaceMaterial->GetFastPathBumpImage()->Bind();
|
||||
|
||||
// texture 3 is the per-surface diffuse map
|
||||
GL_SelectTexture( INTERACTION_TEXUNIT_DIFFUSE );
|
||||
surfaceMaterial->GetFastPathDiffuseImage()->Bind();
|
||||
|
||||
// texture 4 is the per-surface specular map
|
||||
GL_SelectTexture( INTERACTION_TEXUNIT_SPECULAR );
|
||||
surfaceMaterial->GetFastPathSpecularImage()->Bind();
|
||||
|
||||
RB_DrawElementsWithCounters( drawSurf );
|
||||
|
||||
renderLog.CloseBlock();
|
||||
continue;
|
||||
}
|
||||
|
||||
renderLog.OpenBlock( surfaceMaterial->GetName() );
|
||||
|
||||
//bool drawSolid = false;
|
||||
|
||||
|
||||
// we may have multiple alpha tested stages
|
||||
// if the only alpha tested stages are condition register omitted,
|
||||
// draw a normal opaque surface
|
||||
bool didDraw = false;
|
||||
|
||||
drawInteraction_t inter = {};
|
||||
inter.surf = drawSurf;
|
||||
inter.bumpImage = NULL;
|
||||
inter.specularImage = NULL;
|
||||
inter.diffuseImage = NULL;
|
||||
|
||||
inter.diffuseColor[0] = inter.diffuseColor[1] = inter.diffuseColor[2] = inter.diffuseColor[3] = 1;
|
||||
inter.specularColor[0] = inter.specularColor[1] = inter.specularColor[2] = inter.specularColor[3] = 0;
|
||||
|
||||
// perforated surfaces may have multiple alpha tested stages
|
||||
for( stage = 0; stage < surfaceMaterial->GetNumStages(); stage++ )
|
||||
{
|
||||
const shaderStage_t* surfaceStage = surfaceMaterial->GetStage( stage );
|
||||
|
||||
switch( surfaceStage->lighting )
|
||||
{
|
||||
case SL_COVERAGE:
|
||||
{
|
||||
// ignore any coverage stages since they should only be used for the depth fill pass
|
||||
// for diffuse stages that use alpha test.
|
||||
break;
|
||||
}
|
||||
|
||||
case SL_AMBIENT:
|
||||
{
|
||||
// ignore ambient stages while drawing interactions
|
||||
break;
|
||||
}
|
||||
|
||||
case SL_BUMP:
|
||||
{
|
||||
// ignore stage that fails the condition
|
||||
if( !surfaceRegs[ surfaceStage->conditionRegister ] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
// draw any previous interaction
|
||||
if( inter.bumpImage != NULL )
|
||||
{
|
||||
RB_DrawSingleInteraction( &inter );
|
||||
}
|
||||
inter.bumpImage = surfaceStage->texture.image;
|
||||
inter.diffuseImage = NULL;
|
||||
inter.specularImage = NULL;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, NULL,
|
||||
inter.bumpMatrix, NULL );
|
||||
break;
|
||||
}
|
||||
|
||||
case SL_DIFFUSE:
|
||||
{
|
||||
// ignore stage that fails the condition
|
||||
if( !surfaceRegs[ surfaceStage->conditionRegister ] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// draw any previous interaction
|
||||
if( inter.diffuseImage != NULL )
|
||||
{
|
||||
RB_DrawSingleInteraction( &inter );
|
||||
}
|
||||
|
||||
inter.diffuseImage = surfaceStage->texture.image;
|
||||
inter.vertexColor = surfaceStage->vertexColor;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, diffuseColor.ToFloatPtr(),
|
||||
inter.diffuseMatrix, inter.diffuseColor.ToFloatPtr() );
|
||||
break;
|
||||
}
|
||||
|
||||
case SL_SPECULAR:
|
||||
{
|
||||
// ignore stage that fails the condition
|
||||
if( !surfaceRegs[ surfaceStage->conditionRegister ] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
// draw any previous interaction
|
||||
if( inter.specularImage != NULL )
|
||||
{
|
||||
RB_DrawSingleInteraction( &inter );
|
||||
}
|
||||
inter.specularImage = surfaceStage->texture.image;
|
||||
inter.vertexColor = surfaceStage->vertexColor;
|
||||
RB_SetupInteractionStage( surfaceStage, surfaceRegs, specularColor.ToFloatPtr(),
|
||||
inter.specularMatrix, inter.specularColor.ToFloatPtr() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw the final interaction
|
||||
RB_DrawSingleInteraction( &inter );
|
||||
|
||||
renderLog.CloseBlock();
|
||||
}
|
||||
|
||||
#ifdef USE_CORE_PROFILE
|
||||
SetFragmentParm( RENDERPARM_ALPHA_TEST, vec4_zero.ToFloatPtr() );
|
||||
#endif
|
||||
|
||||
renderLog.CloseBlock();
|
||||
renderLog.CloseMainBlock();
|
||||
}
|
||||
|
||||
// RB end
|
||||
|
||||
/*
|
||||
==============================================================================================
|
||||
|
||||
|
@ -3815,7 +4147,7 @@ static void RB_CalculateAdaptation()
|
|||
float avgLuminance;
|
||||
float maxLuminance;
|
||||
double sum;
|
||||
const idVec3 LUMINANCE_VECTOR( 0.2125f, 0.7154f, 0.0721f ); // FIXME be careful wether this should be linear RGB or sRGB
|
||||
const idVec3 LUMINANCE_SRGB( 0.2125f, 0.7154f, 0.0721f ); // be careful wether this should be linear RGB or sRGB
|
||||
idVec4 color;
|
||||
float newAdaptation;
|
||||
float newMaximum;
|
||||
|
@ -3838,7 +4170,7 @@ static void RB_CalculateAdaptation()
|
|||
color[2] = image[i * 4 + 2];
|
||||
color[3] = image[i * 4 + 3];
|
||||
|
||||
luminance = ( color.x * LUMINANCE_VECTOR.x + color.y * LUMINANCE_VECTOR.y + color.z * LUMINANCE_VECTOR.z ) + 0.0001f;
|
||||
luminance = ( color.x * LUMINANCE_SRGB.x + color.y * LUMINANCE_SRGB.y + color.z * LUMINANCE_SRGB.z ) + 0.0001f;
|
||||
if( luminance > maxLuminance )
|
||||
{
|
||||
maxLuminance = luminance;
|
||||
|
@ -3935,11 +4267,13 @@ static void RB_Tonemap( const viewDef_t* viewDef )
|
|||
|
||||
GL_SelectTexture( 0 );
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
if( r_multiSamples.GetInteger() > 0 )
|
||||
{
|
||||
globalImages->currentRenderHDRImageNoMSAA->Bind();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
globalImages->currentRenderHDRImage->Bind();
|
||||
}
|
||||
|
@ -4222,6 +4556,11 @@ void RB_DrawViewInternal( const viewDef_t* viewDef, const int stereoEye )
|
|||
//-------------------------------------------------
|
||||
RB_FillDepthBufferFast( drawSurfs, numDrawSurfs );
|
||||
|
||||
//-------------------------------------------------
|
||||
// fill the depth buffer and the color buffer with precomputed Q3A style lighting
|
||||
//-------------------------------------------------
|
||||
RB_AmbientPass( drawSurfs, numDrawSurfs );
|
||||
|
||||
//-------------------------------------------------
|
||||
// main light renderer
|
||||
//-------------------------------------------------
|
||||
|
@ -4335,6 +4674,7 @@ void RB_DrawViewInternal( const viewDef_t* viewDef, const int stereoEye )
|
|||
GL_LINEAR );
|
||||
*/
|
||||
|
||||
#if defined(USE_HDR_MSAA)
|
||||
if( r_multiSamples.GetInteger() > 0 )
|
||||
{
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, globalFramebuffers.hdrFBO->GetFramebuffer() );
|
||||
|
@ -4353,6 +4693,7 @@ void RB_DrawViewInternal( const viewDef_t* viewDef, const int stereoEye )
|
|||
GL_LINEAR );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER_EXT, globalFramebuffers.hdrFBO->GetFramebuffer() );
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER_EXT, globalFramebuffers.hdr64FBO->GetFramebuffer() );
|
||||
|
@ -4607,15 +4948,18 @@ void RB_PostProcess( const void* data )
|
|||
|
||||
// only do the post process step if resolution scaling is enabled. Prevents the unnecessary copying of the framebuffer and
|
||||
// corresponding full screen quad pass.
|
||||
if( rs_enable.GetInteger() == 0 )
|
||||
if( rs_enable.GetInteger() == 0 && !r_useFilmicPostProcessEffects.GetBool() ) //&& !r_useSMAA.GetInteger() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RENDERLOG_PRINTF( "---------- RB_PostProcess() ----------\n" );
|
||||
|
||||
// resolve the scaled rendering to a temporary texture
|
||||
postProcessCommand_t* cmd = ( postProcessCommand_t* )data;
|
||||
const idScreenRect& viewport = cmd->viewDef->viewport;
|
||||
globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
//globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
globalImages->smaaInputImage->CopyFramebuffer( 0, 0, glConfig.nativeScreenWidth, glConfig.nativeScreenHeight );
|
||||
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
GL_Cull( CT_TWO_SIDED );
|
||||
|
@ -4628,11 +4972,132 @@ void RB_PostProcess( const void* data )
|
|||
GL_Scissor( 0, 0, screenWidth, screenHeight );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
globalImages->currentRenderImage->Bind();
|
||||
globalImages->smaaInputImage->Bind();
|
||||
|
||||
// SMAA
|
||||
{
|
||||
/*
|
||||
* The shader has three passes, chained together as follows:
|
||||
*
|
||||
* |input|------------------·
|
||||
* v |
|
||||
* [ SMAA*EdgeDetection ] |
|
||||
* v |
|
||||
* |edgesTex| |
|
||||
* v |
|
||||
* [ SMAABlendingWeightCalculation ] |
|
||||
* v |
|
||||
* |blendTex| |
|
||||
* v |
|
||||
* [ SMAANeighborhoodBlending ] <------·
|
||||
* v
|
||||
* |output|
|
||||
*/
|
||||
|
||||
// set SMAA_RT_METRICS = rpScreenCorrectionFactor
|
||||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / glConfig.nativeScreenWidth;
|
||||
screenCorrectionParm[1] = 1.0f / glConfig.nativeScreenHeight;
|
||||
screenCorrectionParm[2] = glConfig.nativeScreenWidth;
|
||||
screenCorrectionParm[3] = glConfig.nativeScreenHeight;
|
||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||
|
||||
globalFramebuffers.smaaEdgesFBO->Bind();
|
||||
|
||||
glClearColor( 0, 0, 0, 0 );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
renderProgManager.BindShader_SMAA_EdgeDetection();
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
#if 1
|
||||
//globalImages->smaaEdgesImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
globalFramebuffers.smaaBlendFBO->Bind();
|
||||
//Framebuffer::Unbind();
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
globalImages->smaaEdgesImage->Bind();
|
||||
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->smaaAreaImage->Bind();
|
||||
|
||||
GL_SelectTexture( 2 );
|
||||
globalImages->smaaSearchImage->Bind();
|
||||
|
||||
renderProgManager.BindShader_SMAA_BlendingWeightCalculation();
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
Framebuffer::Unbind();
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
globalImages->BindNull();
|
||||
|
||||
//GL_SelectTexture( 0 );
|
||||
//globalImages->smaaBlendImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
globalImages->smaaInputImage->Bind();
|
||||
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->smaaBlendImage->Bind();
|
||||
|
||||
renderProgManager.BindShader_SMAA_NeighborhoodBlending();
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 1
|
||||
globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
|
||||
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->grainImage1->Bind();
|
||||
|
||||
renderProgManager.BindShader_PostProcess();
|
||||
|
||||
const static int GRAIN_SIZE = 128;
|
||||
|
||||
// screen power of two correction factor
|
||||
float screenCorrectionParm[4];
|
||||
screenCorrectionParm[0] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[1] = 1.0f / GRAIN_SIZE;
|
||||
screenCorrectionParm[2] = 1.0f;
|
||||
screenCorrectionParm[3] = 1.0f;
|
||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||
|
||||
float jitterTexOffset[4];
|
||||
if( r_shadowMapRandomizeJitter.GetBool() )
|
||||
{
|
||||
jitterTexOffset[0] = ( rand() & 255 ) / 255.0;
|
||||
jitterTexOffset[1] = ( rand() & 255 ) / 255.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
jitterTexOffset[0] = 0;
|
||||
jitterTexOffset[1] = 0;
|
||||
}
|
||||
jitterTexOffset[2] = 0.0f;
|
||||
jitterTexOffset[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXOFFSET, jitterTexOffset ); // rpJitterTexOffset
|
||||
|
||||
// Draw
|
||||
RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
|
||||
|
||||
#endif
|
||||
|
||||
GL_SelectTexture( 2 );
|
||||
globalImages->BindNull();
|
||||
|
||||
GL_SelectTexture( 1 );
|
||||
globalImages->BindNull();
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
globalImages->BindNull();
|
||||
|
||||
renderProgManager.Unbind();
|
||||
|
||||
renderLog.CloseBlock();
|
||||
}
|
||||
|
|
|
@ -1090,6 +1090,9 @@ extern idCVar r_hdrDebug;
|
|||
|
||||
extern idCVar r_ldrContrastThreshold;
|
||||
extern idCVar r_ldrContrastOffset;
|
||||
|
||||
extern idCVar r_useFilmicPostProcessEffects;
|
||||
extern idCVar r_forceAmbient;
|
||||
// RB end
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue