Skip to content

Commit 8505c19

Browse files
committed
renderer: add per-stage heightMap keyword
also make USE_HEIGHTMAP_IN_NORMALMAP a macro, obsoletes #189 About the collapse code collapsing heightmap stage while heightmap is a pre-colapsed stage attribute: > @slipher: The commit message says the heightmap is a per-stage attribute, but this looks like it's in a stage by itself? > @illwieckz: The dpMaterial DarkPlaces compatibility layer is not yet ported to the pre-collapsed stage code and I'm using Xonotic assets to test this feature, hence the temporary requirement to collapse a standalone heightmap stage. There is no keyword available to mapper to use the standalone heightmap stage, only the per-stage attribute, so there is no chance a mapper uses the standalone heightmap stage by mistake and we can drop it one day. #252 (review)
1 parent 4a2d183 commit 8505c19

7 files changed

Lines changed: 288 additions & 88 deletions

File tree

src/engine/renderer/gl_shader.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,12 +1466,12 @@ GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
14661466
u_ModelViewProjectionMatrix( this ),
14671467
u_ParallaxDepthScale( this ),
14681468
u_ParallaxOffsetBias( this ),
1469-
u_HeightMapInNormalMap( this ),
14701469
u_NormalScale( this ),
14711470
u_numLights( this ),
14721471
u_Lights( this ),
14731472
GLDeformStage( this ),
14741473
GLCompileMacro_USE_DELUXE_MAPPING( this ),
1474+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
14751475
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
14761476
GLCompileMacro_USE_PHYSICAL_SHADING( this )
14771477
{
@@ -1503,6 +1503,7 @@ void GLShader_lightMapping::SetShaderProgramUniforms( shaderProgram_t *shaderPro
15031503
if( !glConfig2.uniformBufferObjectAvailable ) {
15041504
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
15051505
}
1506+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
15061507
}
15071508

15081509
GLShader_vertexLighting_DBS_entity::GLShader_vertexLighting_DBS_entity( GLShaderManager *manager ) :
@@ -1517,7 +1518,6 @@ GLShader_vertexLighting_DBS_entity::GLShader_vertexLighting_DBS_entity( GLShader
15171518
u_VertexInterpolation( this ),
15181519
u_ParallaxDepthScale( this ),
15191520
u_ParallaxOffsetBias( this ),
1520-
u_HeightMapInNormalMap( this ),
15211521
u_NormalScale( this ),
15221522
u_EnvironmentInterpolation( this ),
15231523
u_LightGridOrigin( this ),
@@ -1527,6 +1527,7 @@ GLShader_vertexLighting_DBS_entity::GLShader_vertexLighting_DBS_entity( GLShader
15271527
GLDeformStage( this ),
15281528
GLCompileMacro_USE_VERTEX_SKINNING( this ),
15291529
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1530+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
15301531
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
15311532
GLCompileMacro_USE_REFLECTIVE_SPECULAR( this ),
15321533
GLCompileMacro_USE_PHYSICAL_SHADING( this )
@@ -1561,6 +1562,7 @@ void GLShader_vertexLighting_DBS_entity::SetShaderProgramUniforms( shaderProgram
15611562
if( !glConfig2.uniformBufferObjectAvailable ) {
15621563
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
15631564
}
1565+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
15641566
}
15651567

15661568
GLShader_vertexLighting_DBS_world::GLShader_vertexLighting_DBS_world( GLShaderManager *manager ) :
@@ -1578,14 +1580,14 @@ GLShader_vertexLighting_DBS_world::GLShader_vertexLighting_DBS_world( GLShaderMa
15781580
u_ModelViewProjectionMatrix( this ),
15791581
u_ParallaxDepthScale( this ),
15801582
u_ParallaxOffsetBias( this ),
1581-
u_HeightMapInNormalMap( this ),
15821583
u_NormalScale( this ),
15831584
u_LightWrapAround( this ),
15841585
u_LightGridOrigin( this ),
15851586
u_LightGridScale( this ),
15861587
u_numLights( this ),
15871588
u_Lights( this ),
15881589
GLDeformStage( this ),
1590+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
15891591
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
15901592
GLCompileMacro_USE_PHYSICAL_SHADING( this )
15911593
{
@@ -1616,6 +1618,7 @@ void GLShader_vertexLighting_DBS_world::SetShaderProgramUniforms( shaderProgram_
16161618
if( !glConfig2.uniformBufferObjectAvailable ) {
16171619
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
16181620
}
1621+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
16191622
}
16201623

16211624
GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderManager *manager ):
@@ -1640,11 +1643,11 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderMana
16401643
u_VertexInterpolation( this ),
16411644
u_ParallaxDepthScale( this ),
16421645
u_ParallaxOffsetBias( this ),
1643-
u_HeightMapInNormalMap( this ),
16441646
u_NormalScale( this ),
16451647
GLDeformStage( this ),
16461648
GLCompileMacro_USE_VERTEX_SKINNING( this ),
16471649
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1650+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
16481651
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
16491652
GLCompileMacro_USE_SHADOWING( this )
16501653
{
@@ -1674,6 +1677,7 @@ void GLShader_forwardLighting_omniXYZ::SetShaderProgramUniforms( shaderProgram_t
16741677
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowMap" ), 5 );
16751678
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_RandomMap" ), 6 );
16761679
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap" ), 7 );
1680+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
16771681
}
16781682

16791683
GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderManager *manager ):
@@ -1699,11 +1703,11 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderMana
16991703
u_VertexInterpolation( this ),
17001704
u_ParallaxDepthScale( this ),
17011705
u_ParallaxOffsetBias( this ),
1702-
u_HeightMapInNormalMap( this ),
17031706
u_NormalScale( this ),
17041707
GLDeformStage( this ),
17051708
GLCompileMacro_USE_VERTEX_SKINNING( this ),
17061709
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1710+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
17071711
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
17081712
GLCompileMacro_USE_SHADOWING( this )
17091713
{
@@ -1734,6 +1738,7 @@ void GLShader_forwardLighting_projXYZ::SetShaderProgramUniforms( shaderProgram_t
17341738
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowMap0" ), 5 );
17351739
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_RandomMap" ), 6 );
17361740
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap0" ), 7 );
1741+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
17371742
}
17381743

17391744
GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun( GLShaderManager *manager ):
@@ -1761,11 +1766,11 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
17611766
u_VertexInterpolation( this ),
17621767
u_ParallaxDepthScale( this ),
17631768
u_ParallaxOffsetBias( this ),
1764-
u_HeightMapInNormalMap( this ),
17651769
u_NormalScale( this ),
17661770
GLDeformStage( this ),
17671771
GLCompileMacro_USE_VERTEX_SKINNING( this ),
17681772
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1773+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
17691774
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
17701775
GLCompileMacro_USE_SHADOWING( this )
17711776
{
@@ -1803,6 +1808,7 @@ void GLShader_forwardLighting_directionalSun::SetShaderProgramUniforms( shaderPr
18031808
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap2" ), 12 );
18041809
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap3" ), 13 );
18051810
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap4" ), 14 );
1811+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
18061812
}
18071813

18081814
GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
@@ -1843,12 +1849,12 @@ GLShader_reflection::GLShader_reflection( GLShaderManager *manager ):
18431849
u_Bones( this ),
18441850
u_ParallaxDepthScale( this ),
18451851
u_ParallaxOffsetBias( this ),
1846-
u_HeightMapInNormalMap( this ),
18471852
u_NormalScale( this ),
18481853
u_VertexInterpolation( this ),
18491854
GLDeformStage( this ),
18501855
GLCompileMacro_USE_VERTEX_SKINNING( this ),
18511856
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1857+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
18521858
GLCompileMacro_USE_PARALLAX_MAPPING( this )
18531859
{
18541860
}
@@ -1871,6 +1877,7 @@ void GLShader_reflection::SetShaderProgramUniforms( shaderProgram_t *shaderProgr
18711877
{
18721878
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ColorMap" ), 0 );
18731879
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_NormalMap" ), 1 );
1880+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
18741881
}
18751882

18761883
GLShader_skybox::GLShader_skybox( GLShaderManager *manager ) :
@@ -1969,6 +1976,7 @@ void GLShader_heatHaze::SetShaderProgramUniforms( shaderProgram_t *shaderProgram
19691976
{
19701977
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_NormalMap" ), 0 );
19711978
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_CurrentMap" ), 1 );
1979+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
19721980
}
19731981

19741982
GLShader_screen::GLShader_screen( GLShaderManager *manager ) :
@@ -2108,13 +2116,13 @@ GLShader_liquid::GLShader_liquid( GLShaderManager *manager ) :
21082116
u_FresnelBias( this ),
21092117
u_ParallaxDepthScale( this ),
21102118
u_ParallaxOffsetBias( this ),
2111-
u_HeightMapInNormalMap( this ),
21122119
u_NormalScale( this ),
21132120
u_FogDensity( this ),
21142121
u_FogColor( this ),
21152122
u_SpecularExponent( this ),
21162123
u_LightGridOrigin( this ),
21172124
u_LightGridScale( this ),
2125+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
21182126
GLCompileMacro_USE_PARALLAX_MAPPING( this )
21192127
{
21202128
}
@@ -2132,6 +2140,7 @@ void GLShader_liquid::SetShaderProgramUniforms( shaderProgram_t *shaderProgram )
21322140
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_NormalMap" ), 3 );
21332141
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid1" ), 6 );
21342142
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid2" ), 7 );
2143+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
21352144
}
21362145

21372146
GLShader_volumetricFog::GLShader_volumetricFog( GLShaderManager *manager ) :

src/engine/renderer/gl_shader.h

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ class GLCompileMacro
784784
USE_TCGEN_ENVIRONMENT,
785785
USE_TCGEN_LIGHTMAP,
786786
USE_DELUXE_MAPPING,
787+
USE_HEIGHTMAP_IN_NORMALMAP,
787788
USE_PARALLAX_MAPPING,
788789
USE_REFLECTIVE_SPECULAR,
789790
USE_SHADOWING,
@@ -1009,6 +1010,31 @@ class GLCompileMacro_USE_DELUXE_MAPPING :
10091010
}
10101011
};
10111012

1013+
class GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP :
1014+
GLCompileMacro
1015+
{
1016+
public:
1017+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( GLShader *shader ) :
1018+
GLCompileMacro( shader )
1019+
{
1020+
}
1021+
1022+
const char *GetName() const
1023+
{
1024+
return "USE_HEIGHTMAP_IN_NORMALMAP";
1025+
}
1026+
1027+
EGLCompileMacro GetType() const
1028+
{
1029+
return EGLCompileMacro::USE_HEIGHTMAP_IN_NORMALMAP;
1030+
}
1031+
1032+
void SetHeightMapInNormalMap( bool enable )
1033+
{
1034+
SetMacro( enable );
1035+
}
1036+
};
1037+
10121038
class GLCompileMacro_USE_PARALLAX_MAPPING :
10131039
GLCompileMacro
10141040
{
@@ -1766,21 +1792,6 @@ class u_ParallaxOffsetBias :
17661792
}
17671793
};
17681794

1769-
class u_HeightMapInNormalMap :
1770-
GLUniform1i
1771-
{
1772-
public:
1773-
u_HeightMapInNormalMap( GLShader *shader ) :
1774-
GLUniform1i( shader, "u_HeightMapInNormalMap" )
1775-
{
1776-
}
1777-
1778-
void SetUniform_HeightMapInNormalMap( int value )
1779-
{
1780-
this->SetValue( value );
1781-
}
1782-
};
1783-
17841795
class u_EnvironmentInterpolation :
17851796
GLUniform1f
17861797
{
@@ -2146,12 +2157,12 @@ class GLShader_lightMapping :
21462157
public u_ModelViewProjectionMatrix,
21472158
public u_ParallaxDepthScale,
21482159
public u_ParallaxOffsetBias,
2149-
public u_HeightMapInNormalMap,
21502160
public u_NormalScale,
21512161
public u_numLights,
21522162
public u_Lights,
21532163
public GLDeformStage,
21542164
public GLCompileMacro_USE_DELUXE_MAPPING,
2165+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
21552166
public GLCompileMacro_USE_PARALLAX_MAPPING,
21562167
public GLCompileMacro_USE_PHYSICAL_SHADING
21572168
{
@@ -2175,7 +2186,6 @@ class GLShader_vertexLighting_DBS_entity :
21752186
public u_VertexInterpolation,
21762187
public u_ParallaxDepthScale,
21772188
public u_ParallaxOffsetBias,
2178-
public u_HeightMapInNormalMap,
21792189
public u_NormalScale,
21802190
public u_EnvironmentInterpolation,
21812191
public u_LightGridOrigin,
@@ -2185,6 +2195,7 @@ class GLShader_vertexLighting_DBS_entity :
21852195
public GLDeformStage,
21862196
public GLCompileMacro_USE_VERTEX_SKINNING,
21872197
public GLCompileMacro_USE_VERTEX_ANIMATION,
2198+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
21882199
public GLCompileMacro_USE_PARALLAX_MAPPING,
21892200
public GLCompileMacro_USE_REFLECTIVE_SPECULAR,
21902201
public GLCompileMacro_USE_PHYSICAL_SHADING
@@ -2209,14 +2220,14 @@ class GLShader_vertexLighting_DBS_world :
22092220
public u_ModelViewProjectionMatrix,
22102221
public u_ParallaxDepthScale,
22112222
public u_ParallaxOffsetBias,
2212-
public u_HeightMapInNormalMap,
22132223
public u_NormalScale,
22142224
public u_LightWrapAround,
22152225
public u_LightGridOrigin,
22162226
public u_LightGridScale,
22172227
public u_numLights,
22182228
public u_Lights,
22192229
public GLDeformStage,
2230+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
22202231
public GLCompileMacro_USE_PARALLAX_MAPPING,
22212232
public GLCompileMacro_USE_PHYSICAL_SHADING
22222233
{
@@ -2250,11 +2261,11 @@ class GLShader_forwardLighting_omniXYZ :
22502261
public u_VertexInterpolation,
22512262
public u_ParallaxDepthScale,
22522263
public u_ParallaxOffsetBias,
2253-
public u_HeightMapInNormalMap,
22542264
public u_NormalScale,
22552265
public GLDeformStage,
22562266
public GLCompileMacro_USE_VERTEX_SKINNING,
22572267
public GLCompileMacro_USE_VERTEX_ANIMATION,
2268+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
22582269
public GLCompileMacro_USE_PARALLAX_MAPPING,
22592270
public GLCompileMacro_USE_SHADOWING //,
22602271
{
@@ -2289,11 +2300,11 @@ class GLShader_forwardLighting_projXYZ :
22892300
public u_VertexInterpolation,
22902301
public u_ParallaxDepthScale,
22912302
public u_ParallaxOffsetBias,
2292-
public u_HeightMapInNormalMap,
22932303
public u_NormalScale,
22942304
public GLDeformStage,
22952305
public GLCompileMacro_USE_VERTEX_SKINNING,
22962306
public GLCompileMacro_USE_VERTEX_ANIMATION,
2307+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
22972308
public GLCompileMacro_USE_PARALLAX_MAPPING,
22982309
public GLCompileMacro_USE_SHADOWING //,
22992310
{
@@ -2330,11 +2341,11 @@ class GLShader_forwardLighting_directionalSun :
23302341
public u_VertexInterpolation,
23312342
public u_ParallaxDepthScale,
23322343
public u_ParallaxOffsetBias,
2333-
public u_HeightMapInNormalMap,
23342344
public u_NormalScale,
23352345
public GLDeformStage,
23362346
public GLCompileMacro_USE_VERTEX_SKINNING,
23372347
public GLCompileMacro_USE_VERTEX_ANIMATION,
2348+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
23382349
public GLCompileMacro_USE_PARALLAX_MAPPING,
23392350
public GLCompileMacro_USE_SHADOWING //,
23402351
{
@@ -2378,12 +2389,12 @@ class GLShader_reflection :
23782389
public u_Bones,
23792390
public u_ParallaxDepthScale,
23802391
public u_ParallaxOffsetBias,
2381-
public u_HeightMapInNormalMap,
23822392
public u_NormalScale,
23832393
public u_VertexInterpolation,
23842394
public GLDeformStage,
23852395
public GLCompileMacro_USE_VERTEX_SKINNING,
23862396
public GLCompileMacro_USE_VERTEX_ANIMATION,
2397+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
23872398
public GLCompileMacro_USE_PARALLAX_MAPPING
23882399
{
23892400
public:
@@ -2584,13 +2595,13 @@ class GLShader_liquid :
25842595
public u_FresnelBias,
25852596
public u_ParallaxDepthScale,
25862597
public u_ParallaxOffsetBias,
2587-
public u_HeightMapInNormalMap,
25882598
public u_NormalScale,
25892599
public u_FogDensity,
25902600
public u_FogColor,
25912601
public u_SpecularExponent,
25922602
public u_LightGridOrigin,
25932603
public u_LightGridScale,
2604+
public GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP,
25942605
public GLCompileMacro_USE_PARALLAX_MAPPING
25952606
{
25962607
public:

0 commit comments

Comments
 (0)