-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gloom: Added LightRender and create a depth-only FBO
- Loading branch information
Showing
9 changed files
with
218 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** @file light.cpp | ||
* | ||
* @authors Copyright (c) 2018 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* LGPL: http://www.gnu.org/licenses/lgpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
* General Public License for more details. You should have received a copy of | ||
* the GNU Lesser General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "gloom/render/light.h" | ||
|
||
#include <de/GLFramebuffer> | ||
|
||
using namespace de; | ||
|
||
namespace gloom { | ||
|
||
DENG2_PIMPL(Light) | ||
{ | ||
Vec3d origin; | ||
Vec3f dir; | ||
Vec3f intensity; | ||
GLTexture shadowMap; | ||
GLFramebuffer framebuf; | ||
|
||
Impl(Public *i) : Base(i) | ||
{ | ||
shadowMap.setAutoGenMips(false); | ||
shadowMap.setFilter(gl::Linear, gl::Linear, gl::MipNone); | ||
shadowMap.setUndefinedContent( | ||
GLTexture::Size(1024, 1024), | ||
GLPixelFormat(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT)); | ||
|
||
framebuf.configure(GLFramebuffer::Depth, shadowMap); | ||
} | ||
}; | ||
|
||
Light::Light() | ||
: d(new Impl(this)) | ||
{} | ||
|
||
Mat4f Light::lightMatrix() const | ||
{ | ||
return Mat4f::ortho(-10, 10, -10, 10, 1, 10) * | ||
Mat4f::lookAt(d->origin + d->dir, d->origin, Vec3f(0, 1, 0)); | ||
} | ||
|
||
} // namespace gloom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** @file lightrender.cpp | ||
* | ||
* @authors Copyright (c) 2018 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* LGPL: http://www.gnu.org/licenses/lgpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
* General Public License for more details. You should have received a copy of | ||
* the GNU Lesser General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "gloom/render/lightrender.h" | ||
#include "gloom/render/light.h" | ||
|
||
namespace gloom { | ||
|
||
DENG2_PIMPL(LightRender) | ||
{ | ||
std::unique_ptr<Light> skyLight; | ||
QHash<ID, std::shared_ptr<Light>> lights; | ||
|
||
Impl(Public *i) : Base(i) | ||
{} | ||
|
||
void glInit() | ||
{ | ||
skyLight.reset(new Light); | ||
} | ||
|
||
void glDeinit() | ||
{ | ||
skyLight.reset(); | ||
} | ||
}; | ||
|
||
LightRender::LightRender() | ||
: d(new Impl(this)) | ||
{} | ||
|
||
void LightRender::glInit(const Context &context) | ||
{ | ||
Render::glInit(context); | ||
d->glInit(); | ||
} | ||
|
||
void LightRender::glDeinit() | ||
{ | ||
d->glDeinit(); | ||
Render::glDeinit(); | ||
} | ||
|
||
void LightRender::render() | ||
{ | ||
|
||
} | ||
|
||
void LightRender::createLights() | ||
{ | ||
|
||
} | ||
|
||
} // namespace gloom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** @file lightrender.h | ||
* | ||
* @authors Copyright (c) 2018 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* LGPL: http://www.gnu.org/licenses/lgpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | ||
* General Public License for more details. You should have received a copy of | ||
* the GNU Lesser General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef GLOOM_LIGHTRENDER_H | ||
#define GLOOM_LIGHTRENDER_H | ||
|
||
#include "gloom/render/render.h" | ||
|
||
namespace gloom { | ||
|
||
/** | ||
* Renders light source shadow maps and the deferred shading pass. | ||
*/ | ||
class LightRender : public Render | ||
{ | ||
public: | ||
LightRender(); | ||
|
||
void glInit(const Context &) override; | ||
void glDeinit() override; | ||
void render() override; | ||
|
||
void createLights(); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
} // namespace gloom | ||
|
||
#endif // GLOOM_LIGHTRENDER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters