Skip to content

Commit d7e9f89

Browse files
committed
Merge branch 'master' into for-0.56.0/sync
2 parents 6d5a986 + 99fa09d commit d7e9f89

File tree

11 files changed

+38
-169
lines changed

11 files changed

+38
-169
lines changed

src/engine/renderer/Material.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void ComputeDynamics( shaderStage_t* pStage ) {
183183
pStage->dynamic = pStage->dynamic || pStage->alphaExp.numOps || pStage->alphaTestExp.numOps;
184184
pStage->dynamic = pStage->dynamic || pStage->rgbExp.numOps || pStage->redExp.numOps || pStage->greenExp.numOps || pStage->blueExp.numOps;
185185
pStage->dynamic = pStage->dynamic || pStage->deformMagnitudeExp.numOps;
186-
pStage->dynamic = pStage->dynamic || pStage->depthScaleExp.numOps || pStage->etaExp.numOps || pStage->etaDeltaExp.numOps
186+
pStage->dynamic = pStage->dynamic || pStage->depthScaleExp.numOps
187187
|| pStage->fogDensityExp.numOps || pStage->fresnelBiasExp.numOps || pStage->fresnelPowerExp.numOps
188188
|| pStage->fresnelScaleExp.numOps || pStage->normalIntensityExp.numOps || pStage->refractionIndexExp.numOps;
189189

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

216216
gl_genericShaderMaterial->BindProgram( material.deformIndex );
217217

218-
gl_genericShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
219-
gl_genericShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );
220-
221218
// u_AlphaThreshold
222219
gl_genericShaderMaterial->SetUniform_AlphaTest( pStage->stateBits );
223220

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

551-
gl_liquidShaderMaterial->SetUniform_UnprojectMatrix( backEnd.viewParms.unprojectionMatrix );
552-
gl_liquidShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
553-
gl_liquidShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );
554-
555548
// NOTE: specular component is computed by shader.
556549
// FIXME: physical mapping is not implemented.
557550
if ( pStage->enableSpecularMapping ) {
@@ -1138,8 +1131,6 @@ void BindShaderSkybox( Material* material ) {
11381131
gl_skyboxShaderMaterial->BindProgram( material->deformIndex );
11391132

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

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

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

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

11871177
// Set shader uniforms.
11881178
gl_liquidShaderMaterial->SetUniform_ViewOrigin( backEnd.viewParms.orientation.origin );
1179+
gl_liquidShaderMaterial->SetUniform_UnprojectMatrix( backEnd.viewParms.unprojectionMatrix );
11891180
gl_liquidShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
11901181
gl_liquidShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );
11911182

@@ -1953,7 +1944,7 @@ void MaterialSystem::AddDrawCommand( const uint32_t materialID, const uint32_t m
19531944
}
19541945

19551946
void MaterialSystem::AddTexture( Texture* texture ) {
1956-
if ( cmd.textureCount > MAX_DRAWCOMMAND_TEXTURES ) {
1947+
if ( cmd.textureCount >= MAX_DRAWCOMMAND_TEXTURES ) {
19571948
Sys::Drop( "Exceeded max DrawCommand textures" );
19581949
}
19591950
cmd.textures[cmd.textureCount] = texture;

src/engine/renderer/gl_shader.cpp

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ ShaderKind shaderKind = ShaderKind::Unknown;
4343

4444
// *INDENT-OFF*
4545

46-
GLShader_generic2D *gl_generic2DShader = nullptr;
4746
GLShader_generic *gl_genericShader = nullptr;
4847
GLShader_genericMaterial *gl_genericShaderMaterial = nullptr;
4948
GLShader_cull *gl_cullShader = nullptr;
@@ -2172,31 +2171,6 @@ void GLShader::WriteUniformsToBuffer( uint32_t* buffer ) {
21722171
}
21732172
}
21742173

2175-
GLShader_generic2D::GLShader_generic2D( GLShaderManager *manager ) :
2176-
GLShader( "generic2D", "generic", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
2177-
u_ColorMap( this ),
2178-
u_DepthMap( this ),
2179-
u_TextureMatrix( this ),
2180-
u_AlphaThreshold( this ),
2181-
u_ModelMatrix( this ),
2182-
u_ModelViewProjectionMatrix( this ),
2183-
u_ColorModulate( this ),
2184-
u_Color( this ),
2185-
u_DepthScale( this ),
2186-
GLDeformStage( this )
2187-
{
2188-
}
2189-
2190-
void GLShader_generic2D::BuildShaderCompileMacros( std::string& compileMacros )
2191-
{
2192-
compileMacros += "GENERIC_2D ";
2193-
}
2194-
2195-
void GLShader_generic2D::SetShaderProgramUniforms( shaderProgram_t *shaderProgram )
2196-
{
2197-
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ColorMap" ), 0 );
2198-
}
2199-
22002174
GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
22012175
GLShader( "generic", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
22022176
u_ColorMap( this ),
@@ -2219,7 +2193,8 @@ GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
22192193
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
22202194
GLCompileMacro_USE_TCGEN_ENVIRONMENT( this ),
22212195
GLCompileMacro_USE_TCGEN_LIGHTMAP( this ),
2222-
GLCompileMacro_USE_DEPTH_FADE( this )
2196+
GLCompileMacro_USE_DEPTH_FADE( this ),
2197+
GLCompileMacro_GENERIC_2D( this )
22232198
{
22242199
}
22252200

@@ -2578,7 +2553,6 @@ GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
25782553
GLShader( "shadowFill", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ),
25792554
u_ColorMap( this ),
25802555
u_TextureMatrix( this ),
2581-
u_ViewOrigin( this ),
25822556
u_AlphaThreshold( this ),
25832557
u_LightOrigin( this ),
25842558
u_LightRadius( this ),
@@ -2658,11 +2632,9 @@ GLShader_skybox::GLShader_skybox( GLShaderManager *manager ) :
26582632
u_ColorMapCube( this ),
26592633
u_CloudMap( this ),
26602634
u_TextureMatrix( this ),
2661-
u_ViewOrigin( this ),
26622635
u_CloudHeight( this ),
26632636
u_UseCloudMap( this ),
26642637
u_AlphaThreshold( this ),
2665-
u_ModelMatrix( this ),
26662638
u_ModelViewProjectionMatrix( this )
26672639
{
26682640
}
@@ -2678,11 +2650,9 @@ GLShader_skyboxMaterial::GLShader_skyboxMaterial( GLShaderManager* manager ) :
26782650
u_ColorMapCube( this ),
26792651
u_CloudMap( this ),
26802652
u_TextureMatrix( this ),
2681-
u_ViewOrigin( this ),
26822653
u_CloudHeight( this ),
26832654
u_UseCloudMap( this ),
26842655
u_AlphaThreshold( this ),
2685-
u_ModelMatrix( this ),
26862656
u_ModelViewProjectionMatrix( this )
26872657
{}
26882658

@@ -2733,13 +2703,10 @@ GLShader_fogGlobal::GLShader_fogGlobal( GLShaderManager *manager ) :
27332703
GLShader( "fogGlobal", ATTR_POSITION, manager ),
27342704
u_ColorMap( this ),
27352705
u_DepthMap( this ),
2736-
u_ViewOrigin( this ),
2737-
u_ViewMatrix( this ),
27382706
u_ModelViewProjectionMatrix( this ),
27392707
u_UnprojectMatrix( this ),
27402708
u_Color( this ),
2741-
u_FogDistanceVector( this ),
2742-
u_FogDepthVector( this )
2709+
u_FogDistanceVector( this )
27432710
{
27442711
}
27452712

@@ -2755,15 +2722,10 @@ GLShader_heatHaze::GLShader_heatHaze( GLShaderManager *manager ) :
27552722
u_NormalMap( this ),
27562723
u_HeightMap( this ),
27572724
u_TextureMatrix( this ),
2758-
u_ViewOrigin( this ),
2759-
u_ViewUp( this ),
27602725
u_DeformMagnitude( this ),
2761-
u_ModelMatrix( this ),
27622726
u_ModelViewProjectionMatrix( this ),
27632727
u_ModelViewMatrixTranspose( this ),
27642728
u_ProjectionMatrixTranspose( this ),
2765-
u_ColorModulate( this ),
2766-
u_Color( this ),
27672729
u_Bones( this ),
27682730
u_NormalScale( this ),
27692731
u_VertexInterpolation( this ),
@@ -2786,16 +2748,11 @@ GLShader_heatHazeMaterial::GLShader_heatHazeMaterial( GLShaderManager* manager )
27862748
u_NormalMap( this ),
27872749
u_HeightMap( this ),
27882750
u_TextureMatrix( this ),
2789-
u_ViewOrigin( this ),
2790-
u_ViewUp( this ),
27912751
u_DeformEnable( this ),
27922752
u_DeformMagnitude( this ),
2793-
u_ModelMatrix( this ),
27942753
u_ModelViewProjectionMatrix( this ),
27952754
u_ModelViewMatrixTranspose( this ),
27962755
u_ProjectionMatrixTranspose( this ),
2797-
u_ColorModulate( this ),
2798-
u_Color( this ),
27992756
u_NormalScale( this ),
28002757
GLDeformStage( this )
28012758
{
@@ -2862,7 +2819,6 @@ GLShader_cameraEffects::GLShader_cameraEffects( GLShaderManager *manager ) :
28622819
u_ColorModulate( this ),
28632820
u_TextureMatrix( this ),
28642821
u_ModelViewProjectionMatrix( this ),
2865-
u_DeformMagnitude( this ),
28662822
u_InverseGamma( this )
28672823
{
28682824
}

src/engine/renderer/gl_shader.h

Lines changed: 25 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,7 @@ class GLCompileMacro
16861686
USE_SHADOWING,
16871687
LIGHT_DIRECTIONAL,
16881688
USE_DEPTH_FADE,
1689+
GENERIC_2D,
16891690
USE_PHYSICAL_MAPPING,
16901691
};
16911692

@@ -2110,6 +2111,26 @@ class GLCompileMacro_USE_DEPTH_FADE :
21102111
}
21112112
};
21122113

2114+
class GLCompileMacro_GENERIC_2D :
2115+
GLCompileMacro {
2116+
public:
2117+
GLCompileMacro_GENERIC_2D( GLShader* shader ) :
2118+
GLCompileMacro( shader ) {
2119+
}
2120+
2121+
const char* GetName() const override {
2122+
return "GENERIC_2D";
2123+
}
2124+
2125+
EGLCompileMacro GetType() const override {
2126+
return EGLCompileMacro::GENERIC_2D;
2127+
}
2128+
2129+
void SetGeneric2D( bool enable ) {
2130+
SetMacro( enable );
2131+
}
2132+
};
2133+
21132134
class GLCompileMacro_USE_PHYSICAL_MAPPING :
21142135
GLCompileMacro
21152136
{
@@ -3437,7 +3458,7 @@ class u_UnprojectMatrix :
34373458
{
34383459
public:
34393460
u_UnprojectMatrix( GLShader *shader ) :
3440-
GLUniformMatrix4f( shader, "u_UnprojectMatrix" )
3461+
GLUniformMatrix4f( shader, "u_UnprojectMatrix", true )
34413462
{
34423463
}
34433464

@@ -3918,28 +3939,6 @@ class u_Lights :
39183939
}
39193940
};
39203941

3921-
// FIXME: this is the same as 'generic' and has no reason for existing.
3922-
// It was added along with RmlUi transforms to add "gl_FragDepth = 0;" to the GLSL,
3923-
// but that turns out not to be needed.
3924-
class GLShader_generic2D :
3925-
public GLShader,
3926-
public u_ColorMap,
3927-
public u_DepthMap,
3928-
public u_TextureMatrix,
3929-
public u_AlphaThreshold,
3930-
public u_ModelMatrix,
3931-
public u_ModelViewProjectionMatrix,
3932-
public u_ColorModulate,
3933-
public u_Color,
3934-
public u_DepthScale,
3935-
public GLDeformStage
3936-
{
3937-
public:
3938-
GLShader_generic2D( GLShaderManager *manager );
3939-
void BuildShaderCompileMacros( std::string& compileMacros ) override;
3940-
void SetShaderProgramUniforms( shaderProgram_t *shaderProgram ) override;
3941-
};
3942-
39433942
class GLShader_generic :
39443943
public GLShader,
39453944
public u_ColorMap,
@@ -3962,7 +3961,8 @@ class GLShader_generic :
39623961
public GLCompileMacro_USE_VERTEX_ANIMATION,
39633962
public GLCompileMacro_USE_TCGEN_ENVIRONMENT,
39643963
public GLCompileMacro_USE_TCGEN_LIGHTMAP,
3965-
public GLCompileMacro_USE_DEPTH_FADE
3964+
public GLCompileMacro_USE_DEPTH_FADE,
3965+
public GLCompileMacro_GENERIC_2D
39663966
{
39673967
public:
39683968
GLShader_generic( GLShaderManager *manager );
@@ -4240,7 +4240,6 @@ class GLShader_shadowFill :
42404240
public GLShader,
42414241
public u_ColorMap,
42424242
public u_TextureMatrix,
4243-
public u_ViewOrigin,
42444243
public u_AlphaThreshold,
42454244
public u_LightOrigin,
42464245
public u_LightRadius,
@@ -4311,11 +4310,9 @@ class GLShader_skybox :
43114310
public u_ColorMapCube,
43124311
public u_CloudMap,
43134312
public u_TextureMatrix,
4314-
public u_ViewOrigin,
43154313
public u_CloudHeight,
43164314
public u_UseCloudMap,
43174315
public u_AlphaThreshold,
4318-
public u_ModelMatrix,
43194316
public u_ModelViewProjectionMatrix
43204317
{
43214318
public:
@@ -4328,11 +4325,9 @@ class GLShader_skyboxMaterial :
43284325
public u_ColorMapCube,
43294326
public u_CloudMap,
43304327
public u_TextureMatrix,
4331-
public u_ViewOrigin,
43324328
public u_CloudHeight,
43334329
public u_UseCloudMap,
43344330
public u_AlphaThreshold,
4335-
public u_ModelMatrix,
43364331
public u_ModelViewProjectionMatrix {
43374332
public:
43384333
GLShader_skyboxMaterial( GLShaderManager* manager );
@@ -4378,13 +4373,10 @@ class GLShader_fogGlobal :
43784373
public GLShader,
43794374
public u_ColorMap,
43804375
public u_DepthMap,
4381-
public u_ViewOrigin,
4382-
public u_ViewMatrix,
43834376
public u_ModelViewProjectionMatrix,
43844377
public u_UnprojectMatrix,
43854378
public u_Color,
4386-
public u_FogDistanceVector,
4387-
public u_FogDepthVector
4379+
public u_FogDistanceVector
43884380
{
43894381
public:
43904382
GLShader_fogGlobal( GLShaderManager *manager );
@@ -4397,15 +4389,10 @@ class GLShader_heatHaze :
43974389
public u_NormalMap,
43984390
public u_HeightMap,
43994391
public u_TextureMatrix,
4400-
public u_ViewOrigin,
4401-
public u_ViewUp,
44024392
public u_DeformMagnitude,
4403-
public u_ModelMatrix,
44044393
public u_ModelViewProjectionMatrix,
44054394
public u_ModelViewMatrixTranspose,
44064395
public u_ProjectionMatrixTranspose,
4407-
public u_ColorModulate,
4408-
public u_Color,
44094396
public u_Bones,
44104397
public u_NormalScale,
44114398
public u_VertexInterpolation,
@@ -4424,16 +4411,11 @@ class GLShader_heatHazeMaterial :
44244411
public u_NormalMap,
44254412
public u_HeightMap,
44264413
public u_TextureMatrix,
4427-
public u_ViewOrigin,
4428-
public u_ViewUp,
44294414
public u_DeformEnable,
44304415
public u_DeformMagnitude,
4431-
public u_ModelMatrix,
44324416
public u_ModelViewProjectionMatrix,
44334417
public u_ModelViewMatrixTranspose,
44344418
public u_ProjectionMatrixTranspose,
4435-
public u_ColorModulate,
4436-
public u_Color,
44374419
public u_NormalScale,
44384420
public GLDeformStage
44394421
{
@@ -4490,7 +4472,6 @@ class GLShader_cameraEffects :
44904472
public u_ColorModulate,
44914473
public u_TextureMatrix,
44924474
public u_ModelViewProjectionMatrix,
4493-
public u_DeformMagnitude,
44944475
public u_InverseGamma
44954476
{
44964477
public:
@@ -4714,7 +4695,6 @@ std::string GetShaderPath();
47144695

47154696
extern ShaderKind shaderKind;
47164697

4717-
extern GLShader_generic2D *gl_generic2DShader;
47184698
extern GLShader_generic *gl_genericShader;
47194699
extern GLShader_genericMaterial *gl_genericShaderMaterial;
47204700
extern GLShader_cull *gl_cullShader;

src/engine/renderer/glsl_source/depthtile1_fp.glsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3737
uniform sampler2D u_DepthMap;
3838
IN(flat) vec3 unprojectionParams;
3939

40-
uniform vec3 u_zFar;
41-
4240
const vec2 pixelScale = 1 / r_FBufSize;
4341

4442
DECLARE_OUTPUT(vec4)

0 commit comments

Comments
 (0)