mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
Simplify
--HG-- branch : multipass-stereo
This commit is contained in:
parent
abafc9b1ef
commit
88cbc2f82b
3 changed files with 65 additions and 64 deletions
|
@ -64,6 +64,15 @@ public:
|
||||||
// This is only used for user provided shaders, not for builtin shaders,
|
// This is only used for user provided shaders, not for builtin shaders,
|
||||||
// as it is a slow method which has to go through all of the options every time.
|
// as it is a slow method which has to go through all of the options every time.
|
||||||
// Builtin shaders should set all flags to 0.
|
// Builtin shaders should set all flags to 0.
|
||||||
|
// Example:
|
||||||
|
// User shader flags Matrices in the Vertex Program:
|
||||||
|
// -> When rendering with a material, the driver will call setUniformDriver,
|
||||||
|
// which will check if the flag Matrices exists, and if so, it will use
|
||||||
|
// the index cache to find which matrices are needed by the shader,
|
||||||
|
// and set those which are found.
|
||||||
|
// This does not work extremely efficient, but it's the most practical option
|
||||||
|
// for passing builtin parameters onto user provided shaders.
|
||||||
|
// Note: May need additional flags related to scene sorting, etcetera.
|
||||||
struct CGPUProgramFeatures
|
struct CGPUProgramFeatures
|
||||||
{
|
{
|
||||||
CGPUProgramFeatures() : DriverFlags(0), MaterialFlags(0) { }
|
CGPUProgramFeatures() : DriverFlags(0), MaterialFlags(0) { }
|
||||||
|
@ -72,26 +81,12 @@ struct CGPUProgramFeatures
|
||||||
enum TDriverFlags
|
enum TDriverFlags
|
||||||
{
|
{
|
||||||
// Matrices
|
// Matrices
|
||||||
ModelView = 0x00000001,
|
Matrices = 0x00000001,
|
||||||
ModelViewInverse = 0x00000002,
|
|
||||||
ModelViewTranspose = 0x00000004,
|
|
||||||
ModelViewInverseTranspose = 0x00000008,
|
|
||||||
|
|
||||||
Projection = 0x00000010,
|
|
||||||
ProjectionInverse = 0x00000020,
|
|
||||||
ProjectionTranspose = 0x00000040,
|
|
||||||
ProjectionInverseTranspose = 0x00000080,
|
|
||||||
|
|
||||||
ModelViewProjection = 0x00000100,
|
|
||||||
ModelViewProjectionInverse = 0x00000200,
|
|
||||||
ModelViewProjectionTranspose = 0x00000400,
|
|
||||||
ModelViewProjectionInverseTranspose = 0x00000800,
|
|
||||||
|
|
||||||
// Fog
|
// Fog
|
||||||
Fog = 0x00001000,
|
Fog = 0x00000002,
|
||||||
};
|
};
|
||||||
uint32 DriverFlags;
|
uint32 DriverFlags;
|
||||||
// uint NumLights;
|
|
||||||
|
|
||||||
enum TMaterialFlags
|
enum TMaterialFlags
|
||||||
{
|
{
|
||||||
|
|
|
@ -309,59 +309,65 @@ bool CDriverGL::setUniformDriver(TProgram program)
|
||||||
|
|
||||||
if (features.DriverFlags)
|
if (features.DriverFlags)
|
||||||
{
|
{
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelView)
|
if (features.DriverFlags & CGPUProgramFeatures::Matrices)
|
||||||
|
{
|
||||||
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelView) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelView), ModelView, Identity);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelView), ModelView, Identity);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewInverse)
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelViewInverse) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewInverse), ModelView, Inverse);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewInverse), ModelView, Inverse);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewTranspose)
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelViewTranspose) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewTranspose), ModelView, Transpose);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewTranspose), ModelView, Transpose);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewInverseTranspose)
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelViewInverseTranspose) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewInverseTranspose), ModelView, InverseTranspose);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewInverseTranspose), ModelView, InverseTranspose);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::Projection)
|
if (prog->getUniformIndex(CGPUProgramIndex::Projection) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::Projection), Projection, Identity);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::Projection), Projection, Identity);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ProjectionInverse)
|
if (prog->getUniformIndex(CGPUProgramIndex::ProjectionInverse) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ProjectionInverse), Projection, Inverse);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ProjectionInverse), Projection, Inverse);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ProjectionTranspose)
|
if (prog->getUniformIndex(CGPUProgramIndex::ProjectionTranspose) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ProjectionTranspose), Projection, Transpose);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ProjectionTranspose), Projection, Transpose);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ProjectionInverseTranspose)
|
if (prog->getUniformIndex(CGPUProgramIndex::ProjectionInverseTranspose) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ProjectionInverseTranspose), Projection, InverseTranspose);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ProjectionInverseTranspose), Projection, InverseTranspose);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjection)
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelViewProjection) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjection), ModelViewProjection, Identity);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjection), ModelViewProjection, Identity);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionInverse)
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionInverse) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionInverse), ModelViewProjection, Inverse);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionInverse), ModelViewProjection, Inverse);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionTranspose)
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionTranspose) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionTranspose), ModelViewProjection, Transpose);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionTranspose), ModelViewProjection, Transpose);
|
||||||
}
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::ModelViewProjectionInverseTranspose)
|
if (prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionInverseTranspose) != ~0)
|
||||||
{
|
{
|
||||||
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionInverseTranspose), ModelViewProjection, InverseTranspose);
|
setUniformMatrix(program, prog->getUniformIndex(CGPUProgramIndex::ModelViewProjectionInverseTranspose), ModelViewProjection, InverseTranspose);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (features.DriverFlags & CGPUProgramFeatures::Fog)
|
if (features.DriverFlags & CGPUProgramFeatures::Fog)
|
||||||
|
{
|
||||||
|
if (prog->getUniformIndex(CGPUProgramIndex::Fog) != ~0)
|
||||||
{
|
{
|
||||||
setUniformFog(program, prog->getUniformIndex(CGPUProgramIndex::Fog));
|
setUniformFog(program, prog->getUniformIndex(CGPUProgramIndex::Fog));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1208,7 +1208,7 @@ void CLandscape::render(const CVector &refineCenter, const CVector &frontVecto
|
||||||
// c[4] take useful constants.
|
// c[4] take useful constants.
|
||||||
driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants0, 0, 1, 0.5f, 0);
|
driver->setUniform4f(IDriver::VertexProgram, program->idx().ProgramConstants0, 0, 1, 0.5f, 0);
|
||||||
// c[5] take RefineCenter
|
// c[5] take RefineCenter
|
||||||
driver->setuniform3f(IDriver::VertexProgram, program->idx().RefineCenter, refineCenter);
|
driver->setUniform3f(IDriver::VertexProgram, program->idx().RefineCenter, refineCenter);
|
||||||
// c[6] take info for Geomorph trnasition to TileNear.
|
// c[6] take info for Geomorph trnasition to TileNear.
|
||||||
driver->setUniform2f(IDriver::VertexProgram, program->idx().TileDist, CLandscapeGlobals::TileDistFarSqr, CLandscapeGlobals::OOTileDistDeltaSqr);
|
driver->setUniform2f(IDriver::VertexProgram, program->idx().TileDist, CLandscapeGlobals::TileDistFarSqr, CLandscapeGlobals::OOTileDistDeltaSqr);
|
||||||
// c[10] take the fog vector.
|
// c[10] take the fog vector.
|
||||||
|
|
Loading…
Reference in a new issue