-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added shadow mapping for directional lights (#315)
- Shadow casting and receiving is enabled on the `Default.ovmat` material by default. - When a new material is created, these 2 settings are OFF by default. - Directional lights (components) have a "Shadow casting" option that is OFF by default. - Includes 2 implementations for shadows: hard-shadows, and soft-shadows/PCF (default). - Introduces a `TextureHandle` class, which wraps an OpenGL texture ID, and can be passed as a uniform. This `TextureHandle` class is used by the framebuffer to expose its rendered image. - `Texture` now inherits from `TextureHandle`. - `ShadowRenderPass` added: handles the rendering of shadow casters in the shadow map - `ShadowRenderFeature` added: ensures that the shadow map is properly bound to each entity set to receive shadows. - Shadow area size is exposed through the `CDirectionaLight` component. Changing this setting will change the radius of the shadow (bigger radius = less precision) - Shadow area size is exposed through the `CDirectionaLight` component. - Shadow follow camera is a setting exposed through the `CDirectionaLight` component allowing the directional light to use the position of the camera as a source for its light space matrix (for shadow map rendering), making shadows "follow" the camera around, instead of being static. - Added a `singleUse` parameter to `Material::Set`, for properties that shouldn't be stored after drawing (i.e. shadow maps texture handles)
- Loading branch information
1 parent
7408317
commit c4262a1
Showing
43 changed files
with
934 additions
and
130 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
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,20 @@ | ||
#shader vertex | ||
#version 430 core | ||
|
||
layout (location = 0) in vec3 geo_Pos; | ||
|
||
uniform mat4 _LightSpaceMatrix; | ||
uniform mat4 _ModelMatrix; | ||
|
||
void main() | ||
{ | ||
gl_Position = _LightSpaceMatrix * _ModelMatrix * vec4(geo_Pos, 1.0); | ||
} | ||
|
||
#shader fragment | ||
#version 430 core | ||
|
||
void main() | ||
{ | ||
gl_FragDepth = gl_FragCoord.z; | ||
} |
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
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
38 changes: 38 additions & 0 deletions
38
Sources/Overload/OvCore/include/OvCore/Rendering/ShadowRenderFeature.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @project: Overload | ||
* @author: Overload Tech. | ||
* @licence: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <OvRendering/Entities/Camera.h> | ||
#include <OvRendering/Features/DebugShapeRenderFeature.h> | ||
|
||
#include <OvCore/ECS/Actor.h> | ||
#include <OvCore/SceneSystem/SceneManager.h> | ||
#include <OvCore/ECS/Components/CModelRenderer.h> | ||
#include <OvCore/Resources/Material.h> | ||
#include <OvCore/ECS/Components/CAmbientBoxLight.h> | ||
#include <OvCore/ECS/Components/CAmbientSphereLight.h> | ||
#include <OvCore/Rendering/SceneRenderer.h> | ||
|
||
namespace OvCore::Rendering | ||
{ | ||
/** | ||
* Draw the scene for actor picking | ||
*/ | ||
class ShadowRenderFeature : public OvRendering::Features::ARenderFeature | ||
{ | ||
public: | ||
/** | ||
* Constructor | ||
* @param p_renderer | ||
*/ | ||
ShadowRenderFeature(OvRendering::Core::CompositeRenderer& p_renderer); | ||
|
||
protected: | ||
virtual void OnBeforeDraw(OvRendering::Data::PipelineState& p_pso, const OvRendering::Entities::Drawable& p_drawable); | ||
virtual void OnAfterDraw(OvRendering::Data::PipelineState& p_pso, const OvRendering::Entities::Drawable& p_drawable); | ||
}; | ||
} |
Oops, something went wrong.