mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Embedded shaders
This commit is contained in:
parent
79f1071322
commit
3738e59283
1 changed files with 0 additions and 539 deletions
|
@ -3392,194 +3392,6 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/hdr_glare_chromatic.pixel",
|
||||
"/*\n"
|
||||
"===========================================================================\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition GPL Source Code\n"
|
||||
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
|
||||
"Copyright (C) 2014 Robert Beckebans\n"
|
||||
"\n"
|
||||
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"===========================================================================\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"#include \"renderprogs/global.inc\"\n"
|
||||
"\n"
|
||||
"uniform sampler2D samp0 : register(s0);\n"
|
||||
"\n"
|
||||
"struct PS_IN\n"
|
||||
"{\n"
|
||||
" float4 position : VPOS;\n"
|
||||
" float2 texcoord0 : TEXCOORD0_centroid;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct PS_OUT\n"
|
||||
"{\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float linterp( float t )\n"
|
||||
"{\n"
|
||||
" return saturate( 1.0 - abs( 2.0 * t - 1.0 ) );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float remap( float t, float a, float b )\n"
|
||||
"{\n"
|
||||
" return saturate( ( t - a ) / ( b - a ) );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"float3 spectrumoffset( float t )\n"
|
||||
"{\n"
|
||||
" float lo = step( t, 0.5 );\n"
|
||||
" float hi = 1.0 - lo;\n"
|
||||
" float w = linterp( remap( t, 1.0 / 6.0, 5.0 / 6.0 ) );\n"
|
||||
" float3 ret = float3( lo, 1.0, hi ) * float3( 1.0 - w, w, 1.0 - w );\n"
|
||||
"\n"
|
||||
" return ret; //pow( ret, float3( 1.0 / 2.2 ) );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main( PS_IN fragment, out PS_OUT result )\n"
|
||||
"{\n"
|
||||
" float2 st = fragment.texcoord0;\n"
|
||||
" \n"
|
||||
" // base color with tone mapping and other post processing applied\n"
|
||||
" float4 color = tex2D( samp0, st );\n"
|
||||
" \n"
|
||||
" const float gaussFact[9] = float[9](0.13298076, 0.12579441, 0.10648267, 0.08065691, 0.05467002, 0.03315905, 0.01799699, 0.00874063, 0.00379866);\n"
|
||||
" \n"
|
||||
" const float3 chromaticOffsets[9] = float3[](\n"
|
||||
" float3(0.5, 0.5, 0.5),\n"
|
||||
" float3(0.8, 0.3, 0.3 ),\n"
|
||||
" float3(1.0, 0.2, 0.2),\n"
|
||||
" float3(0.5, 0.2, 0.8),\n"
|
||||
" float3(0.2, 0.2, 1.0),\n"
|
||||
" float3(0.2, 0.3, 0.9),\n"
|
||||
" float3(0.2, 0.9, 0.2),\n"
|
||||
" float3(0.3, 0.5, 0.3),\n"
|
||||
" float3(0.3, 0.5, 0.3) );\n"
|
||||
" \n"
|
||||
" float3 sumColor = float3( 0.0 );\n"
|
||||
" float3 sumSpectrum = float3( 0.0 );\n"
|
||||
"\n"
|
||||
" const int tap = 4;\n"
|
||||
" const int samples = 9;\n"
|
||||
" \n"
|
||||
" float scale = 13.0;\n"
|
||||
" const float weightScale = 3.0;\n"
|
||||
" \n"
|
||||
" //for( int i = -tap; i < tap; i++ )\n"
|
||||
" for( int i = 0; i < samples; i++ )\n"
|
||||
" {\n"
|
||||
" float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) );\n"
|
||||
" //float t = log( float( i ) / ( float( samples ) - 1.0 ) );\n"
|
||||
" \n"
|
||||
" float3 so = spectrumoffset( t );\n"
|
||||
" float4 color = tex2D( samp0, st + float2( float( i ), 0 ) * rpWindowCoord.xy * scale );\n"
|
||||
" \n"
|
||||
" float weight = gaussFact[ i ];\n"
|
||||
" sumColor += color.rgb * ( so.rgb * weight * weightScale );\n"
|
||||
" //sumSpectrum += so.xyz;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
"#if 1\n"
|
||||
" for( int i = 0; i < samples; i++ )\n"
|
||||
" {\n"
|
||||
" float t = ( ( float( 4 + ( i ) ) ) / ( float( samples ) - 1.0 ) );\n"
|
||||
" \n"
|
||||
" float3 so = spectrumoffset( t );\n"
|
||||
" float4 color = tex2D( samp0, st + float2( float( -i ), 0 ) * rpWindowCoord.xy * scale );\n"
|
||||
" \n"
|
||||
" float weight = gaussFact[ i ];\n"
|
||||
" sumColor += color.rgb * ( so.rgb * weight * weightScale );\n"
|
||||
" //sumSpectrum += so.xyz;\n"
|
||||
" }\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
" result.color = float4( sumColor, 1.0 );\n"
|
||||
" //result.color = float4( sumColor / float(samples), 1.0 );\n"
|
||||
" //result.color = float4( sumColor / sumSpectrum, 1.0 );\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/hdr_glare_chromatic.vertex",
|
||||
"/*\n"
|
||||
"===========================================================================\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition GPL Source Code\n"
|
||||
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
|
||||
"\n"
|
||||
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"===========================================================================\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"#include \"renderprogs/global.inc\"\n"
|
||||
"\n"
|
||||
"struct VS_IN {\n"
|
||||
" float4 position : POSITION;\n"
|
||||
" float2 texcoord : TEXCOORD0;\n"
|
||||
" float4 normal : NORMAL;\n"
|
||||
" float4 tangent : TANGENT;\n"
|
||||
" float4 color : COLOR0;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VS_OUT {\n"
|
||||
" float4 position : POSITION;\n"
|
||||
" float2 texcoord0 : TEXCOORD0;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void main( VS_IN vertex, out VS_OUT result ) {\n"
|
||||
" result.position = vertex.position;\n"
|
||||
"\n"
|
||||
" //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );\n"
|
||||
" //result.position.y = dot4( vertex.position, rpMVPmatrixY );\n"
|
||||
" //result.position.z = dot4( vertex.position, rpMVPmatrixZ );\n"
|
||||
" //result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
|
||||
" result.texcoord0 = vertex.texcoord;\n"
|
||||
"}\n"
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/heathaze.pixel",
|
||||
"/*\n"
|
||||
|
@ -5631,120 +5443,6 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/screen.pixel",
|
||||
"/*\n"
|
||||
"===========================================================================\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition GPL Source Code\n"
|
||||
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
|
||||
"Copyright (C) 2014 Robert Beckebans\n"
|
||||
"\n"
|
||||
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"===========================================================================\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"#include \"renderprogs/global.inc\"\n"
|
||||
"\n"
|
||||
"uniform sampler2D samp0 : register(s0);\n"
|
||||
"\n"
|
||||
"struct PS_IN\n"
|
||||
"{\n"
|
||||
" float4 position : VPOS;\n"
|
||||
" float2 texcoord0 : TEXCOORD0_centroid;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct PS_OUT\n"
|
||||
"{\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void main( PS_IN fragment, out PS_OUT result )\n"
|
||||
"{\n"
|
||||
" float2 tCoords = fragment.texcoord0;\n"
|
||||
" \n"
|
||||
" float4 color = tex2D( samp0, tCoords );\n"
|
||||
" result.color = color;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/screen.vertex",
|
||||
"/*\n"
|
||||
"===========================================================================\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition GPL Source Code\n"
|
||||
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
|
||||
"\n"
|
||||
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"===========================================================================\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"#include \"renderprogs/global.inc\"\n"
|
||||
"\n"
|
||||
"struct VS_IN {\n"
|
||||
" float4 position : POSITION;\n"
|
||||
" float2 texcoord : TEXCOORD0;\n"
|
||||
" float4 normal : NORMAL;\n"
|
||||
" float4 tangent : TANGENT;\n"
|
||||
" float4 color : COLOR0;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VS_OUT {\n"
|
||||
" float4 position : POSITION;\n"
|
||||
" float2 texcoord0 : TEXCOORD0;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void main( VS_IN vertex, out VS_OUT result ) {\n"
|
||||
" result.position = vertex.position;\n"
|
||||
"\n"
|
||||
" //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );\n"
|
||||
" //result.position.y = dot4( vertex.position, rpMVPmatrixY );\n"
|
||||
" //result.position.z = dot4( vertex.position, rpMVPmatrixZ );\n"
|
||||
" //result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
|
||||
" result.texcoord0 = vertex.texcoord;\n"
|
||||
"}\n"
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/shadow.pixel",
|
||||
"/*\n"
|
||||
|
@ -7386,243 +7084,6 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/tonemap.pixel",
|
||||
"/*\n"
|
||||
"===========================================================================\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition GPL Source Code\n"
|
||||
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
|
||||
"Copyright (C) 2009-2014 Robert Beckebans\n"
|
||||
"\n"
|
||||
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"===========================================================================\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"#include \"renderprogs/global.inc\"\n"
|
||||
"\n"
|
||||
"uniform sampler2D samp0 : register(s0);\n"
|
||||
"\n"
|
||||
"struct PS_IN\n"
|
||||
"{\n"
|
||||
" float4 position : VPOS;\n"
|
||||
" float2 texcoord0 : TEXCOORD0_centroid;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct PS_OUT\n"
|
||||
"{\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void main( PS_IN fragment, out PS_OUT result )\n"
|
||||
"{\n"
|
||||
" float2 tCoords = fragment.texcoord0;\n"
|
||||
" \n"
|
||||
"#if defined(BRIGHTPASS_FILTER)\n"
|
||||
" // multiply with 4 because the FBO is only 1/4th of the screen resolution\n"
|
||||
" tCoords *= float2( 4.0, 4.0 );\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
" float4 color = tex2D( samp0, tCoords );\n"
|
||||
" \n"
|
||||
"#if 0\n"
|
||||
" const float hdrGamma = 2.2;\n"
|
||||
" float gamma = 1.0 / hdrGamma;\n"
|
||||
" color.r = pow( color.r, gamma );\n"
|
||||
" color.g = pow( color.g, gamma );\n"
|
||||
" color.b = pow( color.b, gamma );\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
" // see http://www.gamedev.net/reference/articles/article2208.asp\n"
|
||||
" // for Mathematics of Reinhard's Photographic Tone Reproduction Operator\n"
|
||||
" \n"
|
||||
" // get the luminance of the current pixel\n"
|
||||
" float Y = dot( LUMINANCE_VECTOR, color );\n"
|
||||
"\n"
|
||||
"#if defined(BRIGHTPASS)\n"
|
||||
" if(Y < 0.1)\n"
|
||||
" {\n"
|
||||
" //discard;\n"
|
||||
" result.color = float4( 0.0, 0.0, 0.0, 1.0 );\n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
" float hdrKey = rpScreenCorrectionFactor.x;\n"
|
||||
" float hdrAverageLuminance = rpScreenCorrectionFactor.y;\n"
|
||||
" float hdrMaxLuminance = rpScreenCorrectionFactor.z;\n"
|
||||
" \n"
|
||||
" // calculate the relative luminance\n"
|
||||
" float Yr = hdrKey * Y / hdrAverageLuminance;\n"
|
||||
"\n"
|
||||
" float Ymax = hdrMaxLuminance;\n"
|
||||
"\n"
|
||||
" /*\n"
|
||||
"#if 0\n"
|
||||
" float L = Yr * ( 1.0 + Yr / ( Ymax * Ymax ) ) / ( 1.0 + Yr );\n"
|
||||
"#else\n"
|
||||
" float L = 1.0 - exp( -Yr );\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
" color.rgb *= L;\n"
|
||||
" */\n"
|
||||
" \n"
|
||||
" // RGB -> XYZ conversion \n"
|
||||
" const mat3 RGB2XYZ = mat3( 0.4124564, 0.3575761, 0.1804375, \n"
|
||||
" 0.2126729, 0.7151522, 0.0721750, \n"
|
||||
" 0.0193339, 0.1191920, 0.9503041); \n"
|
||||
" \n"
|
||||
" float3 XYZ = RGB2XYZ * color.rgb;\n"
|
||||
" \n"
|
||||
" // XYZ -> Yxy conversion \n"
|
||||
" float3 Yxy; \n"
|
||||
" \n"
|
||||
" // Y = Y luminance\n"
|
||||
" Yxy.r = XYZ.g;\n"
|
||||
" \n"
|
||||
" // x = X / (X + Y + Z)\n"
|
||||
" Yxy.g = XYZ.r / ( XYZ.r + XYZ.g + XYZ.b );\n"
|
||||
" \n"
|
||||
" // y = Y / (X + Y + Z)\n"
|
||||
" Yxy.b = XYZ.g / ( XYZ.r + XYZ.g + XYZ.b );\n"
|
||||
" \n"
|
||||
" // (Lp) map average luminance to the middlegrey zone by scaling pixel luminance \n"
|
||||
" float Lp = Yxy.r * hdrKey / hdrAverageLuminance;\n"
|
||||
" \n"
|
||||
" // (Ld) scale all luminance within a displayable range of 0 to 1\n"
|
||||
" \n"
|
||||
"#if 1 //defined(r_HDRToneMappingOperator_1)\n"
|
||||
" Yxy.r = ( Lp * ( 1.0 + Lp / ( Ymax * Ymax ) ) ) / ( 1.0 + Lp );\n"
|
||||
"#else\n"
|
||||
" Yxy.r = 1.0 - exp( -Lp );\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
" // Yxy -> XYZ conversion \n"
|
||||
" \n"
|
||||
" // X = Y * x / y\n"
|
||||
" XYZ.r = Yxy.r * Yxy.g / Yxy.b;\n"
|
||||
" \n"
|
||||
" // Y = Y\n"
|
||||
" XYZ.g = Yxy.r;\n"
|
||||
" \n"
|
||||
" // Z = Y * (1-x-y) / y or Z = (1 - x - y) * (Y / y)\n"
|
||||
" XYZ.b = ( 1 - Yxy.g - Yxy.b ) * ( Yxy.r / Yxy.b );\n"
|
||||
" \n"
|
||||
" // XYZ -> RGB conversion\n"
|
||||
" const mat3 XYZ2RGB = mat3( 3.2404542, -1.5371385, -0.4985314,\n"
|
||||
" -0.9692660, 1.8760108, 0.0415560,\n"
|
||||
" 0.0556434, -0.2040259, 1.0572252);\n"
|
||||
" \n"
|
||||
" color.rgb = clamp(XYZ2RGB * XYZ, 0.0, 1.0);\n"
|
||||
" // color.rgb *= Yxy.r;\n"
|
||||
" \n"
|
||||
"#if defined(BRIGHTPASS)\n"
|
||||
" // adjust contrast\n"
|
||||
" // L = pow(L, 1.32);\n"
|
||||
" \n"
|
||||
" const half hdrContrastThreshold = rpOverbright.x;\n"
|
||||
" const half hdrContrastOffset = rpOverbright.y;\n"
|
||||
" \n"
|
||||
" float T = max( Lp - hdrContrastThreshold, 0.0 );\n"
|
||||
" // float T = max(1.0 - exp( -Yr ) - hdrContrastThreshold, 0.0);\n"
|
||||
" float B = T > 0.0 ? T / (hdrContrastOffset + T) : T;\n"
|
||||
" \n"
|
||||
" color.rgb *= clamp( B, 0.0, 1.0 );\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
"#if 0\n"
|
||||
" const float hdrGamma = 2.2;\n"
|
||||
" float gamma = 1.0 / hdrGamma;\n"
|
||||
" color.r = pow( color.r, gamma );\n"
|
||||
" color.g = pow( color.g, gamma );\n"
|
||||
" color.b = pow( color.b, gamma );\n"
|
||||
"#endif\n"
|
||||
" \n"
|
||||
" result.color = color;\n"
|
||||
" \n"
|
||||
"#if 0\n"
|
||||
" result.color = float4( Lp, Lp, Lp, 1.0 );\n"
|
||||
"#endif\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/tonemap.vertex",
|
||||
"/*\n"
|
||||
"===========================================================================\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition GPL Source Code\n"
|
||||
"Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. \n"
|
||||
"\n"
|
||||
"This file is part of the Doom 3 BFG Edition GPL Source Code (\"Doom 3 BFG Edition Source Code\"). \n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation, either version 3 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"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.\n"
|
||||
"\n"
|
||||
"===========================================================================\n"
|
||||
"*/\n"
|
||||
"\n"
|
||||
"#include \"renderprogs/global.inc\"\n"
|
||||
"\n"
|
||||
"struct VS_IN {\n"
|
||||
" float4 position : POSITION;\n"
|
||||
" float2 texcoord : TEXCOORD0;\n"
|
||||
" float4 normal : NORMAL;\n"
|
||||
" float4 tangent : TANGENT;\n"
|
||||
" float4 color : COLOR0;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VS_OUT {\n"
|
||||
" float4 position : POSITION;\n"
|
||||
" float2 texcoord0 : TEXCOORD0;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void main( VS_IN vertex, out VS_OUT result ) {\n"
|
||||
" result.position = vertex.position;\n"
|
||||
"\n"
|
||||
" //result.position.x = vertex.position; //dot4( vertex.position, rpMVPmatrixX );\n"
|
||||
" //result.position.y = dot4( vertex.position, rpMVPmatrixY );\n"
|
||||
" //result.position.z = dot4( vertex.position, rpMVPmatrixZ );\n"
|
||||
" //result.position.w = dot4( vertex.position, rpMVPmatrixW );\n"
|
||||
" result.texcoord0 = vertex.texcoord;\n"
|
||||
"}\n"
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
"renderprogs/vertex_color.pixel",
|
||||
"/*\n"
|
||||
|
|
Loading…
Reference in a new issue