Skip to content

Commit

Permalink
Make some uniforms global
Browse files Browse the repository at this point in the history
  • Loading branch information
VReaperV committed Oct 31, 2024
1 parent a8f538a commit 2b83bd4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
21 changes: 21 additions & 0 deletions src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,27 @@ void BindShaderLightMapping( Material* material ) {
}
// FIXME: else

// bind u_LightGrid1
if ( material->enableGridLighting ) {
gl_lightMappingShaderMaterial->SetUniform_LightGrid1Bindless( GL_BindToTMU( BIND_LIGHTMAP, tr.lightGrid1Image ) );
}

// bind u_LightGrid2
if ( material->enableGridDeluxeMapping ) {
gl_lightMappingShaderMaterial->SetUniform_LightGrid2Bindless( GL_BindToTMU( BIND_DELUXEMAP, tr.lightGrid2Image ) );
}

if ( glConfig2.realtimeLighting ) {
gl_lightMappingShaderMaterial->SetUniformBlock_Lights( tr.dlightUBO );

// bind u_LightTiles
if ( r_realtimeLightingRenderer.Get() == Util::ordinal( realtimeLightingRenderer_t::TILED ) ) {
gl_lightMappingShaderMaterial->SetUniform_LightTilesBindless(
GL_BindToTMU( BIND_LIGHTTILES, tr.lighttileRenderImage )
);
}
}

gl_lightMappingShaderMaterial->SetUniform_ViewOrigin( backEnd.orientation.viewOrigin );
gl_lightMappingShaderMaterial->SetUniform_numLights( backEnd.refdef.numLights );
gl_lightMappingShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
Expand Down
20 changes: 10 additions & 10 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ class GLUniformSampler2D : protected GLUniformSampler {

class GLUniformSampler3D : protected GLUniformSampler {
protected:
GLUniformSampler3D( GLShader* shader, const char* name ) :
GLUniformSampler( shader, name, "sampler3D", 1 ) {
GLUniformSampler3D( GLShader* shader, const char* name, const bool global = false ) :
GLUniformSampler( shader, name, "sampler3D", 1, global ) {
}

inline GLint GetLocation() {
Expand All @@ -619,8 +619,8 @@ class GLUniformSampler3D : protected GLUniformSampler {

class GLUniformUSampler3D : protected GLUniformSampler {
protected:
GLUniformUSampler3D( GLShader* shader, const char* name ) :
GLUniformSampler( shader, name, "usampler3D", 1 ) {
GLUniformUSampler3D( GLShader* shader, const char* name, const bool global = false ) :
GLUniformSampler( shader, name, "usampler3D", 1, global ) {
}

inline GLint GetLocation() {
Expand Down Expand Up @@ -2393,7 +2393,7 @@ class u_LightTiles :
GLUniformSampler3D {
public:
u_LightTiles( GLShader* shader ) :
GLUniformSampler3D( shader, "u_LightTiles" ) {
GLUniformSampler3D( shader, "u_LightTiles", true ) {
}

void SetUniform_LightTilesBindless( GLuint64 bindlessHandle ) {
Expand All @@ -2409,7 +2409,7 @@ class u_LightGrid1 :
GLUniformSampler3D {
public:
u_LightGrid1( GLShader* shader ) :
GLUniformSampler3D( shader, "u_LightGrid1" ) {
GLUniformSampler3D( shader, "u_LightGrid1", true ) {
}

void SetUniform_LightGrid1Bindless( GLuint64 bindlessHandle ) {
Expand All @@ -2425,7 +2425,7 @@ class u_LightGrid2 :
GLUniformSampler3D {
public:
u_LightGrid2( GLShader* shader ) :
GLUniformSampler3D( shader, "u_LightGrid2" ) {
GLUniformSampler3D( shader, "u_LightGrid2", true ) {
}

void SetUniform_LightGrid2Bindless( GLuint64 bindlessHandle ) {
Expand Down Expand Up @@ -3478,7 +3478,7 @@ class u_VertexInterpolation :
{
public:
u_VertexInterpolation( GLShader *shader ) :
GLUniform1f( shader, "u_VertexInterpolation" )
GLUniform1f( shader, "u_VertexInterpolation", true )
{
}

Expand Down Expand Up @@ -3553,7 +3553,7 @@ class u_EnvironmentInterpolation :
{
public:
u_EnvironmentInterpolation( GLShader *shader ) :
GLUniform1f( shader, "u_EnvironmentInterpolation" )
GLUniform1f( shader, "u_EnvironmentInterpolation", true )
{
}

Expand All @@ -3568,7 +3568,7 @@ class u_Time :
{
public:
u_Time( GLShader *shader ) :
GLUniform1f( shader, "u_Time" )
GLUniform1f( shader, "u_Time", true ) // Source this from a buffer when entity support is added to the material system
{
}

Expand Down
5 changes: 0 additions & 5 deletions src/engine/renderer/glsl_source/material_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
samplerCube u_EnvironmentMap0 = samplerCube( u_EnvironmentMap0_initial );
samplerCube u_EnvironmentMap1 = samplerCube( u_EnvironmentMap1_initial );
#endif // !USE_REFLECTIVE_SPECULAR */
usampler3D u_LightTiles = usampler3D( u_LightTiles_initial );
#endif // !COMPUTELIGHT_GLSL

#if defined(FOGQUAKE3_GLSL)
Expand All @@ -77,16 +76,12 @@ sampler2D u_DiffuseMap = sampler2D( u_DiffuseMap_initial );
sampler2D u_MaterialMap = sampler2D( u_MaterialMap_initial );
sampler2D u_GlowMap = sampler2D( u_GlowMap_initial );
sampler2D u_LightMap = sampler2D( u_LightMap_initial );
sampler3D u_LightGrid1 = sampler3D( u_LightGrid1_initial );
sampler2D u_DeluxeMap = sampler2D( u_DeluxeMap_initial );
sampler3D u_LightGrid2 = sampler3D( u_LightGrid2_initial );
#endif // !LIGHTMAPPING_GLSL

#if defined(LIQUID_GLSL)
sampler2D u_PortalMap = sampler2D( u_PortalMap_initial );
sampler2D u_DepthMap = sampler2D( u_DepthMap_initial );
sampler3D u_LightGrid1 = sampler3D( u_LightGrid1_initial );
sampler3D u_LightGrid2 = sampler3D( u_LightGrid2_initial );
#endif // !LIQUID_GLSL

#if defined(REFLECTION_CB_GLSL)
Expand Down

0 comments on commit 2b83bd4

Please sign in to comment.