Skip to content

Commit

Permalink
Merge branch 'master' into for-0.56.0/sync
Browse files Browse the repository at this point in the history
  • Loading branch information
VReaperV committed Jan 5, 2025
2 parents 6d5a986 + 99fa09d commit d7e9f89
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 169 deletions.
15 changes: 3 additions & 12 deletions src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static void ComputeDynamics( shaderStage_t* pStage ) {
pStage->dynamic = pStage->dynamic || pStage->alphaExp.numOps || pStage->alphaTestExp.numOps;
pStage->dynamic = pStage->dynamic || pStage->rgbExp.numOps || pStage->redExp.numOps || pStage->greenExp.numOps || pStage->blueExp.numOps;
pStage->dynamic = pStage->dynamic || pStage->deformMagnitudeExp.numOps;
pStage->dynamic = pStage->dynamic || pStage->depthScaleExp.numOps || pStage->etaExp.numOps || pStage->etaDeltaExp.numOps
pStage->dynamic = pStage->dynamic || pStage->depthScaleExp.numOps
|| pStage->fogDensityExp.numOps || pStage->fresnelBiasExp.numOps || pStage->fresnelPowerExp.numOps
|| pStage->fresnelScaleExp.numOps || pStage->normalIntensityExp.numOps || pStage->refractionIndexExp.numOps;

Expand Down Expand Up @@ -215,9 +215,6 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, Material& material, drawSu

gl_genericShaderMaterial->BindProgram( material.deformIndex );

gl_genericShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
gl_genericShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );

// u_AlphaThreshold
gl_genericShaderMaterial->SetUniform_AlphaTest( pStage->stateBits );

Expand Down Expand Up @@ -548,10 +545,6 @@ void UpdateSurfaceDataLiquid( uint32_t* materials, Material& material, drawSurf_
gl_liquidShaderMaterial->SetUniform_FogDensity( fogDensity );
gl_liquidShaderMaterial->SetUniform_FogColor( fogColor );

gl_liquidShaderMaterial->SetUniform_UnprojectMatrix( backEnd.viewParms.unprojectionMatrix );
gl_liquidShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
gl_liquidShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );

// NOTE: specular component is computed by shader.
// FIXME: physical mapping is not implemented.
if ( pStage->enableSpecularMapping ) {
Expand Down Expand Up @@ -1138,8 +1131,6 @@ void BindShaderSkybox( Material* material ) {
gl_skyboxShaderMaterial->BindProgram( material->deformIndex );

// Set shader uniforms.
gl_skyboxShaderMaterial->SetUniform_ViewOrigin( backEnd.viewParms.orientation.origin );
gl_skyboxShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
gl_skyboxShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );
}

Expand All @@ -1156,7 +1147,6 @@ void BindShaderHeatHaze( Material* material ) {
gl_heatHazeShaderMaterial->BindProgram( material->deformIndex );

// Set shader uniforms.
gl_heatHazeShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
gl_heatHazeShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );

gl_heatHazeShaderMaterial->SetUniform_ModelViewMatrixTranspose( glState.modelViewMatrix[glState.stackIndex] );
Expand Down Expand Up @@ -1186,6 +1176,7 @@ void BindShaderLiquid( Material* material ) {

// Set shader uniforms.
gl_liquidShaderMaterial->SetUniform_ViewOrigin( backEnd.viewParms.orientation.origin );
gl_liquidShaderMaterial->SetUniform_UnprojectMatrix( backEnd.viewParms.unprojectionMatrix );
gl_liquidShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
gl_liquidShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );

Expand Down Expand Up @@ -1953,7 +1944,7 @@ void MaterialSystem::AddDrawCommand( const uint32_t materialID, const uint32_t m
}

void MaterialSystem::AddTexture( Texture* texture ) {
if ( cmd.textureCount > MAX_DRAWCOMMAND_TEXTURES ) {
if ( cmd.textureCount >= MAX_DRAWCOMMAND_TEXTURES ) {
Sys::Drop( "Exceeded max DrawCommand textures" );
}
cmd.textures[cmd.textureCount] = texture;
Expand Down
50 changes: 3 additions & 47 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ ShaderKind shaderKind = ShaderKind::Unknown;

// *INDENT-OFF*

GLShader_generic2D *gl_generic2DShader = nullptr;
GLShader_generic *gl_genericShader = nullptr;
GLShader_genericMaterial *gl_genericShaderMaterial = nullptr;
GLShader_cull *gl_cullShader = nullptr;
Expand Down Expand Up @@ -2172,31 +2171,6 @@ void GLShader::WriteUniformsToBuffer( uint32_t* buffer ) {
}
}

GLShader_generic2D::GLShader_generic2D( GLShaderManager *manager ) :
GLShader( "generic2D", "generic", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
u_ColorMap( this ),
u_DepthMap( this ),
u_TextureMatrix( this ),
u_AlphaThreshold( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_ColorModulate( this ),
u_Color( this ),
u_DepthScale( this ),
GLDeformStage( this )
{
}

void GLShader_generic2D::BuildShaderCompileMacros( std::string& compileMacros )
{
compileMacros += "GENERIC_2D ";
}

void GLShader_generic2D::SetShaderProgramUniforms( shaderProgram_t *shaderProgram )
{
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ColorMap" ), 0 );
}

GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
GLShader( "generic", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
u_ColorMap( this ),
Expand All @@ -2219,7 +2193,8 @@ GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
GLCompileMacro_USE_TCGEN_ENVIRONMENT( this ),
GLCompileMacro_USE_TCGEN_LIGHTMAP( this ),
GLCompileMacro_USE_DEPTH_FADE( this )
GLCompileMacro_USE_DEPTH_FADE( this ),
GLCompileMacro_GENERIC_2D( this )
{
}

Expand Down Expand Up @@ -2578,7 +2553,6 @@ GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
GLShader( "shadowFill", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
u_ColorMap( this ),
u_TextureMatrix( this ),
u_ViewOrigin( this ),
u_AlphaThreshold( this ),
u_LightOrigin( this ),
u_LightRadius( this ),
Expand Down Expand Up @@ -2658,11 +2632,9 @@ GLShader_skybox::GLShader_skybox( GLShaderManager *manager ) :
u_ColorMapCube( this ),
u_CloudMap( this ),
u_TextureMatrix( this ),
u_ViewOrigin( this ),
u_CloudHeight( this ),
u_UseCloudMap( this ),
u_AlphaThreshold( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this )
{
}
Expand All @@ -2678,11 +2650,9 @@ GLShader_skyboxMaterial::GLShader_skyboxMaterial( GLShaderManager* manager ) :
u_ColorMapCube( this ),
u_CloudMap( this ),
u_TextureMatrix( this ),
u_ViewOrigin( this ),
u_CloudHeight( this ),
u_UseCloudMap( this ),
u_AlphaThreshold( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this )
{}

Expand Down Expand Up @@ -2733,13 +2703,10 @@ GLShader_fogGlobal::GLShader_fogGlobal( GLShaderManager *manager ) :
GLShader( "fogGlobal", ATTR_POSITION, manager ),
u_ColorMap( this ),
u_DepthMap( this ),
u_ViewOrigin( this ),
u_ViewMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_UnprojectMatrix( this ),
u_Color( this ),
u_FogDistanceVector( this ),
u_FogDepthVector( this )
u_FogDistanceVector( this )
{
}

Expand All @@ -2755,15 +2722,10 @@ GLShader_heatHaze::GLShader_heatHaze( GLShaderManager *manager ) :
u_NormalMap( this ),
u_HeightMap( this ),
u_TextureMatrix( this ),
u_ViewOrigin( this ),
u_ViewUp( this ),
u_DeformMagnitude( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_ModelViewMatrixTranspose( this ),
u_ProjectionMatrixTranspose( this ),
u_ColorModulate( this ),
u_Color( this ),
u_Bones( this ),
u_NormalScale( this ),
u_VertexInterpolation( this ),
Expand All @@ -2786,16 +2748,11 @@ GLShader_heatHazeMaterial::GLShader_heatHazeMaterial( GLShaderManager* manager )
u_NormalMap( this ),
u_HeightMap( this ),
u_TextureMatrix( this ),
u_ViewOrigin( this ),
u_ViewUp( this ),
u_DeformEnable( this ),
u_DeformMagnitude( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_ModelViewMatrixTranspose( this ),
u_ProjectionMatrixTranspose( this ),
u_ColorModulate( this ),
u_Color( this ),
u_NormalScale( this ),
GLDeformStage( this )
{
Expand Down Expand Up @@ -2862,7 +2819,6 @@ GLShader_cameraEffects::GLShader_cameraEffects( GLShaderManager *manager ) :
u_ColorModulate( this ),
u_TextureMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_DeformMagnitude( this ),
u_InverseGamma( this )
{
}
Expand Down
70 changes: 25 additions & 45 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,7 @@ class GLCompileMacro
USE_SHADOWING,
LIGHT_DIRECTIONAL,
USE_DEPTH_FADE,
GENERIC_2D,
USE_PHYSICAL_MAPPING,
};

Expand Down Expand Up @@ -2110,6 +2111,26 @@ class GLCompileMacro_USE_DEPTH_FADE :
}
};

class GLCompileMacro_GENERIC_2D :
GLCompileMacro {
public:
GLCompileMacro_GENERIC_2D( GLShader* shader ) :
GLCompileMacro( shader ) {
}

const char* GetName() const override {
return "GENERIC_2D";
}

EGLCompileMacro GetType() const override {
return EGLCompileMacro::GENERIC_2D;
}

void SetGeneric2D( bool enable ) {
SetMacro( enable );
}
};

class GLCompileMacro_USE_PHYSICAL_MAPPING :
GLCompileMacro
{
Expand Down Expand Up @@ -3437,7 +3458,7 @@ class u_UnprojectMatrix :
{
public:
u_UnprojectMatrix( GLShader *shader ) :
GLUniformMatrix4f( shader, "u_UnprojectMatrix" )
GLUniformMatrix4f( shader, "u_UnprojectMatrix", true )
{
}

Expand Down Expand Up @@ -3918,28 +3939,6 @@ class u_Lights :
}
};

// FIXME: this is the same as 'generic' and has no reason for existing.
// It was added along with RmlUi transforms to add "gl_FragDepth = 0;" to the GLSL,
// but that turns out not to be needed.
class GLShader_generic2D :
public GLShader,
public u_ColorMap,
public u_DepthMap,
public u_TextureMatrix,
public u_AlphaThreshold,
public u_ModelMatrix,
public u_ModelViewProjectionMatrix,
public u_ColorModulate,
public u_Color,
public u_DepthScale,
public GLDeformStage
{
public:
GLShader_generic2D( GLShaderManager *manager );
void BuildShaderCompileMacros( std::string& compileMacros ) override;
void SetShaderProgramUniforms( shaderProgram_t *shaderProgram ) override;
};

class GLShader_generic :
public GLShader,
public u_ColorMap,
Expand All @@ -3962,7 +3961,8 @@ class GLShader_generic :
public GLCompileMacro_USE_VERTEX_ANIMATION,
public GLCompileMacro_USE_TCGEN_ENVIRONMENT,
public GLCompileMacro_USE_TCGEN_LIGHTMAP,
public GLCompileMacro_USE_DEPTH_FADE
public GLCompileMacro_USE_DEPTH_FADE,
public GLCompileMacro_GENERIC_2D
{
public:
GLShader_generic( GLShaderManager *manager );
Expand Down Expand Up @@ -4240,7 +4240,6 @@ class GLShader_shadowFill :
public GLShader,
public u_ColorMap,
public u_TextureMatrix,
public u_ViewOrigin,
public u_AlphaThreshold,
public u_LightOrigin,
public u_LightRadius,
Expand Down Expand Up @@ -4311,11 +4310,9 @@ class GLShader_skybox :
public u_ColorMapCube,
public u_CloudMap,
public u_TextureMatrix,
public u_ViewOrigin,
public u_CloudHeight,
public u_UseCloudMap,
public u_AlphaThreshold,
public u_ModelMatrix,
public u_ModelViewProjectionMatrix
{
public:
Expand All @@ -4328,11 +4325,9 @@ class GLShader_skyboxMaterial :
public u_ColorMapCube,
public u_CloudMap,
public u_TextureMatrix,
public u_ViewOrigin,
public u_CloudHeight,
public u_UseCloudMap,
public u_AlphaThreshold,
public u_ModelMatrix,
public u_ModelViewProjectionMatrix {
public:
GLShader_skyboxMaterial( GLShaderManager* manager );
Expand Down Expand Up @@ -4378,13 +4373,10 @@ class GLShader_fogGlobal :
public GLShader,
public u_ColorMap,
public u_DepthMap,
public u_ViewOrigin,
public u_ViewMatrix,
public u_ModelViewProjectionMatrix,
public u_UnprojectMatrix,
public u_Color,
public u_FogDistanceVector,
public u_FogDepthVector
public u_FogDistanceVector
{
public:
GLShader_fogGlobal( GLShaderManager *manager );
Expand All @@ -4397,15 +4389,10 @@ class GLShader_heatHaze :
public u_NormalMap,
public u_HeightMap,
public u_TextureMatrix,
public u_ViewOrigin,
public u_ViewUp,
public u_DeformMagnitude,
public u_ModelMatrix,
public u_ModelViewProjectionMatrix,
public u_ModelViewMatrixTranspose,
public u_ProjectionMatrixTranspose,
public u_ColorModulate,
public u_Color,
public u_Bones,
public u_NormalScale,
public u_VertexInterpolation,
Expand All @@ -4424,16 +4411,11 @@ class GLShader_heatHazeMaterial :
public u_NormalMap,
public u_HeightMap,
public u_TextureMatrix,
public u_ViewOrigin,
public u_ViewUp,
public u_DeformEnable,
public u_DeformMagnitude,
public u_ModelMatrix,
public u_ModelViewProjectionMatrix,
public u_ModelViewMatrixTranspose,
public u_ProjectionMatrixTranspose,
public u_ColorModulate,
public u_Color,
public u_NormalScale,
public GLDeformStage
{
Expand Down Expand Up @@ -4490,7 +4472,6 @@ class GLShader_cameraEffects :
public u_ColorModulate,
public u_TextureMatrix,
public u_ModelViewProjectionMatrix,
public u_DeformMagnitude,
public u_InverseGamma
{
public:
Expand Down Expand Up @@ -4714,7 +4695,6 @@ std::string GetShaderPath();

extern ShaderKind shaderKind;

extern GLShader_generic2D *gl_generic2DShader;
extern GLShader_generic *gl_genericShader;
extern GLShader_genericMaterial *gl_genericShaderMaterial;
extern GLShader_cull *gl_cullShader;
Expand Down
2 changes: 0 additions & 2 deletions src/engine/renderer/glsl_source/depthtile1_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
uniform sampler2D u_DepthMap;
IN(flat) vec3 unprojectionParams;

uniform vec3 u_zFar;

const vec2 pixelScale = 1 / r_FBufSize;

DECLARE_OUTPUT(vec4)
Expand Down
Loading

0 comments on commit d7e9f89

Please sign in to comment.