Implemented small optimization for hardware occlusion culling.
Implemented parameter to allow hardware occlusion culling to be disabled.
This commit is contained in:
@@ -193,7 +193,8 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
@"dust_enable" : @46,
|
@"dust_enable" : @46,
|
||||||
@"dust_intensity" : @47,
|
@"dust_intensity" : @47,
|
||||||
@"lod_bias" : @48,
|
@"lod_bias" : @48,
|
||||||
@"debug_display" : @49
|
@"enable_realtime_occlusion" : @49,
|
||||||
|
@"debug_display" : @50
|
||||||
|
|
||||||
} copy];
|
} copy];
|
||||||
[self loadShaders];
|
[self loadShaders];
|
||||||
@@ -266,7 +267,7 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
|
|
||||||
-(int)getParameterCount
|
-(int)getParameterCount
|
||||||
{
|
{
|
||||||
return 50;
|
return 51;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -282,7 +283,7 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
|
|
||||||
-(NSString *)getParameterLabelWithIndex: (int)i
|
-(NSString *)getParameterLabelWithIndex: (int)i
|
||||||
{
|
{
|
||||||
NSString *parameter_labels[50] = {
|
NSString *parameter_labels[51] = {
|
||||||
@"Camera FOV",
|
@"Camera FOV",
|
||||||
@"Shadow Quality (0 - 2)",
|
@"Shadow Quality (0 - 2)",
|
||||||
@"Enable per-pixel lighting",
|
@"Enable per-pixel lighting",
|
||||||
@@ -332,13 +333,14 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
@"Dust - Enable",
|
@"Dust - Enable",
|
||||||
@"Dust - Intensity",
|
@"Dust - Intensity",
|
||||||
@"LOD Bias",
|
@"LOD Bias",
|
||||||
|
@"Realtime Occlusion Tests",
|
||||||
@"Debug - Display"
|
@"Debug - Display"
|
||||||
};
|
};
|
||||||
return parameter_labels[i];
|
return parameter_labels[i];
|
||||||
}
|
}
|
||||||
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
||||||
{
|
{
|
||||||
KREngineParameterType types[50] = {
|
KREngineParameterType types[51] = {
|
||||||
|
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
KRENGINE_PARAMETER_INT,
|
KRENGINE_PARAMETER_INT,
|
||||||
@@ -389,13 +391,14 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
KRENGINE_PARAMETER_BOOL,
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_INT
|
KRENGINE_PARAMETER_INT
|
||||||
};
|
};
|
||||||
return types[i];
|
return types[i];
|
||||||
}
|
}
|
||||||
-(float)getParameterValueWithIndex: (int)i
|
-(float)getParameterValueWithIndex: (int)i
|
||||||
{
|
{
|
||||||
float values[50] = {
|
float values[51] = {
|
||||||
_settings.perspective_fov,
|
_settings.perspective_fov,
|
||||||
(float)_settings.m_cShadowBuffers,
|
(float)_settings.m_cShadowBuffers,
|
||||||
_settings.bEnablePerPixel ? 1.0f : 0.0f,
|
_settings.bEnablePerPixel ? 1.0f : 0.0f,
|
||||||
@@ -445,6 +448,7 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
_settings.dust_particle_enable,
|
_settings.dust_particle_enable,
|
||||||
_settings.dust_particle_intensity,
|
_settings.dust_particle_intensity,
|
||||||
_settings.getLODBias(),
|
_settings.getLODBias(),
|
||||||
|
_settings.getEnableRealtimeOcclusion(),
|
||||||
_settings.debug_display
|
_settings.debug_display
|
||||||
};
|
};
|
||||||
return values[i];
|
return values[i];
|
||||||
@@ -642,6 +646,9 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
_settings.setLODBias(v);
|
_settings.setLODBias(v);
|
||||||
break;
|
break;
|
||||||
case 49:
|
case 49:
|
||||||
|
_settings.setEnableRealtimeOcclusion(bNewBoolVal);
|
||||||
|
break;
|
||||||
|
case 50:
|
||||||
_settings.debug_display = (KRRenderSettings::debug_display_type)v;
|
_settings.debug_display = (KRRenderSettings::debug_display_type)v;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -649,12 +656,12 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
|
|
||||||
-(float)getParameterMinWithIndex: (int)i
|
-(float)getParameterMinWithIndex: (int)i
|
||||||
{
|
{
|
||||||
float minValues[50] = {
|
float minValues[51] = {
|
||||||
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.01f, 50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
0.0f, 0.0f, 0.01f, 50.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, -10.0f, 0.0f
|
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -10.0f, 0.0f, 0.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
return minValues[i];
|
return minValues[i];
|
||||||
@@ -662,12 +669,12 @@ void kraken::set_parameter(const std::string ¶meter_name, float parameter_va
|
|||||||
|
|
||||||
-(float)getParameterMaxWithIndex: (int)i
|
-(float)getParameterMaxWithIndex: (int)i
|
||||||
{
|
{
|
||||||
float maxValues[50] = {
|
float maxValues[51] = {
|
||||||
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, 0.5f, 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, 1.0f, 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, 10.0f, 1000.0f, 1.0f, 5.0f, 1000.0f, 1.0f, 5.0f, 3.0f,
|
1.0f, 1.0f, 10.0f, 1000.0f, 1.0f, 5.0f, 1000.0f, 1.0f, 5.0f, 3.0f,
|
||||||
1000.0f, 1000.0f, 0.01f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f, (float)(KRRenderSettings::KRENGINE_DEBUG_DISPLAY_NUMBER - 1)
|
1000.0f, 1000.0f, 0.01f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 10.0f, 1.0f, (float)(KRRenderSettings::KRENGINE_DEBUG_DISPLAY_NUMBER - 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
return maxValues[i];
|
return maxValues[i];
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
KRRenderSettings::KRRenderSettings()
|
KRRenderSettings::KRRenderSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_enable_realtime_occlusion = true;
|
||||||
bShowShadowBuffer = false;
|
bShowShadowBuffer = false;
|
||||||
bShowOctree = false;
|
bShowOctree = false;
|
||||||
bShowDeferred = false;
|
bShowDeferred = false;
|
||||||
@@ -191,4 +192,13 @@ float KRRenderSettings::getLODBias()
|
|||||||
void KRRenderSettings::setLODBias(float v)
|
void KRRenderSettings::setLODBias(float v)
|
||||||
{
|
{
|
||||||
m_lodBias = v;
|
m_lodBias = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KRRenderSettings::getEnableRealtimeOcclusion()
|
||||||
|
{
|
||||||
|
return m_enable_realtime_occlusion;
|
||||||
|
}
|
||||||
|
void KRRenderSettings::setEnableRealtimeOcclusion(bool enable)
|
||||||
|
{
|
||||||
|
m_enable_realtime_occlusion = enable;
|
||||||
}
|
}
|
||||||
@@ -96,9 +96,13 @@ public:
|
|||||||
KRENGINE_DEBUG_DISPLAY_DRAW_CALLS,
|
KRENGINE_DEBUG_DISPLAY_DRAW_CALLS,
|
||||||
KRENGINE_DEBUG_DISPLAY_NUMBER
|
KRENGINE_DEBUG_DISPLAY_NUMBER
|
||||||
} debug_display;
|
} debug_display;
|
||||||
|
|
||||||
|
bool getEnableRealtimeOcclusion();
|
||||||
|
void setEnableRealtimeOcclusion(bool enable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_lodBias;
|
float m_lodBias;
|
||||||
|
bool m_enable_realtime_occlusion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -200,6 +200,11 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::map<KRAABB, int> &visibleBo
|
|||||||
// ----====---- Rendering and occlusion test pass ----====----
|
// ----====---- Rendering and occlusion test pass ----====----
|
||||||
bool bVisible = false;
|
bool bVisible = false;
|
||||||
bool bNeedOcclusionTest = true;
|
bool bNeedOcclusionTest = true;
|
||||||
|
|
||||||
|
if(!pCamera->settings.getEnableRealtimeOcclusion()) {
|
||||||
|
bVisible = true;
|
||||||
|
bNeedOcclusionTest = false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!bVisible) {
|
if(!bVisible) {
|
||||||
// Assume bounding boxes are visible without occlusion test queries if the camera is inside the box.
|
// Assume bounding boxes are visible without occlusion test queries if the camera is inside the box.
|
||||||
@@ -239,7 +244,10 @@ void KRScene::render(KROctreeNode *pOctreeNode, std::map<KRAABB, int> &visibleBo
|
|||||||
for(int i=0; i<8; i++) {
|
for(int i=0; i<8; i++) {
|
||||||
if(pOctreeNode->getChildren()[i] != NULL) child_count++;
|
if(pOctreeNode->getChildren()[i] != NULL) child_count++;
|
||||||
}
|
}
|
||||||
if(child_count == 1) bVisible = true;
|
if(child_count == 1) {
|
||||||
|
bVisible = true;
|
||||||
|
bNeedOcclusionTest = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user