@@ -54,6 +54,7 @@ GLShader_lightMappingMaterial *gl_lightMappingShaderMaterial = nullpt
5454GLShader_forwardLighting_omniXYZ *gl_forwardLightingShader_omniXYZ = nullptr ;
5555GLShader_forwardLighting_projXYZ *gl_forwardLightingShader_projXYZ = nullptr ;
5656GLShader_forwardLighting_directionalSun *gl_forwardLightingShader_directionalSun = nullptr ;
57+ GLShader_luminanceReduction *gl_luminanceReductionShader = nullptr ;
5758GLShader_shadowFill *gl_shadowFillShader = nullptr ;
5859GLShader_reflection *gl_reflectionShader = nullptr ;
5960GLShader_reflectionMaterial *gl_reflectionShaderMaterial = nullptr ;
@@ -80,6 +81,7 @@ GLShader_depthtile2 *gl_depthtile2Shader = nullptr;
8081GLShader_lighttile *gl_lighttileShader = nullptr ;
8182GLShader_fxaa *gl_fxaaShader = nullptr ;
8283GLShaderManager gl_shaderManager;
84+ GLBuffer luminanceBuffer ( " luminance" , Util::ordinal( BufferBind::LUMINANCE ), GL_MAP_WRITE_BIT, GL_MAP_INVALIDATE_RANGE_BIT );
8385
8486namespace // Implementation details
8587{
@@ -405,6 +407,9 @@ static const std::vector<addedExtension_t> fragmentVertexAddedExtensions = {
405407 where the core variables have different names. */
406408 { glConfig2.shaderDrawParametersAvailable , -1 , " ARB_shader_draw_parameters" },
407409 { glConfig2.SSBOAvailable , 430 , " ARB_shader_storage_buffer_object" },
410+ { glConfig2.shadingLanguage420PackAvailable , 420 , " ARB_shading_language_420pack" },
411+ { glConfig2.explicitUniformLocationAvailable , 430 , " ARB_explicit_uniform_location" },
412+ { glConfig2.shaderAtomicCountersAvailable , 420 , " ARB_shader_atomic_counters" },
408413 /* Even though these are part of the GL_KHR_shader_subgroup extension, we need to enable
409414 the individual extensions for each feature.
410415 GL_KHR_shader_subgroup itself can't be used in the shader. */
@@ -552,6 +557,10 @@ static std::string GenVertexHeader() {
552557 AddDefine ( str, " BIND_LIGHTMAP_DATA" , Util::ordinal ( BufferBind::LIGHTMAP_DATA ) );
553558 }
554559
560+ if ( glConfig2.adaptiveExposureAvailable ) {
561+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
562+ }
563+
555564 return str;
556565}
557566
@@ -592,6 +601,10 @@ static std::string GenFragmentHeader() {
592601 AddDefine ( str, " BIND_LIGHTMAP_DATA" , Util::ordinal ( BufferBind::LIGHTMAP_DATA ) );
593602 }
594603
604+ if ( glConfig2.adaptiveExposureAvailable ) {
605+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
606+ }
607+
595608 return str;
596609}
597610
@@ -617,6 +630,10 @@ static std::string GenComputeHeader() {
617630 AddDefine ( str, " BIND_DEBUG" , Util::ordinal ( BufferBind::DEBUG ) );
618631 }
619632
633+ if ( glConfig2.adaptiveExposureAvailable ) {
634+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
635+ }
636+
620637 if ( glConfig2.usingBindlessTextures ) {
621638 str += " layout(bindless_image) uniform;\n " ;
622639 }
@@ -2640,6 +2657,17 @@ void GLShader_forwardLighting_directionalSun::SetShaderProgramUniforms( shaderPr
26402657 glUniform1i ( glGetUniformLocation ( shaderProgram->program , " u_HeightMap" ), 15 );
26412658}
26422659
2660+ GLShader_luminanceReduction::GLShader_luminanceReduction ( GLShaderManager* manager ) :
2661+ GLShader( " luminanceReduction" , 0 , manager, false , false , true ),
2662+ u_ViewWidth( this ),
2663+ u_ViewHeight( this ),
2664+ u_TonemapParms2( this ) {
2665+ }
2666+
2667+ void GLShader_luminanceReduction::SetShaderProgramUniforms ( shaderProgram_t* shaderProgram ) {
2668+ glUniform1i ( glGetUniformLocation ( shaderProgram->program , " initialRenderImage" ), 0 );
2669+ }
2670+
26432671GLShader_shadowFill::GLShader_shadowFill ( GLShaderManager *manager ) :
26442672 GLShader( " shadowFill" , ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
26452673 u_ColorMap( this ),
@@ -2910,7 +2938,10 @@ GLShader_cameraEffects::GLShader_cameraEffects( GLShaderManager *manager ) :
29102938 u_ColorModulate( this ),
29112939 u_TextureMatrix( this ),
29122940 u_ModelViewProjectionMatrix( this ),
2941+ u_ViewWidth( this ),
2942+ u_ViewHeight( this ),
29132943 u_Tonemap( this ),
2944+ u_TonemapAdaptiveExposure( this ),
29142945 u_TonemapParms( this ),
29152946 u_TonemapExposure( this ),
29162947 u_InverseGamma( this )
0 commit comments