Advertisement
illwieckz

overBright GLSL

Feb 15th, 2024 (edited)
1,817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.00 KB | None | 0 0
  1. diff --git a/src.cmake b/src.cmake
  2. index 54ad95a45..33c2a1a95 100644
  3. --- a/src.cmake
  4. +++ b/src.cmake
  5. @@ -188,6 +188,8 @@ set(GLSLSOURCELIST
  6.      ${ENGINE_DIR}/renderer/glsl_source/liquid_vp.glsl
  7.      ${ENGINE_DIR}/renderer/glsl_source/motionblur_fp.glsl
  8.      ${ENGINE_DIR}/renderer/glsl_source/motionblur_vp.glsl
  9. +    ${ENGINE_DIR}/renderer/glsl_source/overBright_fp.glsl
  10. +    ${ENGINE_DIR}/renderer/glsl_source/overBright_vp.glsl
  11.      ${ENGINE_DIR}/renderer/glsl_source/portal_fp.glsl
  12.      ${ENGINE_DIR}/renderer/glsl_source/portal_vp.glsl
  13.      ${ENGINE_DIR}/renderer/glsl_source/reflection_CB_fp.glsl
  14.  
  15.  
  16. diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp
  17. index 099452671..b508eb48b 100644
  18. --- a/src/engine/renderer/gl_shader.cpp
  19. +++ b/src/engine/renderer/gl_shader.cpp
  20. @@ -35,6 +35,7 @@ ShaderKind shaderKind = ShaderKind::Unknown;
  21.  
  22.  // *INDENT-OFF*
  23.  
  24. +GLShader_overBright                      *gl_overBrightShader = nullptr;
  25.  GLShader_generic2D                       *gl_generic2DShader = nullptr;
  26.  GLShader_generic                         *gl_genericShader = nullptr;
  27.  GLShader_lightMapping                    *gl_lightMappingShader = nullptr;
  28. @@ -1545,6 +1546,12 @@ void GLShader::SetRequiredVertexPointers()
  29.     GL_VertexAttribsState( ( _vertexAttribsRequired | _vertexAttribs | macroVertexAttribs ) );  // & ~_vertexAttribsUnsupported);
  30.  }
  31.  
  32. +GLShader_overBright::GLShader_overBright( GLShaderManager *manager ) :
  33. +   GLShader( "overBright", "overBright", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
  34. +   u_LightFactor( this )
  35. +{
  36. +}
  37. +
  38.  GLShader_generic2D::GLShader_generic2D( GLShaderManager *manager ) :
  39.     GLShader( "generic2D", "generic", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
  40.     u_TextureMatrix( this ),
  41.  
  42.  
  43. diff --git a/src/engine/renderer/gl_shader.h b/src/engine/renderer/gl_shader.h
  44. index f2b7c9e88..66cc94cf4 100644
  45. --- a/src/engine/renderer/gl_shader.h
  46. +++ b/src/engine/renderer/gl_shader.h
  47. @@ -2393,6 +2393,14 @@ class u_Lights :
  48.     }
  49.  };
  50.  
  51. +class GLShader_overBright :
  52. +   public GLShader,
  53. +   public u_LightFactor
  54. +{
  55. +public:
  56. +   GLShader_overBright( GLShaderManager *manager );
  57. +};
  58. +
  59.  // This is just a copy of the GLShader_generic, but with a special
  60.  // define for RmlUI transforms. It probably has a lot of unnecessary
  61.  // code that could be pruned.
  62. @@ -2903,6 +2911,7 @@ std::string GetShaderPath();
  63.  
  64.  extern ShaderKind shaderKind;
  65.  
  66. +extern GLShader_overBright                      *gl_overBrightShader;
  67.  extern GLShader_generic2D                       *gl_generic2DShader;
  68.  extern GLShader_generic                         *gl_genericShader;
  69.  extern GLShader_lightMapping                    *gl_lightMappingShader;
  70.  
  71.  
  72. diff --git a/src/engine/renderer/glsl_source/overBright_fp.glsl b/src/engine/renderer/glsl_source/overBright_fp.glsl
  73. new file mode 100644
  74. index 000000000..739f3c733
  75. --- /dev/null
  76. +++ b/src/engine/renderer/glsl_source/overBright_fp.glsl
  77. @@ -0,0 +1,8 @@
  78. +DECLARE_OUTPUT(vec4)
  79. +
  80. +uniform float u_LightFactor;
  81. +
  82. +void main()
  83. +{
  84. +   outputColor = vec4( u_LightFactor, u_LightFactor, u_LightFactor, 1 );
  85. +}
  86.  
  87.  
  88. diff --git a/src/engine/renderer/glsl_source/overBright_vp.glsl b/src/engine/renderer/glsl_source/overBright_vp.glsl
  89. new file mode 100644
  90. index 000000000..b13f0ada0
  91. --- /dev/null
  92. +++ b/src/engine/renderer/glsl_source/overBright_vp.glsl
  93. @@ -0,0 +1,3 @@
  94. +void main ()
  95. +{
  96. +}
  97.  
  98.  
  99. diff --git a/src/engine/renderer/shaders.cpp b/src/engine/renderer/shaders.cpp
  100. index 35f6d3a97..17ad5a2e1 100644
  101. --- a/src/engine/renderer/shaders.cpp
  102. +++ b/src/engine/renderer/shaders.cpp
  103. @@ -47,6 +47,8 @@
  104.  #include "liquid_vp.glsl.h"
  105.  #include "motionblur_fp.glsl.h"
  106.  #include "motionblur_vp.glsl.h"
  107. +#include "overBright_fp.glsl.h"
  108. +#include "overBright_vp.glsl.h"
  109.  #include "portal_fp.glsl.h"
  110.  #include "portal_vp.glsl.h"
  111.  #include "reflection_CB_fp.glsl.h"
  112. @@ -101,6 +103,8 @@ std::unordered_map<std::string, std::string> shadermap({
  113.     { "glsl/liquid_vp.glsl", std::string(reinterpret_cast<const char*>(liquid_vp_glsl), sizeof(liquid_vp_glsl)) },
  114.     { "glsl/motionblur_fp.glsl", std::string(reinterpret_cast<const char*>(motionblur_fp_glsl), sizeof(motionblur_fp_glsl)) },
  115.     { "glsl/motionblur_vp.glsl", std::string(reinterpret_cast<const char*>(motionblur_vp_glsl), sizeof(motionblur_vp_glsl)) },
  116. +   { "glsl/overBright_fp.glsl", std::string(reinterpret_cast<const char*>(overBright_fp_glsl), sizeof(overBright_fp_glsl)) },
  117. +   { "glsl/overBright_vp.glsl", std::string(reinterpret_cast<const char*>(overBright_vp_glsl), sizeof(overBright_vp_glsl)) },
  118.     { "glsl/portal_fp.glsl", std::string(reinterpret_cast<const char*>(portal_fp_glsl), sizeof(portal_fp_glsl)) },
  119.     { "glsl/portal_vp.glsl", std::string(reinterpret_cast<const char*>(portal_vp_glsl), sizeof(portal_vp_glsl)) },
  120.     { "glsl/reflection_CB_fp.glsl", std::string(reinterpret_cast<const char*>(reflection_CB_fp_glsl), sizeof(reflection_CB_fp_glsl)) },
  121.  
  122.  
  123. diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp
  124. index 6975277b3..d46ae5246 100644
  125. --- a/src/engine/renderer/tr_shade.cpp
  126. +++ b/src/engine/renderer/tr_shade.cpp
  127. @@ -58,6 +58,9 @@ static void GLSL_InitGPUShadersOrError()
  128.  
  129.     gl_shaderManager.GenerateBuiltinHeaders();
  130.  
  131. +   // overBright light multiplication
  132. +   gl_shaderManager.load( gl_overBrightShader );
  133. +
  134.     // single texture rendering
  135.     gl_shaderManager.load( gl_generic2DShader );
  136.     gl_shaderManager.load( gl_genericShader );
  137. @@ -2353,6 +2356,17 @@ static void Render_liquid( shaderStage_t *pStage )
  138.     GL_CheckErrors();
  139.  }
  140.  
  141. +static void Render_overBright()
  142. +{
  143. +   GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );
  144. +   gl_overBrightShader->BindProgram( 0 );
  145. +   gl_overBrightShader->SetUniform_LightFactor( 1 );
  146. +
  147. +   Tess_DrawElements();
  148. +
  149. +   GL_CheckErrors();
  150. +}
  151. +
  152.  static void Render_fog()
  153.  {
  154.     fog_t  *fog;
  155. @@ -2887,6 +2901,8 @@ void Tess_StageIteratorGeneric()
  156.         }
  157.     }
  158.  
  159. +   Render_overBright();
  160. +
  161.     if ( !r_noFog->integer && tess.fogNum >= 1 && tess.surfaceShader->fogPass != fogPass_t::FP_NONE )
  162.     {
  163.         Render_fog();
  164.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement