summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp')
-rw-r--r--3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp b/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp
index 8a0ca30a2d7..382802b5db5 100644
--- a/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp
+++ b/3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp
@@ -105,7 +105,7 @@ static const float s_meshScale[] =
0.05f
};
-// Vertex decl for our screen space quad (used in deferred rendering)
+// Vertex layout for our screen space quad (used in deferred rendering)
struct PosTexCoord0Vertex
{
float m_x;
@@ -116,24 +116,24 @@ struct PosTexCoord0Vertex
static void init()
{
- ms_decl
+ ms_layout
.begin()
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
.end();
}
- static bgfx::VertexDecl ms_decl;
+ static bgfx::VertexLayout ms_layout;
};
-bgfx::VertexDecl PosTexCoord0Vertex::ms_decl;
+bgfx::VertexLayout PosTexCoord0Vertex::ms_layout;
// Utility function to draw a screen space quad for deferred rendering
void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf, bool _originBottomLeft, float _width = 1.0f, float _height = 1.0f)
{
- if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_decl) )
+ if (3 == bgfx::getAvailTransientVertexBuffer(3, PosTexCoord0Vertex::ms_layout) )
{
bgfx::TransientVertexBuffer vb;
- bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_decl);
+ bgfx::allocTransientVertexBuffer(&vb, 3, PosTexCoord0Vertex::ms_layout);
PosTexCoord0Vertex* vertex = (PosTexCoord0Vertex*)vb.data;
const float minx = -_width;
@@ -186,8 +186,8 @@ void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf
class ExampleRSM : public entry::AppI
{
public:
- ExampleRSM(const char* _name, const char* _description)
- : entry::AppI(_name, _description)
+ ExampleRSM(const char* _name, const char* _description, const char* _url)
+ : entry::AppI(_name, _description, _url)
, m_reading(0)
, m_currFrame(UINT32_MAX)
, m_cameraSpin(false)
@@ -258,12 +258,12 @@ public:
u_rsmAmount = bgfx::createUniform("u_rsmAmount", bgfx::UniformType::Vec4); // How much RSM to use vs directional light
// Create texture sampler uniforms (used when we bind textures)
- s_normal = bgfx::createUniform("s_normal", bgfx::UniformType::Int1); // Normal gbuffer
- s_depth = bgfx::createUniform("s_depth", bgfx::UniformType::Int1); // Normal gbuffer
- s_color = bgfx::createUniform("s_color", bgfx::UniformType::Int1); // Color (albedo) gbuffer
- s_light = bgfx::createUniform("s_light", bgfx::UniformType::Int1); // Light buffer
- s_shadowMap = bgfx::createUniform("s_shadowMap", bgfx::UniformType::Int1); // Shadow map
- s_rsm = bgfx::createUniform("s_rsm", bgfx::UniformType::Int1); // Reflective shadow map
+ s_normal = bgfx::createUniform("s_normal", bgfx::UniformType::Sampler); // Normal gbuffer
+ s_depth = bgfx::createUniform("s_depth", bgfx::UniformType::Sampler); // Normal gbuffer
+ s_color = bgfx::createUniform("s_color", bgfx::UniformType::Sampler); // Color (albedo) gbuffer
+ s_light = bgfx::createUniform("s_light", bgfx::UniformType::Sampler); // Light buffer
+ s_shadowMap = bgfx::createUniform("s_shadowMap", bgfx::UniformType::Sampler); // Shadow map
+ s_rsm = bgfx::createUniform("s_rsm", bgfx::UniformType::Sampler); // Reflective shadow map
// Create program from shaders.
m_gbufferProgram = loadProgram("vs_rsm_gbuffer", "fs_rsm_gbuffer"); // Gbuffer
@@ -351,21 +351,20 @@ public:
, false
, 1
, bgfx::TextureFormat::D16
- , BGFX_TEXTURE_RT /* | BGFX_TEXTURE_COMPARE_LEQUAL*/
- ); // Note I'm not setting BGFX_TEXTURE_COMPARE_LEQUAL. Why?
+ , BGFX_TEXTURE_RT /* | BGFX_SAMPLER_COMPARE_LEQUAL*/
+ ); // Note I'm not setting BGFX_SAMPLER_COMPARE_LEQUAL. Why?
// Normally a PCF shadow map such as this requires a compare. However, this sample also
// reads from this texture in the lighting pass, and only uses the PCF capabilites in the
// combine pass, so the flag is disabled by default.
m_shadowBuffer = bgfx::createFrameBuffer(BX_COUNTOF(m_shadowBufferTex), m_shadowBufferTex, true);
- // Vertex decl
+ // Vertex layout
PosTexCoord0Vertex::init();
// Init camera
cameraCreate();
- float camPos[] = {0.0f, 1.5f, 0.0f};
- cameraSetPosition(camPos);
+ cameraSetPosition({0.0f, 1.5f, 0.0f});
cameraSetVerticalAngle(-0.3f);
// Init directional light
@@ -476,7 +475,7 @@ public:
lightAt[1] = 0.0f;
lightAt[2] = 0.0f;
- bx::mtxLookAt(smView, bx::load(lightEye), bx::load(lightAt) );
+ bx::mtxLookAt(smView, bx::load<bx::Vec3>(lightEye), bx::load<bx::Vec3>(lightAt) );
const float area = 10.0f;
const bgfx::Caps* caps = bgfx::getCaps();
bx::mtxOrtho(smProj, -area, area, -area, area, -100.0f, 100.0f, 0.0f, caps->homogeneousDepth);
@@ -759,4 +758,9 @@ public:
} // namespace
-ENTRY_IMPLEMENT_MAIN(ExampleRSM, "31-rsm", "Global Illumination with Reflective Shadow Map.");
+ENTRY_IMPLEMENT_MAIN(
+ ExampleRSM
+ , "31-rsm"
+ , "Global Illumination with Reflective Shadow Map."
+ , "https://bkaradzic.github.io/bgfx/examples.html#rsm"
+ );