OpenGL3: Drop unused fixed-function emulation materials

This commit is contained in:
numzero 2023-04-02 21:06:09 +03:00 committed by sfan5
parent 54314691ec
commit 718ba69e1b
13 changed files with 31 additions and 889 deletions

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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);
}

@ -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);
}

@ -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;
}

@ -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;
}

@ -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);
}

@ -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";
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

@ -384,6 +384,8 @@ private:
IContextManager* ContextManager;
void addDummyMaterial(E_MATERIAL_TYPE type);
std::vector<u16> QuadsIndices;
void initQuadsIndices(int max_vertex_count = 65536);

@ -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() :

@ -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: