Fixed bug that caused octree visualization to intermittently display opaque visuals

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40146
This commit is contained in:
kearwood
2012-10-27 00:50:17 +00:00
parent b2c13a1281
commit db43a1468e
4 changed files with 35 additions and 17 deletions

View File

@@ -105,8 +105,6 @@ bool KRAABB::visible(const KRMat4 &matViewProjection) const
// test if bounding box would be within the visible range of the clip space transformed by matViewProjection // test if bounding box would be within the visible range of the clip space transformed by matViewProjection
// This is used for view frustrum culling // This is used for view frustrum culling
KRVector3 minCorner, maxCorner;
int outside_count[6] = {0, 0, 0, 0, 0, 0}; int outside_count[6] = {0, 0, 0, 0, 0, 0};
for(int iCorner=0; iCorner<8; iCorner++) { for(int iCorner=0; iCorner<8; iCorner++) {

View File

@@ -426,6 +426,10 @@ void KRCamera::renderFrame(KRScene &scene, KRVector3 &lightDirection) {
GLDEBUG(glCullFace(GL_BACK)); GLDEBUG(glCullFace(GL_BACK));
GLDEBUG(glEnable(GL_CULL_FACE)); GLDEBUG(glEnable(GL_CULL_FACE));
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
KRShader *pVisShader = m_pContext->getShaderManager()->getShader("visualize_overlay", this, false, false, false, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT); KRShader *pVisShader = m_pContext->getShaderManager()->getShader("visualize_overlay", this, false, false, false, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);

View File

@@ -128,7 +128,9 @@ float const PI = 3.141592653589793f;
@"debug_super_shiny" : @28, @"debug_super_shiny" : @28,
@"debug_octree" : @29, @"debug_octree" : @29,
@"debug_deferred" : @30, @"debug_deferred" : @30,
@"enable_deferred_lighting" : @31 @"enable_deferred_lighting" : @31,
@"near_clip" : @32,
@"far_clip" : @33
} copy]; } copy];
[self loadShaders]; [self loadShaders];
@@ -188,7 +190,7 @@ float const PI = 3.141592653589793f;
-(int)getParameterCount -(int)getParameterCount
{ {
return 32; return 34;
} }
-(NSString *)getParameterNameWithIndex: (int)i -(NSString *)getParameterNameWithIndex: (int)i
@@ -198,7 +200,7 @@ float const PI = 3.141592653589793f;
-(NSString *)getParameterLabelWithIndex: (int)i -(NSString *)getParameterLabelWithIndex: (int)i
{ {
NSString *parameter_labels[32] = { NSString *parameter_labels[34] = {
@"Camera FOV", @"Camera FOV",
@"Shadow Quality (0 - 2)", @"Shadow Quality (0 - 2)",
@"Enable per-pixel lighting", @"Enable per-pixel lighting",
@@ -230,13 +232,15 @@ float const PI = 3.141592653589793f;
@"Debug - Super Shiny", @"Debug - Super Shiny",
@"Debug - Octree Visualize", @"Debug - Octree Visualize",
@"Debug - Deferred Lights Visualize", @"Debug - Deferred Lights Visualize",
@"Enable Deferred Lighting" @"Enable Deferred Lighting",
@"Near Clip Plane",
@"Far Clip Plane"
}; };
return parameter_labels[i]; return parameter_labels[i];
} }
-(KREngineParameterType)getParameterTypeWithIndex: (int)i -(KREngineParameterType)getParameterTypeWithIndex: (int)i
{ {
KREngineParameterType types[32] = { KREngineParameterType types[34] = {
KRENGINE_PARAMETER_FLOAT, KRENGINE_PARAMETER_FLOAT,
KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_INT,
@@ -269,13 +273,15 @@ float const PI = 3.141592653589793f;
KRENGINE_PARAMETER_BOOL, KRENGINE_PARAMETER_BOOL,
KRENGINE_PARAMETER_BOOL, KRENGINE_PARAMETER_BOOL,
KRENGINE_PARAMETER_BOOL, KRENGINE_PARAMETER_BOOL,
KRENGINE_PARAMETER_BOOL KRENGINE_PARAMETER_BOOL,
KRENGINE_PARAMETER_FLOAT,
KRENGINE_PARAMETER_FLOAT
}; };
return types[i]; return types[i];
} }
-(float)getParameterValueWithIndex: (int)i -(float)getParameterValueWithIndex: (int)i
{ {
float values[32] = { float values[34] = {
_camera->perspective_fov, _camera->perspective_fov,
(float)_camera->m_cShadowBuffers, (float)_camera->m_cShadowBuffers,
_camera->bEnablePerPixel ? 1.0f : 0.0f, _camera->bEnablePerPixel ? 1.0f : 0.0f,
@@ -307,7 +313,9 @@ float const PI = 3.141592653589793f;
_camera->bDebugSuperShiny ? 1.0f : 0.0f, _camera->bDebugSuperShiny ? 1.0f : 0.0f,
_camera->bShowOctree ? 1.0f : 0.0f, _camera->bShowOctree ? 1.0f : 0.0f,
_camera->bShowDeferred ? 1.0f : 0.0f, _camera->bShowDeferred ? 1.0f : 0.0f,
_camera->bEnableDeferredLighting ? 1.0f : 0.0f _camera->bEnableDeferredLighting ? 1.0f : 0.0f,
_camera->getPerspectiveNearZ(),
_camera->getPerspectiveFarZ()
}; };
return values[i]; return values[i];
} }
@@ -452,16 +460,22 @@ float const PI = 3.141592653589793f;
_camera->bEnableDeferredLighting = bNewBoolVal; _camera->bEnableDeferredLighting = bNewBoolVal;
} }
break; break;
case 32:
_camera->setPerspectiveNear(v);
break;
case 33:
_camera->setPerpsectiveFarZ(v);
break;
} }
} }
-(float)getParameterMinWithIndex: (int)i -(float)getParameterMinWithIndex: (int)i
{ {
float minValues[32] = { float minValues[34] = {
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, 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,
0.0f, 0.0f, 0.0f, 0.0f 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 50.0f
}; };
return minValues[i]; return minValues[i];
@@ -469,11 +483,11 @@ float const PI = 3.141592653589793f;
-(float)getParameterMaxWithIndex: (int)i -(float)getParameterMaxWithIndex: (int)i
{ {
float maxValues[32] = { float maxValues[34] = {
PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f, 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, 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, 0.5f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f 1.0f, 1.0f, 1.0f, 1.0f, 1000.0f, 50000.0f
}; };
return maxValues[i]; return maxValues[i];

View File

@@ -232,7 +232,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::set<KRAABB> &visibleBounds,
KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix(); KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix();
// Enable additive blending // Enable additive blending
if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT) { if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_FLARES) {
GLDEBUG(glEnable(GL_BLEND)); GLDEBUG(glEnable(GL_BLEND));
} }
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE)); GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
@@ -262,10 +262,12 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::set<KRAABB> &visibleBounds,
pOctreeNode->endOcclusionQuery(); pOctreeNode->endOcclusionQuery();
if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT) { if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_FLARES) {
GLDEBUG(glDisable(GL_BLEND)); GLDEBUG(glDisable(GL_BLEND));
} else { } else if(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT) {
GLDEBUG(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); GLDEBUG(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
} else {
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
} }