Remove unused fixed function materials

This commit is contained in:
Gregor Parzefall 2023-06-14 15:24:43 +02:00 committed by sfan5
parent 8c856408f5
commit 98589d2fd2
32 changed files with 50 additions and 2012 deletions

@ -28,9 +28,6 @@ namespace scene
//! Overlays Mesh Wireframe
EDS_MESH_WIRE_OVERLAY = 8,
//! Temporary use transparency Material Type
EDS_HALF_TRANSPARENCY = 16,
//! Show Bounding Boxes of all MeshBuffers
EDS_BBOX_BUFFERS = 32,

@ -18,75 +18,6 @@ namespace video
diffuse material. */
EMT_SOLID = 0,
//! Solid material with 2 texture layers.
/** The second is blended onto the first using the alpha value
of the vertex colors. This material is currently not implemented in OpenGL.
*/
EMT_SOLID_2_LAYER,
//! Material type with standard lightmap technique
/** There should be 2 textures: The first texture layer is a
diffuse map, the second is a light map. Dynamic light is
ignored. */
EMT_LIGHTMAP,
//! Material type with lightmap technique like EMT_LIGHTMAP.
/** But lightmap and diffuse texture are added instead of modulated. */
EMT_LIGHTMAP_ADD,
//! Material type with standard lightmap technique
/** There should be 2 textures: The first texture layer is a
diffuse map, the second is a light map. Dynamic light is
ignored. The texture colors are effectively multiplied by 2
for brightening. Like known in DirectX as D3DTOP_MODULATE2X. */
EMT_LIGHTMAP_M2,
//! Material type with standard lightmap technique
/** There should be 2 textures: The first texture layer is a
diffuse map, the second is a light map. Dynamic light is
ignored. The texture colors are effectively multiplied by 4
for brightening. Like known in DirectX as D3DTOP_MODULATE4X. */
EMT_LIGHTMAP_M4,
//! Like EMT_LIGHTMAP, but also supports dynamic lighting.
EMT_LIGHTMAP_LIGHTING,
//! Like EMT_LIGHTMAP_M2, but also supports dynamic lighting.
EMT_LIGHTMAP_LIGHTING_M2,
//! Like EMT_LIGHTMAP_M4, but also supports dynamic lighting.
EMT_LIGHTMAP_LIGHTING_M4,
//! Detail mapped material.
/** The first texture is diffuse color map, the second is added
to this and usually displayed with a bigger scale value so that
it adds more detail. The detail map is added to the diffuse map
using ADD_SIGNED, so that it is possible to add and subtract
color from the diffuse map. For example a value of
(127,127,127) will not change the appearance of the diffuse map
at all. Often used for terrain rendering. */
EMT_DETAIL_MAP,
//! Look like a reflection of the environment around it.
/** To make this possible, a texture called 'sphere map' is
used, which must be set as the first texture. */
EMT_SPHERE_MAP,
//! A reflecting material with an optional non reflecting texture layer.
/** The reflection map should be set as first texture. */
EMT_REFLECTION_2_LAYER,
//! A transparent material.
/** Only the first texture is used. The new color is calculated
by simply adding the source color and the dest color. This
means if for example a billboard using a texture with black
background and a red circle on it is drawn with this material,
the result is that only the red circle will be drawn a little
bit transparent, and everything which was black is 100%
transparent and not visible. This material type is useful for
particle effects. */
EMT_TRANSPARENT_ADD_COLOR,
//! Makes the material transparent based on the texture alpha channel.
/** The final color is blended together from the destination
color and the texture color, using the alpha channel value as
@ -115,12 +46,6 @@ namespace video
//! Makes the material transparent based on the vertex alpha value.
EMT_TRANSPARENT_VERTEX_ALPHA,
//! A transparent reflecting material with an optional additional non reflecting texture layer.
/** The reflection map should be set as first texture. The
transparency depends on the alpha value in the vertex colors. A
texture which will not reflect can be set as second texture.*/
EMT_TRANSPARENT_REFLECTION_2_LAYER,
//! BlendFunc = source * sourceFactor + dest * destFactor ( E_BLEND_FUNC )
/** Using only first texture. Generic blending method.
The blend function is set to SMaterial::MaterialTypeParam with
@ -135,22 +60,9 @@ namespace video
const char* const sBuiltInMaterialTypeNames[] =
{
"solid",
"solid_2layer",
"lightmap",
"lightmap_add",
"lightmap_m2",
"lightmap_m4",
"lightmap_light",
"lightmap_light_m2",
"lightmap_light_m4",
"detail_map",
"sphere_map",
"reflection_2layer",
"trans_add",
"trans_alphach",
"trans_alphach_ref",
"trans_vertex_alpha",
"trans_reflection_2layer",
"onetexture_blend",
0
};

@ -292,7 +292,7 @@ namespace video
SMaterial()
: MaterialType(EMT_SOLID), AmbientColor(255,255,255,255), DiffuseColor(255,255,255,255),
EmissiveColor(0,0,0,0), SpecularColor(255,255,255,255),
Shininess(0.0f), MaterialTypeParam(0.0f), MaterialTypeParam2(0.0f), Thickness(1.0f),
Shininess(0.0f), MaterialTypeParam(0.0f), Thickness(1.0f),
ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL),
ColorMaterial(ECM_DIFFUSE), BlendOperation(EBO_NONE), BlendFactor(0.0f),
PolygonOffsetFactor(0), PolygonOffsetDirection(EPO_FRONT),
@ -350,10 +350,6 @@ namespace video
EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_ONETEXTURE_BLEND. */
f32 MaterialTypeParam;
//! Second free parameter, dependent on the material type.
/** Mostly ignored. */
f32 MaterialTypeParam2;
//! Thickness of non-3dimensional elements such as lines and points.
f32 Thickness;
@ -664,7 +660,6 @@ namespace video
SpecularColor != b.SpecularColor ||
Shininess != b.Shininess ||
MaterialTypeParam != b.MaterialTypeParam ||
MaterialTypeParam2 != b.MaterialTypeParam2 ||
Thickness != b.Thickness ||
Wireframe != b.Wireframe ||
PointCloud != b.PointCloud ||
@ -728,10 +723,8 @@ namespace video
//! as it asks the material renders directly what they do with the material.
bool isTransparent() const
{
if ( MaterialType==EMT_TRANSPARENT_ADD_COLOR ||
MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL ||
MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA ||
MaterialType==EMT_TRANSPARENT_REFLECTION_2_LAYER )
if ( MaterialType==EMT_TRANSPARENT_ALPHA_CHANNEL ||
MaterialType==EMT_TRANSPARENT_VERTEX_ALPHA )
return true;
return false;

@ -1,70 +0,0 @@
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,70 +0,0 @@
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,72 +0,0 @@
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,70 +0,0 @@
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,53 +0,0 @@
/* 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,51 +0,0 @@
/* 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,72 +0,0 @@
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,62 +0,0 @@
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,48 +0,0 @@
/* 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);
}

@ -274,54 +274,23 @@ void CAnimatedMeshSceneNode::render()
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
// for debug purposes only:
bool renderMeshes = true;
video::SMaterial mat;
if (DebugDataVisible && PassCount==1)
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
// overwrite half transparency
if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY)
const bool transparent = driver->needsTransparentRenderPass(Materials[i]);
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (transparent == isTransparentPass)
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
mat = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->setMaterial(mat);
driver->drawMeshBuffer(mb);
}
renderMeshes = false;
}
}
// render original meshes
if (renderMeshes)
{
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
const bool transparent = driver->needsTransparentRenderPass(Materials[i]);
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (transparent == isTransparentPass)
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
}
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
}
}

@ -943,19 +943,8 @@ bool CB3DMeshFileLoader::readChunkBRUS()
//Two textures:
if (B3dMaterial.Textures[1])
{
if (B3dMaterial.alpha==1.f)
{
if (B3dMaterial.Textures[1]->Blend == 5) //(Multiply 2)
B3dMaterial.Material.MaterialType = video::EMT_LIGHTMAP_M2;
else
B3dMaterial.Material.MaterialType = video::EMT_LIGHTMAP;
B3dMaterial.Material.Lighting = false;
}
else
{
B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
B3dMaterial.Material.ZWriteEnable = video::EZW_OFF;
}
B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
B3dMaterial.Material.ZWriteEnable = video::EZW_OFF;
}
else if (B3dMaterial.Textures[0]) //One texture:
{
@ -967,10 +956,6 @@ bool CB3DMeshFileLoader::readChunkBRUS()
}
else if (B3dMaterial.Textures[0]->Flags & 0x4) //(Masked)
B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; // TODO: create color key texture
else if (B3dMaterial.Textures[0]->Flags & 0x40)
B3dMaterial.Material.MaterialType = video::EMT_SPHERE_MAP;
else if (B3dMaterial.Textures[0]->Flags & 0x80)
B3dMaterial.Material.MaterialType = video::EMT_SPHERE_MAP; // TODO: Should be cube map
else if (B3dMaterial.alpha == 1.f)
B3dMaterial.Material.MaterialType = video::EMT_SOLID;
else

@ -102,45 +102,21 @@ void CMeshSceneNode::render()
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
Box = Mesh->getBoundingBox();
// for debug purposes only:
bool renderMeshes = true;
video::SMaterial mat;
if (DebugDataVisible && PassCount==1)
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
{
// overwrite half transparency
if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY)
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
if (mb)
{
for (u32 g=0; g<Mesh->getMeshBufferCount(); ++g)
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
const bool transparent = driver->needsTransparentRenderPass(material);
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (transparent == isTransparentPass)
{
mat = Materials[g];
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
driver->setMaterial(mat);
driver->drawMeshBuffer(Mesh->getMeshBuffer(g));
}
renderMeshes = false;
}
}
// render original meshes
if (renderMeshes)
{
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
if (mb)
{
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
const bool transparent = driver->needsTransparentRenderPass(material);
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (transparent == isTransparentPass)
{
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
}
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
}
}
}

@ -204,22 +204,9 @@ COGLES2Driver::~COGLES2Driver()
// Create callbacks.
COGLES2MaterialSolidCB* SolidCB = new COGLES2MaterialSolidCB();
COGLES2MaterialSolid2CB* Solid2LayerCB = new COGLES2MaterialSolid2CB();
COGLES2MaterialLightmapCB* LightmapCB = new COGLES2MaterialLightmapCB(1.f);
COGLES2MaterialLightmapCB* LightmapAddCB = new COGLES2MaterialLightmapCB(1.f);
COGLES2MaterialLightmapCB* LightmapM2CB = new COGLES2MaterialLightmapCB(2.f);
COGLES2MaterialLightmapCB* LightmapM4CB = new COGLES2MaterialLightmapCB(4.f);
COGLES2MaterialLightmapCB* LightmapLightingCB = new COGLES2MaterialLightmapCB(1.f);
COGLES2MaterialLightmapCB* LightmapLightingM2CB = new COGLES2MaterialLightmapCB(2.f);
COGLES2MaterialLightmapCB* LightmapLightingM4CB = new COGLES2MaterialLightmapCB(4.f);
COGLES2MaterialSolid2CB* DetailMapCB = new COGLES2MaterialSolid2CB();
COGLES2MaterialReflectionCB* SphereMapCB = new COGLES2MaterialReflectionCB();
COGLES2MaterialReflectionCB* Reflection2LayerCB = new COGLES2MaterialReflectionCB();
COGLES2MaterialSolidCB* TransparentAddColorCB = new COGLES2MaterialSolidCB();
COGLES2MaterialSolidCB* TransparentAlphaChannelCB = new COGLES2MaterialSolidCB();
COGLES2MaterialSolidCB* TransparentAlphaChannelRefCB = new COGLES2MaterialSolidCB();
COGLES2MaterialSolidCB* TransparentVertexAlphaCB = new COGLES2MaterialSolidCB();
COGLES2MaterialReflectionCB* TransparentReflection2LayerCB = new COGLES2MaterialReflectionCB();
COGLES2MaterialOneTextureBlendCB* OneTextureBlendCB = new COGLES2MaterialOneTextureBlendCB();
// Create built-in materials.
@ -230,65 +217,8 @@ COGLES2Driver::~COGLES2Driver()
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 + "COGLES2Solid2.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2Solid2Layer.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 + "COGLES2Solid2.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2LightmapModulate.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 + "COGLES2LightmapAdd.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 + "COGLES2LightmapModulate.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 + "COGLES2Solid2.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2DetailMap.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 + "COGLES2SphereMap.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2SphereMap.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 + "COGLES2Reflection2Layer.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2Reflection2Layer.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 + "COGLES2Solid.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2Solid.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);
FragmentShader = OGLES2ShaderPath + "COGLES2TransparentAlphaChannel.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);
@ -302,13 +232,6 @@ COGLES2Driver::~COGLES2Driver()
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 + "COGLES2Reflection2Layer.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2Reflection2Layer.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, TransparentReflection2LayerCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
VertexShader = OGLES2ShaderPath + "COGLES2Solid.vsh";
FragmentShader = OGLES2ShaderPath + "COGLES2OneTextureBlend.fsh";
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",
@ -317,22 +240,9 @@ COGLES2Driver::~COGLES2Driver()
// 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

@ -100,7 +100,7 @@ void COGLES2MaterialBaseCB::OnSetConstants(IMaterialRendererServices* services,
services->setPixelShaderConstant(ThicknessID, &Thickness, 1);
}
// EMT_SOLID + EMT_TRANSPARENT_ADD_COLOR + EMT_TRANSPARENT_ALPHA_CHANNEL + EMT_TRANSPARENT_VERTEX_ALPHA
// EMT_SOLID + EMT_TRANSPARENT_ALPHA_CHANNEL + EMT_TRANSPARENT_VERTEX_ALPHA
COGLES2MaterialSolidCB::COGLES2MaterialSolidCB() :
FirstUpdate(true), TMatrix0ID(-1), AlphaRefID(-1), TextureUsage0ID(-1), TextureUnit0ID(-1), AlphaRef(0.5f), TextureUsage0(0), TextureUnit0(0)
@ -139,142 +139,6 @@ void COGLES2MaterialSolidCB::OnSetConstants(IMaterialRendererServices* services,
services->setPixelShaderConstant(TextureUnit0ID, &TextureUnit0, 1);
}
// EMT_SOLID_2_LAYER + EMT_DETAIL_MAP
COGLES2MaterialSolid2CB::COGLES2MaterialSolid2CB() :
FirstUpdate(true), TMatrix0ID(-1), TMatrix1ID(-1), TextureUsage0ID(-1), TextureUsage1ID(-1), TextureUnit0ID(-1), TextureUnit1ID(-1),
TextureUsage0(0), TextureUsage1(0), TextureUnit0(0), TextureUnit1(1)
{
}
void COGLES2MaterialSolid2CB::OnSetMaterial(const SMaterial& material)
{
COGLES2MaterialBaseCB::OnSetMaterial(material);
TextureUsage0 = (material.TextureLayer[0].Texture) ? 1 : 0;
TextureUsage1 = (material.TextureLayer[1].Texture) ? 1 : 0;
}
void COGLES2MaterialSolid2CB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
{
COGLES2MaterialBaseCB::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
COGLES2MaterialLightmapCB::COGLES2MaterialLightmapCB(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 COGLES2MaterialLightmapCB::OnSetMaterial(const SMaterial& material)
{
COGLES2MaterialBaseCB::OnSetMaterial(material);
TextureUsage0 = (material.TextureLayer[0].Texture) ? 1 : 0;
TextureUsage1 = (material.TextureLayer[1].Texture) ? 1 : 0;
}
void COGLES2MaterialLightmapCB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
{
COGLES2MaterialBaseCB::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
COGLES2MaterialReflectionCB::COGLES2MaterialReflectionCB() :
FirstUpdate(true), TMatrix0ID(-1), TextureUsage0ID(-1), TextureUsage1ID(-1), TextureUnit0ID(-1), TextureUnit1ID(-1),
TextureUsage0(0), TextureUsage1(0), TextureUnit0(0), TextureUnit1(1)
{
}
void COGLES2MaterialReflectionCB::OnSetMaterial(const SMaterial& material)
{
COGLES2MaterialBaseCB::OnSetMaterial(material);
TextureUsage0 = (material.TextureLayer[0].Texture) ? 1 : 0;
TextureUsage1 = (material.TextureLayer[1].Texture) ? 1 : 0;
}
void COGLES2MaterialReflectionCB::OnSetConstants(IMaterialRendererServices* services, s32 userData)
{
COGLES2MaterialBaseCB::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
COGLES2MaterialOneTextureBlendCB::COGLES2MaterialOneTextureBlendCB() :

@ -86,79 +86,6 @@ protected:
s32 TextureUnit0;
};
class COGLES2MaterialSolid2CB : public COGLES2MaterialBaseCB
{
public:
COGLES2MaterialSolid2CB();
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 COGLES2MaterialLightmapCB : public COGLES2MaterialBaseCB
{
public:
COGLES2MaterialLightmapCB(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 COGLES2MaterialReflectionCB : public COGLES2MaterialBaseCB
{
public:
COGLES2MaterialReflectionCB();
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 COGLES2MaterialOneTextureBlendCB : public COGLES2MaterialBaseCB
{
public:

@ -30,7 +30,7 @@ COGLES2MaterialRenderer::COGLES2MaterialRenderer(COGLES2Driver* driver,
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial,
s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false), Program(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), Program(0), UserData(userData)
{
#ifdef _DEBUG
setDebugName("COGLES2MaterialRenderer");
@ -42,9 +42,6 @@ COGLES2MaterialRenderer::COGLES2MaterialRenderer(COGLES2Driver* driver,
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -62,7 +59,7 @@ COGLES2MaterialRenderer::COGLES2MaterialRenderer(COGLES2Driver* driver,
COGLES2MaterialRenderer::COGLES2MaterialRenderer(COGLES2Driver* driver,
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial, s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false), Program(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), Program(0), UserData(userData)
{
switch (baseMaterial)
{
@ -70,9 +67,6 @@ COGLES2MaterialRenderer::COGLES2MaterialRenderer(COGLES2Driver* driver,
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -167,11 +161,6 @@ void COGLES2MaterialRenderer::OnSetMaterial(const video::SMaterial& material,
cacheHandler->setBlend(true);
cacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else if (FixedBlending)
{
cacheHandler->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
cacheHandler->setBlend(true);
}
else if (Blending)
{
E_BLEND_FACTOR srcRGBFact,dstRGBFact,srcAlphaFact,dstAlphaFact;
@ -197,7 +186,7 @@ void COGLES2MaterialRenderer::OnUnsetMaterial()
bool COGLES2MaterialRenderer::isTransparent() const
{
return (Alpha || Blending || FixedBlending);
return (Alpha || Blending);
}

@ -84,7 +84,6 @@ protected:
bool Alpha;
bool Blending;
bool FixedBlending;
struct SUniformInfo
{

@ -157,28 +157,11 @@ void COGLES1Driver::createMaterialRenderers()
// create OGLES1 material renderers
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_SOLID(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_SOLID_2_LAYER(this));
// add the same renderer for all lightmap types
COGLES1MaterialRenderer_LIGHTMAP* lmr = new COGLES1MaterialRenderer_LIGHTMAP(this);
addMaterialRenderer(lmr); // for EMT_LIGHTMAP:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4:
lmr->drop();
// add remaining material renderer
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_DETAIL_MAP(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_SPHERE_MAP(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_REFLECTION_2_LAYER(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_ADD_COLOR(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(this));
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(this));
// add basic 1 texture blending
addAndDropMaterialRenderer(new COGLES1MaterialRenderer_ONETEXTURE_BLEND(this));

@ -150,82 +150,6 @@ public:
};
//! Solid 2 layer material renderer
class COGLES1MaterialRenderer_SOLID_2_LAYER : public COGLES1MaterialRenderer
{
public:
COGLES1MaterialRenderer_SOLID_2_LAYER(video::COGLES1Driver* d)
: COGLES1MaterialRenderer(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PRIMARY_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_PRIMARY_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
}
}
}
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
}
}
};
//! Transparent add color material renderer
class COGLES1MaterialRenderer_TRANSPARENT_ADD_COLOR : public COGLES1MaterialRenderer
{
public:
COGLES1MaterialRenderer_TRANSPARENT_ADD_COLOR(video::COGLES1Driver* d)
: COGLES1MaterialRenderer(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->getCacheHandler()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
Driver->getCacheHandler()->setBlend(true);
if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
virtual void OnUnsetMaterial()
{
Driver->getCacheHandler()->setBlend(false);
}
//! Returns if the material is transparent.
virtual bool isTransparent() const
{
return true;
}
};
//! Transparent vertex alpha material renderer
class COGLES1MaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public COGLES1MaterialRenderer
{
@ -358,255 +282,6 @@ public:
}
};
//! material renderer for all kinds of lightmaps
class COGLES1MaterialRenderer_LIGHTMAP : public COGLES1MaterialRenderer
{
public:
COGLES1MaterialRenderer_LIGHTMAP(video::COGLES1Driver* d)
: COGLES1MaterialRenderer(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
// diffuse map
switch (material.MaterialType)
{
case EMT_LIGHTMAP_LIGHTING:
case EMT_LIGHTMAP_LIGHTING_M2:
case EMT_LIGHTMAP_LIGHTING_M4:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
break;
case EMT_LIGHTMAP_ADD:
case EMT_LIGHTMAP:
case EMT_LIGHTMAP_M2:
case EMT_LIGHTMAP_M4:
default:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
break;
}
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
// lightmap
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
if (material.MaterialType == EMT_LIGHTMAP_ADD)
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD);
else
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS);
switch (material.MaterialType)
{
case EMT_LIGHTMAP_M4:
case EMT_LIGHTMAP_LIGHTING_M4:
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 4.0f);
break;
case EMT_LIGHTMAP_M2:
case EMT_LIGHTMAP_LIGHTING_M2:
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
break;
default:
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.0f);
}
}
}
}
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 1.f );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
}
};
class COGLES1MaterialRenderer_DETAIL_MAP : public COGLES1MaterialRenderer
{
public:
COGLES1MaterialRenderer_DETAIL_MAP(video::COGLES1Driver* d) : COGLES1MaterialRenderer(d)
{
}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD_SIGNED);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
}
}
void OnUnsetMaterial() override
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
}
};
//! sphere map material renderer
class COGLES1MaterialRenderer_SPHERE_MAP : public COGLES1MaterialRenderer
{
public:
COGLES1MaterialRenderer_SPHERE_MAP(video::COGLES1Driver* d)
: COGLES1MaterialRenderer(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
// glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
// glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
// glEnable(GL_TEXTURE_GEN_S);
// glEnable(GL_TEXTURE_GEN_T);
}
}
virtual void OnUnsetMaterial()
{
// glDisable(GL_TEXTURE_GEN_S);
// glDisable(GL_TEXTURE_GEN_T);
}
};
//! reflection 2 layer material renderer
class COGLES1MaterialRenderer_REFLECTION_2_LAYER : public COGLES1MaterialRenderer
{
public:
COGLES1MaterialRenderer_REFLECTION_2_LAYER(video::COGLES1Driver* d)
: COGLES1MaterialRenderer(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
}
// glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
// glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
// glEnable(GL_TEXTURE_GEN_S);
// glEnable(GL_TEXTURE_GEN_T);
}
}
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
// glDisable(GL_TEXTURE_GEN_S);
// glDisable(GL_TEXTURE_GEN_T);
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
}
}
};
//! reflection 2 layer material renderer
class COGLES1MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public COGLES1MaterialRenderer
{
public:
COGLES1MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::COGLES1Driver* d)
: COGLES1MaterialRenderer(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->getCacheHandler()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
Driver->getCacheHandler()->setBlend(true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE);
}
// glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
// glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
// glEnable(GL_TEXTURE_GEN_S);
// glEnable(GL_TEXTURE_GEN_T);
}
}
virtual void OnUnsetMaterial()
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
// glDisable(GL_TEXTURE_GEN_S);
// glDisable(GL_TEXTURE_GEN_T);
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0);
}
Driver->getCacheHandler()->setBlend(false);
}
//! Returns if the material is transparent.
virtual bool isTransparent() const
{
return true;
}
};
} // end namespace video
} // end namespace irr

@ -207,30 +207,12 @@ bool COpenGLDriver::genericDriverInit()
void COpenGLDriver::createMaterialRenderers()
{
// create OpenGL material renderers
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID_2_LAYER(this));
// add the same renderer for all lightmap types
COpenGLMaterialRenderer_LIGHTMAP* lmr = new COpenGLMaterialRenderer_LIGHTMAP(this);
addMaterialRenderer(lmr); // for EMT_LIGHTMAP:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2:
addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4:
lmr->drop();
// add remaining material renderer
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(this));
// add basic 1 texture blending
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_ONETEXTURE_BLEND(this));

@ -168,113 +168,6 @@ protected:
};
//! Solid 2 layer material renderer
class COpenGLMaterialRenderer_SOLID_2_LAYER : public IMaterialRenderer
{
public:
COpenGLMaterialRenderer_SOLID_2_LAYER(video::COpenGLDriver* d) : Driver(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PRIMARY_COLOR_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);
#endif
}
}
}
void OnUnsetMaterial() override
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
#endif
}
}
protected:
video::COpenGLDriver* Driver;
};
//! Transparent add color material renderer
class COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR : public IMaterialRenderer
{
public:
COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(video::COpenGLDriver* d) : Driver(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->getCacheHandler()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
Driver->getCacheHandler()->setBlend(true);
}
void OnUnsetMaterial() override
{
Driver->getCacheHandler()->setBlend(false);
}
//! Returns if the material is transparent.
bool isTransparent() const override
{
return true;
}
protected:
video::COpenGLDriver* Driver;
};
//! Transparent vertex alpha material renderer
class COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA : public IMaterialRenderer
{
@ -458,397 +351,6 @@ protected:
video::COpenGLDriver* Driver;
};
//! material renderer for all kinds of lightmaps
class COpenGLMaterialRenderer_LIGHTMAP : public IMaterialRenderer
{
public:
COpenGLMaterialRenderer_LIGHTMAP(video::COpenGLDriver* d) : Driver(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB);
// diffuse map
switch (material.MaterialType)
{
case EMT_LIGHTMAP_LIGHTING:
case EMT_LIGHTMAP_LIGHTING_M2:
case EMT_LIGHTMAP_LIGHTING_M4:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
break;
case EMT_LIGHTMAP_ADD:
case EMT_LIGHTMAP:
case EMT_LIGHTMAP_M2:
case EMT_LIGHTMAP_M4:
default:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
break;
}
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
// lightmap
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
if (material.MaterialType == EMT_LIGHTMAP_ADD)
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
else
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_PREVIOUS_ARB);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
if (material.MaterialType == EMT_LIGHTMAP_ADD)
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
else
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT);
#endif
switch (material.MaterialType)
{
case EMT_LIGHTMAP_M4:
case EMT_LIGHTMAP_LIGHTING_M4:
#ifdef GL_ARB_texture_env_combine
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 4.0f);
#else
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 4.0f);
#endif
break;
case EMT_LIGHTMAP_M2:
case EMT_LIGHTMAP_LIGHTING_M2:
#ifdef GL_ARB_texture_env_combine
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0f);
#else
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
#endif
break;
default:
#ifdef GL_ARB_texture_env_combine
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f);
#else
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f);
#endif
}
}
}
}
void OnUnsetMaterial() override
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#ifdef GL_ARB_texture_env_combine
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.f );
#else
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.f );
#endif
}
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
protected:
video::COpenGLDriver* Driver;
};
//! detail map material renderer
class COpenGLMaterialRenderer_DETAIL_MAP : public IMaterialRenderer
{
public:
COpenGLMaterialRenderer_DETAIL_MAP(video::COpenGLDriver* d) : Driver(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
// detail map on second layer
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD_SIGNED_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
#endif
}
}
}
void OnUnsetMaterial() override
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
}
protected:
video::COpenGLDriver* Driver;
};
//! sphere map material renderer
class COpenGLMaterialRenderer_SPHERE_MAP : public IMaterialRenderer
{
public:
COpenGLMaterialRenderer_SPHERE_MAP(video::COpenGLDriver* d) : Driver(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(1);
// texture needs to be flipped for OpenGL
core::matrix4 tmp = Driver->getTransform(ETS_TEXTURE_0);
tmp[5]*=-1;
Driver->setTransform(ETS_TEXTURE_0, tmp);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
}
}
void OnUnsetMaterial() override
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
}
protected:
video::COpenGLDriver* Driver;
};
//! reflection 2 layer material renderer
class COpenGLMaterialRenderer_REFLECTION_2_LAYER : public IMaterialRenderer
{
public:
COpenGLMaterialRenderer_REFLECTION_2_LAYER(video::COpenGLDriver* d) : Driver(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
#endif
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
}
}
}
void OnUnsetMaterial() override
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
}
}
protected:
video::COpenGLDriver* Driver;
};
//! reflection 2 layer material renderer
class COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public IMaterialRenderer
{
public:
COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::COpenGLDriver* d) : Driver(d) {}
virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) override
{
if (Driver->getFixedPipelineState() == COpenGLDriver::EOFPS_DISABLE)
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_DISABLE_TO_ENABLE);
else
Driver->setFixedPipelineState(COpenGLDriver::EOFPS_ENABLE);
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->getCacheHandler()->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Driver->getCacheHandler()->setBlend(true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_ARB);
#endif
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
#ifdef GL_ARB_texture_env_combine
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB);
#else
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_ARB);
#endif
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
}
}
}
void OnUnsetMaterial() override
{
if (Driver->queryFeature(EVDF_MULTITEXTURE))
{
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
}
Driver->getCacheHandler()->setActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Driver->getCacheHandler()->setBlend(false);
}
//! Returns if the material is transparent.
bool isTransparent() const override
{
return true;
}
protected:
video::COpenGLDriver* Driver;
};
} // end namespace video
} // end namespace irr

@ -48,7 +48,7 @@ COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* drive
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial,
s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false), AlphaTest(false), Program(0), Program2(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), AlphaTest(false), Program(0), Program2(0), UserData(userData)
{
#ifdef _DEBUG
setDebugName("COpenGLSLMaterialRenderer");
@ -60,9 +60,6 @@ COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* drive
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -88,7 +85,7 @@ COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver* drive
COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver* driver,
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial, s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false), AlphaTest(false), Program(0), Program2(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), AlphaTest(false), Program(0), Program2(0), UserData(userData)
{
switch (baseMaterial)
{
@ -96,9 +93,6 @@ COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(COpenGLDriver* driver,
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -246,11 +240,6 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
cacheHandler->setAlphaTest(true);
cacheHandler->setAlphaFunc(GL_GREATER, 0.f);
}
else if (FixedBlending)
{
cacheHandler->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
cacheHandler->setBlend(true);
}
else if (Blending)
{
E_BLEND_FACTOR srcRGBFact,dstRGBFact,srcAlphaFact,dstAlphaFact;
@ -289,7 +278,7 @@ void COpenGLSLMaterialRenderer::OnUnsetMaterial()
Driver->irrGlUseProgram(0);
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
if (Alpha || FixedBlending || Blending)
if (Alpha || Blending)
{
cacheHandler->setBlend(false);
}
@ -303,7 +292,7 @@ void COpenGLSLMaterialRenderer::OnUnsetMaterial()
//! Returns if the material is transparent.
bool COpenGLSLMaterialRenderer::isTransparent() const
{
return (Alpha || Blending || FixedBlending);
return (Alpha || Blending);
}

@ -110,7 +110,6 @@ protected:
bool Alpha;
bool Blending;
bool FixedBlending;
bool AlphaTest;
struct SUniformInfo

@ -25,8 +25,8 @@ namespace video
COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDriver* driver,
s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false),
AlphaTest(false), VertexShader(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), AlphaTest(false),
VertexShader(0), UserData(userData)
{
#ifdef _DEBUG
setDebugName("COpenGLShaderMaterialRenderer");
@ -44,9 +44,6 @@ COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDrive
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -69,8 +66,8 @@ COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(video::COpenGLDrive
COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(COpenGLDriver* driver,
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial, s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false),
AlphaTest(false), VertexShader(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), AlphaTest(false),
VertexShader(0), UserData(userData)
{
PixelShader.set_used(4);
for (u32 i=0; i<4; ++i)
@ -84,9 +81,6 @@ COpenGLShaderMaterialRenderer::COpenGLShaderMaterialRenderer(COpenGLDriver* driv
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -205,11 +199,6 @@ void COpenGLShaderMaterialRenderer::OnSetMaterial(const video::SMaterial& materi
cacheHandler->setBlend(true);
cacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else if (FixedBlending)
{
cacheHandler->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
cacheHandler->setBlend(true);
}
else if (Blending)
{
E_BLEND_FACTOR srcRGBFact,dstRGBFact,srcAlphaFact,dstAlphaFact;
@ -260,7 +249,7 @@ void COpenGLShaderMaterialRenderer::OnUnsetMaterial()
#endif
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
if (Alpha || FixedBlending || Blending)
if (Alpha || Blending)
{
cacheHandler->setBlend(false);
}
@ -274,7 +263,7 @@ void COpenGLShaderMaterialRenderer::OnUnsetMaterial()
//! Returns if the material is transparent.
bool COpenGLShaderMaterialRenderer::isTransparent() const
{
return (Alpha || Blending || FixedBlending);
return (Alpha || Blending);
}

@ -77,7 +77,6 @@ protected:
// Note that SMaterial.BlendOperation + SMaterial.BlendFactor are in some drivers already evaluated before OnSetMaterial.
bool Alpha;
bool Blending;
bool FixedBlending;
bool AlphaTest;
GLuint VertexShader;

@ -335,11 +335,6 @@ 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.
@ -352,7 +347,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
// 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.
const core::stringc VertexShader = OGLES2ShaderPath + "Solid.vsh";
@ -361,19 +355,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
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);
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",
@ -389,8 +370,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
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);
addDummyMaterial(EMT_TRANSPARENT_REFLECTION_2_LAYER);
// EMT_ONETEXTURE_BLEND
FragmentShader = OGLES2ShaderPath + "OneTextureBlend.fsh";
addHighLevelShaderMaterialFromFiles(VertexShader, "main", EVST_VS_2_0, FragmentShader, "main", EPST_PS_2_0, "", "main",

@ -94,7 +94,7 @@ void COpenGL3MaterialBaseCB::OnSetConstants(IMaterialRendererServices* services,
services->setPixelShaderConstant(ThicknessID, &Thickness, 1);
}
// EMT_SOLID + EMT_TRANSPARENT_ADD_COLOR + EMT_TRANSPARENT_ALPHA_CHANNEL + EMT_TRANSPARENT_VERTEX_ALPHA
// EMT_SOLID + EMT_TRANSPARENT_ALPHA_CHANNEL + EMT_TRANSPARENT_VERTEX_ALPHA
COpenGL3MaterialSolidCB::COpenGL3MaterialSolidCB() :
FirstUpdate(true), TMatrix0ID(-1), AlphaRefID(-1), TextureUsage0ID(-1), TextureUnit0ID(-1), AlphaRef(0.5f), TextureUsage0(0), TextureUnit0(0)

@ -28,7 +28,7 @@ COpenGL3MaterialRenderer::COpenGL3MaterialRenderer(COpenGL3DriverBase* driver,
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial,
s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false), Program(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), Program(0), UserData(userData)
{
#ifdef _DEBUG
setDebugName("MaterialRenderer");
@ -40,9 +40,6 @@ COpenGL3MaterialRenderer::COpenGL3MaterialRenderer(COpenGL3DriverBase* driver,
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -60,7 +57,7 @@ COpenGL3MaterialRenderer::COpenGL3MaterialRenderer(COpenGL3DriverBase* driver,
COpenGL3MaterialRenderer::COpenGL3MaterialRenderer(COpenGL3DriverBase* driver,
IShaderConstantSetCallBack* callback,
E_MATERIAL_TYPE baseMaterial, s32 userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), FixedBlending(false), Program(0), UserData(userData)
: Driver(driver), CallBack(callback), Alpha(false), Blending(false), Program(0), UserData(userData)
{
switch (baseMaterial)
{
@ -68,9 +65,6 @@ COpenGL3MaterialRenderer::COpenGL3MaterialRenderer(COpenGL3DriverBase* driver,
case EMT_TRANSPARENT_ALPHA_CHANNEL:
Alpha = true;
break;
case EMT_TRANSPARENT_ADD_COLOR:
FixedBlending = true;
break;
case EMT_ONETEXTURE_BLEND:
Blending = true;
break;
@ -165,11 +159,6 @@ void COpenGL3MaterialRenderer::OnSetMaterial(const video::SMaterial& material,
cacheHandler->setBlend(true);
cacheHandler->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
else if (FixedBlending)
{
cacheHandler->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
cacheHandler->setBlend(true);
}
else if (Blending)
{
E_BLEND_FACTOR srcRGBFact,dstRGBFact,srcAlphaFact,dstAlphaFact;
@ -195,7 +184,7 @@ void COpenGL3MaterialRenderer::OnUnsetMaterial()
bool COpenGL3MaterialRenderer::isTransparent() const
{
return (Alpha || Blending || FixedBlending);
return (Alpha || Blending);
}

@ -80,7 +80,6 @@ protected:
bool Alpha;
bool Blending;
bool FixedBlending;
struct SUniformInfo
{