- Performance optimization - Eliminating extra matrix calculations for shaders that do not use the results

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40137
This commit is contained in:
kearwood
2012-10-20 02:15:48 +00:00
parent 1f512462b7
commit fa91aafb5b
10 changed files with 149 additions and 145 deletions

View File

@@ -47,8 +47,8 @@ KRCamera::KRCamera(KRContext &context) : KRContextObject(context) {
backingHeight = 0;
double const PI = 3.141592653589793f;
double const D2R = PI * 2 / 360;
float const PI = 3.141592653589793f;
float const D2R = PI * 2 / 360;
bShowShadowBuffer = false;
bShowOctree = false;
@@ -791,8 +791,8 @@ void KRCamera::renderPost()
const char *pChar = szText;
int iPos=0;
double dScale = 1.0 / 24.0;
double dTexScale = 1.0 / 16.0;
float dScale = 1.0 / 24.0;
float dTexScale = 1.0 / 16.0;
while(*pChar) {
int iChar = *pChar++ - '\0';
int iCol = iChar % 16;

View File

@@ -81,28 +81,28 @@ public:
bool bEnableDiffuse;
bool bEnableSpecular;
bool bEnableDeferredLighting;
double dSunR;
double dSunG;
double dSunB;
double dAmbientR;
double dAmbientG;
double dAmbientB;
double perspective_fov;
float dSunR;
float dSunG;
float dSunB;
float dAmbientR;
float dAmbientG;
float dAmbientB;
float perspective_fov;
int dof_quality;
double dof_depth;
double dof_falloff;
float dof_depth;
float dof_falloff;
bool bEnableFlash;
double flash_intensity;
double flash_depth;
double flash_falloff;
float flash_intensity;
float flash_depth;
float flash_falloff;
bool bEnableVignette;
double vignette_radius;
double vignette_falloff;
float vignette_radius;
float vignette_falloff;
KRVector2 m_viewportSize;

View File

@@ -60,17 +60,17 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F
-(NSString *)getParameterNameWithIndex: (int)i;
-(NSString *)getParameterLabelWithIndex: (int)i;
-(KREngineParameterType)getParameterTypeWithIndex: (int)i;
-(double)getParameterMinWithIndex: (int)i;
-(double)getParameterMaxWithIndex: (int)i;
-(double)getParameterValueWithIndex: (int)i;
-(void)setParameterValueWithIndex: (int)i Value: (double)v;
-(void)setParameterValueWithName: (NSString *)name Value: (double)v;
-(float)getParameterMinWithIndex: (int)i;
-(float)getParameterMaxWithIndex: (int)i;
-(float)getParameterValueWithIndex: (int)i;
-(void)setParameterValueWithIndex: (int)i Value: (float)v;
-(void)setParameterValueWithName: (NSString *)name Value: (float)v;
-(int)getParameterIndexWithName: (NSString *)name;
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix;
- (void)renderScene: (KRScene *)pScene WithPosition: (KRVector3)position Yaw: (GLfloat)yaw Pitch: (GLfloat)pitch Roll: (GLfloat)roll;
- (void)setNearZ: (double)dNearZ;
- (void)setFarZ: (double)dFarZ;
- (void)setNearZ: (float)dNearZ;
- (void)setFarZ: (float)dFarZ;
@end

View File

@@ -51,7 +51,7 @@ using namespace std;
@implementation KREngine
@synthesize debug_text = _debug_text;
double const PI = 3.141592653589793f;
float const PI = 3.141592653589793f;
+ (KREngine *)sharedInstance
@@ -273,11 +273,11 @@ double const PI = 3.141592653589793f;
};
return types[i];
}
-(double)getParameterValueWithIndex: (int)i
-(float)getParameterValueWithIndex: (int)i
{
double values[32] = {
float values[32] = {
_camera->perspective_fov,
(double)_camera->m_cShadowBuffers,
(float)_camera->m_cShadowBuffers,
_camera->bEnablePerPixel ? 1.0f : 0.0f,
_camera->bEnableDiffuseMap ? 1.0f : 0.0f,
_camera->bEnableNormalMap ? 1.0f : 0.0f,
@@ -311,7 +311,7 @@ double const PI = 3.141592653589793f;
};
return values[i];
}
-(void)setParameterValueWithIndex: (int)i Value: (double)v
-(void)setParameterValueWithIndex: (int)i Value: (float)v
{
bool bNewBoolVal = v > 0.5;
NSLog(@"Set Parameter: (%s, %f)", [[self getParameterNameWithIndex: i] UTF8String], v);
@@ -455,9 +455,9 @@ double const PI = 3.141592653589793f;
}
}
-(double)getParameterMinWithIndex: (int)i
-(float)getParameterMinWithIndex: (int)i
{
double minValues[32] = {
float minValues[32] = {
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
@@ -467,9 +467,9 @@ double const PI = 3.141592653589793f;
return minValues[i];
}
-(double)getParameterMaxWithIndex: (int)i
-(float)getParameterMaxWithIndex: (int)i
{
double maxValues[32] = {
float maxValues[32] = {
PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f,
1.0f, 10.0f, 2.0f, 1.0f, 1.0f, 1.0f, 5.0f, 1.0f,
0.5f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
@@ -479,7 +479,7 @@ double const PI = 3.141592653589793f;
return maxValues[i];
}
-(void)setParameterValueWithName: (NSString *)name Value: (double)v
-(void)setParameterValueWithName: (NSString *)name Value: (float)v
{
int cParameters = [self getParameterCount];
for(int i=0; i < cParameters; i++) {
@@ -501,11 +501,11 @@ double const PI = 3.141592653589793f;
return -1; // not found
}
- (void)setNearZ: (double)dNearZ
- (void)setNearZ: (float)dNearZ
{
_camera->setPerspectiveNear(dNearZ);
}
- (void)setFarZ: (double)dFarZ
- (void)setFarZ: (float)dFarZ
{
_camera->setPerpsectiveFarZ(dFarZ);
}
@@ -521,35 +521,35 @@ double const PI = 3.141592653589793f;
// ---===--- Sun Temperature and intensity ---===---
-(void) setSunTemperature:(double)t
-(void) setSunTemperature:(float)t
{
double i = [self getSunIntensity];
float i = [self getSunIntensity];
_camera->dSunR = (t < 0.5f ? t * 2.0f : 1.0f) * i;
_camera->dSunG = (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i;
_camera->dSunB = (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i;
}
-(void) setSunIntensity:(double)i
-(void) setSunIntensity:(float)i
{
double t = [self getSunTemperature];
float t = [self getSunTemperature];
_camera->dSunR = (t < 0.5f ? t * 2.0f : 1.0f) * i;
_camera->dSunG = (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i;
_camera->dSunB = (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i;
}
-(double) getSunIntensity
-(float) getSunIntensity
{
double i = _camera->dSunR;
float i = _camera->dSunR;
if(_camera->dSunG > i) i = _camera->dSunG;
if(_camera->dSunB > i) i = _camera->dSunB;
return i;
}
-(double) getSunTemperature
-(float) getSunTemperature
{
double i = [self getSunIntensity];
float i = [self getSunIntensity];
if(i == 0.0f) return 0.5f; // Avoid division by zero; assume black has a colour temperature of 0.5
if(_camera->dSunB == i) {
// Cold side, t < 0.5
@@ -562,35 +562,35 @@ double const PI = 3.141592653589793f;
// ---===--- Ambient Temperature and intensity ---===---
-(void) setAmbientTemperature:(double)t
-(void) setAmbientTemperature:(float)t
{
double i = [self getAmbientIntensity];
float i = [self getAmbientIntensity];
_camera->dAmbientR = (t < 0.5f ? t * 2.0f : 1.0f) * i;
_camera->dAmbientG = (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i;
_camera->dAmbientB = (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i;
}
-(void) setAmbientIntensity:(double)i
-(void) setAmbientIntensity:(float)i
{
double t = [self getAmbientTemperature];
float t = [self getAmbientTemperature];
_camera->dAmbientR = (t < 0.5f ? t * 2.0f : 1.0f) * i;
_camera->dAmbientG = (t < 0.5f ? t * 2.0f : (1.0f - t) * 2.0f) * i;
_camera->dAmbientB = (t < 0.5f ? 1.0f : (1.0f - t) * 2.0f) * i;
}
-(double) getAmbientIntensity
-(float) getAmbientIntensity
{
double i = _camera->dAmbientR;
float i = _camera->dAmbientR;
if(_camera->dAmbientG > i) i = _camera->dAmbientG;
if(_camera->dAmbientB > i) i = _camera->dAmbientB;
return i;
}
-(double) getAmbientTemperature
-(float) getAmbientTemperature
{
double i = [self getAmbientIntensity];
float i = [self getAmbientIntensity];
if(i == 0.0f) return 0.5f; // Avoid division by zero; assume black has a colour temperature of 0.5
if(_camera->dAmbientB == i) {
// Cold side, t < 0.5

View File

@@ -223,7 +223,7 @@ void KRMat4::ortho(GLfloat left, GLfloat right, GLfloat top, GLfloat bottom, GLf
bool KRMat4::invert() {
// Based on gluInvertMatrix implementation
double inv[16], det;
float inv[16], det;
int i;
inv[0] = m_mat[5]*m_mat[10]*m_mat[15] - m_mat[5]*m_mat[11]*m_mat[14] - m_mat[9]*m_mat[6]*m_mat[15]

View File

@@ -128,59 +128,59 @@ bool KRMaterialManager::load(const char *szName, KRDataBlock *data) {
}
} else if(strcmp(szSymbol[0], "ka") == 0) {
char *pScan2 = szSymbol[1];
double r = strtof(pScan2, &pScan2);
float r = strtof(pScan2, &pScan2);
if(cSymbols == 2) {
pMaterial->setAmbient(KRVector3(r, r, r));
} else if(cSymbols == 4) {
pScan2 = szSymbol[2];
double g = strtof(pScan2, &pScan2);
float g = strtof(pScan2, &pScan2);
pScan2 = szSymbol[3];
double b = strtof(pScan2, &pScan2);
float b = strtof(pScan2, &pScan2);
pMaterial->setAmbient(KRVector3(r, g, b));
}
} else if(strcmp(szSymbol[0], "kd") == 0) {
char *pScan2 = szSymbol[1];
double r = strtof(pScan2, &pScan2);
float r = strtof(pScan2, &pScan2);
if(cSymbols == 2) {
pMaterial->setDiffuse(KRVector3(r, r, r));
} else if(cSymbols == 4) {
pScan2 = szSymbol[2];
double g = strtof(pScan2, &pScan2);
float g = strtof(pScan2, &pScan2);
pScan2 = szSymbol[3];
double b = strtof(pScan2, &pScan2);
float b = strtof(pScan2, &pScan2);
pMaterial->setDiffuse(KRVector3(r, g, b));
}
} else if(strcmp(szSymbol[0], "ks") == 0) {
char *pScan2 = szSymbol[1];
double r = strtof(pScan2, &pScan2);
float r = strtof(pScan2, &pScan2);
if(cSymbols == 2) {
pMaterial->setSpecular(KRVector3(r, r, r));
} else if(cSymbols == 4) {
pScan2 = szSymbol[2];
double g = strtof(pScan2, &pScan2);
float g = strtof(pScan2, &pScan2);
pScan2 = szSymbol[3];
double b = strtof(pScan2, &pScan2);
float b = strtof(pScan2, &pScan2);
pMaterial->setSpecular(KRVector3(r, g, b));
}
} else if(strcmp(szSymbol[0], "kr") == 0) {
char *pScan2 = szSymbol[1];
double r = strtof(pScan2, &pScan2);
float r = strtof(pScan2, &pScan2);
if(cSymbols == 2) {
pMaterial->setReflection(KRVector3(r, r, r));
} else if(cSymbols == 4) {
pScan2 = szSymbol[2];
double g = strtof(pScan2, &pScan2);
float g = strtof(pScan2, &pScan2);
pScan2 = szSymbol[3];
double b = strtof(pScan2, &pScan2);
float b = strtof(pScan2, &pScan2);
pMaterial->setReflection(KRVector3(r, g, b));
}
} else if(strcmp(szSymbol[0], "tr") == 0) {
char *pScan2 = szSymbol[1];
double a = strtof(pScan2, &pScan2);
float a = strtof(pScan2, &pScan2);
pMaterial->setTransparency(a);
} else if(strcmp(szSymbol[0], "ns") == 0) {
char *pScan2 = szSymbol[1];
double a = strtof(pScan2, &pScan2);
float a = strtof(pScan2, &pScan2);
pMaterial->setShininess(a);
} else if(strncmp(szSymbol[0], "map", 3) == 0) {
// Truncate file extension
@@ -213,7 +213,7 @@ bool KRMaterialManager::load(const char *szName, KRDataBlock *data) {
iScaleParam = -1;
} else {
char *pScan3 = szSymbol[iScanSymbol];
double v = strtof(pScan3, &pScan3);
float v = strtof(pScan3, &pScan3);
if(iScaleParam == 0) {
texture_scale.x = v;
iScaleParam++;

View File

@@ -168,7 +168,7 @@ void KRPointLight::generateMesh() {
std::vector<Facet3> f = std::vector<Facet3>(facet_count);
int i,it;
double a;
float a;
KRVector3 p[6] = {
KRVector3(0,0,1),
KRVector3(0,0,-1),

View File

@@ -68,7 +68,7 @@ public:
#endif
double sun_pitch, sun_yaw;
float sun_pitch, sun_yaw;
void notify_sceneGraphCreate(KRNode *pNode);

View File

@@ -134,11 +134,9 @@ KRShader::KRShader(char *szKey, std::string options, std::string vertShaderSourc
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_INVMVP_NO_TRANSLATE] = glGetUniformLocation(m_iProgram, "inv_mvp_matrix_no_translate"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_MODEL_VIEW_INVERSE_TRANSPOSE] = glGetUniformLocation(m_iProgram, "model_view_inverse_transpose_matrix"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_MODEL_INVERSE_TRANSPOSE] = glGetUniformLocation(m_iProgram, "model_inverse_transpose_matrix"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_M2V] = glGetUniformLocation(m_iProgram, "model_view_matrix"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_MODEL_VIEW] = glGetUniformLocation(m_iProgram, "model_view_matrix"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_MODEL_MATRIX] = glGetUniformLocation(m_iProgram, "model_matrix"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_V2M] = glGetUniformLocation(m_iProgram, "inv_model_view_matrix"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_SHADOWMVP1] = glGetUniformLocation(m_iProgram, "shadow_mvp1"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_SHADOWMVP2] = glGetUniformLocation(m_iProgram, "shadow_mvp2"));
GLDEBUG(m_uniforms[KRENGINE_UNIFORM_SHADOWMVP3] = glGetUniformLocation(m_iProgram, "shadow_mvp3"));
@@ -206,89 +204,96 @@ bool KRShader::bind(KRCamera *pCamera, KRMat4 &matModel, KRMat4 &matView, KRMat4
if(m_iProgram == 0) {
return false;
}
KRMat4 inverseViewMatrix = matView;
inverseViewMatrix.invert();
KRVector3 cameraPosition = KRMat4::Dot(inverseViewMatrix, KRVector3::Zero());
// Transform location of camera to object space for calculation of specular halfVec
KRMat4 inverseModelMatrix = matModel;
inverseModelMatrix.invert();
KRVector3 cameraPosObject = KRMat4::Dot(inverseModelMatrix, cameraPosition);
KRVector3 lightDirObject = KRMat4::Dot(inverseModelMatrix, lightDirection);
lightDirObject.normalize();
GLDEBUG(glUseProgram(m_iProgram));
if(m_uniforms[KRENGINE_UNIFORM_LIGHT_DIRECTION_MODEL_SPACE] != -1 || m_uniforms[KRENGINE_UNIFORM_CAMERAPOS_MODEL_SPACE] != -1) {
KRMat4 inverseModelMatrix = matModel;
inverseModelMatrix.invert();
if(m_uniforms[KRENGINE_UNIFORM_LIGHT_DIRECTION_MODEL_SPACE] != -1) {
// Bind the light direction vector
KRVector3 lightDirObject = KRMat4::Dot(inverseModelMatrix, lightDirection);
lightDirObject.normalize();
lightDirObject.setUniform(m_uniforms[KRENGINE_UNIFORM_LIGHT_DIRECTION_MODEL_SPACE]);
}
if(m_uniforms[KRENGINE_UNIFORM_CAMERAPOS_MODEL_SPACE] != -1) {
// Transform location of camera to object space for calculation of specular halfVec
KRMat4 inverseViewMatrix = matView;
inverseViewMatrix.invert();
KRVector3 cameraPosition = KRMat4::Dot(inverseViewMatrix, KRVector3::Zero());
KRVector3 cameraPosObject = KRMat4::Dot(inverseModelMatrix, cameraPosition);
cameraPosObject.setUniform(m_uniforms[KRENGINE_UNIFORM_CAMERAPOS_MODEL_SPACE]);
}
}
// Bind our modelmatrix variable to be a uniform called mvpmatrix in our shaderprogram
mvpMatrix.setUniform(m_uniforms[KRENGINE_UNIFORM_MVP]);
if(m_uniforms[KRShader::KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE] != -1 || m_uniforms[KRENGINE_UNIFORM_MODEL_VIEW_INVERSE_TRANSPOSE] != -1) {
KRMat4 matModelView = matModel * matView;
matModelView.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_MODEL_VIEW]);
KRMat4 matModelViewInverseTranspose = matView * matModel;
matModelViewInverseTranspose.transpose();
matModelViewInverseTranspose.invert();
matModelViewInverseTranspose.setUniform(m_uniforms[KRENGINE_UNIFORM_MODEL_VIEW_INVERSE_TRANSPOSE]);
if(m_uniforms[KRShader::KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE] != -1) {
KRVector3 view_space_model_origin = KRMat4::Dot(matModelView, KRVector3::Zero()); // Origin point of model space is the light source position. No perspective, so no w divide required
view_space_model_origin.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE]);
}
KRMat4 matModelInverseTranspose = matModel;
matModelInverseTranspose.transpose();
matModelInverseTranspose.invert();
if(m_uniforms[KRENGINE_UNIFORM_MODEL_VIEW_INVERSE_TRANSPOSE] != -1) {
KRMat4 matModelViewInverseTranspose = matModelView;
matModelViewInverseTranspose.transpose();
matModelViewInverseTranspose.invert();
matModelViewInverseTranspose.setUniform(m_uniforms[KRENGINE_UNIFORM_MODEL_VIEW_INVERSE_TRANSPOSE]);
}
}
matModelInverseTranspose.setUniform(m_uniforms[KRENGINE_UNIFORM_MODEL_INVERSE_TRANSPOSE]);
if(m_uniforms[KRENGINE_UNIFORM_MODEL_INVERSE_TRANSPOSE] != -1) {
KRMat4 matModelInverseTranspose = matModel;
matModelInverseTranspose.transpose();
matModelInverseTranspose.invert();
matModelInverseTranspose.setUniform(m_uniforms[KRENGINE_UNIFORM_MODEL_INVERSE_TRANSPOSE]);
}
KRMat4 matInvProjection;
matInvProjection = pCamera->getProjectionMatrix();
matInvProjection.invert();
matInvProjection.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_INVP]);
if(m_uniforms[KRShader::KRENGINE_UNIFORM_INVP] != -1) {
KRMat4 matInvProjection = pCamera->getProjectionMatrix();
matInvProjection.invert();
matInvProjection.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_INVP]);
}
KRMat4 matInvMVP = mvpMatrix;
matInvMVP.invert();
matInvMVP.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_INVMVP]);
if(m_uniforms[KRShader::KRENGINE_UNIFORM_INVMVP] != -1) {
KRMat4 matInvMVP = mvpMatrix;
matInvMVP.invert();
matInvMVP.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_INVMVP]);
}
KRMat4 matInvMVPNoTranslate = matModel * matView;
// Remove the translation
matInvMVPNoTranslate.getPointer()[3] = 0;
matInvMVPNoTranslate.getPointer()[7] = 0;
matInvMVPNoTranslate.getPointer()[11] = 0;
matInvMVPNoTranslate.getPointer()[12] = 0;
matInvMVPNoTranslate.getPointer()[13] = 0;
matInvMVPNoTranslate.getPointer()[14] = 0;
matInvMVPNoTranslate.getPointer()[15] = 1.0;
matInvMVPNoTranslate = matInvMVPNoTranslate * pCamera->getProjectionMatrix();
matInvMVPNoTranslate.invert();
matInvMVPNoTranslate.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_INVMVP_NO_TRANSLATE]);
if(m_uniforms[KRShader::KRENGINE_UNIFORM_INVMVP_NO_TRANSLATE] != -1) {
KRMat4 matInvMVPNoTranslate = matModel * matView;
// Remove the translation
matInvMVPNoTranslate.getPointer()[3] = 0;
matInvMVPNoTranslate.getPointer()[7] = 0;
matInvMVPNoTranslate.getPointer()[11] = 0;
matInvMVPNoTranslate.getPointer()[12] = 0;
matInvMVPNoTranslate.getPointer()[13] = 0;
matInvMVPNoTranslate.getPointer()[14] = 0;
matInvMVPNoTranslate.getPointer()[15] = 1.0;
matInvMVPNoTranslate = matInvMVPNoTranslate * pCamera->getProjectionMatrix();
matInvMVPNoTranslate.invert();
matInvMVPNoTranslate.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_INVMVP_NO_TRANSLATE]);
}
matModel.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_MODEL_MATRIX]);
{
KRMat4 matModelToView2 = KRMat4() * matModel * matView;
matModelToView2.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_M2V]);
KRVector3 view_space_model_origin = KRMat4::Dot(matModelToView2, KRVector3::Zero()); // Origin point of model space is the light source position. No perspective, so no w divide required
view_space_model_origin.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_LIGHT_POSITION_VIEW_SPACE]);
KRMat4 matViewToModel = matModelToView2;
matViewToModel.invert();
matViewToModel.setUniform(m_uniforms[KRShader::KRENGINE_UNIFORM_V2M]);
if(m_uniforms[KRENGINE_UNIFORM_VIEWPORT] != -1) {
GLDEBUG(glUniform4f(
m_uniforms[KRENGINE_UNIFORM_VIEWPORT],
(GLfloat)0.0,
(GLfloat)0.0,
(GLfloat)pCamera->getViewportSize().x,
(GLfloat)pCamera->getViewportSize().y
));
}
// Bind the light direction vector
lightDirObject.setUniform(m_uniforms[KRENGINE_UNIFORM_LIGHT_DIRECTION_MODEL_SPACE]);
// Bind the camera position, in model space
cameraPosObject.setUniform(m_uniforms[KRENGINE_UNIFORM_CAMERAPOS_MODEL_SPACE]);
GLDEBUG(glUniform4f(
m_uniforms[KRENGINE_UNIFORM_VIEWPORT],
(GLfloat)0.0,
(GLfloat)0.0,
(GLfloat)pCamera->getViewportSize().x,
(GLfloat)pCamera->getViewportSize().y
));
// Bind the shadowmap space matrices
for(int iShadow=0; iShadow < cShadowBuffers; iShadow++) {
pShadowMatrices[iShadow].setUniform(m_uniforms[KRENGINE_UNIFORM_SHADOWMVP1 + iShadow]);

View File

@@ -92,8 +92,7 @@ public:
KRENGINE_UNIFORM_INVMVP_NO_TRANSLATE,
KRENGINE_UNIFORM_MODEL_VIEW_INVERSE_TRANSPOSE,
KRENGINE_UNIFORM_MODEL_INVERSE_TRANSPOSE,
KRENGINE_UNIFORM_M2V,
KRENGINE_UNIFORM_V2M,
KRENGINE_UNIFORM_MODEL_VIEW,
KRENGINE_UNIFORM_MODEL_MATRIX,
KRENGINE_UNIFORM_CAMERAPOS_MODEL_SPACE,