]> git.lizzy.rs Git - irrlicht.git/commitdiff
OpenGL3: Drop unused fixed-function emulation materials
authornumzero <numzer0@yandex.ru>
Sun, 2 Apr 2023 18:06:09 +0000 (21:06 +0300)
committersfan5 <sfan5@live.de>
Fri, 7 Apr 2023 15:42:54 +0000 (17:42 +0200)
13 files changed:
media/Shaders/DetailMap.fsh [deleted file]
media/Shaders/LightmapAdd.fsh [deleted file]
media/Shaders/LightmapModulate.fsh [deleted file]
media/Shaders/Reflection2Layer.fsh [deleted file]
media/Shaders/Reflection2Layer.vsh [deleted file]
media/Shaders/Solid2.vsh [deleted file]
media/Shaders/Solid2Layer.fsh [deleted file]
media/Shaders/SphereMap.fsh [deleted file]
media/Shaders/SphereMap.vsh [deleted file]
source/Irrlicht/OpenGL/Driver.cpp
source/Irrlicht/OpenGL/Driver.h
source/Irrlicht/OpenGL/FixedPipelineRenderer.cpp
source/Irrlicht/OpenGL/FixedPipelineRenderer.h

diff --git a/media/Shaders/DetailMap.fsh b/media/Shaders/DetailMap.fsh
deleted file mode 100644 (file)
index 01c94d7..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#version 100
-
-precision mediump float;
-
-/* Uniforms */
-
-uniform int uTextureUsage0;
-uniform int uTextureUsage1;
-uniform sampler2D uTextureUnit0;
-uniform sampler2D uTextureUnit1;
-uniform int uFogEnable;
-uniform int uFogType;
-uniform vec4 uFogColor;
-uniform float uFogStart;
-uniform float uFogEnd;
-uniform float uFogDensity;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec2 vTextureCoord1;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-float computeFog()
-{
-       const float LOG2 = 1.442695;
-       float FogFactor = 0.0;
-
-       if (uFogType == 0) // Exp
-       {
-               FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
-       }
-       else if (uFogType == 1) // Linear
-       {
-               float Scale = 1.0 / (uFogEnd - uFogStart);
-               FogFactor = (uFogEnd - vFogCoord) * Scale;
-       }
-       else if (uFogType == 2) // Exp2
-       {
-               FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
-       }
-
-       FogFactor = clamp(FogFactor, 0.0, 1.0);
-
-       return FogFactor;
-}
-
-void main()
-{
-       vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
-       vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
-
-       if (bool(uTextureUsage0))
-               Color0 = texture2D(uTextureUnit0, vTextureCoord0);
-
-       if (bool(uTextureUsage1))
-               Color1 = texture2D(uTextureUnit1, vTextureCoord1);
-
-       vec4 FinalColor = vec4(Color0 + (Color1 - 0.5)) * vVertexColor + vSpecularColor;
-
-       if (bool(uFogEnable))
-       {
-               float FogFactor = computeFog();
-               vec4 FogColor = uFogColor;
-               FogColor.a = 1.0;
-               FinalColor = mix(FogColor, FinalColor, FogFactor);
-       }
-
-       gl_FragColor = FinalColor;
-}
diff --git a/media/Shaders/LightmapAdd.fsh b/media/Shaders/LightmapAdd.fsh
deleted file mode 100644 (file)
index 895625f..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#version 100
-
-precision mediump float;
-
-/* Uniforms */
-
-uniform int uTextureUsage0;
-uniform int uTextureUsage1;
-uniform sampler2D uTextureUnit0;
-uniform sampler2D uTextureUnit1;
-uniform int uFogEnable;
-uniform int uFogType;
-uniform vec4 uFogColor;
-uniform float uFogStart;
-uniform float uFogEnd;
-uniform float uFogDensity;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec2 vTextureCoord1;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-float computeFog()
-{
-       const float LOG2 = 1.442695;
-       float FogFactor = 0.0;
-
-       if (uFogType == 0) // Exp
-       {
-               FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
-       }
-       else if (uFogType == 1) // Linear
-       {
-               float Scale = 1.0 / (uFogEnd - uFogStart);
-               FogFactor = (uFogEnd - vFogCoord) * Scale;
-       }
-       else if (uFogType == 2) // Exp2
-       {
-               FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
-       }
-
-       FogFactor = clamp(FogFactor, 0.0, 1.0);
-
-       return FogFactor;
-}
-
-void main()
-{
-       vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
-       vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
-
-       if (bool(uTextureUsage0))
-               Color0 = texture2D(uTextureUnit0, vTextureCoord0);
-
-       if (bool(uTextureUsage1))
-               Color1 = texture2D(uTextureUnit1, vTextureCoord1);
-
-       vec4 FinalColor = (Color0 + Color1) * vVertexColor + vSpecularColor;
-
-       if (bool(uFogEnable))
-       {
-               float FogFactor = computeFog();
-               vec4 FogColor = uFogColor;
-               FogColor.a = 1.0;
-               FinalColor = mix(FogColor, FinalColor, FogFactor);
-       }
-
-       gl_FragColor = FinalColor;
-}
diff --git a/media/Shaders/LightmapModulate.fsh b/media/Shaders/LightmapModulate.fsh
deleted file mode 100644 (file)
index 74e9df1..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#version 100
-
-precision mediump float;
-
-/* Uniforms */
-
-uniform float uModulate;
-uniform int uTextureUsage0;
-uniform int uTextureUsage1;
-uniform sampler2D uTextureUnit0;
-uniform sampler2D uTextureUnit1;
-uniform int uFogEnable;
-uniform int uFogType;
-uniform vec4 uFogColor;
-uniform float uFogStart;
-uniform float uFogEnd;
-uniform float uFogDensity;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec2 vTextureCoord1;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-float computeFog()
-{
-       const float LOG2 = 1.442695;
-       float FogFactor = 0.0;
-
-       if (uFogType == 0) // Exp
-       {
-               FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
-       }
-       else if (uFogType == 1) // Linear
-       {
-               float Scale = 1.0 / (uFogEnd - uFogStart);
-               FogFactor = (uFogEnd - vFogCoord) * Scale;
-       }
-       else if (uFogType == 2) // Exp2
-       {
-               FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
-       }
-
-       FogFactor = clamp(FogFactor, 0.0, 1.0);
-
-       return FogFactor;
-}
-
-void main()
-{
-       vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
-       vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
-
-       if (bool(uTextureUsage0))
-               Color0 = texture2D(uTextureUnit0, vTextureCoord0);
-
-       if (bool(uTextureUsage1))
-               Color1 = texture2D(uTextureUnit1, vTextureCoord1);
-
-       vec4 FinalColor = (Color0 * Color1 * uModulate) * vVertexColor;
-       FinalColor += vSpecularColor;
-
-       if (bool(uFogEnable))
-       {
-               float FogFactor = computeFog();
-               vec4 FogColor = uFogColor;
-               FogColor.a = 1.0;
-               FinalColor = mix(FogColor, FinalColor, FogFactor);
-       }
-
-       gl_FragColor = FinalColor;
-}
diff --git a/media/Shaders/Reflection2Layer.fsh b/media/Shaders/Reflection2Layer.fsh
deleted file mode 100644 (file)
index bdc3c66..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#version 100
-
-precision mediump float;
-
-/* Uniforms */
-
-uniform int uTextureUsage0;
-uniform int uTextureUsage1;
-uniform sampler2D uTextureUnit0;
-uniform sampler2D uTextureUnit1;
-uniform int uFogEnable;
-uniform int uFogType;
-uniform vec4 uFogColor;
-uniform float uFogStart;
-uniform float uFogEnd;
-uniform float uFogDensity;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec2 vTextureCoord1;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-float computeFog()
-{
-       const float LOG2 = 1.442695;
-       float FogFactor = 0.0;
-
-       if (uFogType == 0) // Exp
-       {
-               FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
-       }
-       else if (uFogType == 1) // Linear
-       {
-               float Scale = 1.0 / (uFogEnd - uFogStart);
-               FogFactor = (uFogEnd - vFogCoord) * Scale;
-       }
-       else if (uFogType == 2) // Exp2
-       {
-               FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
-       }
-
-       FogFactor = clamp(FogFactor, 0.0, 1.0);
-
-       return FogFactor;
-}
-
-void main()
-{
-       vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
-       vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
-
-       if (bool(uTextureUsage0))
-               Color0 = texture2D(uTextureUnit0, vTextureCoord0);
-
-       if (bool(uTextureUsage1))
-               Color1 = texture2D(uTextureUnit1, vTextureCoord1);
-
-       vec4 FinalColor = (Color0 * Color1) * vVertexColor + vSpecularColor;
-
-       if (bool(uFogEnable))
-       {
-               float FogFactor = computeFog();
-               vec4 FogColor = uFogColor;
-               FogColor.a = 1.0;
-               FinalColor = mix(FogColor, FinalColor, FogFactor);
-       }
-
-       gl_FragColor = FinalColor;
-}
diff --git a/media/Shaders/Reflection2Layer.vsh b/media/Shaders/Reflection2Layer.vsh
deleted file mode 100644 (file)
index aafac22..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#version 100
-
-/* Attributes */
-
-attribute vec3 inVertexPosition;
-attribute vec3 inVertexNormal;
-attribute vec4 inVertexColor;
-attribute vec2 inTexCoord0;
-attribute vec2 inTexCoord1;
-
-/* Uniforms */
-
-uniform mat4 uWVPMatrix;
-uniform mat4 uWVMatrix;
-uniform mat4 uNMatrix;
-uniform mat4 uTMatrix0;
-
-uniform vec4 uGlobalAmbient;
-uniform vec4 uMaterialAmbient;
-uniform vec4 uMaterialDiffuse;
-uniform vec4 uMaterialEmissive;
-uniform vec4 uMaterialSpecular;
-uniform float uMaterialShininess;
-
-uniform float uThickness;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec2 vTextureCoord1;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-void main()
-{
-       gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
-       gl_PointSize = uThickness;
-
-       vec4 TextureCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 1.0, 1.0);
-       vTextureCoord0 = vec4(uTMatrix0 * TextureCoord0).xy;
-
-       vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
-       vec3 P = normalize(Position);
-       vec3 N = normalize(vec4(uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
-       vec3 R = reflect(P, N);
-
-       float V = 2.0 * sqrt(R.x*R.x + R.y*R.y + (R.z+1.0)*(R.z+1.0));
-       vTextureCoord1 = vec2(R.x/V + 0.5, R.y/V + 0.5);
-
-       vVertexColor = inVertexColor.bgra;
-       vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
-
-       vFogCoord = length(Position);
-}
diff --git a/media/Shaders/Solid2.vsh b/media/Shaders/Solid2.vsh
deleted file mode 100644 (file)
index c49ecfc..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#version 100
-
-/* Attributes */
-
-attribute vec3 inVertexPosition;
-attribute vec3 inVertexNormal;
-attribute vec4 inVertexColor;
-attribute vec2 inTexCoord0;
-attribute vec2 inTexCoord1;
-
-/* Uniforms */
-
-uniform mat4 uWVPMatrix;
-uniform mat4 uWVMatrix;
-uniform mat4 uNMatrix;
-uniform mat4 uTMatrix0;
-uniform mat4 uTMatrix1;
-
-uniform vec4 uGlobalAmbient;
-uniform vec4 uMaterialAmbient;
-uniform vec4 uMaterialDiffuse;
-uniform vec4 uMaterialEmissive;
-uniform vec4 uMaterialSpecular;
-uniform float uMaterialShininess;
-
-uniform float uThickness;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec2 vTextureCoord1;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-void main()
-{
-       gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
-       gl_PointSize = uThickness;
-
-       vec4 TextureCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 1.0, 1.0);
-       vTextureCoord0 = vec4(uTMatrix0 * TextureCoord0).xy;
-
-       vec4 TextureCoord1 = vec4(inTexCoord1.x, inTexCoord1.y, 1.0, 1.0);
-       vTextureCoord1 = vec4(uTMatrix1 * TextureCoord1).xy;
-
-       vVertexColor = inVertexColor.bgra;
-       vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
-
-       vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
-
-       vFogCoord = length(Position);
-}
diff --git a/media/Shaders/Solid2Layer.fsh b/media/Shaders/Solid2Layer.fsh
deleted file mode 100644 (file)
index 3c8a39d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#version 100
-
-precision mediump float;
-
-/* Uniforms */
-
-uniform int uTextureUsage0;
-uniform int uTextureUsage1;
-uniform sampler2D uTextureUnit0;
-uniform sampler2D uTextureUnit1;
-uniform int uFogEnable;
-uniform int uFogType;
-uniform vec4 uFogColor;
-uniform float uFogStart;
-uniform float uFogEnd;
-uniform float uFogDensity;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec2 vTextureCoord1;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-float computeFog()
-{
-       const float LOG2 = 1.442695;
-       float FogFactor = 0.0;
-
-       if (uFogType == 0) // Exp
-       {
-               FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
-       }
-       else if (uFogType == 1) // Linear
-       {
-               float Scale = 1.0 / (uFogEnd - uFogStart);
-               FogFactor = (uFogEnd - vFogCoord) * Scale;
-       }
-       else if (uFogType == 2) // Exp2
-       {
-               FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
-       }
-
-       FogFactor = clamp(FogFactor, 0.0, 1.0);
-
-       return FogFactor;
-}
-
-void main()
-{
-       vec4 Color0 = vec4(1.0, 1.0, 1.0, 1.0);
-       vec4 Color1 = vec4(1.0, 1.0, 1.0, 1.0);
-
-       if (bool(uTextureUsage0))
-               Color0 = texture2D(uTextureUnit0, vTextureCoord0);
-
-       if (bool(uTextureUsage1))
-               Color1 = texture2D(uTextureUnit1, vTextureCoord1);
-
-       vec4 FinalColor = (Color0 * vVertexColor.a + Color1 * (1.0 - vVertexColor.a)) * vVertexColor;
-       FinalColor += vSpecularColor;
-
-       if (bool(uFogEnable))
-       {
-               float FogFactor = computeFog();
-               vec4 FogColor = uFogColor;
-               FogColor.a = 1.0;
-               FinalColor = mix(FogColor, FinalColor, FogFactor);
-       }
-
-       gl_FragColor = FinalColor;
-
-}
diff --git a/media/Shaders/SphereMap.fsh b/media/Shaders/SphereMap.fsh
deleted file mode 100644 (file)
index df1010e..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#version 100
-
-precision mediump float;
-
-/* Uniforms */
-
-uniform int uTextureUsage0;
-uniform sampler2D uTextureUnit0;
-uniform int uFogEnable;
-uniform int uFogType;
-uniform vec4 uFogColor;
-uniform float uFogStart;
-uniform float uFogEnd;
-uniform float uFogDensity;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-float computeFog()
-{
-       const float LOG2 = 1.442695;
-       float FogFactor = 0.0;
-
-       if (uFogType == 0) // Exp
-       {
-               FogFactor = exp2(-uFogDensity * vFogCoord * LOG2);
-       }
-       else if (uFogType == 1) // Linear
-       {
-               float Scale = 1.0 / (uFogEnd - uFogStart);
-               FogFactor = (uFogEnd - vFogCoord) * Scale;
-       }
-       else if (uFogType == 2) // Exp2
-       {
-               FogFactor = exp2(-uFogDensity * uFogDensity * vFogCoord * vFogCoord * LOG2);
-       }
-
-       FogFactor = clamp(FogFactor, 0.0, 1.0);
-
-       return FogFactor;
-}
-
-void main()
-{
-       vec4 Color = vVertexColor;
-
-       if (bool(uTextureUsage0))
-               Color *= texture2D(uTextureUnit0, vTextureCoord0);
-       Color += vSpecularColor;
-
-       if (bool(uFogEnable))
-       {
-               float FogFactor = computeFog();
-               vec4 FogColor = uFogColor;
-               FogColor.a = 1.0;
-               Color = mix(FogColor, Color, FogFactor);
-       }
-
-       gl_FragColor = Color;
-}
diff --git a/media/Shaders/SphereMap.vsh b/media/Shaders/SphereMap.vsh
deleted file mode 100644 (file)
index 5062d79..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#version 100
-
-/* Attributes */
-
-attribute vec3 inVertexPosition;
-attribute vec3 inVertexNormal;
-attribute vec4 inVertexColor;
-attribute vec2 inTexCoord0;
-attribute vec2 inTexCoord1;
-
-/* Uniforms */
-
-uniform mat4 uWVPMatrix;
-uniform mat4 uWVMatrix;
-uniform mat4 uNMatrix;
-
-uniform vec4 uGlobalAmbient;
-uniform vec4 uMaterialAmbient;
-uniform vec4 uMaterialDiffuse;
-uniform vec4 uMaterialEmissive;
-uniform vec4 uMaterialSpecular;
-uniform float uMaterialShininess;
-
-uniform float uThickness;
-
-/* Varyings */
-
-varying vec2 vTextureCoord0;
-varying vec4 vVertexColor;
-varying vec4 vSpecularColor;
-varying float vFogCoord;
-
-void main()
-{
-       gl_Position = uWVPMatrix * vec4(inVertexPosition, 1.0);
-       gl_PointSize = uThickness;
-
-       vec3 Position = (uWVMatrix * vec4(inVertexPosition, 1.0)).xyz;
-       vec3 P = normalize(Position);
-       vec3 N = normalize(vec4(uNMatrix * vec4(inVertexNormal, 0.0)).xyz);
-       vec3 R = reflect(P, N);
-
-       float V = 2.0 * sqrt(R.x*R.x + R.y*R.y + (R.z+1.0)*(R.z+1.0));
-       vTextureCoord0 = vec2(R.x/V + 0.5, R.y/V + 0.5);
-
-       vVertexColor = inVertexColor.bgra;
-       vSpecularColor = vec4(0.0, 0.0, 0.0, 0.0);
-
-       vFogCoord = length(Position);
-}
index 641536fca183ccb0a3903ee8ff8db65332a5b5d7..6dec58f100c1bc9e70258e66e36fea0e3d9ab8ae 100644 (file)
@@ -317,140 +317,73 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
                fsFile->drop();
        }
 
+       void COpenGL3DriverBase::addDummyMaterial(E_MATERIAL_TYPE type) {
+               auto index = addMaterialRenderer(getMaterialRenderer(EMT_SOLID), "DUMMY");
+               assert(index == type);
+       }
+
        void COpenGL3DriverBase::createMaterialRenderers()
        {
                // Create callbacks.
 
                COpenGL3MaterialSolidCB* SolidCB = new COpenGL3MaterialSolidCB();
-               COpenGL3MaterialSolid2CB* Solid2LayerCB = new COpenGL3MaterialSolid2CB();
-               COpenGL3MaterialLightmapCB* LightmapCB = new COpenGL3MaterialLightmapCB(1.f);
-               COpenGL3MaterialLightmapCB* LightmapAddCB = new COpenGL3MaterialLightmapCB(1.f);
-               COpenGL3MaterialLightmapCB* LightmapM2CB = new COpenGL3MaterialLightmapCB(2.f);
-               COpenGL3MaterialLightmapCB* LightmapM4CB = new COpenGL3MaterialLightmapCB(4.f);
-               COpenGL3MaterialLightmapCB* LightmapLightingCB = new COpenGL3MaterialLightmapCB(1.f);
-               COpenGL3MaterialLightmapCB* LightmapLightingM2CB = new COpenGL3MaterialLightmapCB(2.f);
-               COpenGL3MaterialLightmapCB* LightmapLightingM4CB = new COpenGL3MaterialLightmapCB(4.f);
-               COpenGL3MaterialSolid2CB* DetailMapCB = new COpenGL3MaterialSolid2CB();
-               COpenGL3MaterialReflectionCB* SphereMapCB = new COpenGL3MaterialReflectionCB();
-               COpenGL3MaterialReflectionCB* Reflection2LayerCB = new COpenGL3MaterialReflectionCB();
-               COpenGL3MaterialSolidCB* TransparentAddColorCB = new COpenGL3MaterialSolidCB();
                COpenGL3MaterialSolidCB* TransparentAlphaChannelCB = new COpenGL3MaterialSolidCB();
                COpenGL3MaterialSolidCB* TransparentAlphaChannelRefCB = new COpenGL3MaterialSolidCB();
                COpenGL3MaterialSolidCB* TransparentVertexAlphaCB = new COpenGL3MaterialSolidCB();
-               COpenGL3MaterialReflectionCB* TransparentReflection2LayerCB = new COpenGL3MaterialReflectionCB();
                COpenGL3MaterialOneTextureBlendCB* OneTextureBlendCB = new COpenGL3MaterialOneTextureBlendCB();
 
                // Create built-in materials.
+               // The addition order must be the same as in the E_MATERIAL_TYPE enumeration. Thus the
+               // addDummyMaterial calls for materials no longer supported.
 
-               core::stringc VertexShader = OGLES2ShaderPath + "Solid.vsh";
-               core::stringc FragmentShader = OGLES2ShaderPath + "Solid.fsh";
+               const core::stringc VertexShader = OGLES2ShaderPath + "Solid.vsh";
 
+               // EMT_SOLID
+               core::stringc FragmentShader = OGLES2ShaderPath + "Solid.fsh";
                addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
                        EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, SolidCB, EMT_SOLID, 0);
 
-               VertexShader = OGLES2ShaderPath + "Solid2.vsh";
-               FragmentShader = OGLES2ShaderPath + "Solid2Layer.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, Solid2LayerCB, EMT_SOLID, 0);
-
-               VertexShader = OGLES2ShaderPath + "Solid2.vsh";
-               FragmentShader = OGLES2ShaderPath + "LightmapModulate.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, LightmapCB, EMT_SOLID, 0);
-
-               FragmentShader = OGLES2ShaderPath + "LightmapAdd.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, LightmapAddCB, EMT_SOLID, 0);
-
-               FragmentShader = OGLES2ShaderPath + "LightmapModulate.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, LightmapM2CB, EMT_SOLID, 0);
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, LightmapM4CB, EMT_SOLID, 0);
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, LightmapLightingCB, EMT_SOLID, 0);
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, LightmapLightingM2CB, EMT_SOLID, 0);
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, LightmapLightingM4CB, EMT_SOLID, 0);
-
-               VertexShader = OGLES2ShaderPath + "Solid2.vsh";
-               FragmentShader = OGLES2ShaderPath + "DetailMap.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, DetailMapCB, EMT_SOLID, 0);
-
-               VertexShader = OGLES2ShaderPath + "SphereMap.vsh";
-               FragmentShader = OGLES2ShaderPath + "SphereMap.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, SphereMapCB, EMT_SOLID, 0);
-
-               VertexShader = OGLES2ShaderPath + "Reflection2Layer.vsh";
-               FragmentShader = OGLES2ShaderPath + "Reflection2Layer.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, Reflection2LayerCB, EMT_SOLID, 0);
-
-               VertexShader = OGLES2ShaderPath + "Solid.vsh";
-               FragmentShader = OGLES2ShaderPath + "Solid.fsh";
-
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentAddColorCB, EMT_TRANSPARENT_ADD_COLOR, 0);
-
+               addDummyMaterial(EMT_SOLID_2_LAYER);
+               addDummyMaterial(EMT_LIGHTMAP);
+               addDummyMaterial(EMT_LIGHTMAP_ADD);
+               addDummyMaterial(EMT_LIGHTMAP_M2);
+               addDummyMaterial(EMT_LIGHTMAP_M4);
+               addDummyMaterial(EMT_LIGHTMAP_LIGHTING);
+               addDummyMaterial(EMT_LIGHTMAP_LIGHTING_M2);
+               addDummyMaterial(EMT_LIGHTMAP_LIGHTING_M4);
+               addDummyMaterial(EMT_DETAIL_MAP);
+               addDummyMaterial(EMT_SPHERE_MAP);
+               addDummyMaterial(EMT_REFLECTION_2_LAYER);
+               addDummyMaterial(EMT_TRANSPARENT_ADD_COLOR);
+
+               // EMT_TRANSPARENT_ALPHA_CHANNEL
                FragmentShader = OGLES2ShaderPath + "TransparentAlphaChannel.fsh";
                addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
                        EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentAlphaChannelCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
 
+               // EMT_TRANSPARENT_ALPHA_CHANNEL_REF
                FragmentShader = OGLES2ShaderPath + "TransparentAlphaChannelRef.fsh";
-
                addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
                        EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentAlphaChannelRefCB, EMT_SOLID, 0);
 
+               // EMT_TRANSPARENT_VERTEX_ALPHA
                FragmentShader = OGLES2ShaderPath + "TransparentVertexAlpha.fsh";
-
                addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
                        EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentVertexAlphaCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
 
-               VertexShader = OGLES2ShaderPath + "Reflection2Layer.vsh";
-               FragmentShader = OGLES2ShaderPath + "Reflection2Layer.fsh";
+               addDummyMaterial(EMT_TRANSPARENT_REFLECTION_2_LAYER);
 
-               addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
-                       EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentReflection2LayerCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
-
-               VertexShader = OGLES2ShaderPath + "Solid.vsh";
+               // EMT_ONETEXTURE_BLEND
                FragmentShader = OGLES2ShaderPath + "OneTextureBlend.fsh";
-
                addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
                        EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, OneTextureBlendCB, EMT_ONETEXTURE_BLEND, 0);
 
                // Drop callbacks.
 
                SolidCB->drop();
-               Solid2LayerCB->drop();
-               LightmapCB->drop();
-               LightmapAddCB->drop();
-               LightmapM2CB->drop();
-               LightmapM4CB->drop();
-               LightmapLightingCB->drop();
-               LightmapLightingM2CB->drop();
-               LightmapLightingM4CB->drop();
-               DetailMapCB->drop();
-               SphereMapCB->drop();
-               Reflection2LayerCB->drop();
-               TransparentAddColorCB->drop();
                TransparentAlphaChannelCB->drop();
                TransparentAlphaChannelRefCB->drop();
                TransparentVertexAlphaCB->drop();
-               TransparentReflection2LayerCB->drop();
                OneTextureBlendCB->drop();
 
                // Create 2D material renderers
index 06907b7ae37b9855347067bb2951559fcafa7939..c91ccfea9d8b05aa3b991318e35a707d0ded5155 100644 (file)
@@ -384,6 +384,8 @@ private:
 
                IContextManager* ContextManager;
 
+               void addDummyMaterial(E_MATERIAL_TYPE type);
+
                std::vector<u16> QuadsIndices;
                void initQuadsIndices(int max_vertex_count = 65536);
 
index 2922470938b1708d6e974f56c9c7dc4dcf0fc66f..421788acd2628d1be5e66e5acd6e344231464634 100644 (file)
@@ -1,3 +1,4 @@
+// Copyright (C) 2023 Vitaliy Lobachevskiy
 // Copyright (C) 2014 Patryk Nadrowski
 // This file is part of the "Irrlicht Engine".
 // For conditions of distribution and use, see copyright notice in Irrlicht.h
@@ -137,142 +138,6 @@ void COpenGL3MaterialSolidCB::OnSetConstants(IMaterialRendererServices* services
        services->setPixelShaderConstant(TextureUnit0ID, &TextureUnit0, 1);
 }
 
-// EMT_SOLID_2_LAYER + EMT_DETAIL_MAP
-
-COpenGL3MaterialSolid2CB::COpenGL3MaterialSolid2CB() :
-       FirstUpdate(true), TMatrix0ID(-1), TMatrix1ID(-1), TextureUsage0ID(-1), TextureUsage1ID(-1), TextureUnit0ID(-1), TextureUnit1ID(-1),
-       TextureUsage0(0), TextureUsage1(0), TextureUnit0(0), TextureUnit1(1)
-{
-}
-
-void COpenGL3MaterialSolid2CB::OnSetMaterial(const SMaterial& material)
-{
-       COpenGL3MaterialBaseCB::OnSetMaterial(material);
-
-       TextureUsage0 = (material.TextureLayer[0].Texture) ? 1 : 0;
-       TextureUsage1 = (material.TextureLayer[1].Texture) ? 1 : 0;
-}
-
-void COpenGL3MaterialSolid2CB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
-{
-       COpenGL3MaterialBaseCB::OnSetConstants(services, userData);
-
-       IVideoDriver* driver = services->getVideoDriver();
-
-       if (FirstUpdate)
-       {
-               TMatrix0ID = services->getVertexShaderConstantID("uTMatrix0");
-               TMatrix1ID = services->getVertexShaderConstantID("uTMatrix1");
-               TextureUsage0ID = services->getVertexShaderConstantID("uTextureUsage0");
-               TextureUsage1ID = services->getVertexShaderConstantID("uTextureUsage1");
-               TextureUnit0ID = services->getVertexShaderConstantID("uTextureUnit0");
-               TextureUnit1ID = services->getVertexShaderConstantID("uTextureUnit1");
-
-               FirstUpdate = false;
-       }
-
-       core::matrix4 Matrix = driver->getTransform(ETS_TEXTURE_0);
-       services->setPixelShaderConstant(TMatrix0ID, Matrix.pointer(), 16);
-
-       Matrix = driver->getTransform(E_TRANSFORMATION_STATE(ETS_TEXTURE_0 + 1));
-       services->setPixelShaderConstant(TMatrix1ID, Matrix.pointer(), 16);
-
-       services->setPixelShaderConstant(TextureUsage0ID, &TextureUsage0, 1);
-       services->setPixelShaderConstant(TextureUsage1ID, &TextureUsage1, 1);
-       services->setPixelShaderConstant(TextureUnit0ID, &TextureUnit0, 1);
-       services->setPixelShaderConstant(TextureUnit1ID, &TextureUnit1, 1);
-}
-
-// EMT_LIGHTMAP + EMT_LIGHTMAP_ADD + EMT_LIGHTMAP_M2 + EMT_LIGHTMAP_M4
-
-COpenGL3MaterialLightmapCB::COpenGL3MaterialLightmapCB(float modulate) :
-       FirstUpdate(true), TMatrix0ID(-1), TMatrix1ID(-1), ModulateID(-1), TextureUsage0ID(-1), TextureUsage1ID(-1), TextureUnit0ID(-1), TextureUnit1ID(-1),
-       Modulate(modulate), TextureUsage0(0), TextureUsage1(0), TextureUnit0(0), TextureUnit1(1)
-{
-}
-
-void COpenGL3MaterialLightmapCB::OnSetMaterial(const SMaterial& material)
-{
-       COpenGL3MaterialBaseCB::OnSetMaterial(material);
-
-       TextureUsage0 = (material.TextureLayer[0].Texture) ? 1 : 0;
-       TextureUsage1 = (material.TextureLayer[1].Texture) ? 1 : 0;
-}
-
-void COpenGL3MaterialLightmapCB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
-{
-       COpenGL3MaterialBaseCB::OnSetConstants(services, userData);
-
-       IVideoDriver* driver = services->getVideoDriver();
-
-       if (FirstUpdate)
-       {
-               TMatrix0ID = services->getVertexShaderConstantID("uTMatrix0");
-               TMatrix1ID = services->getVertexShaderConstantID("uTMatrix1");
-               ModulateID = services->getVertexShaderConstantID("uModulate");
-               TextureUsage0ID = services->getVertexShaderConstantID("uTextureUsage0");
-               TextureUsage1ID = services->getVertexShaderConstantID("uTextureUsage1");
-               TextureUnit0ID = services->getVertexShaderConstantID("uTextureUnit0");
-               TextureUnit1ID = services->getVertexShaderConstantID("uTextureUnit1");
-
-               FirstUpdate = false;
-       }
-
-       core::matrix4 Matrix = driver->getTransform(ETS_TEXTURE_0);
-       services->setPixelShaderConstant(TMatrix0ID, Matrix.pointer(), 16);
-
-       Matrix = driver->getTransform(E_TRANSFORMATION_STATE(ETS_TEXTURE_0 + 1));
-       services->setPixelShaderConstant(TMatrix1ID, Matrix.pointer(), 16);
-
-       services->setPixelShaderConstant(ModulateID, &Modulate, 1);
-       services->setPixelShaderConstant(TextureUsage0ID, &TextureUsage0, 1);
-       services->setPixelShaderConstant(TextureUsage1ID, &TextureUsage1, 1);
-       services->setPixelShaderConstant(TextureUnit0ID, &TextureUnit0, 1);
-       services->setPixelShaderConstant(TextureUnit1ID, &TextureUnit1, 1);
-}
-
-// EMT_SPHERE_MAP + EMT_REFLECTION_2_LAYER + EMT_TRANSPARENT_REFLECTION_2_LAYER
-
-COpenGL3MaterialReflectionCB::COpenGL3MaterialReflectionCB() :
-       FirstUpdate(true), TMatrix0ID(-1), TextureUsage0ID(-1), TextureUsage1ID(-1), TextureUnit0ID(-1), TextureUnit1ID(-1),
-       TextureUsage0(0), TextureUsage1(0), TextureUnit0(0), TextureUnit1(1)
-{
-}
-
-void COpenGL3MaterialReflectionCB::OnSetMaterial(const SMaterial& material)
-{
-       COpenGL3MaterialBaseCB::OnSetMaterial(material);
-
-       TextureUsage0 = (material.TextureLayer[0].Texture) ? 1 : 0;
-       TextureUsage1 = (material.TextureLayer[1].Texture) ? 1 : 0;
-}
-
-void COpenGL3MaterialReflectionCB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
-{
-       COpenGL3MaterialBaseCB::OnSetConstants(services, userData);
-
-       IVideoDriver* driver = services->getVideoDriver();
-
-       if (FirstUpdate)
-       {
-               TMatrix0ID = services->getVertexShaderConstantID("uTMatrix0");
-               TextureUsage0ID = services->getVertexShaderConstantID("uTextureUsage0");
-               TextureUsage1ID = services->getVertexShaderConstantID("uTextureUsage1");
-               TextureUnit0ID = services->getVertexShaderConstantID("uTextureUnit0");
-               TextureUnit1ID = services->getVertexShaderConstantID("uTextureUnit1");
-
-               FirstUpdate = false;
-       }
-
-       core::matrix4 Matrix = driver->getTransform(ETS_TEXTURE_0);
-       services->setPixelShaderConstant(TMatrix0ID, Matrix.pointer(), 16);
-
-       services->setPixelShaderConstant(TextureUsage0ID, &TextureUsage0, 1);
-       services->setPixelShaderConstant(TextureUsage1ID, &TextureUsage1, 1);
-       services->setPixelShaderConstant(TextureUnit0ID, &TextureUnit0, 1);
-       services->setPixelShaderConstant(TextureUnit1ID, &TextureUnit1, 1);
-}
-
 // EMT_ONETEXTURE_BLEND
 
 COpenGL3MaterialOneTextureBlendCB::COpenGL3MaterialOneTextureBlendCB() :
index aea935fa3358327990b9dd2e0c090f988638924a..cfbb3b662c18c2e6a51597a1f71d2be3d628fd08 100644 (file)
@@ -1,3 +1,4 @@
+// Copyright (C) 2023 Vitaliy Lobachevskiy
 // Copyright (C) 2014 Patryk Nadrowski
 // This file is part of the "Irrlicht Engine".
 // For conditions of distribution and use, see copyright notice in Irrlicht.h
@@ -82,79 +83,6 @@ protected:
        s32 TextureUnit0;
 };
 
-class COpenGL3MaterialSolid2CB : public COpenGL3MaterialBaseCB
-{
-public:
-       COpenGL3MaterialSolid2CB();
-
-       virtual void OnSetMaterial(const SMaterial& material);
-       virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData);
-
-protected:
-       bool FirstUpdate;
-
-       s32 TMatrix0ID;
-       s32 TMatrix1ID;
-       s32 TextureUsage0ID;
-       s32 TextureUsage1ID;
-       s32 TextureUnit0ID;
-       s32 TextureUnit1ID;
-
-       s32 TextureUsage0;
-       s32 TextureUsage1;
-       s32 TextureUnit0;
-       s32 TextureUnit1;
-};
-
-class COpenGL3MaterialLightmapCB : public COpenGL3MaterialBaseCB
-{
-public:
-       COpenGL3MaterialLightmapCB(float modulate);
-
-       virtual void OnSetMaterial(const SMaterial& material);
-       virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData);
-
-protected:
-       bool FirstUpdate;
-
-       s32 TMatrix0ID;
-       s32 TMatrix1ID;
-       s32 ModulateID;
-       s32 TextureUsage0ID;
-       s32 TextureUsage1ID;
-       s32 TextureUnit0ID;
-       s32 TextureUnit1ID;
-
-       f32 Modulate;
-       s32 TextureUsage0;
-       s32 TextureUsage1;
-       s32 TextureUnit0;
-       s32 TextureUnit1;
-};
-
-class COpenGL3MaterialReflectionCB : public COpenGL3MaterialBaseCB
-{
-public:
-       COpenGL3MaterialReflectionCB();
-
-       virtual void OnSetMaterial(const SMaterial& material);
-       virtual void OnSetConstants(IMaterialRendererServices* services, s32 userData);
-
-protected:
-       bool FirstUpdate;
-
-       s32 TMatrix0ID;
-       s32 TextureUsage0ID;
-       s32 TextureUsage1ID;
-       s32 TextureUnit0ID;
-       s32 TextureUnit1ID;
-
-       s32 TextureUsage0;
-       s32 TextureUsage1;
-       s32 TextureUnit0;
-       s32 TextureUnit1;
-};
-
 class COpenGL3MaterialOneTextureBlendCB : public COpenGL3MaterialBaseCB
 {
 public: