mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 06:42:57 +02:00
Keylight inheritance mode works.
This commit is contained in:
parent
58c6f8e9c4
commit
e974cac177
4 changed files with 57 additions and 13 deletions
|
@ -165,18 +165,14 @@ void ZoneEntityRenderer::doRender(RenderArgs* args) {
|
|||
|
||||
if (_visible) {
|
||||
// Finally, push the light visible in the frame
|
||||
if (_keyLightMode == COMPONENT_MODE_ENABLED) {
|
||||
if (_keyLightMode != BACKGROUND_MODE_INHERIT) {
|
||||
_stage->_currentFrame.pushSunLight(_sunIndex);
|
||||
} else if (_keyLightMode == COMPONENT_MODE_DISABLED) {
|
||||
// DEAL WITH OFF LIGHT
|
||||
}
|
||||
|
||||
// The ambient light only if it has a valid texture to render with
|
||||
if (_validAmbientTexture || _validSkyboxTexture) {
|
||||
if (_ambientLightMode == COMPONENT_MODE_ENABLED) {
|
||||
if (_ambientLightMode != BACKGROUND_MODE_INHERIT) {
|
||||
_stage->_currentFrame.pushAmbientLight(_ambientIndex);
|
||||
} else if (_ambientLightMode == COMPONENT_MODE_DISABLED) {
|
||||
// DEAL WITH OFF LIGHT
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +197,6 @@ void ZoneEntityRenderer::removeFromScene(const ScenePointer& scene, Transaction&
|
|||
Parent::removeFromScene(scene, transaction);
|
||||
}
|
||||
|
||||
|
||||
void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) {
|
||||
DependencyManager::get<EntityTreeRenderer>()->updateZone(entity->getID());
|
||||
|
||||
|
@ -244,11 +239,11 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
|||
updateKeyZoneItemFromEntity();
|
||||
|
||||
if (sunChanged) {
|
||||
updateKeySunFromEntity();
|
||||
updateKeySunFromEntity(entity);
|
||||
}
|
||||
|
||||
if (sunChanged || skyboxChanged) {
|
||||
updateKeyAmbientFromEntity();
|
||||
updateKeyAmbientFromEntity(entity);
|
||||
}
|
||||
|
||||
if (backgroundChanged || skyboxChanged) {
|
||||
|
@ -317,7 +312,9 @@ bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
|
|||
return false;
|
||||
}
|
||||
|
||||
void ZoneEntityRenderer::updateKeySunFromEntity() {
|
||||
void ZoneEntityRenderer::updateKeySunFromEntity(const TypedEntityPointer& entity) {
|
||||
setKeyLightMode((ComponentMode)entity->getKeyLightMode());
|
||||
|
||||
const auto& sunLight = editSunLight();
|
||||
sunLight->setType(model::Light::SUN);
|
||||
sunLight->setPosition(_lastPosition);
|
||||
|
@ -329,7 +326,9 @@ void ZoneEntityRenderer::updateKeySunFromEntity() {
|
|||
sunLight->setDirection(_keyLightProperties.getDirection());
|
||||
}
|
||||
|
||||
void ZoneEntityRenderer::updateKeyAmbientFromEntity() {
|
||||
void ZoneEntityRenderer::updateKeyAmbientFromEntity(const TypedEntityPointer& entity) {
|
||||
setAmbientLightMode((ComponentMode)entity->getAmbientLightMode());
|
||||
|
||||
const auto& ambientLight = editAmbientLight();
|
||||
ambientLight->setType(model::Light::AMBIENT);
|
||||
ambientLight->setPosition(_lastPosition);
|
||||
|
|
|
@ -46,8 +46,8 @@ protected:
|
|||
|
||||
private:
|
||||
void updateKeyZoneItemFromEntity();
|
||||
void updateKeySunFromEntity();
|
||||
void updateKeyAmbientFromEntity();
|
||||
void updateKeySunFromEntity(const TypedEntityPointer& entity);
|
||||
void updateKeyAmbientFromEntity(const TypedEntityPointer& entity);
|
||||
void updateHazeFromEntity(const TypedEntityPointer& entity);
|
||||
void updateKeyBackgroundFromEntity(const TypedEntityPointer& entity);
|
||||
void updateAmbientMap();
|
||||
|
|
|
@ -28,6 +28,34 @@ static const auto MAX_BIAS = 0.006f;
|
|||
const LightStage::Index LightStage::INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
||||
|
||||
LightStage::LightStage() {
|
||||
// Add off lights
|
||||
const LightPointer ambientOffLight { std::make_shared<model::Light>() };
|
||||
ambientOffLight->setAmbientIntensity(0.0f);
|
||||
ambientOffLight->setColor(model::Vec3(0.0));
|
||||
ambientOffLight->setIntensity(0.0f);
|
||||
ambientOffLight->setType(model::Light::Type::AMBIENT);
|
||||
_ambientOffLight = addLight(ambientOffLight);
|
||||
|
||||
const LightPointer pointOffLight { std::make_shared<model::Light>() };
|
||||
pointOffLight->setAmbientIntensity(0.0f);
|
||||
pointOffLight->setColor(model::Vec3(0.0));
|
||||
pointOffLight->setIntensity(0.0f);
|
||||
pointOffLight->setType(model::Light::Type::POINT);
|
||||
_pointOffLight = addLight(pointOffLight);
|
||||
|
||||
const LightPointer spotOffLight { std::make_shared<model::Light>() };
|
||||
spotOffLight->setAmbientIntensity(0.0f);
|
||||
spotOffLight->setColor(model::Vec3(0.0));
|
||||
spotOffLight->setIntensity(0.0f);
|
||||
spotOffLight->setType(model::Light::Type::SPOT);
|
||||
_spotOffLight = addLight(spotOffLight);
|
||||
|
||||
const LightPointer sunOffLight { std::make_shared<model::Light>() };
|
||||
sunOffLight->setAmbientIntensity(0.0f);
|
||||
sunOffLight->setColor(model::Vec3(0.0));
|
||||
sunOffLight->setIntensity(0.0f);
|
||||
sunOffLight->setType(model::Light::Type::SUN);
|
||||
_sunOffLight = addLight(sunOffLight);
|
||||
}
|
||||
|
||||
LightStage::Shadow::Schema::Schema() {
|
||||
|
|
|
@ -185,6 +185,11 @@ public:
|
|||
|
||||
Frame _currentFrame;
|
||||
|
||||
Index getAmbientOffLight() { return _ambientOffLight; }
|
||||
Index getPointOffLight() { return _pointOffLight; }
|
||||
Index getSpotOffLight() { return _spotOffLight; }
|
||||
Index getSunOffLight() { return _sunOffLight; }
|
||||
|
||||
protected:
|
||||
|
||||
struct Desc {
|
||||
|
@ -199,6 +204,18 @@ protected:
|
|||
Descs _descs;
|
||||
LightMap _lightMap;
|
||||
|
||||
// define off lights
|
||||
|
||||
const LightPointer ambientOffLight { std::make_shared<model::Light>() };
|
||||
const LightPointer pointOffLight { std::make_shared<model::Light>() };
|
||||
const LightPointer spotOffLight { std::make_shared<model::Light>() };
|
||||
const LightPointer sunOffLight { std::make_shared<model::Light>() };
|
||||
|
||||
Index _ambientOffLight;
|
||||
Index _pointOffLight;
|
||||
Index _spotOffLight;
|
||||
Index _sunOffLight;
|
||||
|
||||
};
|
||||
using LightStagePointer = std::shared_ptr<LightStage>;
|
||||
|
||||
|
|
Loading…
Reference in a new issue