Clean up Irrlicht shader API

This commit is contained in:
sfan5 2024-12-29 18:58:26 +01:00
parent 40afc84597
commit 1ea8763259
12 changed files with 79 additions and 458 deletions

@ -1,85 +0,0 @@
#pragma once
#include "irrTypes.h"
namespace irr
{
namespace video
{
//! Compile target enumeration for the addHighLevelShaderMaterial() method.
enum E_VERTEX_SHADER_TYPE
{
EVST_VS_1_1 = 0,
EVST_VS_2_0,
EVST_VS_2_a,
EVST_VS_3_0,
EVST_VS_4_0,
EVST_VS_4_1,
EVST_VS_5_0,
//! This is not a type, but a value indicating how much types there are.
EVST_COUNT
};
//! Names for all vertex shader types, each entry corresponds to a E_VERTEX_SHADER_TYPE entry.
const c8 *const VERTEX_SHADER_TYPE_NAMES[] = {
"vs_1_1",
"vs_2_0",
"vs_2_a",
"vs_3_0",
"vs_4_0",
"vs_4_1",
"vs_5_0",
0};
//! Compile target enumeration for the addHighLevelShaderMaterial() method.
enum E_PIXEL_SHADER_TYPE
{
EPST_PS_1_1 = 0,
EPST_PS_1_2,
EPST_PS_1_3,
EPST_PS_1_4,
EPST_PS_2_0,
EPST_PS_2_a,
EPST_PS_2_b,
EPST_PS_3_0,
EPST_PS_4_0,
EPST_PS_4_1,
EPST_PS_5_0,
//! This is not a type, but a value indicating how much types there are.
EPST_COUNT
};
//! Names for all pixel shader types, each entry corresponds to a E_PIXEL_SHADER_TYPE entry.
const c8 *const PIXEL_SHADER_TYPE_NAMES[] = {
"ps_1_1",
"ps_1_2",
"ps_1_3",
"ps_1_4",
"ps_2_0",
"ps_2_a",
"ps_2_b",
"ps_3_0",
"ps_4_0",
"ps_4_1",
"ps_5_0",
0};
//! Enum for supported geometry shader types
enum E_GEOMETRY_SHADER_TYPE
{
EGST_GS_4_0 = 0,
//! This is not a type, but a value indicating how much types there are.
EGST_COUNT
};
//! String names for supported geometry shader types
const c8 *const GEOMETRY_SHADER_TYPE_NAMES[] = {
"gs_4_0",
0};
} // end namespace video
} // end namespace irr

@ -4,7 +4,6 @@
#pragma once
#include "EShaderTypes.h"
#include "EMaterialTypes.h"
#include "EPrimitiveTypes.h"
#include "path.h"
@ -31,26 +30,15 @@ public:
virtual ~IGPUProgrammingServices() {}
//! Adds a new high-level shading material renderer to the VideoDriver.
/** Currently only HLSL/D3D9 and GLSL/OpenGL are supported.
/**
\param vertexShaderProgram String containing the source of the vertex
shader program. This can be 0 if no vertex program shall be used.
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram (p.e. "main")
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgram String containing the source of the pixel
shader program. This can be 0 if no pixel shader shall be used.
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgram String containing the source of the
geometry shader program. This can be 0 if no geometry shader shall be
used.
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param shaderName Name of the shader for debug purposes
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
@ -73,108 +61,43 @@ public:
error log and can be caught with a custom event receiver. */
virtual s32 addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8 *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const c8 *geometryShaderProgram,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
const c8 *shaderName = nullptr,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
//! convenience function for use without geometry shaders
s32 addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const c8 *pixelShaderProgram = 0,
const c8 *pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
IShaderConstantSetCallBack *callback = 0,
const c8 *pixelShaderProgram = nullptr,
const c8 *shaderName = nullptr,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0)
{
return addHighLevelShaderMaterial(
vertexShaderProgram, vertexShaderEntryPointName,
vsCompileTarget, pixelShaderProgram,
pixelShaderEntryPointName, psCompileTarget,
0, "main", EGST_GS_4_0,
vertexShaderProgram, pixelShaderProgram,
nullptr, shaderName,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, without geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1.
*/
s32 addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *pixelShaderProgram = 0,
IShaderConstantSetCallBack *callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0)
{
return addHighLevelShaderMaterial(
vertexShaderProgram, "main",
EVST_VS_1_1, pixelShaderProgram,
"main", EPST_PS_1_1,
0, "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, with geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1 and geometry shader 4.0.
*/
s32 addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *pixelShaderProgram = 0,
const c8 *geometryShaderProgram = 0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0)
{
return addHighLevelShaderMaterial(
vertexShaderProgram, "main",
EVST_VS_1_1, pixelShaderProgram,
"main", EPST_PS_1_1,
geometryShaderProgram, "main", EGST_GS_4_0,
inType, outType, verticesOut,
callback, baseMaterial, userData);
}
//! Like addHighLevelShaderMaterial(), but loads from files.
/** \param vertexShaderProgramFileName Text file containing the source
of the vertex shader program. Set to empty string if no vertex shader
shall be created.
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram (p.e. "main")
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgramFileName Text file containing the source of
the pixel shader program. Set to empty string if no pixel shader shall
be created.
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgramFileName Name of the source of
the geometry shader program. Set to empty string if no geometry shader
shall be created.
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param shaderName Name of the shader for debug purposes
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
@ -197,164 +120,16 @@ public:
error log and can be caught with a custom event receiver. */
virtual s32 addHighLevelShaderMaterialFromFiles(
const io::path &vertexShaderProgramFileName,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const io::path &pixelShaderProgramFileName,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const io::path &geometryShaderProgramFileName,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
const c8 *shaderName = nullptr,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
//! convenience function for use without geometry shaders
s32 addHighLevelShaderMaterialFromFiles(
const io::path &vertexShaderProgramFileName,
const c8 *vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const io::path &pixelShaderProgramFileName = "",
const c8 *pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
IShaderConstantSetCallBack *callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0)
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, vertexShaderEntryPointName,
vsCompileTarget, pixelShaderProgramFileName,
pixelShaderEntryPointName, psCompileTarget,
"", "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, without geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1.
*/
s32 addHighLevelShaderMaterialFromFiles(
const io::path &vertexShaderProgramFileName,
const io::path &pixelShaderProgramFileName = "",
IShaderConstantSetCallBack *callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0)
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, "main",
EVST_VS_1_1, pixelShaderProgramFileName,
"main", EPST_PS_1_1,
"", "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! convenience function for use with many defaults, with geometry shader
/** All shader names are set to "main" and compile targets are shader
type 1.1 and geometry shader 4.0.
*/
s32 addHighLevelShaderMaterialFromFiles(
const io::path &vertexShaderProgramFileName,
const io::path &pixelShaderProgramFileName = "",
const io::path &geometryShaderProgramFileName = "",
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0)
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgramFileName, "main",
EVST_VS_1_1, pixelShaderProgramFileName,
"main", EPST_PS_1_1,
geometryShaderProgramFileName, "main", EGST_GS_4_0,
inType, outType, verticesOut,
callback, baseMaterial, userData);
}
//! Like addHighLevelShaderMaterial(), but loads from files.
/** \param vertexShaderProgram Text file handle containing the source
of the vertex shader program. Set to 0 if no vertex shader shall be
created.
\param vertexShaderEntryPointName Name of the entry function of the
vertexShaderProgram
\param vsCompileTarget Vertex shader version the high level shader
shall be compiled to.
\param pixelShaderProgram Text file handle containing the source of
the pixel shader program. Set to 0 if no pixel shader shall be created.
\param pixelShaderEntryPointName Entry name of the function of the
pixelShaderProgram (p.e. "main")
\param psCompileTarget Pixel shader version the high level shader
shall be compiled to.
\param geometryShaderProgram Text file handle containing the source of
the geometry shader program. Set to 0 if no geometry shader shall be
created.
\param geometryShaderEntryPointName Entry name of the function of the
geometryShaderProgram (p.e. "main")
\param gsCompileTarget Geometry shader version the high level shader
shall be compiled to.
\param inType Type of vertices passed to geometry shader
\param outType Type of vertices created by geometry shader
\param verticesOut Maximal number of vertices created by geometry
shader. If 0, maximal number supported is assumed.
\param callback Pointer to an implementation of
IShaderConstantSetCallBack in which you can set the needed vertex and
pixel shader program constants. Set this to 0 if you don't need this.
\param baseMaterial Base material which renderstates will be used to
shade the material.
\param userData a user data int. This int can be set to any value and
will be set as parameter in the callback method when calling
OnSetConstants(). In this way it is easily possible to use the same
callback method for multiple materials and distinguish between them
during the call.
\return Number of the material type which can be set in
SMaterial::MaterialType to use the renderer. -1 is returned if an
error occurred, e.g. if a shader program could not be compiled or a
compile target is not reachable. The error strings are then printed to
the error log and can be caught with a custom event receiver. */
virtual s32 addHighLevelShaderMaterialFromFiles(
io::IReadFile *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
io::IReadFile *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
io::IReadFile *geometryShaderProgram,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) = 0;
//! convenience function for use without geometry shaders
s32 addHighLevelShaderMaterialFromFiles(
io::IReadFile *vertexShaderProgram,
const c8 *vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
io::IReadFile *pixelShaderProgram = 0,
const c8 *pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
IShaderConstantSetCallBack *callback = 0,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0)
{
return addHighLevelShaderMaterialFromFiles(
vertexShaderProgram, vertexShaderEntryPointName,
vsCompileTarget, pixelShaderProgram,
pixelShaderEntryPointName, psCompileTarget,
0, "main", EGST_GS_4_0,
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0,
callback, baseMaterial, userData);
}
//! Delete a shader material and associated data.
/**
After you have deleted a material it is invalid to still use and doing

@ -1520,34 +1520,24 @@ IGPUProgrammingServices *CNullDriver::getGPUProgrammingServices()
//! Adds a new material renderer to the VideoDriver, based on a high level shading language.
s32 CNullDriver::addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8 *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const c8 *geometryShaderProgram,
const c8 *geometryShaderEntryPointName,
E_GEOMETRY_SHADER_TYPE gsCompileTarget,
const c8 *shaderName,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType,
u32 verticesOut,
IShaderConstantSetCallBack *callback,
E_MATERIAL_TYPE baseMaterial,
s32 userData)
{
os::Printer::log("High level shader materials not available (yet) in this driver, sorry");
os::Printer::log("Shader materials not available in this driver", ELL_ERROR);
return -1;
}
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
const io::path &vertexShaderProgramFileName,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const io::path &pixelShaderProgramFileName,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const io::path &geometryShaderProgramFileName,
const c8 *geometryShaderEntryPointName,
E_GEOMETRY_SHADER_TYPE gsCompileTarget,
const c8 *shaderName,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType,
u32 verticesOut,
IShaderConstantSetCallBack *callback,
@ -1583,9 +1573,7 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
}
s32 result = addHighLevelShaderMaterialFromFiles(
vsfile, vertexShaderEntryPointName, vsCompileTarget,
psfile, pixelShaderEntryPointName, psCompileTarget,
gsfile, geometryShaderEntryPointName, gsCompileTarget,
vsfile, psfile, gsfile, shaderName,
inType, outType, verticesOut,
callback, baseMaterial, userData);
@ -1603,14 +1591,9 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
io::IReadFile *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
io::IReadFile *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
io::IReadFile *geometryShaderProgram,
const c8 *geometryShaderEntryPointName,
E_GEOMETRY_SHADER_TYPE gsCompileTarget,
const c8 *shaderName,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType,
u32 verticesOut,
IShaderConstantSetCallBack *callback,
@ -1656,9 +1639,7 @@ s32 CNullDriver::addHighLevelShaderMaterialFromFiles(
}
s32 result = this->addHighLevelShaderMaterial(
vs, vertexShaderEntryPointName, vsCompileTarget,
ps, pixelShaderEntryPointName, psCompileTarget,
gs, geometryShaderEntryPointName, gsCompileTarget,
vs, ps, gs, shaderName,
inType, outType, verticesOut,
callback, baseMaterial, userData);

@ -449,54 +449,39 @@ public:
//! Adds a new material renderer to the VideoDriver, based on a high level shading language.
virtual s32 addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName = 0,
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const c8 *pixelShaderProgram = 0,
const c8 *pixelShaderEntryPointName = 0,
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
const c8 *geometryShaderProgram = 0,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
const c8 *pixelShaderProgram,
const c8 *geometryShaderProgram,
const c8 *shaderName = nullptr,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) override;
s32 userData = 0)override;
virtual s32 addHighLevelShaderMaterialFromFiles(
const io::path &vertexShaderProgramFile,
const c8 *vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const io::path &pixelShaderProgramFile = "",
const c8 *pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
const io::path &geometryShaderProgramFileName = "",
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
const io::path &vertexShaderProgramFileName,
const io::path &pixelShaderProgramFileName,
const io::path &geometryShaderProgramFileName,
const c8 *shaderName = nullptr,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) override;
virtual s32 addHighLevelShaderMaterialFromFiles(
s32 addHighLevelShaderMaterialFromFiles(
io::IReadFile *vertexShaderProgram,
const c8 *vertexShaderEntryPointName = "main",
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
io::IReadFile *pixelShaderProgram = 0,
const c8 *pixelShaderEntryPointName = "main",
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
io::IReadFile *geometryShaderProgram = 0,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
const c8 *shaderName = nullptr,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) override;
s32 userData = 0);
virtual void deleteShaderMaterial(s32 material) override;

@ -2654,14 +2654,9 @@ bool COpenGLDriver::setPixelShaderConstant(s32 index, const u32 *ints, int count
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
s32 COpenGLDriver::addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8 *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const c8 *geometryShaderProgram,
const c8 *geometryShaderEntryPointName,
E_GEOMETRY_SHADER_TYPE gsCompileTarget,
const c8 *shaderName,
scene::E_PRIMITIVE_TYPE inType,
scene::E_PRIMITIVE_TYPE outType,
u32 verticesOut,
@ -2673,9 +2668,9 @@ s32 COpenGLDriver::addHighLevelShaderMaterial(
COpenGLSLMaterialRenderer *r = new COpenGLSLMaterialRenderer(
this, nr,
vertexShaderProgram, vertexShaderEntryPointName, vsCompileTarget,
pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget,
geometryShaderProgram, geometryShaderEntryPointName, gsCompileTarget,
vertexShaderProgram,
pixelShaderProgram,
geometryShaderProgram,
inType, outType, verticesOut,
callback, baseMaterial, userData);

@ -240,18 +240,13 @@ public:
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
virtual s32 addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8 *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const c8 *geometryShaderProgram,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
const c8 *shaderName = nullptr,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) override;

@ -34,14 +34,8 @@ namespace video
//! Constructor
COpenGLSLMaterialRenderer::COpenGLSLMaterialRenderer(video::COpenGLDriver *driver,
s32 &outMaterialTypeNr, const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8 *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const c8 *geometryShaderProgram,
const c8 *geometryShaderEntryPointName,
E_GEOMETRY_SHADER_TYPE gsCompileTarget,
scene::E_PRIMITIVE_TYPE inType, scene::E_PRIMITIVE_TYPE outType,
u32 verticesOut,
IShaderConstantSetCallBack *callback,

@ -33,14 +33,8 @@ public:
COpenGLDriver *driver,
s32 &outMaterialTypeNr,
const c8 *vertexShaderProgram = 0,
const c8 *vertexShaderEntryPointName = 0,
E_VERTEX_SHADER_TYPE vsCompileTarget = video::EVST_VS_1_1,
const c8 *pixelShaderProgram = 0,
const c8 *pixelShaderEntryPointName = 0,
E_PIXEL_SHADER_TYPE psCompileTarget = video::EPST_PS_1_1,
const c8 *geometryShaderProgram = 0,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,

@ -386,28 +386,28 @@ void COpenGL3DriverBase::createMaterialRenderers()
// 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);
addHighLevelShaderMaterialFromFiles(VertexShader, FragmentShader, "", "Solid",
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, SolidCB, EMT_SOLID, 0);
// 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);
addHighLevelShaderMaterialFromFiles(VertexShader, FragmentShader, "", "TransparentAlphaChannel",
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);
addHighLevelShaderMaterialFromFiles(VertexShader, FragmentShader, "", "TransparentAlphaChannelRef",
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);
addHighLevelShaderMaterialFromFiles(VertexShader, FragmentShader, "", "TransparentVertexAlpha",
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, TransparentVertexAlphaCB, EMT_TRANSPARENT_ALPHA_CHANNEL, 0);
// 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);
addHighLevelShaderMaterialFromFiles(VertexShader, FragmentShader, "", "OneTextureBlend",
scene::EPT_TRIANGLES, scene::EPT_TRIANGLE_STRIP, 0, OneTextureBlendCB, EMT_ONETEXTURE_BLEND, 0);
// Drop callbacks.
@ -1588,14 +1588,9 @@ bool COpenGL3DriverBase::setPixelShaderConstant(s32 index, const u32 *ints, int
//! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.
s32 COpenGL3DriverBase::addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName,
E_VERTEX_SHADER_TYPE vsCompileTarget,
const c8 *pixelShaderProgram,
const c8 *pixelShaderEntryPointName,
E_PIXEL_SHADER_TYPE psCompileTarget,
const c8 *geometryShaderProgram,
const c8 *geometryShaderEntryPointName,
E_GEOMETRY_SHADER_TYPE gsCompileTarget,
const c8 *shaderName,
scene::E_PRIMITIVE_TYPE inType,
scene::E_PRIMITIVE_TYPE outType,
u32 verticesOut,

@ -189,18 +189,13 @@ public:
//! Adds a new material renderer to the VideoDriver
virtual s32 addHighLevelShaderMaterial(
const c8 *vertexShaderProgram,
const c8 *vertexShaderEntryPointName = 0,
E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
const c8 *pixelShaderProgram = 0,
const c8 *pixelShaderEntryPointName = 0,
E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
const c8 *geometryShaderProgram = 0,
const c8 *geometryShaderEntryPointName = "main",
E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
const c8 *pixelShaderProgram,
const c8 *geometryShaderProgram = nullptr,
const c8 *shaderName = nullptr,
scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
u32 verticesOut = 0,
IShaderConstantSetCallBack *callback = 0,
IShaderConstantSetCallBack *callback = nullptr,
E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
s32 userData = 0) override;

@ -19,7 +19,6 @@
#include <IMaterialRendererServices.h>
#include <IShaderConstantSetCallBack.h>
#include "client/renderingengine.h"
#include <EShaderTypes.h>
#include "gettext.h"
#include "log.h"
#include "gamedef.h"
@ -615,10 +614,16 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
#define textureFlags texture2
)";
/// Unique name of this shader, for debug/logging
std::string log_name = name;
/* Define constants for node and object shaders */
const bool node_shader = drawtype != NodeDrawType_END;
if (node_shader) {
log_name.append(" mat=").append(itos(material_type))
.append(" draw=").append(itos(drawtype));
bool use_discard = fully_programmable;
if (!use_discard) {
// workaround for a certain OpenGL implementation lacking GL_ALPHA_TEST
@ -762,18 +767,15 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
geometry_shader_ptr = geometry_shader.c_str();
}
irr_ptr<ShaderCallback> cb{new ShaderCallback(m_setter_factories)};
infostream<<"Compiling high level shaders for "<<name<<std::endl;
auto cb = make_irr<ShaderCallback>(m_setter_factories);
infostream << "Compiling high level shaders for " << log_name << std::endl;
s32 shadermat = gpu->addHighLevelShaderMaterial(
vertex_shader.c_str(), nullptr, video::EVST_VS_1_1,
fragment_shader.c_str(), nullptr, video::EPST_PS_1_1,
geometry_shader_ptr, nullptr, video::EGST_GS_4_0, scene::EPT_TRIANGLES, scene::EPT_TRIANGLES, 0,
cb.get(), shaderinfo.base_material, 1);
vertex_shader.c_str(), fragment_shader.c_str(), geometry_shader_ptr,
log_name.c_str(), scene::EPT_TRIANGLES, scene::EPT_TRIANGLES, 0,
cb.get(), shaderinfo.base_material);
if (shadermat == -1) {
errorstream<<"generate_shader(): "
"failed to generate \""<<name<<"\", "
"addHighLevelShaderMaterial failed."
<<std::endl;
errorstream << "generateShader(): failed to generate shaders for "
<< log_name << ", addHighLevelShaderMaterial failed." << std::endl;
dumpShaderProgram(warningstream, "Vertex", vertex_shader);
dumpShaderProgram(warningstream, "Fragment", fragment_shader);
dumpShaderProgram(warningstream, "Geometry", geometry_shader);

@ -14,10 +14,9 @@
#include "client/client.h"
#include "client/clientmap.h"
#include "profiler.h"
#include "EShaderTypes.h"
#include "IGPUProgrammingServices.h"
#include "IMaterialRenderer.h"
#include <IVideoDriver.h>
#include "IVideoDriver.h"
ShadowRenderer::ShadowRenderer(IrrlichtDevice *device, Client *client) :
m_smgr(device->getSceneManager()), m_driver(device->getVideoDriver()),
@ -539,10 +538,9 @@ void ShadowRenderer::createShaders()
m_shadow_depth_cb = new ShadowDepthShaderCB();
depth_shader = gpu->addHighLevelShaderMaterial(
readShaderFile(depth_shader_vs).c_str(), "vertexMain",
video::EVST_VS_1_1,
readShaderFile(depth_shader_fs).c_str(), "pixelMain",
video::EPST_PS_1_2, m_shadow_depth_cb, video::EMT_ONETEXTURE_BLEND);
readShaderFile(depth_shader_vs).c_str(),
readShaderFile(depth_shader_fs).c_str(), nullptr,
m_shadow_depth_cb, video::EMT_ONETEXTURE_BLEND);
if (depth_shader == -1) {
// upsi, something went wrong loading shader.
@ -578,10 +576,9 @@ void ShadowRenderer::createShaders()
m_shadow_depth_entity_cb = new ShadowDepthShaderCB();
depth_shader_entities = gpu->addHighLevelShaderMaterial(
readShaderFile(depth_shader_vs).c_str(), "vertexMain",
video::EVST_VS_1_1,
readShaderFile(depth_shader_fs).c_str(), "pixelMain",
video::EPST_PS_1_2, m_shadow_depth_entity_cb);
readShaderFile(depth_shader_vs).c_str(),
readShaderFile(depth_shader_fs).c_str(), nullptr,
m_shadow_depth_entity_cb);
if (depth_shader_entities == -1) {
// upsi, something went wrong loading shader.
@ -616,10 +613,9 @@ void ShadowRenderer::createShaders()
m_shadow_mix_cb = new shadowScreenQuadCB();
m_screen_quad = new shadowScreenQuad();
mixcsm_shader = gpu->addHighLevelShaderMaterial(
readShaderFile(depth_shader_vs).c_str(), "vertexMain",
video::EVST_VS_1_1,
readShaderFile(depth_shader_fs).c_str(), "pixelMain",
video::EPST_PS_1_2, m_shadow_mix_cb);
readShaderFile(depth_shader_vs).c_str(),
readShaderFile(depth_shader_fs).c_str(), nullptr,
m_shadow_mix_cb);
m_screen_quad->getMaterial().MaterialType =
(video::E_MATERIAL_TYPE)mixcsm_shader;
@ -655,10 +651,9 @@ void ShadowRenderer::createShaders()
m_shadow_depth_trans_cb = new ShadowDepthShaderCB();
depth_shader_trans = gpu->addHighLevelShaderMaterial(
readShaderFile(depth_shader_vs).c_str(), "vertexMain",
video::EVST_VS_1_1,
readShaderFile(depth_shader_fs).c_str(), "pixelMain",
video::EPST_PS_1_2, m_shadow_depth_trans_cb);
readShaderFile(depth_shader_vs).c_str(),
readShaderFile(depth_shader_fs).c_str(), nullptr,
m_shadow_depth_trans_cb);
if (depth_shader_trans == -1) {
// upsi, something went wrong loading shader.