mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:29:32 +02:00
Merge pull request #6 from zzmp/refactor/skybox-tex-orange
Use keyLight in DLE instead of _skyboxTexture
This commit is contained in:
commit
f09f28096f
4 changed files with 14 additions and 18 deletions
|
@ -3818,7 +3818,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
// Setup the current Zone Entity lighting
|
// Setup the current Zone Entity lighting
|
||||||
{
|
{
|
||||||
auto stage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
auto stage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
||||||
DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(stage->getSunLight(), stage->getSkybox()->getCubemap());
|
DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(stage->getSunLight());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -273,6 +273,7 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
|
|
||||||
if (_hasPreviousZone) {
|
if (_hasPreviousZone) {
|
||||||
sceneKeyLight->resetAmbientSphere();
|
sceneKeyLight->resetAmbientSphere();
|
||||||
|
sceneKeyLight->setAmbientMap(nullptr);
|
||||||
sceneKeyLight->setColor(_previousKeyLightColor);
|
sceneKeyLight->setColor(_previousKeyLightColor);
|
||||||
sceneKeyLight->setIntensity(_previousKeyLightIntensity);
|
sceneKeyLight->setIntensity(_previousKeyLightIntensity);
|
||||||
sceneKeyLight->setAmbientIntensity(_previousKeyLightAmbientIntensity);
|
sceneKeyLight->setAmbientIntensity(_previousKeyLightAmbientIntensity);
|
||||||
|
@ -383,6 +384,7 @@ void EntityTreeRenderer::applyZonePropertiesToScene(std::shared_ptr<ZoneEntityIt
|
||||||
|
|
||||||
if (!isAmbientTextureSet) {
|
if (!isAmbientTextureSet) {
|
||||||
sceneKeyLight->resetAmbientSphere();
|
sceneKeyLight->resetAmbientSphere();
|
||||||
|
sceneKeyLight->setAmbientMap(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,12 +316,12 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
|
||||||
{
|
{
|
||||||
auto& program = _shadowMapEnabled ? _directionalLightShadow : _directionalLight;
|
auto& program = _shadowMapEnabled ? _directionalLightShadow : _directionalLight;
|
||||||
LightLocationsPtr locations = _shadowMapEnabled ? _directionalLightShadowLocations : _directionalLightLocations;
|
LightLocationsPtr locations = _shadowMapEnabled ? _directionalLightShadowLocations : _directionalLightLocations;
|
||||||
|
const auto& keyLight = _allocatedLights[_globalLights.front()];
|
||||||
|
|
||||||
// Setup the global directional pass pipeline
|
// Setup the global directional pass pipeline
|
||||||
{
|
{
|
||||||
if (_shadowMapEnabled) {
|
if (_shadowMapEnabled) {
|
||||||
//if (_skyboxTexture) {
|
if (keyLight->getAmbientMap()) {
|
||||||
if (_skyboxTexture) {
|
|
||||||
program = _directionalSkyboxLightShadow;
|
program = _directionalSkyboxLightShadow;
|
||||||
locations = _directionalSkyboxLightShadowLocations;
|
locations = _directionalSkyboxLightShadowLocations;
|
||||||
} else {
|
} else {
|
||||||
|
@ -329,7 +329,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
|
||||||
locations = _directionalAmbientSphereLightShadowLocations;
|
locations = _directionalAmbientSphereLightShadowLocations;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (_skyboxTexture) {
|
if (keyLight->getAmbientMap()) {
|
||||||
program = _directionalSkyboxLight;
|
program = _directionalSkyboxLight;
|
||||||
locations = _directionalSkyboxLightLocations;
|
locations = _directionalSkyboxLightLocations;
|
||||||
} else {
|
} else {
|
||||||
|
@ -357,7 +357,7 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
|
||||||
geometryCache->renderQuad(batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color);
|
geometryCache->renderQuad(batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_skyboxTexture) {
|
if (keyLight->getAmbientMap()) {
|
||||||
batch.setResourceTexture(SKYBOX_MAP_UNIT, nullptr);
|
batch.setResourceTexture(SKYBOX_MAP_UNIT, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,14 +496,14 @@ void DeferredLightingEffect::render(const render::RenderContextPointer& renderCo
|
||||||
|
|
||||||
void DeferredLightingEffect::setupKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int skyboxCubemapUnit) {
|
void DeferredLightingEffect::setupKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int skyboxCubemapUnit) {
|
||||||
PerformanceTimer perfTimer("DLE->setupBatch()");
|
PerformanceTimer perfTimer("DLE->setupBatch()");
|
||||||
auto globalLight = _allocatedLights[_globalLights.front()];
|
auto keyLight = _allocatedLights[_globalLights.front()];
|
||||||
|
|
||||||
if (lightBufferUnit >= 0) {
|
if (lightBufferUnit >= 0) {
|
||||||
batch.setUniformBuffer(lightBufferUnit, globalLight->getSchemaBuffer());
|
batch.setUniformBuffer(lightBufferUnit, keyLight->getSchemaBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalLight->getAmbientMap() && (skyboxCubemapUnit >= 0)) {
|
if (keyLight->getAmbientMap() && (skyboxCubemapUnit >= 0)) {
|
||||||
batch.setResourceTexture(skyboxCubemapUnit, globalLight->getAmbientMap());
|
batch.setResourceTexture(skyboxCubemapUnit, keyLight->getAmbientMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,18 +562,14 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture) {
|
void DeferredLightingEffect::setGlobalLight(const model::LightPointer& light) {
|
||||||
auto globalLight = _allocatedLights.front();
|
auto globalLight = _allocatedLights.front();
|
||||||
globalLight->setDirection(light->getDirection());
|
globalLight->setDirection(light->getDirection());
|
||||||
globalLight->setColor(light->getColor());
|
globalLight->setColor(light->getColor());
|
||||||
globalLight->setIntensity(light->getIntensity());
|
globalLight->setIntensity(light->getIntensity());
|
||||||
globalLight->setAmbientIntensity(light->getAmbientIntensity());
|
globalLight->setAmbientIntensity(light->getAmbientIntensity());
|
||||||
globalLight->setAmbientSphere(light->getAmbientSphere());
|
globalLight->setAmbientSphere(light->getAmbientSphere());
|
||||||
|
globalLight->setAmbientMap(light->getAmbientMap());
|
||||||
_skyboxTexture = (light->getAmbientMap() ? light->getAmbientMap() : _skyboxTexture);
|
|
||||||
|
|
||||||
// Update the available mipmap levels
|
|
||||||
globalLight->setAmbientMap(_skyboxTexture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
model::MeshPointer DeferredLightingEffect::getSpotLightMesh() {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
void setupKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int skyboxCubemapUnit);
|
void setupKeyLightBatch(gpu::Batch& batch, int lightBufferUnit, int skyboxCubemapUnit);
|
||||||
|
|
||||||
// update global lighting
|
// update global lighting
|
||||||
void setGlobalLight(const model::LightPointer& light, const gpu::TexturePointer& skyboxTexture);
|
void setGlobalLight(const model::LightPointer& light);
|
||||||
|
|
||||||
const LightStage& getLightStage() { return _lightStage; }
|
const LightStage& getLightStage() { return _lightStage; }
|
||||||
void setShadowMapEnabled(bool enable) { _shadowMapEnabled = enable; };
|
void setShadowMapEnabled(bool enable) { _shadowMapEnabled = enable; };
|
||||||
|
@ -96,8 +96,6 @@ private:
|
||||||
std::vector<int> _pointLights;
|
std::vector<int> _pointLights;
|
||||||
std::vector<int> _spotLights;
|
std::vector<int> _spotLights;
|
||||||
|
|
||||||
gpu::TexturePointer _skyboxTexture;
|
|
||||||
|
|
||||||
// Class describing the uniform buffer with all the parameters common to the deferred shaders
|
// Class describing the uniform buffer with all the parameters common to the deferred shaders
|
||||||
class DeferredTransform {
|
class DeferredTransform {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue