Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #2975

Merged
merged 4 commits into from
Nov 24, 2023
Merged

Devel #2975

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# and provide build configuration options.
######################################################################

cmake_minimum_required(VERSION 3.10.0)
cmake_minimum_required(VERSION 3.13.0)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
2 changes: 1 addition & 1 deletion Docs/CodingStandards.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This document describes the coding standards all developers are expected to adhe
<li>Use abstract classes or templates not `void*`</li>
<li>Use overloaded methods not varargs.</li>
</ul></li>
<li>Minimum C++ compiler level is MSVC 12 (VS2013) or gcc 4.8. Compilers which do not support C++11 properly are not supported.</li>
<li>Minimum C++ compiler level is MSVC 14 (VS2015) or gcc 5. Compilers which do not support C++14 properly are not supported.</li>
<li>Use the <a href="https://en.cppreference.com/w/cpp/language/pimpl">PImpl idiom</a> to reduce dependencies between classes.</li>
<li>Always use <a href="https://isocpp.org/wiki/faq/const-correctness">const-correctness</a>. Methods taking non-primitive types as parameters should generally take them as const references, methods returning non-primitive types should generally return them as const references. Declare all methods that do not modify internal state `const`. For lazy-update getter methods, declare the internal state which is lazy-updated `mutable`.</li>
<li>Prefer `private` over `protected` to encourage encapsulation. Use public interfaces internally too.</li>
Expand Down
63 changes: 30 additions & 33 deletions Docs/src/ogre-shadows.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ question). Parts of the scene visible only to the camera must be
shadowed. We do not care about parts of the scene seen only by the
light.

Please note that this tutorial is more explicit and in depth than required
@note This tutorial is more explicit and in depth than required
to merely render shadows in OGRE as to teach you the theory behind the
rendering shadows as well.

In practice, the snapshot from the viewpoint of the light is stored as a
floating point depth buffer. It is important to use a format that
supports enough precision to avoid shadow acne (z-fighting) on lit
surfaces. In Ogre, we can specify the depth format to use; in the
example code, we will choose the 32-bit format.
example code, we will choose the 16-bit format.

Once shadow determination has occurred (whether a fragment is in shadow
or not), Ogre provides two different ways to render the shadows into the
Expand Down Expand Up @@ -335,18 +335,19 @@ See  @cite Chong06 for a unified notion of aliasing.

Ogre provides a powerful framework that allows us to do a lot of shadow
map customization. In Ogre, we turn on custom shadow mapping through the
scene manager (here, sceneMgr). It is recommended that this happen early
scene manager. It is recommended that this happen early
as it may affect how certain resources are loaded.

```cpp
// Use Ogre's custom shadow mapping ability
MaterialManager *materialMgr = Ogre::MaterialManager::getSingletonPtr();
sceneMgr->setShadowTexturePixelFormat(PF_DEPTH16);
sceneMgr->setShadowTechnique( SHADOWTYPE_TEXTURE_ADDITIVE );
sceneMgr->setShadowTextureCasterMaterial(materialMgr->getByName("Ogre/DepthShadowmap/Caster/Float"));
sceneMgr->setShadowTextureReceiverMaterial(materialMgr->getByName("Ogre/DepthShadowmap/Receiver/Float"));
sceneMgr->setShadowTextureSelfShadow(true);
sceneMgr->setShadowTextureSize(1024);
Ogre::SceneManager *mSceneMgr = ...;
Ogre::MaterialManager *materialMgr = Ogre::MaterialManager::getSingletonPtr();
mSceneMgr->setShadowTexturePixelFormat(PF_DEPTH16);
mSceneMgr->setShadowTechnique( SHADOWTYPE_TEXTURE_ADDITIVE );
mSceneMgr->setShadowTextureCasterMaterial(materialMgr->getByName("PSSM/shadow_caster"));
mSceneMgr->setShadowTextureReceiverMaterial(materialMgr->getByName("Ogre/DepthShadowmap/Receiver/RockWall"));
mSceneMgr->setShadowTextureSelfShadow(true);
mSceneMgr->setShadowTextureSize(1024);
```

The setShadowTechnique call is all that is required for Ogre’s default
Expand All @@ -361,43 +362,41 @@ defined in a material script. They tell Ogre which shaders to use when
rendering shadow casters into the shadow map and rendering shadow
receivers during shadow determination.

The `DepthShadowmap.material` script is given below:

@snippet Samples/Media/materials/scripts/DepthShadowmap.material shadow_material

The material uses unified programs for HLSL, GLSL and GLSLES.
We’ll present the GLSL code below. Note that while most of the
shader files are direct translations of each other, DirectX HLSL shaders
must handle percentage closest filtering slightly differently from
OpenGL. OpenGL chooses the convention of having integers index sample
centers whereas DirectX chooses integers to index sample corners. Also
note the variable names in the shaders presented below are slightly
We’ll present the GLSL code below. Note that the variable names in the shaders presented below are slightly
different from those presented earlier in this document. This is due in
part to the awkwardness of expressing subscripts in variable names and
also in part because \f$u_3\f$ is less evocative of depth than \f$z\f$, etc.
With minimal effort one can match the shader equations with those
presented earlier. The code is presented here mostly to demonstrate how
things fit together.

@include Samples/Media/materials/programs/GLSL/pssmCasterVp.glsl
## Caster
```cpp
uniform mat4 worldViewProjMatrix;
attribute vec4 vertex;

void main()
{
gl_Position = worldViewProjMatrix * vertex;
}
```

This is a pretty standard vertex shader.

@include Samples/Media/materials/programs/GLSL/pssmCasterFp.glsl

Just write out the depth values here. The bias and derivatives are handled by the @c depth_bias set in the pass.

## Receiver

@include Samples/Media/materials/programs/GLSL/DepthShadowmapReceiverVp.glsl

This is a pretty standard vertex shader as well.

@include Samples/Media/materials/programs/GLSL/DepthShadowmapReceiverFp.glsl

Additionally this file implements percentage closest filtering. To use unfiltered
shadow mapping, comment out the PCF block as noted and uncomment the
Non-PCF block. Note that after doing this, the uSTexWidth and
uSTexHeight variables are likely to be optimized away and so you should
uncomment these variables in the materials script as well.
shadow mapping, comment out the PCF define.

## Debugging Shadows
Since shadows are a difficult subject, so it is a good idea to have the Shadow Map
Expand Down Expand Up @@ -451,8 +450,8 @@ Ogre is provided with several alternative shadow camera setups:
- Ogre::PSSMShadowCameraSetup: Parallel Split Shadow Map (PSSM) shadow camera setup.
- Ogre::PlaneOptimalShadowCameraSetup: Implements the plane optimal shadow camera algorithm.

These Shadow Camera Setups can be enabled for the whole Scene with SceneManager::setShadowCameraSetup
or per light with Light::setCustomShadowCameraSetup
These Shadow Camera Setups can be enabled for the whole Scene with Ogre::SceneManager::setShadowCameraSetup
or per light with Ogre::Light::setCustomShadowCameraSetup

The following shows how to activate Plane Optimal Shadow Mapping given
some pointer to a MovablePlane and a pointer to a light.
Expand All @@ -461,14 +460,12 @@ Ogre::MovablePlane *movablePlane = new Ogre::MovablePlane( Ogre::Vector3::UNIT_Y
Ogre::Entity *movablePlaneEntity = mSceneMgr->createEntity( "movablePlane", "Floor.mesh" );
Ogre::SceneNode *movablePlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("MovablePlaneNode");
movablePlaneNode->attachObject(movablePlaneEntity);
Ogre::ShadowCameraSetupPtr shadowCameraSetup = Ogre::PlaneOptimalShadowCameraSetup::create(movablePlane);
light->setCustomShadowCameraSetup(Ogre::ShadowCameraSetupPtr(shadowCameraSetup));
light->setCustomShadowCameraSetup(Ogre::PlaneOptimalShadowCameraSetup::create(movablePlane));
```

Another example, using LiSPSM Camera Setup:
```cpp
Ogre::ShadowCameraSetupPtr shadowCameraSetup = Ogre::LiSPSMShadowCameraSetup::create();
mSceneMgr->setShadowCameraSetup(shadowCameraSetup);
mSceneMgr->setShadowCameraSetup(Ogre::LiSPSMShadowCameraSetup::create());
```

For big scenes with directional lights one of the better performing Shadow Camera Setups is PSSM.
Expand All @@ -489,7 +486,7 @@ mSceneMgr->setShadowTextureConfig(0, 2048, 2048, Ogre::PF_DEPTH16);
mSceneMgr->setShadowTextureConfig(1, 1024, 1024, Ogre::PF_DEPTH16);
mSceneMgr->setShadowTextureConfig(2, 512, 512, Ogre::PF_DEPTH16);

Ogre::PSSMShadowCameraSetup* pssmSetup = new Ogre::PSSMShadowCameraSetup(); //static_cast<Ogre::PSSMShadowCameraSetup*>(shadowCameraSetup->getPointer());
Ogre::PSSMShadowCameraSetup* pssmSetup = new Ogre::PSSMShadowCameraSetup();
pssmSetup->setSplitPadding(1);
pssmSetup->calculateSplitPoints(3, 1, mSceneMgr->getShadowFarDistance());
pssmSetup->setOptimalAdjustFactor(0, 2);
Expand Down
2 changes: 1 addition & 1 deletion PlugIns/RsImageCodec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_dependencies(Codec_RsImage rsimage)
target_link_libraries(Codec_RsImage PUBLIC OgreMain PRIVATE ${RS_LIB_PATH} ${CMAKE_DL_LIBS})

if(MSVC)
target_link_libraries(Codec_RsImage PRIVATE wsock32 ws2_32 bcrypt userenv)
target_link_libraries(Codec_RsImage PRIVATE wsock32 ws2_32 bcrypt userenv Ntdll)
endif()

target_include_directories(Codec_RsImage PUBLIC
Expand Down
3 changes: 1 addition & 2 deletions PlugIns/RsImageCodec/src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
image = "0.24.5"
half = "~2.2.1"
image = "0.24.7"

[lib]
crate-type = ["staticlib"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#if PCF
#define PCF

#ifdef PCF
uniform float inverseShadowmapSize;
#endif
uniform sampler2D shadowMap;
Expand All @@ -18,7 +20,7 @@ void main()
#endif

// shadowUV.z contains lightspace position of current object
#if PCF
#ifdef PCF
float pixeloffset = inverseShadowmapSize;
vec4 depths = vec4(
texture2D(shadowMap, shadowUV.xy + vec2(-pixeloffset, 0.0)).x,
Expand Down
8 changes: 0 additions & 8 deletions Samples/Media/materials/programs/GLSL/pssmCasterVp.glsl

This file was deleted.

2 changes: 0 additions & 2 deletions Samples/Media/materials/scripts/DepthShadowmap.material
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//! [shadow_material]
// Specific receiver material for rockwall
material Ogre/DepthShadowmap/Receiver/RockWall
{
Expand All @@ -19,7 +18,6 @@ material Ogre/DepthShadowmap/Receiver/RockWall
}
}
}
//! [shadow_material]

// Specific receiver material for Athene
material Ogre/DepthShadowmap/Receiver/Athene
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:
- cmd: SET PATH=C:\Python310-x64;C:\Python310-x64\Scripts;%PATH%
- cmd: pip install swig==4.1.1
- cmd: curl -sSf -o rustup-init.exe https://win.rustup.rs/
- cmd: rustup-init.exe -y --default-toolchain 1.69.0
- cmd: rustup-init.exe -y
- cmd: curl -LO https://sdk.lunarg.com/sdk/download/1.2.189.2/windows/VulkanSDK-1.2.189.2-Installer.exe
- cmd: VulkanSDK-1.2.189.2-Installer.exe --accept-licenses --default-answer --confirm-command install
- cmd: cd %APPVEYOR_BUILD_FOLDER%
Expand Down