mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
Fixing the rendering of ProceduralSkybox
This commit is contained in:
parent
fa9b0930d2
commit
a485d3d6de
4 changed files with 20 additions and 13 deletions
|
@ -3507,7 +3507,7 @@ namespace render {
|
||||||
|
|
||||||
skybox = skyStage->getSkybox();
|
skybox = skyStage->getSkybox();
|
||||||
if (skybox) {
|
if (skybox) {
|
||||||
model::Skybox::render(batch, *(Application::getInstance()->getDisplayViewFrustum()), *skybox);
|
skybox->render(batch, *(Application::getInstance()->getDisplayViewFrustum()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,10 @@ public:
|
||||||
void setCubemap(const gpu::TexturePointer& cubemap);
|
void setCubemap(const gpu::TexturePointer& cubemap);
|
||||||
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
|
const gpu::TexturePointer& getCubemap() const { return _cubemap; }
|
||||||
|
|
||||||
|
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const {
|
||||||
|
render(batch, frustum, (*this));
|
||||||
|
}
|
||||||
|
|
||||||
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox);
|
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -36,11 +36,19 @@ void ProceduralSkybox::setProcedural(const ProceduralPointer& procedural) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
|
||||||
|
ProceduralSkybox::render(batch, frustum, (*this));
|
||||||
|
}
|
||||||
|
|
||||||
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox) {
|
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox) {
|
||||||
|
if (!(skybox._procedural)) {
|
||||||
|
Skybox::render(batch, viewFrustum, skybox);
|
||||||
|
}
|
||||||
|
|
||||||
static gpu::BufferPointer theBuffer;
|
static gpu::BufferPointer theBuffer;
|
||||||
static gpu::Stream::FormatPointer theFormat;
|
static gpu::Stream::FormatPointer theFormat;
|
||||||
|
|
||||||
if (skybox._procedural || skybox.getCubemap()) {
|
if (skybox._procedural && skybox._procedural->_enabled && skybox._procedural->ready()) {
|
||||||
if (!theBuffer) {
|
if (!theBuffer) {
|
||||||
const float CLIP = 1.0f;
|
const float CLIP = 1.0f;
|
||||||
const glm::vec2 vertices[4] = { { -CLIP, -CLIP }, { CLIP, -CLIP }, { -CLIP, CLIP }, { CLIP, CLIP } };
|
const glm::vec2 vertices[4] = { { -CLIP, -CLIP }, { CLIP, -CLIP }, { -CLIP, CLIP }, { CLIP, CLIP } };
|
||||||
|
@ -60,18 +68,12 @@ void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum,
|
||||||
batch.setInputBuffer(gpu::Stream::POSITION, theBuffer, 0, 8);
|
batch.setInputBuffer(gpu::Stream::POSITION, theBuffer, 0, 8);
|
||||||
batch.setInputFormat(theFormat);
|
batch.setInputFormat(theFormat);
|
||||||
|
|
||||||
if (skybox._procedural && skybox._procedural->_enabled && skybox._procedural->ready()) {
|
if (skybox.getCubemap() && skybox.getCubemap()->isDefined()) {
|
||||||
if (skybox.getCubemap() && skybox.getCubemap()->isDefined()) {
|
batch.setResourceTexture(0, skybox.getCubemap());
|
||||||
batch.setResourceTexture(0, skybox.getCubemap());
|
|
||||||
}
|
|
||||||
|
|
||||||
skybox._procedural->prepare(batch, glm::vec3(1));
|
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// skybox has no cubemap, just clear the color buffer
|
skybox._procedural->prepare(batch, glm::vec3(1));
|
||||||
auto color = skybox.getColor();
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(color, 0.0f), 0.0f, 0, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
|
|
||||||
void setProcedural(const ProceduralPointer& procedural);
|
void setProcedural(const ProceduralPointer& procedural);
|
||||||
|
|
||||||
|
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const;
|
||||||
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox);
|
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in a new issue