Skip to content

Conversation

@sp0lsh
Copy link
Contributor

@sp0lsh sp0lsh commented Sep 10, 2018

Depends on: #158

  • fix shadows in distance over 4000 units from origin
  • tight projection around camera frustum
  • light projection near and far planes bases on scene intersection
  • moving light projection matrices in texel-sized increments
  • fix shimmering
  • test ProjectExamples (SGJ18)
  • smooth PCF with linear interpolation
  • EVSM2 and EVSM4
  • pass sponza test
  • cleanup prototype
  • AABB unit tests
  • GetForwardVector() etc. moved from MovementSystem to EntityTransform
  • fixed frustum debug draw

polyengine_standalone_05_11_2018_06_55_29

References:
https://github.com/TheRealMJP/Shadows
https://github.com/bartwronski/CSharpRenderer
https://docs.microsoft.com/pl-pl/windows/desktop/DxTechArts/common-techniques-to-improve-shadow-depth-maps
https://gamedev.stackexchange.com/questions/73851/how-do-i-fit-the-camera-frustum-inside-directional-light-space

Michal Kłos added 3 commits September 9, 2018 01:14
@sp0lsh sp0lsh changed the title Rendering: Sshadows pt 2 WIP Rendering: Shadows pt 2 WIP Sep 11, 2018
@MuniuDev MuniuDev changed the title Rendering: Shadows pt 2 WIP [WIP] Rendering: Shadows pt 2 Sep 11, 2018
#include "Common/PrimitiveCube.hpp"
#include "Common/PrimitiveQuad.hpp"

#include "Debugging//DebugDrawSystem.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnessecary double forwardslash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sp0lsh sp0lsh changed the title [WIP] Rendering: Shadows pt 2 Rendering: Shadows pt 2 Nov 25, 2018
/// <see cref="AABox.Contains()"/>
inline bool Intersects(const AABox& rhs) const
{
return (abs(Min.X - rhs.Min.X) * 2.0f < (Size.X + rhs.Size.X))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is Vector::abs method (or at least should be), use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BasicMath.hpp has Poly::abs for float, double and long double overloads but no Vector.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I added this to trello.

vec2 depthScale = uEVSMBias * 0.01 * exponents * warpedDepth;
vec2 minVariance = depthScale * depthScale;

return ChebyshevUpperBound(moments.xy, warpedDepth.x, minVariance.x, uLightBleedingReduction);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check your indentation setting in the IDE. These files are all over the place.

outputEVSM[3] = vec4(warpedDepth[3], warpedDepth[3] * warpedDepth[3]);

vec4 finalOutput = outputEVSM[0] + outputEVSM[1] + outputEVSM[2] + outputEVSM[3];
finalOutput *= 0.25f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation inconsistency

#include <Proxy/GLShaderProgram.hpp>
#include <Common/PrimitiveCube.hpp>
#include <Common/PrimitiveQuad.hpp>
#include "GLRenderingDevice.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please conform to the new convention of using <> instead of quotes for the includes. This applies to the whole PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated all includes is GLRenderingDevice

//
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
//
// CHECK_FBO_STATUS();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

glViewport(0, 0, screenSize.Width, screenSize.Height);

for (int i = 9; i > 0; --i)
for (int i = 10; i > 0; --i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number alert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to constant

glBindVertexArray(0);

for (int i = 9; i > 0; --i)
for (int i = 10; i > 0; --i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to constant

// GLuint FBOShadowMapResolve1;
// GLShaderProgram ShadowMapShader;
// GLShaderProgram EVSMResolveShader;
// GLShaderProgram EVSMBlurShader;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@MuniuDev MuniuDev merged commit ee36b8b into PolyEngineTeam:dev Dec 16, 2018
MuniuDev pushed a commit to MuniuDev/PolyEngine that referenced this pull request Dec 28, 2018
* test case

* calculating light bounds in AABox around frustum in game example for debug

* added tight projection around camera frustum, light projection near and far planes based on scene intersection and moving light in texel-sized increments

* shadow bug dependent on camera direction

* imgui reacting to input and drawing on screen from render device

* proper init, render deinit and windows created by game

* comments

* comments

* commented #pragma failing travis ci

* removed #pragma

* removed  pragma from resource

* commented unused components

* commented out wrong variable doh...

* prototype of shadow casters culling

* moved code to rendering device, tested on example scene and on sponza, seems ok

* added AABox around every drawn mesh and still fails on sponza

* removed shadow casters AABox

* stable shadows working on sponza and test scene

* stable shadowmap

* interpolated Percentage Closer Filtering

* shadows prototype cleanup

* shadow ramblings

* merged with dev

* cmake attempt

* moved imgui to third parties, cmake updated for Engine, RenderingDevice and Game Project. Spams a lot

* removed sanity spam

* resource cleanup

* imguisystem cleanup

* imgui world component cleanup

* added non windows API attributes to imconfig.h

* moved imgui to pch

* silencing third party gcc -Wimplicit-fallthrough=

* enabled -fPIC (Position Independent Code) for imgui static lib to be included in shared libs

* fixing gcc includes

* fixing cgg includes

* made includes same as in GLTextureDeviceProxy

* removed commented out code

* ImguiUpdate is now in System, Imgui context creation moved to ImguiSystem constructor, removed Resource and WorldComponent

* moved Imgui to Engine subdirectory

* Added clipboard support, tweaked mouse handling and input that can be consumed by any system

* added UTF8 char input from keyboard keys

* fixing input consumption (works on all widowns: engine and game)

* added output queue and events handled by SDL

* CI fix

* CI fix and cleanup

* CI fix

* CI fix

* fix

* Moved getting axis vector from MovementSystem to EntityTransform

* shadowmap ortho projection has correct direction based on dir light forward vector

* shadowmap projection in [0, 1] range

* stable shadows on frustum transform and properties change

* shadows prototype with tight bound around frustum and ortho projection in [0, 1] on Z

* more changes

* tweaks to AABB intersection tests

* added tweakable shadow bias and glPolygonOffset

* working evsm2 and evsm4

* shadow projection working with shadow bounds extended by vertical shadow casters

* some EVSM4 shadows that work

* created pass with shadowmap

* switched renderer to use Shadommap pass

* parametrizing shadow types

* EVSM2 seems to work as well

* removed debug light parameters, shadowmap pass has pcf and evsm versions

* removed debug variables from light and camera components

* CI fix

* CI fix

* CI fix

* CI fix

* CI Fix

* debug rendering cleanup

* cleanup and comments

* cleanup

* compilation fix

* cleanup

* cleanup

* ignore shader dump extension

* fix

* Added comment for .dump file extention

* cleanup

* AABB unit tests

* CI fix, tabbed documents

* CI fix, tabbed documents

* review fix, tabbed code

* assert and nullptr fix

* None RenderingSettingsComponent fix

* review fix

* review fix, updated includes

* review fix, removed commented code

* magic variable moved to constant

* CI fix

* CI fix
MuniuDev pushed a commit to MuniuDev/PolyEngine that referenced this pull request Jan 2, 2019
* test case

* calculating light bounds in AABox around frustum in game example for debug

* added tight projection around camera frustum, light projection near and far planes based on scene intersection and moving light in texel-sized increments

* shadow bug dependent on camera direction

* imgui reacting to input and drawing on screen from render device

* proper init, render deinit and windows created by game

* comments

* comments

* commented #pragma failing travis ci

* removed #pragma

* removed  pragma from resource

* commented unused components

* commented out wrong variable doh...

* prototype of shadow casters culling

* moved code to rendering device, tested on example scene and on sponza, seems ok

* added AABox around every drawn mesh and still fails on sponza

* removed shadow casters AABox

* stable shadows working on sponza and test scene

* stable shadowmap

* interpolated Percentage Closer Filtering

* shadows prototype cleanup

* shadow ramblings

* merged with dev

* cmake attempt

* moved imgui to third parties, cmake updated for Engine, RenderingDevice and Game Project. Spams a lot

* removed sanity spam

* resource cleanup

* imguisystem cleanup

* imgui world component cleanup

* added non windows API attributes to imconfig.h

* moved imgui to pch

* silencing third party gcc -Wimplicit-fallthrough=

* enabled -fPIC (Position Independent Code) for imgui static lib to be included in shared libs

* fixing gcc includes

* fixing cgg includes

* made includes same as in GLTextureDeviceProxy

* removed commented out code

* ImguiUpdate is now in System, Imgui context creation moved to ImguiSystem constructor, removed Resource and WorldComponent

* moved Imgui to Engine subdirectory

* Added clipboard support, tweaked mouse handling and input that can be consumed by any system

* added UTF8 char input from keyboard keys

* fixing input consumption (works on all widowns: engine and game)

* added output queue and events handled by SDL

* CI fix

* CI fix and cleanup

* CI fix

* CI fix

* fix

* Moved getting axis vector from MovementSystem to EntityTransform

* shadowmap ortho projection has correct direction based on dir light forward vector

* shadowmap projection in [0, 1] range

* stable shadows on frustum transform and properties change

* shadows prototype with tight bound around frustum and ortho projection in [0, 1] on Z

* more changes

* tweaks to AABB intersection tests

* added tweakable shadow bias and glPolygonOffset

* working evsm2 and evsm4

* shadow projection working with shadow bounds extended by vertical shadow casters

* some EVSM4 shadows that work

* created pass with shadowmap

* switched renderer to use Shadommap pass

* parametrizing shadow types

* EVSM2 seems to work as well

* removed debug light parameters, shadowmap pass has pcf and evsm versions

* removed debug variables from light and camera components

* CI fix

* CI fix

* CI fix

* CI fix

* CI Fix

* debug rendering cleanup

* cleanup and comments

* cleanup

* compilation fix

* cleanup

* cleanup

* ignore shader dump extension

* fix

* Added comment for .dump file extention

* cleanup

* AABB unit tests

* CI fix, tabbed documents

* CI fix, tabbed documents

* review fix, tabbed code

* assert and nullptr fix

* None RenderingSettingsComponent fix

* review fix

* review fix, updated includes

* review fix, removed commented code

* magic variable moved to constant

* CI fix

* CI fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants