mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
CLeaning up the code for the RenderableLightEntityItem
This commit is contained in:
parent
92a9037b07
commit
0c45627d94
7 changed files with 198 additions and 183 deletions
|
@ -11,9 +11,7 @@
|
||||||
|
|
||||||
#include <glm/gtx/quaternion.hpp>
|
#include <glm/gtx/quaternion.hpp>
|
||||||
|
|
||||||
#include <gpu/Batch.h>
|
|
||||||
|
|
||||||
#include <DeferredLightingEffect.h>
|
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
|
|
||||||
|
@ -29,16 +27,68 @@ RenderableLightEntityItem::RenderableLightEntityItem(const EntityItemID& entityI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableLightEntityItem::updateLightFromEntity(render::PendingChanges& pendingChanges) {
|
bool RenderableLightEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) {
|
||||||
|
_myItem = scene->allocateID();
|
||||||
|
|
||||||
|
auto renderItem = std::make_shared<LightPayload>();
|
||||||
|
updateRenderItemFromEntity(renderItem.get());
|
||||||
|
|
||||||
|
auto renderPayload = std::make_shared<LightPayload::Payload>(renderItem);
|
||||||
|
|
||||||
|
render::Item::Status::Getters statusGetters;
|
||||||
|
makeEntityItemStatusGetters(self, statusGetters);
|
||||||
|
renderPayload->addStatusGetters(statusGetters);
|
||||||
|
|
||||||
|
pendingChanges.resetItem(_myItem, renderPayload);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableLightEntityItem::somethingChangedNotification() {
|
||||||
|
if (_lightPropertiesChanged) {
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
LightEntityItem::somethingChangedNotification();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableLightEntityItem::removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) {
|
||||||
|
pendingChanges.removeItem(_myItem);
|
||||||
|
render::Item::clearID(_myItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableLightEntityItem::locationChanged(bool tellPhysics) {
|
||||||
|
EntityItem::locationChanged(tellPhysics);
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableLightEntityItem::dimensionsChanged() {
|
||||||
|
EntityItem::dimensionsChanged();
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableLightEntityItem::checkFading() {
|
||||||
|
bool transparent = isTransparent();
|
||||||
|
if (transparent != _prevIsTransparent) {
|
||||||
|
notifyChanged();
|
||||||
|
_isFading = false;
|
||||||
|
_prevIsTransparent = transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderableLightEntityItem::notifyChanged() {
|
||||||
|
|
||||||
if (!render::Item::isValidID(_myItem)) {
|
if (!render::Item::isValidID(_myItem)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render::PendingChanges pendingChanges;
|
||||||
|
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||||
|
|
||||||
pendingChanges.updateItem<LightRenderItem>(_myItem, [this](LightRenderItem& data) {
|
updateLightFromEntity(pendingChanges);
|
||||||
data.updateLightFromEntity(this);
|
|
||||||
});
|
scene->enqueuePendingChanges(pendingChanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void RenderableLightEntityItem::render(RenderArgs* args) {
|
void RenderableLightEntityItem::render(RenderArgs* args) {
|
||||||
PerformanceTimer perfTimer("RenderableLightEntityItem::render");
|
PerformanceTimer perfTimer("RenderableLightEntityItem::render");
|
||||||
|
@ -72,75 +122,54 @@ bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& ori
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RenderableLightEntityItem::updateLightFromEntity(render::PendingChanges& pendingChanges) {
|
||||||
namespace render {
|
if (!render::Item::isValidID(_myItem)) {
|
||||||
template <> const ItemKey payloadGetKey(const LightRenderItem::Pointer& payload) {
|
return;
|
||||||
return ItemKey::Builder::light();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <> const Item::Bound payloadGetBound(const LightRenderItem::Pointer& payload) {
|
|
||||||
if (payload) {
|
pendingChanges.updateItem<LightPayload>(_myItem, [this](LightPayload& data) {
|
||||||
return payload->_bound;
|
this->updateRenderItemFromEntity(&data);
|
||||||
}
|
});
|
||||||
return render::Item::Bound();
|
|
||||||
}
|
|
||||||
template <> void payloadRender(const LightRenderItem::Pointer& payload, RenderArgs* args) {
|
|
||||||
if (args) {
|
|
||||||
if (payload) {
|
|
||||||
payload->render(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LightRenderItem::LightRenderItem() :
|
void RenderableLightEntityItem::updateRenderItemFromEntity(LightPayload* lightPayload) {
|
||||||
_light(std::make_shared<model::Light>())
|
auto entity = this;
|
||||||
{
|
auto light = lightPayload->editLight();
|
||||||
}
|
light->setPosition(entity->getPosition());
|
||||||
|
light->setOrientation(entity->getRotation());
|
||||||
void LightRenderItem::updateLightFromEntity(RenderableLightEntityItem* entity) {
|
|
||||||
_light->setPosition(entity->getPosition());
|
|
||||||
_light->setOrientation(entity->getRotation());
|
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
_bound = entity->getAABox(success);
|
lightPayload->editBound() = entity->getAABox(success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
_bound = render::Item::Bound();
|
lightPayload->editBound() = render::Item::Bound();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 dimensions = entity->getDimensions();
|
glm::vec3 dimensions = entity->getDimensions();
|
||||||
float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z);
|
float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z);
|
||||||
_light->setMaximumRadius(largestDiameter / 2.0f);
|
light->setMaximumRadius(largestDiameter / 2.0f);
|
||||||
|
|
||||||
_light->setColor(toGlm(entity->getXColor()));
|
light->setColor(toGlm(entity->getXColor()));
|
||||||
|
|
||||||
float intensity = entity->getIntensity();//* entity->getFadingRatio();
|
float intensity = entity->getIntensity();//* entity->getFadingRatio();
|
||||||
_light->setIntensity(intensity);
|
light->setIntensity(intensity);
|
||||||
|
|
||||||
_light->setFalloffRadius(entity->getFalloffRadius());
|
light->setFalloffRadius(entity->getFalloffRadius());
|
||||||
|
|
||||||
|
|
||||||
float exponent = entity->getExponent();
|
float exponent = entity->getExponent();
|
||||||
float cutoff = glm::radians(entity->getCutoff());
|
float cutoff = glm::radians(entity->getCutoff());
|
||||||
if (!entity->getIsSpotlight()) {
|
if (!entity->getIsSpotlight()) {
|
||||||
_light->setType(model::Light::POINT);
|
light->setType(model::Light::POINT);
|
||||||
} else {
|
} else {
|
||||||
_light->setType(model::Light::SPOT);
|
light->setType(model::Light::SPOT);
|
||||||
|
|
||||||
_light->setSpotAngle(cutoff);
|
light->setSpotAngle(cutoff);
|
||||||
_light->setSpotExponent(exponent);
|
light->setSpotExponent(exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LightRenderItem::render(RenderArgs* args) {
|
|
||||||
|
|
||||||
//updateLightFromEntity();
|
|
||||||
|
|
||||||
DependencyManager::get<DeferredLightingEffect>()->addLight(_light);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,32 +13,9 @@
|
||||||
#define hifi_RenderableLightEntityItem_h
|
#define hifi_RenderableLightEntityItem_h
|
||||||
|
|
||||||
#include <LightEntityItem.h>
|
#include <LightEntityItem.h>
|
||||||
#include <model/Light.h>
|
#include <LightPayload.h>
|
||||||
#include "RenderableEntityItem.h"
|
#include "RenderableEntityItem.h"
|
||||||
|
|
||||||
class RenderableLightEntityItem;
|
|
||||||
|
|
||||||
class LightRenderItem {
|
|
||||||
public:
|
|
||||||
using Payload = render::Payload<LightRenderItem>;
|
|
||||||
using Pointer = Payload::DataPointer;
|
|
||||||
|
|
||||||
model::LightPointer _light;
|
|
||||||
|
|
||||||
render::Item::Bound _bound;
|
|
||||||
|
|
||||||
LightRenderItem();
|
|
||||||
void render(RenderArgs* args);
|
|
||||||
|
|
||||||
void updateLightFromEntity(RenderableLightEntityItem* entity);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace render {
|
|
||||||
template <> const ItemKey payloadGetKey(const LightRenderItem::Pointer& payload);
|
|
||||||
template <> const Item::Bound payloadGetBound(const LightRenderItem::Pointer& payload);
|
|
||||||
template <> void payloadRender(const LightRenderItem::Pointer& payload, RenderArgs* args);
|
|
||||||
}
|
|
||||||
|
|
||||||
class RenderableLightEntityItem : public LightEntityItem {
|
class RenderableLightEntityItem : public LightEntityItem {
|
||||||
public:
|
public:
|
||||||
|
@ -53,67 +30,18 @@ public:
|
||||||
|
|
||||||
void updateLightFromEntity(render::PendingChanges& pendingChanges);
|
void updateLightFromEntity(render::PendingChanges& pendingChanges);
|
||||||
|
|
||||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override {
|
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override;
|
||||||
_myItem = scene->allocateID();
|
|
||||||
|
|
||||||
auto renderItem = std::make_shared<LightRenderItem>();
|
virtual void somethingChangedNotification() override;
|
||||||
renderItem->updateLightFromEntity(this);
|
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override;
|
||||||
|
|
||||||
auto renderPayload = std::make_shared<LightRenderItem::Payload>(renderItem);
|
virtual void locationChanged(bool tellPhysics = true) override;
|
||||||
|
|
||||||
render::Item::Status::Getters statusGetters;
|
virtual void dimensionsChanged() override;
|
||||||
makeEntityItemStatusGetters(self, statusGetters);
|
|
||||||
renderPayload->addStatusGetters(statusGetters);
|
|
||||||
|
|
||||||
pendingChanges.resetItem(_myItem, renderPayload);
|
void checkFading();
|
||||||
|
|
||||||
return true;
|
void notifyChanged();
|
||||||
}
|
|
||||||
|
|
||||||
virtual void somethingChangedNotification() override {
|
|
||||||
if (_lightPropertiesChanged) {
|
|
||||||
notifyChanged();
|
|
||||||
}
|
|
||||||
LightEntityItem::somethingChangedNotification();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override {
|
|
||||||
pendingChanges.removeItem(_myItem);
|
|
||||||
render::Item::clearID(_myItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void locationChanged(bool tellPhysics = true) override {
|
|
||||||
EntityItem::locationChanged(tellPhysics);
|
|
||||||
notifyChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void dimensionsChanged() override {
|
|
||||||
EntityItem::dimensionsChanged();
|
|
||||||
notifyChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void checkFading() {
|
|
||||||
bool transparent = isTransparent();
|
|
||||||
if (transparent != _prevIsTransparent) {
|
|
||||||
notifyChanged();
|
|
||||||
_isFading = false;
|
|
||||||
_prevIsTransparent = transparent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void notifyChanged() {
|
|
||||||
|
|
||||||
if (!render::Item::isValidID(_myItem)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
render::PendingChanges pendingChanges;
|
|
||||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
|
||||||
|
|
||||||
updateLightFromEntity(pendingChanges);
|
|
||||||
|
|
||||||
scene->enqueuePendingChanges(pendingChanges);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _prevIsTransparent { isTransparent() };
|
bool _prevIsTransparent { isTransparent() };
|
||||||
|
@ -121,6 +49,8 @@ private:
|
||||||
|
|
||||||
// Dirty flag turn true when either setSubClassProperties or readEntitySubclassDataFromBuffer is changing a value
|
// Dirty flag turn true when either setSubClassProperties or readEntitySubclassDataFromBuffer is changing a value
|
||||||
|
|
||||||
|
void updateRenderItemFromEntity(LightPayload* lightPayload);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -425,7 +425,6 @@ void PrepareDeferred::run(const SceneContextPointer& sceneContext, const RenderC
|
||||||
outputs.edit0() = _deferredFramebuffer;
|
outputs.edit0() = _deferredFramebuffer;
|
||||||
outputs.edit1() = _deferredFramebuffer->getLightingFramebuffer();
|
outputs.edit1() = _deferredFramebuffer->getLightingFramebuffer();
|
||||||
|
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
|
@ -457,7 +456,8 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c
|
||||||
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) {
|
const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) {
|
||||||
|
|
||||||
auto args = renderContext->args;
|
auto args = renderContext->args;
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
auto& batch = (*args->_batch);
|
||||||
|
// gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
|
|
||||||
// Framebuffer copy operations cannot function as multipass stereo operations.
|
// Framebuffer copy operations cannot function as multipass stereo operations.
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
@ -567,7 +567,7 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c
|
||||||
batch.setResourceTexture(SKYBOX_MAP_UNIT, nullptr);
|
batch.setResourceTexture(SKYBOX_MAP_UNIT, nullptr);
|
||||||
}
|
}
|
||||||
batch.setResourceTexture(SHADOW_MAP_UNIT, nullptr);
|
batch.setResourceTexture(SHADOW_MAP_UNIT, nullptr);
|
||||||
});
|
// });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,9 +589,10 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto args = renderContext->args;
|
auto args = renderContext->args;
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
auto& batch = (*args->_batch);
|
||||||
|
// gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
// Framebuffer copy operations cannot function as multipass stereo operations.
|
// Framebuffer copy operations cannot function as multipass stereo operations.
|
||||||
batch.enableStereo(false);
|
/// batch.enableStereo(false);
|
||||||
|
|
||||||
// THe main viewport is assumed to be the mono viewport (or the 2 stereo faces side by side within that viewport)
|
// THe main viewport is assumed to be the mono viewport (or the 2 stereo faces side by side within that viewport)
|
||||||
auto viewport = args->_viewport;
|
auto viewport = args->_viewport;
|
||||||
|
@ -730,12 +731,13 @@ void RenderDeferredLocals::run(const render::SceneContextPointer& sceneContext,
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderDeferredCleanup::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
|
void RenderDeferredCleanup::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
|
||||||
auto args = renderContext->args;
|
auto args = renderContext->args;
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
auto& batch = (*args->_batch);
|
||||||
|
// gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
// Probably not necessary in the long run because the gpu layer would unbound this texture if used as render target
|
// Probably not necessary in the long run because the gpu layer would unbound this texture if used as render target
|
||||||
batch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr);
|
batch.setResourceTexture(DEFERRED_BUFFER_COLOR_UNIT, nullptr);
|
||||||
batch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr);
|
batch.setResourceTexture(DEFERRED_BUFFER_NORMAL_UNIT, nullptr);
|
||||||
|
@ -752,7 +754,7 @@ void RenderDeferredCleanup::run(const render::SceneContextPointer& sceneContext,
|
||||||
batch.setUniformBuffer(SCATTERING_PARAMETERS_BUFFER_SLOT, nullptr);
|
batch.setUniformBuffer(SCATTERING_PARAMETERS_BUFFER_SLOT, nullptr);
|
||||||
// batch.setUniformBuffer(LIGHTING_MODEL_BUFFER_SLOT, nullptr);
|
// batch.setUniformBuffer(LIGHTING_MODEL_BUFFER_SLOT, nullptr);
|
||||||
batch.setUniformBuffer(DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT, nullptr);
|
batch.setUniformBuffer(DEFERRED_FRAME_TRANSFORM_BUFFER_SLOT, nullptr);
|
||||||
});
|
// });
|
||||||
|
|
||||||
auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
|
auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
|
||||||
|
|
||||||
|
@ -788,9 +790,14 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
|
||||||
_gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__);
|
_gpuTimer = std::make_shared < gpu::RangeTimer>(__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
auto previousBatch = args->_batch;
|
||||||
|
gpu::Batch batch;
|
||||||
|
// f(batch);
|
||||||
|
args->_batch = &batch;
|
||||||
|
|
||||||
|
// gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
_gpuTimer->begin(batch);
|
_gpuTimer->begin(batch);
|
||||||
});
|
// });
|
||||||
|
|
||||||
setupJob.run(sceneContext, renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, ssaoFramebuffer, subsurfaceScatteringResource);
|
setupJob.run(sceneContext, renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, ssaoFramebuffer, subsurfaceScatteringResource);
|
||||||
|
|
||||||
|
@ -798,9 +805,13 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
|
||||||
|
|
||||||
cleanupJob.run(sceneContext, renderContext);
|
cleanupJob.run(sceneContext, renderContext);
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
// gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
_gpuTimer->end(batch);
|
_gpuTimer->end(batch);
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
args->_context->appendFrameBatch(batch);
|
||||||
|
args->_batch = previousBatch;
|
||||||
|
|
||||||
|
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||||
config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage());
|
config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage());
|
||||||
|
|
45
libraries/render-utils/src/LightPayload.cpp
Normal file
45
libraries/render-utils/src/LightPayload.cpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
//
|
||||||
|
// LightPayload.cpp
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 9/6/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
#include "LightPayload.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <gpu/Batch.h>
|
||||||
|
#include "DeferredLightingEffect.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace render {
|
||||||
|
template <> const ItemKey payloadGetKey(const LightPayload::Pointer& payload) {
|
||||||
|
return ItemKey::Builder::light();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> const Item::Bound payloadGetBound(const LightPayload::Pointer& payload) {
|
||||||
|
if (payload) {
|
||||||
|
return payload->editBound();
|
||||||
|
}
|
||||||
|
return render::Item::Bound();
|
||||||
|
}
|
||||||
|
template <> void payloadRender(const LightPayload::Pointer& payload, RenderArgs* args) {
|
||||||
|
if (args) {
|
||||||
|
if (payload) {
|
||||||
|
payload->render(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LightPayload::LightPayload() :
|
||||||
|
_light(std::make_shared<model::Light>())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightPayload::render(RenderArgs* args) {
|
||||||
|
|
||||||
|
DependencyManager::get<DeferredLightingEffect>()->addLight(_light);
|
||||||
|
}
|
41
libraries/render-utils/src/LightPayload.h
Normal file
41
libraries/render-utils/src/LightPayload.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// LightPayload.h
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 9/6/16.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_LightPayload_h
|
||||||
|
#define hifi_LightPayload_h
|
||||||
|
|
||||||
|
|
||||||
|
#include <model/Light.h>
|
||||||
|
#include <render/Item.h>
|
||||||
|
|
||||||
|
|
||||||
|
class LightPayload {
|
||||||
|
public:
|
||||||
|
using Payload = render::Payload<LightPayload>;
|
||||||
|
using Pointer = Payload::DataPointer;
|
||||||
|
|
||||||
|
LightPayload();
|
||||||
|
void render(RenderArgs* args);
|
||||||
|
|
||||||
|
model::LightPointer editLight() { return _light; }
|
||||||
|
render::Item::Bound& editBound() { return _bound; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
model::LightPointer _light;
|
||||||
|
render::Item::Bound _bound;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace render {
|
||||||
|
template <> const ItemKey payloadGetKey(const LightPayload::Pointer& payload);
|
||||||
|
template <> const Item::Bound payloadGetBound(const LightPayload::Pointer& payload);
|
||||||
|
template <> void payloadRender(const LightPayload::Pointer& payload, RenderArgs* args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -47,7 +47,7 @@ void main(void) {
|
||||||
texCoord += texcoordFrameTransform.xy;*/
|
texCoord += texcoordFrameTransform.xy;*/
|
||||||
|
|
||||||
vec4 fragPosition = unpackDeferredPositionFromZeye(texCoord);
|
vec4 fragPosition = unpackDeferredPositionFromZeye(texCoord);
|
||||||
DeferredFragment frag = unpackDeferredFragmentNoPositionNoAmbient(texCoord);
|
DeferredFragment frag = unpackDeferredFragmentNoPosition(texCoord);
|
||||||
|
|
||||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||||
discard;
|
discard;
|
||||||
|
|
|
@ -109,47 +109,6 @@ Item {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotPerf {
|
|
||||||
title: "Batch Timing"
|
|
||||||
height: parent.evalEvenHeight()
|
|
||||||
object: parent.drawOpaqueConfig
|
|
||||||
valueUnit: "ms"
|
|
||||||
valueScale: 1
|
|
||||||
valueNumDigits: "4"
|
|
||||||
plots: [
|
|
||||||
{
|
|
||||||
object: Render.getConfig("OpaqueRangeTimer"),
|
|
||||||
prop: "gpuBatchTime",
|
|
||||||
label: "Opaque",
|
|
||||||
color: "#FFFFFF"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
object: Render.getConfig("LinearDepth"),
|
|
||||||
prop: "gpuBatchTime",
|
|
||||||
label: "LinearDepth",
|
|
||||||
color: "#00FF00"
|
|
||||||
},{
|
|
||||||
object: Render.getConfig("SurfaceGeometry"),
|
|
||||||
prop: "gpuBatchTime",
|
|
||||||
label: "SurfaceGeometry",
|
|
||||||
color: "#00FFFF"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
object: Render.getConfig("RenderDeferred"),
|
|
||||||
prop: "gpuBatchTime",
|
|
||||||
label: "DeferredLighting",
|
|
||||||
color: "#FF00FF"
|
|
||||||
}
|
|
||||||
,
|
|
||||||
{
|
|
||||||
object: Render.getConfig("ToneAndPostRangeTimer"),
|
|
||||||
prop: "gpuBatchTime",
|
|
||||||
label: "tone and post",
|
|
||||||
color: "#FF0000"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue