mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:09:34 +02:00
Displaying the stack of zone components
This commit is contained in:
parent
d9ad45bf4a
commit
b8a2b38fd5
2 changed files with 57 additions and 46 deletions
|
@ -127,31 +127,35 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I
|
||||||
auto deferredTransform = inputs;
|
auto deferredTransform = inputs;
|
||||||
|
|
||||||
auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
|
auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
|
||||||
model::LightPointer keyLight;
|
std::vector<model::LightPointer> keyLightStack;
|
||||||
if (lightStage && lightStage->_currentFrame._sunLights.size()) {
|
if (lightStage && lightStage->_currentFrame._sunLights.size()) {
|
||||||
keyLight = lightStage->getLight(lightStage->_currentFrame._sunLights.front());
|
for (auto index : lightStage->_currentFrame._sunLights) {
|
||||||
}
|
keyLightStack.push_back(lightStage->getLight(index));
|
||||||
else {
|
}
|
||||||
keyLight = DependencyManager::get<DeferredLightingEffect>()->getGlobalLight();
|
|
||||||
}
|
}
|
||||||
|
keyLightStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getGlobalLight());
|
||||||
|
|
||||||
|
std::vector<model::LightPointer> ambientLightStack;
|
||||||
|
if (lightStage && lightStage->_currentFrame._ambientLights.size()) {
|
||||||
|
for (auto index : lightStage->_currentFrame._ambientLights) {
|
||||||
|
ambientLightStack.push_back(lightStage->getLight(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ambientLightStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getGlobalLight());
|
||||||
|
|
||||||
model::LightPointer keyAmbiLight;
|
|
||||||
if (lightStage && lightStage->_currentFrame._ambientLights.size()) {
|
|
||||||
keyAmbiLight = lightStage->getLight(lightStage->_currentFrame._ambientLights.front());
|
|
||||||
} else {
|
|
||||||
keyAmbiLight = DependencyManager::get<DeferredLightingEffect>()->getGlobalLight();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto backgroundStage = DependencyManager::get<DeferredLightingEffect>()->getBackgroundStage();
|
auto backgroundStage = DependencyManager::get<DeferredLightingEffect>()->getBackgroundStage();
|
||||||
model::SkyboxPointer skybox;
|
std::vector<model::SkyboxPointer> skyboxStack;
|
||||||
if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) {
|
if (backgroundStage && backgroundStage->_currentFrame._backgrounds.size()) {
|
||||||
auto background = backgroundStage->getBackground(backgroundStage->_currentFrame._backgrounds.front());
|
for (auto index : backgroundStage->_currentFrame._backgrounds) {
|
||||||
if (background) {
|
auto background = backgroundStage->getBackground(index);
|
||||||
skybox = background->getSkybox();
|
if (background) {
|
||||||
}
|
skyboxStack.push_back(background->getSkybox());
|
||||||
} else {
|
}
|
||||||
skybox = DependencyManager::get<DeferredLightingEffect>()->getDefaultSkybox();
|
}
|
||||||
}
|
}
|
||||||
|
skyboxStack.push_back(DependencyManager::get<DeferredLightingEffect>()->getDefaultSkybox());
|
||||||
|
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [=](gpu::Batch& batch) {
|
||||||
|
|
||||||
|
@ -165,34 +169,40 @@ void DebugZoneLighting::run(const render::RenderContextPointer& context, const I
|
||||||
batch.setUniformBuffer(ZONE_DEFERRED_TRANSFORM_BUFFER, deferredTransform->getFrameTransformBuffer());
|
batch.setUniformBuffer(ZONE_DEFERRED_TRANSFORM_BUFFER, deferredTransform->getFrameTransformBuffer());
|
||||||
|
|
||||||
batch.setPipeline(getKeyLightPipeline());
|
batch.setPipeline(getKeyLightPipeline());
|
||||||
model.setTranslation(glm::vec3(-4.0, -3.0, -10.0));
|
auto numKeys = keyLightStack.size();
|
||||||
batch.setModelTransform(model);
|
for (int i = numKeys - 1; i >= 0; i--) {
|
||||||
if (keyLight) {
|
model.setTranslation(glm::vec3(-4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0)));
|
||||||
batch.setUniformBuffer(ZONE_KEYLIGHT_BUFFER, keyLight->getLightSchemaBuffer());
|
batch.setModelTransform(model);
|
||||||
}
|
if (keyLightStack[i]) {
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.setUniformBuffer(ZONE_KEYLIGHT_BUFFER, keyLightStack[i]->getLightSchemaBuffer());
|
||||||
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
batch.setPipeline(getAmbientPipeline());
|
batch.setPipeline(getAmbientPipeline());
|
||||||
model.setTranslation(glm::vec3(-4.0, 0.0, -10.0));
|
auto numAmbients = ambientLightStack.size();
|
||||||
batch.setModelTransform(model);
|
for (int i = numAmbients - 1; i >= 0; i--) {
|
||||||
if (keyAmbiLight) {
|
model.setTranslation(glm::vec3(0.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0)));
|
||||||
batch.setUniformBuffer(ZONE_AMBIENT_BUFFER, keyAmbiLight->getAmbientSchemaBuffer());
|
batch.setModelTransform(model);
|
||||||
|
if (ambientLightStack[i]) {
|
||||||
if (keyAmbiLight->getAmbientMap()) {
|
batch.setUniformBuffer(ZONE_AMBIENT_BUFFER, ambientLightStack[i]->getAmbientSchemaBuffer());
|
||||||
batch.setResourceTexture(ZONE_AMBIENT_MAP, keyAmbiLight->getAmbientMap());
|
if (ambientLightStack[i]->getAmbientMap()) {
|
||||||
}
|
batch.setResourceTexture(ZONE_AMBIENT_MAP, ambientLightStack[i]->getAmbientMap());
|
||||||
}
|
}
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
batch.setPipeline(getBackgroundPipeline());
|
batch.setPipeline(getBackgroundPipeline());
|
||||||
model.setTranslation(glm::vec3(-4.0, 3.0, -10.0));
|
auto numBackgrounds = skyboxStack.size();
|
||||||
batch.setModelTransform(model);
|
for (int i = numBackgrounds - 1; i >= 0; i--) {
|
||||||
if (skybox) {
|
model.setTranslation(glm::vec3(4.0, -3.0 + (i * 1.0), -10.0 - (i * 3.0)));
|
||||||
batch.setResourceTexture(ZONE_SKYBOX_MAP, skybox->getCubemap());
|
batch.setModelTransform(model);
|
||||||
batch.setUniformBuffer(ZONE_SKYBOX_BUFFER, skybox->getSchemaBuffer());
|
if (skyboxStack[i]) {
|
||||||
}
|
batch.setResourceTexture(ZONE_SKYBOX_MAP, skyboxStack[i]->getCubemap());
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.setUniformBuffer(ZONE_SKYBOX_BUFFER, skyboxStack[i]->getSchemaBuffer());
|
||||||
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ void main(void) {
|
||||||
<$evalGlobeWidget()$>
|
<$evalGlobeWidget()$>
|
||||||
|
|
||||||
Light light = getLight();
|
Light light = getLight();
|
||||||
vec3 lightDirection = getLightDirection(light);
|
vec3 lightDirection = normalize(getLightDirection(light));
|
||||||
vec3 lightIrradiance = getLightIrradiance(light);
|
vec3 lightIrradiance = getLightIrradiance(light);
|
||||||
vec3 color = vec3(0.0);
|
vec3 color = vec3(0.0);
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ void main(void) {
|
||||||
|
|
||||||
vec3 outSpherePos = normalize(vec3(sphereUV, -sqrt(1.0 - sphereR2)));
|
vec3 outSpherePos = normalize(vec3(sphereUV, -sqrt(1.0 - sphereR2)));
|
||||||
vec3 outNormal = vec3(getViewInverse() * vec4(outSpherePos, 0.0));
|
vec3 outNormal = vec3(getViewInverse() * vec4(outSpherePos, 0.0));
|
||||||
float val = step(SUN_THRESHOLD, dot(-lightDirection, outNormal));
|
|
||||||
|
float val = step(SUN_THRESHOLD, dot(-lightDirection, outNormal));
|
||||||
|
|
||||||
color = lightIrradiance * vec3(val);
|
color = lightIrradiance * vec3(val);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue