@@ -54,6 +54,7 @@ GLShader_lightMappingMaterial *gl_lightMappingShaderMaterial = nullpt
54
54
GLShader_forwardLighting_omniXYZ *gl_forwardLightingShader_omniXYZ = nullptr ;
55
55
GLShader_forwardLighting_projXYZ *gl_forwardLightingShader_projXYZ = nullptr ;
56
56
GLShader_forwardLighting_directionalSun *gl_forwardLightingShader_directionalSun = nullptr ;
57
+ GLShader_luminanceReduction *gl_luminanceReductionShader = nullptr ;
57
58
GLShader_shadowFill *gl_shadowFillShader = nullptr ;
58
59
GLShader_reflection *gl_reflectionShader = nullptr ;
59
60
GLShader_reflectionMaterial *gl_reflectionShaderMaterial = nullptr ;
@@ -80,6 +81,7 @@ GLShader_depthtile2 *gl_depthtile2Shader = nullptr;
80
81
GLShader_lighttile *gl_lighttileShader = nullptr ;
81
82
GLShader_fxaa *gl_fxaaShader = nullptr ;
82
83
GLShaderManager gl_shaderManager;
84
+ GLBuffer luminanceBuffer ( " luminance" , Util::ordinal( BufferBind::LUMINANCE ), GL_MAP_WRITE_BIT, GL_MAP_INVALIDATE_RANGE_BIT );
83
85
84
86
namespace // Implementation details
85
87
{
@@ -405,6 +407,9 @@ static const std::vector<addedExtension_t> fragmentVertexAddedExtensions = {
405
407
where the core variables have different names. */
406
408
{ glConfig2.shaderDrawParametersAvailable , -1 , " ARB_shader_draw_parameters" },
407
409
{ 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" },
408
413
/* Even though these are part of the GL_KHR_shader_subgroup extension, we need to enable
409
414
the individual extensions for each feature.
410
415
GL_KHR_shader_subgroup itself can't be used in the shader. */
@@ -552,6 +557,10 @@ static std::string GenVertexHeader() {
552
557
AddDefine ( str, " BIND_LIGHTMAP_DATA" , Util::ordinal ( BufferBind::LIGHTMAP_DATA ) );
553
558
}
554
559
560
+ if ( glConfig2.adaptiveExposureAvailable ) {
561
+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
562
+ }
563
+
555
564
return str;
556
565
}
557
566
@@ -592,6 +601,10 @@ static std::string GenFragmentHeader() {
592
601
AddDefine ( str, " BIND_LIGHTMAP_DATA" , Util::ordinal ( BufferBind::LIGHTMAP_DATA ) );
593
602
}
594
603
604
+ if ( glConfig2.adaptiveExposureAvailable ) {
605
+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
606
+ }
607
+
595
608
return str;
596
609
}
597
610
@@ -617,6 +630,10 @@ static std::string GenComputeHeader() {
617
630
AddDefine ( str, " BIND_DEBUG" , Util::ordinal ( BufferBind::DEBUG ) );
618
631
}
619
632
633
+ if ( glConfig2.adaptiveExposureAvailable ) {
634
+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
635
+ }
636
+
620
637
if ( glConfig2.usingBindlessTextures ) {
621
638
str += " layout(bindless_image) uniform;\n " ;
622
639
}
@@ -2640,6 +2657,17 @@ void GLShader_forwardLighting_directionalSun::SetShaderProgramUniforms( shaderPr
2640
2657
glUniform1i ( glGetUniformLocation ( shaderProgram->program , " u_HeightMap" ), 15 );
2641
2658
}
2642
2659
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
+
2643
2671
GLShader_shadowFill::GLShader_shadowFill ( GLShaderManager *manager ) :
2644
2672
GLShader( " shadowFill" , ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
2645
2673
u_ColorMap( this ),
@@ -2910,7 +2938,10 @@ GLShader_cameraEffects::GLShader_cameraEffects( GLShaderManager *manager ) :
2910
2938
u_ColorModulate( this ),
2911
2939
u_TextureMatrix( this ),
2912
2940
u_ModelViewProjectionMatrix( this ),
2941
+ u_ViewWidth( this ),
2942
+ u_ViewHeight( this ),
2913
2943
u_Tonemap( this ),
2944
+ u_TonemapAdaptiveExposure( this ),
2914
2945
u_TonemapParms( this ),
2915
2946
u_TonemapExposure( this ),
2916
2947
u_InverseGamma( this )
0 commit comments