Skip to content

Commit 7e1489e

Browse files
committed
renderer: add per-stage heightMap keyword
also make USE_HEIGHTMAP_IN_NORMALMAP a macro, obsoletes DaemonEngine#189
1 parent 1f8dfae commit 7e1489e

7 files changed

Lines changed: 278 additions & 87 deletions

File tree

src/engine/renderer/gl_shader.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,12 +1461,12 @@ GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
14611461
u_ModelViewProjectionMatrix( this ),
14621462
u_ParallaxDepthScale( this ),
14631463
u_ParallaxOffsetBias( this ),
1464-
u_HeightMapInNormalMap( this ),
14651464
u_NormalScale( this ),
14661465
u_numLights( this ),
14671466
u_Lights( this ),
14681467
GLDeformStage( this ),
14691468
GLCompileMacro_USE_DELUXE_MAPPING( this ),
1469+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
14701470
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
14711471
GLCompileMacro_USE_PHYSICAL_SHADING( this )
14721472
{
@@ -1498,6 +1498,7 @@ void GLShader_lightMapping::SetShaderProgramUniforms( shaderProgram_t *shaderPro
14981498
if( !glConfig2.uniformBufferObjectAvailable ) {
14991499
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
15001500
}
1501+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
15011502
}
15021503

15031504
GLShader_vertexLighting_DBS_entity::GLShader_vertexLighting_DBS_entity( GLShaderManager *manager ) :
@@ -1512,7 +1513,6 @@ GLShader_vertexLighting_DBS_entity::GLShader_vertexLighting_DBS_entity( GLShader
15121513
u_VertexInterpolation( this ),
15131514
u_ParallaxDepthScale( this ),
15141515
u_ParallaxOffsetBias( this ),
1515-
u_HeightMapInNormalMap( this ),
15161516
u_NormalScale( this ),
15171517
u_EnvironmentInterpolation( this ),
15181518
u_LightGridOrigin( this ),
@@ -1522,6 +1522,7 @@ GLShader_vertexLighting_DBS_entity::GLShader_vertexLighting_DBS_entity( GLShader
15221522
GLDeformStage( this ),
15231523
GLCompileMacro_USE_VERTEX_SKINNING( this ),
15241524
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1525+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
15251526
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
15261527
GLCompileMacro_USE_REFLECTIVE_SPECULAR( this ),
15271528
GLCompileMacro_USE_PHYSICAL_SHADING( this )
@@ -1556,6 +1557,7 @@ void GLShader_vertexLighting_DBS_entity::SetShaderProgramUniforms( shaderProgram
15561557
if( !glConfig2.uniformBufferObjectAvailable ) {
15571558
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
15581559
}
1560+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
15591561
}
15601562

15611563
GLShader_vertexLighting_DBS_world::GLShader_vertexLighting_DBS_world( GLShaderManager *manager ) :
@@ -1573,14 +1575,14 @@ GLShader_vertexLighting_DBS_world::GLShader_vertexLighting_DBS_world( GLShaderMa
15731575
u_ModelViewProjectionMatrix( this ),
15741576
u_ParallaxDepthScale( this ),
15751577
u_ParallaxOffsetBias( this ),
1576-
u_HeightMapInNormalMap( this ),
15771578
u_NormalScale( this ),
15781579
u_LightWrapAround( this ),
15791580
u_LightGridOrigin( this ),
15801581
u_LightGridScale( this ),
15811582
u_numLights( this ),
15821583
u_Lights( this ),
15831584
GLDeformStage( this ),
1585+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
15841586
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
15851587
GLCompileMacro_USE_PHYSICAL_SHADING( this )
15861588
{
@@ -1611,6 +1613,7 @@ void GLShader_vertexLighting_DBS_world::SetShaderProgramUniforms( shaderProgram_
16111613
if( !glConfig2.uniformBufferObjectAvailable ) {
16121614
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_Lights" ), 9 );
16131615
}
1616+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
16141617
}
16151618

16161619
GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderManager *manager ):
@@ -1635,11 +1638,11 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderMana
16351638
u_VertexInterpolation( this ),
16361639
u_ParallaxDepthScale( this ),
16371640
u_ParallaxOffsetBias( this ),
1638-
u_HeightMapInNormalMap( this ),
16391641
u_NormalScale( this ),
16401642
GLDeformStage( this ),
16411643
GLCompileMacro_USE_VERTEX_SKINNING( this ),
16421644
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1645+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
16431646
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
16441647
GLCompileMacro_USE_SHADOWING( this )
16451648
{
@@ -1669,6 +1672,7 @@ void GLShader_forwardLighting_omniXYZ::SetShaderProgramUniforms( shaderProgram_t
16691672
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowMap" ), 5 );
16701673
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_RandomMap" ), 6 );
16711674
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap" ), 7 );
1675+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
16721676
}
16731677

16741678
GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderManager *manager ):
@@ -1694,11 +1698,11 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderMana
16941698
u_VertexInterpolation( this ),
16951699
u_ParallaxDepthScale( this ),
16961700
u_ParallaxOffsetBias( this ),
1697-
u_HeightMapInNormalMap( this ),
16981701
u_NormalScale( this ),
16991702
GLDeformStage( this ),
17001703
GLCompileMacro_USE_VERTEX_SKINNING( this ),
17011704
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1705+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
17021706
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
17031707
GLCompileMacro_USE_SHADOWING( this )
17041708
{
@@ -1729,6 +1733,7 @@ void GLShader_forwardLighting_projXYZ::SetShaderProgramUniforms( shaderProgram_t
17291733
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowMap0" ), 5 );
17301734
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_RandomMap" ), 6 );
17311735
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap0" ), 7 );
1736+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
17321737
}
17331738

17341739
GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun( GLShaderManager *manager ):
@@ -1756,11 +1761,11 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
17561761
u_VertexInterpolation( this ),
17571762
u_ParallaxDepthScale( this ),
17581763
u_ParallaxOffsetBias( this ),
1759-
u_HeightMapInNormalMap( this ),
17601764
u_NormalScale( this ),
17611765
GLDeformStage( this ),
17621766
GLCompileMacro_USE_VERTEX_SKINNING( this ),
17631767
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1768+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
17641769
GLCompileMacro_USE_PARALLAX_MAPPING( this ),
17651770
GLCompileMacro_USE_SHADOWING( this )
17661771
{
@@ -1798,6 +1803,7 @@ void GLShader_forwardLighting_directionalSun::SetShaderProgramUniforms( shaderPr
17981803
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap2" ), 12 );
17991804
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap3" ), 13 );
18001805
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap4" ), 14 );
1806+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
18011807
}
18021808

18031809
GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
@@ -1838,12 +1844,12 @@ GLShader_reflection::GLShader_reflection( GLShaderManager *manager ):
18381844
u_Bones( this ),
18391845
u_ParallaxDepthScale( this ),
18401846
u_ParallaxOffsetBias( this ),
1841-
u_HeightMapInNormalMap( this ),
18421847
u_NormalScale( this ),
18431848
u_VertexInterpolation( this ),
18441849
GLDeformStage( this ),
18451850
GLCompileMacro_USE_VERTEX_SKINNING( this ),
18461851
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
1852+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
18471853
GLCompileMacro_USE_PARALLAX_MAPPING( this )
18481854
{
18491855
}
@@ -1866,6 +1872,7 @@ void GLShader_reflection::SetShaderProgramUniforms( shaderProgram_t *shaderProgr
18661872
{
18671873
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ColorMap" ), 0 );
18681874
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_NormalMap" ), 1 );
1875+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
18691876
}
18701877

18711878
GLShader_skybox::GLShader_skybox( GLShaderManager *manager ) :
@@ -1964,6 +1971,7 @@ void GLShader_heatHaze::SetShaderProgramUniforms( shaderProgram_t *shaderProgram
19641971
{
19651972
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_NormalMap" ), 0 );
19661973
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_CurrentMap" ), 1 );
1974+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
19671975
}
19681976

19691977
GLShader_screen::GLShader_screen( GLShaderManager *manager ) :
@@ -2103,13 +2111,13 @@ GLShader_liquid::GLShader_liquid( GLShaderManager *manager ) :
21032111
u_FresnelBias( this ),
21042112
u_ParallaxDepthScale( this ),
21052113
u_ParallaxOffsetBias( this ),
2106-
u_HeightMapInNormalMap( this ),
21072114
u_NormalScale( this ),
21082115
u_FogDensity( this ),
21092116
u_FogColor( this ),
21102117
u_SpecularExponent( this ),
21112118
u_LightGridOrigin( this ),
21122119
u_LightGridScale( this ),
2120+
GLCompileMacro_USE_HEIGHTMAP_IN_NORMALMAP( this ),
21132121
GLCompileMacro_USE_PARALLAX_MAPPING( this )
21142122
{
21152123
}
@@ -2127,6 +2135,7 @@ void GLShader_liquid::SetShaderProgramUniforms( shaderProgram_t *shaderProgram )
21272135
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_NormalMap" ), 3 );
21282136
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid1" ), 6 );
21292137
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_LightGrid2" ), 7 );
2138+
glUniform1i( glGetUniformLocation( shaderProgram->program, "u_HeightMap" ), 15 );
21302139
}
21312140

21322141
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)