summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/31-rsm
diff options
context:
space:
mode:
author Julian Sikorski <belegdol+github@gmail.com>2019-10-13 13:50:38 +0200
committer R. Belmont <rb6502@users.noreply.github.com>2019-10-13 07:50:38 -0400
commit0837e7451a84f95c29dbdb9bd6b8b931fee1635d (patch)
tree626bcbd250a7fbebdf5958a288d2f438d4f9fb5a /3rdparty/bgfx/examples/31-rsm
parentc913ccb59d713ce0b91135520719ac5385e54358 (diff)
WIP: sync bgfx, bx and bimg with latest upstream (#5723)
* Sync with bgfx upstream revision b91d0b6 * Sync with bx upstream revision d60912b * Sync with bimg upstream revision bd81f60 * Add astc-codec decoder * Rename VertexDecl to VertexLayout * Rename UniformType enum Int1 to Sampler. * Add NVN stub * Fix unused-const-variable error on macOS * Drop redundant explicit language parameters buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only applied to objective c++ files. As such, hardcoding -x offers no benefit while preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on macOS) from working. * Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning * Build bgfx as Objective-C++ on macOS It is needed due to included headers * Enable Direct3D12 and Vulkan bgfx rendering backends * Enable building of spirv shaders * Properly escape /c in cmd call * Comment out dx12 bgfx renderer * Honor VERBOSE setting during shaders build * Only invert hlsl shader XYZ_TO_sRGB matrix for opengl * Add spirv shaders * OpenGL ES needs transposed matrix too * Metal needs transposed matrix as well
Diffstat (limited to '3rdparty/bgfx/examples/31-rsm')
-rw-r--r--3rdparty/bgfx/examples/31-rsm/makefile2
-rw-r--r--3rdparty/bgfx/examples/31-rsm/reflectiveshadowmap.cpp46
2 files changed, 26 insertions, 22 deletions
diff --git a/3rdparty/bgfx/examples/31-rsm/makefile b/3rdparty/bgfx/examples/31-rsm/makefile
index 171709170a4..ef9203197d7 100644
--- a/3rdparty/bgfx/examples/31-rsm/makefile
+++ b/3rdparty/bgfx/examples/31-rsm/makefile
@@ -1,5 +1,5 @@
#
-# Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+# Copyright 2011-2019 Branimir Karadzic. All rights reserved.
# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
#
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"
+ );