From dc1ee2e33cdc8afb188bdc2d1b6a5c9d807069b3 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Mon, 12 Feb 2018 13:05:19 +0100 Subject: [PATCH] Docking kind of works but overall unstable * crashes when reloading render module * spurious crashes on the first frame --- 3rdparty/bgfx/src/amalgamated.cpp | 4 +- CMakeLists.txt | 1 + data/shaders/Makefile | 6 + data/shaders/common/bgfx_shader.sh | 322 +++++++++++ data/shaders/common/common.sh | 7 + data/shaders/common/shaderlib.sh | 352 ++++++++++++ data/shaders/debug/Makefile | 3 + data/shaders/debug/fs_debug.sc | 14 + data/shaders/debug/fs_debug.sc.bin | Bin 0 -> 143 bytes data/shaders/debug/varying.def.sc | 13 + data/shaders/debug/vs_debug.sc | 15 + data/shaders/glsl/fs_cubes.bin | Bin 0 -> 83 bytes data/shaders/glsl/fs_debug.sc.bin | Bin 0 -> 131 bytes data/shaders/glsl/fs_hdr_mesh.bin | Bin 0 -> 1649 bytes data/shaders/glsl/fs_ibl_mesh.bin | Bin 0 -> 1855 bytes data/shaders/glsl/fs_ibl_skybox.sc.bin | Bin 0 -> 1708 bytes data/shaders/glsl/fs_lines.sc.bin | Bin 0 -> 83 bytes data/shaders/glsl/fs_lines_occluded.sc.bin | Bin 0 -> 239 bytes data/shaders/glsl/fs_mesh.bin | Bin 0 -> 1347 bytes data/shaders/glsl/fs_sms_mesh.bin | Bin 0 -> 7988 bytes data/shaders/glsl/fs_sms_mesh.bin.orig | 503 ++++++++++++++++++ data/shaders/glsl/fs_sms_mesh.sc.bin | Bin 0 -> 8304 bytes data/shaders/glsl/fs_sms_mesh_pd.bin | Bin 0 -> 8286 bytes data/shaders/glsl/fs_sms_mesh_textured.sc.bin | Bin 0 -> 8537 bytes data/shaders/glsl/fs_sms_shadow.bin | Bin 0 -> 76 bytes data/shaders/glsl/fs_sms_shadow.sc.bin | Bin 0 -> 76 bytes data/shaders/glsl/fs_sms_shadow_pd.bin | Bin 0 -> 290 bytes data/shaders/glsl/vs_cubes.bin | Bin 0 -> 295 bytes data/shaders/glsl/vs_debug.sc.bin | Bin 0 -> 295 bytes data/shaders/glsl/vs_hdr_mesh.bin | Bin 0 -> 614 bytes data/shaders/glsl/vs_ibl_mesh.bin | Bin 0 -> 627 bytes data/shaders/glsl/vs_ibl_skybox.sc.bin | Bin 0 -> 718 bytes data/shaders/glsl/vs_lines.sc.bin | Bin 0 -> 2142 bytes data/shaders/glsl/vs_mesh.bin | Bin 0 -> 1369 bytes data/shaders/glsl/vs_sms_mesh.bin | Bin 0 -> 828 bytes data/shaders/glsl/vs_sms_mesh.sc.bin | Bin 0 -> 744 bytes data/shaders/glsl/vs_sms_mesh_textured.sc.bin | Bin 0 -> 827 bytes data/shaders/glsl/vs_sms_shadow.bin | Bin 0 -> 224 bytes data/shaders/glsl/vs_sms_shadow_pd.bin | Bin 0 -> 277 bytes data/shaders/include/shaderlib.sh | 386 ++++++++++++++ data/shaders/lines/Makefile | 5 + data/shaders/lines/fs_lines.sc | 13 + data/shaders/lines/fs_lines_occluded.sc | 16 + data/shaders/lines/varying.def.sc | 9 + data/shaders/lines/vs_lines.sc | 71 +++ data/shaders/scene/Makefile | 6 + data/shaders/scene/fs_sms_mesh.sc | 11 + data/shaders/scene/fs_sms_mesh_textured.sc | 12 + data/shaders/scene/fs_sms_shadow.sh | 115 ++++ data/shaders/scene/varying.def.sc | 13 + data/shaders/scene/vs_sms_mesh.sc | 24 + data/shaders/scene/vs_sms_mesh_textured.sc | 27 + data/shaders/shadowmap/Makefile | 3 + data/shaders/shadowmap/fs_sms_shadow.sc | 11 + data/shaders/shadowmap/varying.def.sc | 13 + data/shaders/shadowmap/vs_sms_mesh.sc | 24 + data/shaders/skybox/Makefile | 3 + data/shaders/skybox/fs_ibl_skybox.sc | 33 ++ data/shaders/skybox/shaderlib.sh | 386 ++++++++++++++ data/shaders/skybox/uniforms.sh | 28 + data/shaders/skybox/varying.def.sc | 13 + data/shaders/skybox/vs_ibl_skybox.sc | 29 + data/shaders/src/Makefile | 5 + data/shaders/src/bgfx_shader.sh | 466 ++++++++++++++++ data/shaders/src/fs_cubes.sc | 13 + data/shaders/src/fs_sms_mesh.sc | 11 + data/shaders/src/fs_sms_mesh_pd.sc | 11 + data/shaders/src/fs_sms_mesh_pd_textured.sc | 12 + data/shaders/src/fs_sms_shadow.sh | 115 ++++ data/shaders/src/fs_sms_shadow.sh.orig | 102 ++++ data/shaders/src/mesh.out | Bin 0 -> 8825 bytes data/shaders/src/shaderlib.sh | 386 ++++++++++++++ data/shaders/src/uniforms.sh | 28 + data/shaders/src/varying.def.sc | 13 + data/shaders/src/vs_cubes.sc | 15 + data/shaders/src/vs_sms_shadow.sc | 13 + src/Globals.h | 3 + src/RuntimeModuleManager.cc | 26 +- src/Utils.cc | 23 + src/Utils.h | 26 +- src/main.cc | 80 ++- src/modules/CharacterModule.cc | 12 +- src/modules/RenderModule.cc | 311 +++++------ src/modules/RenderModule.h | 6 +- src/modules/RenderUtils.cc | 133 ++--- src/modules/TestModule.cc | 14 +- tests/CMakeLists.txt | 5 +- 87 files changed, 4005 insertions(+), 315 deletions(-) create mode 100644 data/shaders/Makefile create mode 100644 data/shaders/common/bgfx_shader.sh create mode 100644 data/shaders/common/common.sh create mode 100644 data/shaders/common/shaderlib.sh create mode 100644 data/shaders/debug/Makefile create mode 100644 data/shaders/debug/fs_debug.sc create mode 100644 data/shaders/debug/fs_debug.sc.bin create mode 100644 data/shaders/debug/varying.def.sc create mode 100644 data/shaders/debug/vs_debug.sc create mode 100644 data/shaders/glsl/fs_cubes.bin create mode 100644 data/shaders/glsl/fs_debug.sc.bin create mode 100644 data/shaders/glsl/fs_hdr_mesh.bin create mode 100644 data/shaders/glsl/fs_ibl_mesh.bin create mode 100644 data/shaders/glsl/fs_ibl_skybox.sc.bin create mode 100644 data/shaders/glsl/fs_lines.sc.bin create mode 100644 data/shaders/glsl/fs_lines_occluded.sc.bin create mode 100644 data/shaders/glsl/fs_mesh.bin create mode 100644 data/shaders/glsl/fs_sms_mesh.bin create mode 100644 data/shaders/glsl/fs_sms_mesh.bin.orig create mode 100644 data/shaders/glsl/fs_sms_mesh.sc.bin create mode 100644 data/shaders/glsl/fs_sms_mesh_pd.bin create mode 100644 data/shaders/glsl/fs_sms_mesh_textured.sc.bin create mode 100644 data/shaders/glsl/fs_sms_shadow.bin create mode 100644 data/shaders/glsl/fs_sms_shadow.sc.bin create mode 100644 data/shaders/glsl/fs_sms_shadow_pd.bin create mode 100644 data/shaders/glsl/vs_cubes.bin create mode 100644 data/shaders/glsl/vs_debug.sc.bin create mode 100644 data/shaders/glsl/vs_hdr_mesh.bin create mode 100644 data/shaders/glsl/vs_ibl_mesh.bin create mode 100644 data/shaders/glsl/vs_ibl_skybox.sc.bin create mode 100644 data/shaders/glsl/vs_lines.sc.bin create mode 100644 data/shaders/glsl/vs_mesh.bin create mode 100644 data/shaders/glsl/vs_sms_mesh.bin create mode 100644 data/shaders/glsl/vs_sms_mesh.sc.bin create mode 100644 data/shaders/glsl/vs_sms_mesh_textured.sc.bin create mode 100644 data/shaders/glsl/vs_sms_shadow.bin create mode 100644 data/shaders/glsl/vs_sms_shadow_pd.bin create mode 100644 data/shaders/include/shaderlib.sh create mode 100644 data/shaders/lines/Makefile create mode 100644 data/shaders/lines/fs_lines.sc create mode 100644 data/shaders/lines/fs_lines_occluded.sc create mode 100644 data/shaders/lines/varying.def.sc create mode 100644 data/shaders/lines/vs_lines.sc create mode 100644 data/shaders/scene/Makefile create mode 100644 data/shaders/scene/fs_sms_mesh.sc create mode 100644 data/shaders/scene/fs_sms_mesh_textured.sc create mode 100644 data/shaders/scene/fs_sms_shadow.sh create mode 100644 data/shaders/scene/varying.def.sc create mode 100644 data/shaders/scene/vs_sms_mesh.sc create mode 100644 data/shaders/scene/vs_sms_mesh_textured.sc create mode 100644 data/shaders/shadowmap/Makefile create mode 100644 data/shaders/shadowmap/fs_sms_shadow.sc create mode 100644 data/shaders/shadowmap/varying.def.sc create mode 100644 data/shaders/shadowmap/vs_sms_mesh.sc create mode 100644 data/shaders/skybox/Makefile create mode 100644 data/shaders/skybox/fs_ibl_skybox.sc create mode 100644 data/shaders/skybox/shaderlib.sh create mode 100644 data/shaders/skybox/uniforms.sh create mode 100644 data/shaders/skybox/varying.def.sc create mode 100644 data/shaders/skybox/vs_ibl_skybox.sc create mode 100644 data/shaders/src/Makefile create mode 100644 data/shaders/src/bgfx_shader.sh create mode 100644 data/shaders/src/fs_cubes.sc create mode 100644 data/shaders/src/fs_sms_mesh.sc create mode 100644 data/shaders/src/fs_sms_mesh_pd.sc create mode 100644 data/shaders/src/fs_sms_mesh_pd_textured.sc create mode 100644 data/shaders/src/fs_sms_shadow.sh create mode 100644 data/shaders/src/fs_sms_shadow.sh.orig create mode 100644 data/shaders/src/mesh.out create mode 100644 data/shaders/src/shaderlib.sh create mode 100644 data/shaders/src/uniforms.sh create mode 100644 data/shaders/src/varying.def.sc create mode 100644 data/shaders/src/vs_cubes.sc create mode 100644 data/shaders/src/vs_sms_shadow.sc create mode 100644 src/Utils.cc diff --git a/3rdparty/bgfx/src/amalgamated.cpp b/3rdparty/bgfx/src/amalgamated.cpp index 6d81fc6..02138ae 100644 --- a/3rdparty/bgfx/src/amalgamated.cpp +++ b/3rdparty/bgfx/src/amalgamated.cpp @@ -19,8 +19,8 @@ #include "renderer_gl.cpp" #include "renderer_vk.cpp" #include "renderer_gnm.cpp" -#include "shader_dxbc.cpp" -#include "shader_dx9bc.cpp" +//#include "shader_dxbc.cpp" +//#include "shader_dx9bc.cpp" #include "shader_spirv.cpp" #include "topology.cpp" #include "vertexdecl.cpp" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7612011..a5a93f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ SUBDIRS ( SET ( protot_SRCS src/RuntimeModuleManager.cc + src/Utils.cc 3rdparty/glfw/deps/glad.c 3rdparty/imgui_dock/imgui_dock.cpp diff --git a/data/shaders/Makefile b/data/shaders/Makefile new file mode 100644 index 0000000..9c49196 --- /dev/null +++ b/data/shaders/Makefile @@ -0,0 +1,6 @@ +all: + cd debug && $(MAKE) + cd lines && $(MAKE) + cd scene && $(MAKE) + cd shadowmap && $(MAKE) + cd skybox && $(MAKE) diff --git a/data/shaders/common/bgfx_shader.sh b/data/shaders/common/bgfx_shader.sh new file mode 100644 index 0000000..8b8948c --- /dev/null +++ b/data/shaders/common/bgfx_shader.sh @@ -0,0 +1,322 @@ +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef BGFX_SHADER_H_HEADER_GUARD +#define BGFX_SHADER_H_HEADER_GUARD + +#if !defined(BGFX_CONFIG_MAX_BONES) +# define BGFX_CONFIG_MAX_BONES 32 +#endif // !defined(BGFX_CONFIG_MAX_BONES) + +#ifndef __cplusplus + +#if BGFX_SHADER_LANGUAGE_HLSL +# define dFdx(_x) ddx(_x) +# define dFdy(_y) ddy(-_y) +# define inversesqrt(_x) rsqrt(_x) +# define fract(_x) frac(_x) + +# define bvec2 bool2 +# define bvec3 bool3 +# define bvec4 bool4 + +# if BGFX_SHADER_LANGUAGE_HLSL > 3 +struct BgfxSampler2D +{ + SamplerState m_sampler; + Texture2D m_texture; +}; + +vec4 bgfxTexture2D(BgfxSampler2D _sampler, vec2 _coord) +{ + return _sampler.m_texture.Sample(_sampler.m_sampler, _coord); +} + +vec4 bgfxTexture2DLod(BgfxSampler2D _sampler, vec2 _coord, float _level) +{ + return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level); +} + +vec4 bgfxTexture2DProj(BgfxSampler2D _sampler, vec3 _coord) +{ + vec2 coord = _coord.xy * rcp(_coord.z); + return _sampler.m_texture.Sample(_sampler.m_sampler, coord); +} + +vec4 bgfxTexture2DProj(BgfxSampler2D _sampler, vec4 _coord) +{ + vec2 coord = _coord.xy * rcp(_coord.w); + return _sampler.m_texture.Sample(_sampler.m_sampler, coord); +} + +struct BgfxSampler2DShadow +{ + SamplerComparisonState m_sampler; + Texture2D m_texture; +}; + +float bgfxShadow2D(BgfxSampler2DShadow _sampler, vec3 _coord) +{ + return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, _coord.xy, _coord.z * 2.0 - 1.0); +} + +float bgfxShadow2DProj(BgfxSampler2DShadow _sampler, vec4 _coord) +{ + vec3 coord = _coord.xyz * rcp(_coord.w); + return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, coord.xy, coord.z * 2.0 - 1.0); +} + +struct BgfxSampler3D +{ + SamplerState m_sampler; + Texture3D m_texture; +}; + +struct BgfxISampler3D +{ + Texture3D m_texture; +}; + +struct BgfxUSampler3D +{ + Texture3D m_texture; +}; + +vec4 bgfxTexture3D(BgfxSampler3D _sampler, vec3 _coord) +{ + return _sampler.m_texture.Sample(_sampler.m_sampler, _coord); +} + +vec4 bgfxTexture3DLod(BgfxSampler3D _sampler, vec3 _coord, float _level) +{ + return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level); +} + +ivec4 bgfxTexture3D(BgfxISampler3D _sampler, vec3 _coord) +{ + ivec3 size; + _sampler.m_texture.GetDimensions(size.x, size.y, size.z); + return _sampler.m_texture.Load(ivec4(_coord * size, 0) ); +} + +uvec4 bgfxTexture3D(BgfxUSampler3D _sampler, vec3 _coord) +{ + uvec3 size; + _sampler.m_texture.GetDimensions(size.x, size.y, size.z); + return _sampler.m_texture.Load(uvec4(_coord * size, 0) ); +} + +struct BgfxSamplerCube +{ + SamplerState m_sampler; + TextureCube m_texture; +}; + +vec4 bgfxTextureCube(BgfxSamplerCube _sampler, vec3 _coord) +{ + return _sampler.m_texture.Sample(_sampler.m_sampler, _coord); +} + +vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level) +{ + return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level); +} + +# define SAMPLER2D(_name, _reg) \ + uniform SamplerState _name ## Sampler : register(s[_reg]); \ + uniform Texture2D _name ## Texture : register(t[_reg]); \ + static BgfxSampler2D _name = { _name ## Sampler, _name ## Texture } +# define sampler2D BgfxSampler2D +# define texture2D(_sampler, _coord) bgfxTexture2D(_sampler, _coord) +# define texture2DLod(_sampler, _coord, _level) bgfxTexture2DLod(_sampler, _coord, _level) +# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord) + +# define SAMPLER2DSHADOW(_name, _reg) \ + uniform SamplerComparisonState _name ## Sampler : register(s[_reg]); \ + uniform Texture2D _name ## Texture : register(t[_reg]); \ + static BgfxSampler2DShadow _name = { _name ## Sampler, _name ## Texture } +# define sampler2DShadow BgfxSampler2DShadow +# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord) +# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord) + +# define SAMPLER3D(_name, _reg) \ + uniform SamplerState _name ## Sampler : register(s[_reg]); \ + uniform Texture3D _name ## Texture : register(t[_reg]); \ + static BgfxSampler3D _name = { _name ## Sampler, _name ## Texture } +# define ISAMPLER3D(_name, _reg) \ + uniform Texture3D _name ## Texture : register(t[_reg]); \ + static BgfxISampler3D _name = { _name ## Texture } +# define USAMPLER3D(_name, _reg) \ + uniform Texture3D _name ## Texture : register(t[_reg]); \ + static BgfxUSampler3D _name = { _name ## Texture } +# define sampler3D BgfxSampler3D +# define texture3D(_sampler, _coord) bgfxTexture3D(_sampler, _coord) +# define texture3DLod(_sampler, _coord, _level) bgfxTexture3DLod(_sampler, _coord, _level) + +# define SAMPLERCUBE(_name, _reg) \ + uniform SamplerState _name ## Sampler : register(s[_reg]); \ + uniform TextureCube _name ## Texture : register(t[_reg]); \ + static BgfxSamplerCube _name = { _name ## Sampler, _name ## Texture } +# define samplerCube BgfxSamplerCube +# define textureCube(_sampler, _coord) bgfxTextureCube(_sampler, _coord) +# define textureCubeLod(_sampler, _coord, _level) bgfxTextureCubeLod(_sampler, _coord, _level) +# else + +# define sampler2DShadow sampler2D + +vec4 bgfxTexture2DProj(sampler2D _sampler, vec3 _coord) +{ + return tex2Dproj(_sampler, vec4(_coord.xy, 0.0, _coord.z) ); +} + +vec4 bgfxTexture2DProj(sampler2D _sampler, vec4 _coord) +{ + return tex2Dproj(_sampler, _coord); +} + +float bgfxShadow2D(sampler2DShadow _sampler, vec3 _coord) +{ +#if 0 + float occluder = tex2D(_sampler, _coord.xy).x; + return step(_coord.z * 2.0 - 1.0, occluder); +#else + return tex2Dproj(_sampler, vec4(_coord.xy, _coord.z * 2.0 - 1.0, 1.0) ).x; +#endif // 0 +} + +float bgfxShadow2DProj(sampler2DShadow _sampler, vec4 _coord) +{ +#if 0 + vec3 coord = _coord.xyz * rcp(_coord.w); + float occluder = tex2D(_sampler, coord.xy).x; + return step(coord.z * 2.0 - 1.0, occluder); +#else + return tex2Dproj(_sampler, _coord).x; +#endif // 0 +} + +# define SAMPLER2D(_name, _reg) uniform sampler2D _name : register(s ## _reg) +# define texture2D(_sampler, _coord) tex2D(_sampler, _coord) +# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord) + +# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name : register(s ## _reg) +# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord) +# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord) + +# define SAMPLER3D(_name, _reg) uniform sampler3D _name : register(s ## _reg) +# define texture3D(_sampler, _coord) tex3D(_sampler, _coord) + +# define SAMPLERCUBE(_name, _reg) uniform samplerCUBE _name : register(s[_reg]) +# define textureCube(_sampler, _coord) texCUBE(_sampler, _coord) + +# if BGFX_SHADER_LANGUAGE_HLSL == 2 +# define texture2DLod(_sampler, _coord, _level) tex2D(_sampler, (_coord).xy) +# define texture3DLod(_sampler, _coord, _level) tex3D(_sampler, (_coord).xyz) +# define textureCubeLod(_sampler, _coord, _level) texCUBE(_sampler, (_coord).xyz) +# else +# define texture2DLod(_sampler, _coord, _level) tex2Dlod(_sampler, vec4( (_coord).xy, 0.0, _level) ) +# define texture3DLod(_sampler, _coord, _level) tex3Dlod(_sampler, vec4( (_coord).xyz, _level) ) +# define textureCubeLod(_sampler, _coord, _level) texCUBElod(_sampler, vec4( (_coord).xyz, _level) ) +# endif // BGFX_SHADER_LANGUAGE_HLSL == 2 + +# endif // BGFX_SHADER_LANGUAGE_HLSL > 3 + +vec2 vec2_splat(float _x) { return vec2(_x, _x); } +vec3 vec3_splat(float _x) { return vec3(_x, _x, _x); } +vec4 vec4_splat(float _x) { return vec4(_x, _x, _x, _x); } + +uvec2 uvec2_splat(uint _x) { return uvec2(_x, _x); } +uvec3 uvec3_splat(uint _x) { return uvec3(_x, _x, _x); } +uvec4 uvec4_splat(uint _x) { return uvec4(_x, _x, _x, _x); } + +vec3 instMul(vec3 _vec, mat3 _mtx) { return mul(_mtx, _vec); } +vec3 instMul(mat3 _mtx, vec3 _vec) { return mul(_vec, _mtx); } +vec4 instMul(vec4 _vec, mat4 _mtx) { return mul(_mtx, _vec); } +vec4 instMul(mat4 _mtx, vec4 _vec) { return mul(_vec, _mtx); } + +bvec2 lessThan(vec2 _a, vec2 _b) { return _a < _b; } +bvec3 lessThan(vec3 _a, vec3 _b) { return _a < _b; } +bvec4 lessThan(vec4 _a, vec4 _b) { return _a < _b; } + +bvec2 lessThanEqual(vec2 _a, vec2 _b) { return _a <= _b; } +bvec3 lessThanEqual(vec3 _a, vec3 _b) { return _a <= _b; } +bvec4 lessThanEqual(vec4 _a, vec4 _b) { return _a <= _b; } + +bvec2 greaterThan(vec2 _a, vec2 _b) { return _a > _b; } +bvec3 greaterThan(vec3 _a, vec3 _b) { return _a > _b; } +bvec4 greaterThan(vec4 _a, vec4 _b) { return _a > _b; } + +bvec2 greaterThanEqual(vec2 _a, vec2 _b) { return _a >= _b; } +bvec3 greaterThanEqual(vec3 _a, vec3 _b) { return _a >= _b; } +bvec4 greaterThanEqual(vec4 _a, vec4 _b) { return _a >= _b; } + +bvec2 notEqual(vec2 _a, vec2 _b) { return _a != _b; } +bvec3 notEqual(vec3 _a, vec3 _b) { return _a != _b; } +bvec4 notEqual(vec4 _a, vec4 _b) { return _a != _b; } + +bvec2 equal(vec2 _a, vec2 _b) { return _a == _b; } +bvec3 equal(vec3 _a, vec3 _b) { return _a == _b; } +bvec4 equal(vec4 _a, vec4 _b) { return _a == _b; } + +float mix(float _a, float _b, float _t) { return lerp(_a, _b, _t); } +vec2 mix(vec2 _a, vec2 _b, vec2 _t) { return lerp(_a, _b, _t); } +vec3 mix(vec3 _a, vec3 _b, vec3 _t) { return lerp(_a, _b, _t); } +vec4 mix(vec4 _a, vec4 _b, vec4 _t) { return lerp(_a, _b, _t); } + +float mod(float _a, float _b) { return _a - _b * floor(_a / _b); } +vec2 mod(vec2 _a, vec2 _b) { return _a - _b * floor(_a / _b); } +vec3 mod(vec3 _a, vec3 _b) { return _a - _b * floor(_a / _b); } +vec4 mod(vec4 _a, vec4 _b) { return _a - _b * floor(_a / _b); } + +#else +# define atan2(_x, _y) atan(_x, _y) +# define mul(_a, _b) ( (_a) * (_b) ) +# define saturate(_x) clamp(_x, 0.0, 1.0) +# define SAMPLER2D(_name, _reg) uniform sampler2D _name +# define SAMPLER3D(_name, _reg) uniform sampler3D _name +# define SAMPLERCUBE(_name, _reg) uniform samplerCube _name +# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name +# define vec2_splat(_x) vec2(_x) +# define vec3_splat(_x) vec3(_x) +# define vec4_splat(_x) vec4(_x) +# define uvec2_splat(_x) uvec2(_x) +# define uvec3_splat(_x) uvec3(_x) +# define uvec4_splat(_x) uvec4(_x) + +# if BGFX_SHADER_LANGUAGE_GLSL >= 130 +# define ISAMPLER3D(_name, _reg) uniform isampler3D _name +# define USAMPLER3D(_name, _reg) uniform usampler3D _name +ivec4 texture3D(isampler3D _sampler, vec3 _coord) { return texture(_sampler, _coord); } +uvec4 texture3D(usampler3D _sampler, vec3 _coord) { return texture(_sampler, _coord); } +# endif // BGFX_SHADER_LANGUAGE_GLSL >= 130 + +vec3 instMul(vec3 _vec, mat3 _mtx) { return mul(_vec, _mtx); } +vec3 instMul(mat3 _mtx, vec3 _vec) { return mul(_mtx, _vec); } +vec4 instMul(vec4 _vec, mat4 _mtx) { return mul(_vec, _mtx); } +vec4 instMul(mat4 _mtx, vec4 _vec) { return mul(_mtx, _vec); } + +float rcp(float _a) { return 1.0/_a; } +vec2 rcp(vec2 _a) { return vec2(1.0)/_a; } +vec3 rcp(vec3 _a) { return vec3(1.0)/_a; } +vec4 rcp(vec4 _a) { return vec4(1.0)/_a; } +#endif // BGFX_SHADER_LANGUAGE_* + +uniform vec4 u_viewRect; +uniform vec4 u_viewTexel; +uniform mat4 u_view; +uniform mat4 u_invView; +uniform mat4 u_proj; +uniform mat4 u_invProj; +uniform mat4 u_viewProj; +uniform mat4 u_invViewProj; +uniform mat4 u_model[BGFX_CONFIG_MAX_BONES]; +uniform mat4 u_modelView; +uniform mat4 u_modelViewProj; +uniform vec4 u_alphaRef4; +#define u_alphaRef u_alphaRef4.x + +#endif // __cplusplus + +#endif // BGFX_SHADER_H_HEADER_GUARD diff --git a/data/shaders/common/common.sh b/data/shaders/common/common.sh new file mode 100644 index 0000000..e42c20e --- /dev/null +++ b/data/shaders/common/common.sh @@ -0,0 +1,7 @@ +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include +#include "shaderlib.sh" diff --git a/data/shaders/common/shaderlib.sh b/data/shaders/common/shaderlib.sh new file mode 100644 index 0000000..b8915d1 --- /dev/null +++ b/data/shaders/common/shaderlib.sh @@ -0,0 +1,352 @@ +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef __SHADERLIB_SH__ +#define __SHADERLIB_SH__ + +vec4 encodeRE8(float _r) +{ + float exponent = ceil(log2(_r) ); + return vec4(_r / exp2(exponent) + , 0.0 + , 0.0 + , (exponent + 128.0) / 255.0 + ); +} + +float decodeRE8(vec4 _re8) +{ + float exponent = _re8.w * 255.0 - 128.0; + return _re8.x * exp2(exponent); +} + +vec4 encodeRGBE8(vec3 _rgb) +{ + vec4 rgbe8; + float maxComponent = max(max(_rgb.x, _rgb.y), _rgb.z); + float exponent = ceil(log2(maxComponent) ); + rgbe8.xyz = _rgb / exp2(exponent); + rgbe8.w = (exponent + 128.0) / 255.0; + return rgbe8; +} + +vec3 decodeRGBE8(vec4 _rgbe8) +{ + float exponent = _rgbe8.w * 255.0 - 128.0; + vec3 rgb = _rgbe8.xyz * exp2(exponent); + return rgb; +} + +vec3 encodeNormalUint(vec3 _normal) +{ + return _normal * 0.5 + 0.5; +} + +vec3 decodeNormalUint(vec3 _encodedNormal) +{ + return _encodedNormal * 2.0 - 1.0; +} + +vec2 encodeNormalSphereMap(vec3 _normal) +{ + return normalize(_normal.xy) * sqrt(_normal.z * 0.5 + 0.5); +} + +vec3 decodeNormalSphereMap(vec2 _encodedNormal) +{ + float zz = dot(_encodedNormal, _encodedNormal) * 2.0 - 1.0; + return vec3(normalize(_encodedNormal.xy) * sqrt(1.0 - zz*zz), zz); +} + +// Reference: +// Octahedron normal vector encoding +// http://kriscg.blogspot.com/2014/04/octahedron-normal-vector-encoding.html +vec2 octahedronWrap(vec2 _val) +{ + return (1.0 - abs(_val.yx) ) + * mix(vec2_splat(-1.0), vec2_splat(1.0), vec2(greaterThanEqual(_val.xy, vec2_splat(0.0) ) ) ); +} + +vec2 encodeNormalOctahedron(vec3 _normal) +{ + _normal /= abs(_normal.x) + abs(_normal.y) + abs(_normal.z); + _normal.xy = _normal.z >= 0.0 ? _normal.xy : octahedronWrap(_normal.xy); + _normal.xy = _normal.xy * 0.5 + 0.5; + return _normal.xy; +} + +vec3 decodeNormalOctahedron(vec2 _encodedNormal) +{ + _encodedNormal = _encodedNormal * 2.0 - 1.0; + + vec3 normal; + normal.z = 1.0 - abs(_encodedNormal.x) - abs(_encodedNormal.y); + normal.xy = normal.z >= 0.0 ? _encodedNormal.xy : octahedronWrap(_encodedNormal.xy); + return normalize(normal); +} + +// Reference: +// RGB/XYZ Matrices +// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html +vec3 convertRGB2XYZ(vec3 _rgb) +{ + vec3 xyz; + xyz.x = dot(vec3(0.4124564, 0.3575761, 0.1804375), _rgb); + xyz.y = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + xyz.z = dot(vec3(0.0193339, 0.1191920, 0.9503041), _rgb); + return xyz; +} + +vec3 convertXYZ2RGB(vec3 _xyz) +{ + vec3 rgb; + rgb.x = dot(vec3( 3.2404542, -1.5371385, -0.4985314), _xyz); + rgb.y = dot(vec3(-0.9692660, 1.8760108, 0.0415560), _xyz); + rgb.z = dot(vec3( 0.0556434, -0.2040259, 1.0572252), _xyz); + return rgb; +} + +vec3 convertXYZ2Yxy(vec3 _xyz) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_xyY.html + float inv = 1.0/dot(_xyz, vec3(1.0, 1.0, 1.0) ); + return vec3(_xyz.y, _xyz.x*inv, _xyz.y*inv); +} + +vec3 convertYxy2XYZ(vec3 _Yxy) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_xyY_to_XYZ.html + vec3 xyz; + xyz.x = _Yxy.x*_Yxy.y/_Yxy.z; + xyz.y = _Yxy.x; + xyz.z = _Yxy.x*(1.0 - _Yxy.y - _Yxy.z)/_Yxy.z; + return xyz; +} + +vec3 convertRGB2Yxy(vec3 _rgb) +{ + return convertXYZ2Yxy(convertRGB2XYZ(_rgb) ); +} + +vec3 convertYxy2RGB(vec3 _Yxy) +{ + return convertXYZ2RGB(convertYxy2XYZ(_Yxy) ); +} + +vec3 convertRGB2Yuv(vec3 _rgb) +{ + vec3 yuv; + yuv.x = dot(_rgb, vec3(0.299, 0.587, 0.114) ); + yuv.y = (_rgb.x - yuv.x)*0.713 + 0.5; + yuv.z = (_rgb.z - yuv.x)*0.564 + 0.5; + return yuv; +} + +vec3 convertYuv2RGB(vec3 _yuv) +{ + vec3 rgb; + rgb.x = _yuv.x + 1.403*(_yuv.y-0.5); + rgb.y = _yuv.x - 0.344*(_yuv.y-0.5) - 0.714*(_yuv.z-0.5); + rgb.z = _yuv.x + 1.773*(_yuv.z-0.5); + return rgb; +} + +vec3 convertRGB2YIQ(vec3 _rgb) +{ + vec3 yiq; + yiq.x = dot(vec3(0.299, 0.587, 0.114 ), _rgb); + yiq.y = dot(vec3(0.595716, -0.274453, -0.321263), _rgb); + yiq.z = dot(vec3(0.211456, -0.522591, 0.311135), _rgb); + return yiq; +} + +vec3 convertYIQ2RGB(vec3 _yiq) +{ + vec3 rgb; + rgb.x = dot(vec3(1.0, 0.9563, 0.6210), _yiq); + rgb.y = dot(vec3(1.0, -0.2721, -0.6474), _yiq); + rgb.z = dot(vec3(1.0, -1.1070, 1.7046), _yiq); + return rgb; +} + +vec3 toLinear(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(2.2) ); +} + +vec4 toLinear(vec4 _rgba) +{ + return vec4(toLinear(_rgba.xyz), _rgba.w); +} + +vec3 toLinearAccurate(vec3 _rgb) +{ + vec3 lo = _rgb / 12.92; + vec3 hi = pow( (_rgb + 0.055) / 1.055, vec3_splat(2.4) ); + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.04045) ) ) ); + return rgb; +} + +vec4 toLinearAccurate(vec4 _rgba) +{ + return vec4(toLinearAccurate(_rgba.xyz), _rgba.w); +} + +float toGamma(float _r) +{ + return pow(abs(_r), 1.0/2.2); +} + +vec3 toGamma(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(1.0/2.2) ); +} + +vec4 toGamma(vec4 _rgba) +{ + return vec4(toGamma(_rgba.xyz), _rgba.w); +} + +vec3 toGammaAccurate(vec3 _rgb) +{ + vec3 lo = _rgb * 12.92; + vec3 hi = pow(abs(_rgb), vec3_splat(1.0/2.4) ) * 1.055 - 0.055; + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.0031308) ) ) ); + return rgb; +} + +vec4 toGammaAccurate(vec4 _rgba) +{ + return vec4(toGammaAccurate(_rgba.xyz), _rgba.w); +} + +vec3 toReinhard(vec3 _rgb) +{ + return toGamma(_rgb/(_rgb+vec3_splat(1.0) ) ); +} + +vec4 toReinhard(vec4 _rgba) +{ + return vec4(toReinhard(_rgba.xyz), _rgba.w); +} + +vec3 toFilmic(vec3 _rgb) +{ + _rgb = max(vec3_splat(0.0), _rgb - 0.004); + _rgb = (_rgb*(6.2*_rgb + 0.5) ) / (_rgb*(6.2*_rgb + 1.7) + 0.06); + return _rgb; +} + +vec4 toFilmic(vec4 _rgba) +{ + return vec4(toFilmic(_rgba.xyz), _rgba.w); +} + +vec3 luma(vec3 _rgb) +{ + float yy = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + return vec3_splat(yy); +} + +vec4 luma(vec4 _rgba) +{ + return vec4(luma(_rgba.xyz), _rgba.w); +} + +vec3 conSatBri(vec3 _rgb, vec3 _csb) +{ + vec3 rgb = _rgb * _csb.z; + rgb = mix(luma(rgb), rgb, _csb.y); + rgb = mix(vec3_splat(0.5), rgb, _csb.x); + return rgb; +} + +vec4 conSatBri(vec4 _rgba, vec3 _csb) +{ + return vec4(conSatBri(_rgba.xyz, _csb), _rgba.w); +} + +vec3 posterize(vec3 _rgb, float _numColors) +{ + return floor(_rgb*_numColors) / _numColors; +} + +vec4 posterize(vec4 _rgba, float _numColors) +{ + return vec4(posterize(_rgba.xyz, _numColors), _rgba.w); +} + +vec3 sepia(vec3 _rgb) +{ + vec3 color; + color.x = dot(_rgb, vec3(0.393, 0.769, 0.189) ); + color.y = dot(_rgb, vec3(0.349, 0.686, 0.168) ); + color.z = dot(_rgb, vec3(0.272, 0.534, 0.131) ); + return color; +} + +vec4 sepia(vec4 _rgba) +{ + return vec4(sepia(_rgba.xyz), _rgba.w); +} + +vec3 blendOverlay(vec3 _base, vec3 _blend) +{ + vec3 lt = 2.0 * _base * _blend; + vec3 gte = 1.0 - 2.0 * (1.0 - _base) * (1.0 - _blend); + return mix(lt, gte, step(vec3_splat(0.5), _base) ); +} + +vec4 blendOverlay(vec4 _base, vec4 _blend) +{ + return vec4(blendOverlay(_base.xyz, _blend.xyz), _base.w); +} + +vec3 adjustHue(vec3 _rgb, float _hue) +{ + vec3 yiq = convertRGB2YIQ(_rgb); + float angle = _hue + atan2(yiq.z, yiq.y); + float len = length(yiq.yz); + return convertYIQ2RGB(vec3(yiq.x, len*cos(angle), len*sin(angle) ) ); +} + +vec4 packFloatToRgba(float _value) +{ + const vec4 shift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0); + const vec4 mask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); + vec4 comp = fract(_value * shift); + comp -= comp.xxyz * mask; + return comp; +} + +float unpackRgbaToFloat(vec4 _rgba) +{ + const vec4 shift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0); + return dot(_rgba, shift); +} + +vec2 packHalfFloat(float _value) +{ + const vec2 shift = vec2(256, 1.0); + const vec2 mask = vec2(0, 1.0 / 256.0); + vec2 comp = fract(_value * shift); + comp -= comp.xx * mask; + return comp; +} + +float unpackHalfFloat(vec2 _rg) +{ + const vec2 shift = vec2(1.0 / 256.0, 1.0); + return dot(_rg, shift); +} + +float random(vec2 _uv) +{ + return fract(sin(dot(_uv.xy, vec2(12.9898, 78.233) ) ) * 43758.5453); +} + +#endif // __SHADERLIB_SH__ diff --git a/data/shaders/debug/Makefile b/data/shaders/debug/Makefile new file mode 100644 index 0000000..48c5f94 --- /dev/null +++ b/data/shaders/debug/Makefile @@ -0,0 +1,3 @@ +all: fs_debug.sc varying.def.sc vs_debug.sc + ../../../build/3rdparty/bgfx/shaderc -f fs_debug.sc -o ../glsl/fs_debug.sc.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f vs_debug.sc -o ../glsl/vs_debug.sc.bin --type vertex --platform linux -i ../common --varyingdef -p 120 diff --git a/data/shaders/debug/fs_debug.sc b/data/shaders/debug/fs_debug.sc new file mode 100644 index 0000000..8f9d731 --- /dev/null +++ b/data/shaders/debug/fs_debug.sc @@ -0,0 +1,14 @@ +$input v_color0 +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform vec4 u_color; + +void main() +{ + gl_FragColor = u_color * v_color0; +} diff --git a/data/shaders/debug/fs_debug.sc.bin b/data/shaders/debug/fs_debug.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..5639a2d3ce9c4c468d9884bbd2f4e1a542ea580c GIT binary patch literal 143 zcmZ<@_F!Go{oa$2fxR?7IX@@Ah>4Mbfsvtzfq|hcv8XaLFI^!cGd-g~p)57oM4=3# z#=x4ZG%qtPzbF@35^8`oS6O~$ib8H;W}bqECRa6=f>+EU^Fp literal 0 HcmV?d00001 diff --git a/data/shaders/debug/varying.def.sc b/data/shaders/debug/varying.def.sc new file mode 100644 index 0000000..2bd6633 --- /dev/null +++ b/data/shaders/debug/varying.def.sc @@ -0,0 +1,13 @@ +vec3 v_view : TEXCOORD0 = vec3(0.0, 0.0, 0.0); +vec4 v_shadowcoord : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_position : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec3 v_dir : TEXCOORD3 = vec3(0.0, 0.0, 0.0); +vec2 v_texcoord0 : TEXCOORD4 = vec2(0.0, 0.0); +vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); + +vec3 a_position : POSITION; +vec4 a_normal : NORMAL; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; + diff --git a/data/shaders/debug/vs_debug.sc b/data/shaders/debug/vs_debug.sc new file mode 100644 index 0000000..1c69373 --- /dev/null +++ b/data/shaders/debug/vs_debug.sc @@ -0,0 +1,15 @@ +$input a_position, a_color0 +$output v_color0 + +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); + v_color0 = a_color0; +} diff --git a/data/shaders/glsl/fs_cubes.bin b/data/shaders/glsl/fs_cubes.bin new file mode 100644 index 0000000000000000000000000000000000000000..6f8e3df8290f17719ce34f7fcf469721fe729841 GIT binary patch literal 83 zcmZ<@_F!4k{oa#-!G(c=p)9eeGBYn-p)57oM4>D`IX@@A$iSMbEI%_vAvZBIPeDVI btC~weAw4JFttc_w86>Y@i=?uai;DpOOe-0S literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_debug.sc.bin b/data/shaders/glsl/fs_debug.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..bce1283ea13b21d794d400682d490837d3b698e5 GIT binary patch literal 131 zcmZ<@_F!Go{oa$2fxR?7IX@@Ah>4MbfsrANfq|hcv8XaLFI}N5HQ7X=3?ge_%~hJ0 znU-Ia3lWBDvgRtw&rDIsP0Y+w(9qpanNd)0(T6 Hi;DpOXHh6c literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_hdr_mesh.bin b/data/shaders/glsl/fs_hdr_mesh.bin new file mode 100644 index 0000000000000000000000000000000000000000..6a3d0772e1490e4659364ccca80bea4322bf82de GIT binary patch literal 1649 zcmah}+isgc5G7GnDLnQI=5dM11{Q1+S?NO~MSbc^KL8PjSV&wfe8aB#1O1o&V`pY} zF}71hiX2#G&N*{tW}kn4|1|mg<)C<_=^9Z(S-LzF!&fK%(WwW|C+ZOq5=5FfZ4Ra_zhMw*yXK)e7zz6=h3uWM0R%J2b0Y)r4L@@wE@L29GydcTvsBi}Ys{s&725{R$ zcy!pmhMwo!PwKLo@j%HK>8h*)O=J~W@v%jj3{obt+hG>UQvxgXfyzDkPBj>)A=gA6 z@PlAyg|#n&ua9J#=b`=!CFqBC@}wQp0o#-yg)v2}irPG*McWid5uLt;2=UoA7#-(M z?wB)>k%z~DoN~wrw7+8Btj?kKA40_%YC=%-Xml}_(Q_~$?@CcdLm(3t7s)UV#}AQh zNMwCY1{NedO@fQp;*I%Jq)K$@^rd8%RZc#Rg%}ve}_?IR8js5+Yo^G1kp!d?64T2bu_61Kb%! zjp=WR7_ihlNkhKQPKG@kURNRASM$6mMcFKrIO^gjW0LHA>ldyM%09jx45ekGYROY; y?>*$*QuVD+T3{bdd*5#^Y8jb2;2zYNs-{*g%JjL-7Eevtv>0!bXYOy;b^ZYiH1iAz?oeEaUovaYQ6O`O;5HGjTo;#J1h^5jz! zSL^3*>1riB#rsp4Eadw(u9Nnmc}@TZzMu8`kE#-;-ybY%$EriRS(9C|2*@tp6jjc$ zxqV{ZrOAG7H=A??=ja;}#j`W#tVT2N?QGJO^FFgm{+H}nM`z!%yv&jciy^v$S8%7116%m5%~ zEulCQMvp;pXc46_Ed+&D4V(bDTw1rq48nu^D9+$g7JGd{-WUYw?wg~)(-AUM^-mq_ zsm?xygj1~Sp8xSPofWv8ig(6DI+&9w=22(t(Q!1N2(rRQymt~DI6o6k(iy>^_Z1ae zV~jmlPnU+m!tGW!Rl+X?s&55Y`yr7;x`l>*!?lD#V)Y{j2S^YUk8q|sbriWIi0b7S z+xM1aeR}{+5)vo{46Z+mCF$t?2iMTxs@-$E(%>WJznf-kvN_H}-g-{stj@h`(Lm_M zH$x*GP#nA#V79$bEY>=UA1k(gD6*oGTdzAZgT!+F$FAQgJ>w$Z0!#$mzwf3K12`{A bPXhQRPDFkT^yFUm(&I%3#n0_m+qV7!a_zgr)zXU;70 zBz77w!n6F}+2`)(xA%X`ugN>-<0f5Zbylw4b{wbUd|IXJyt&;x_Ue|K# z_Xo$>X7#>U%wU^8MzBpMMLlvii(*>UrPzx>Q-AUBzCBuH<#L|a0uKiKpJTK;a<^46 zfif!=z&!Vl3)0AAHLvQFkK{Unb-6^x(ok&Z|1gFHdX>$KL(a%kPaGFhV9Yof-}^fl zkD>1eo(F=jEGSAOB!(Fw6O**w)Hy}MOepAU*H|VyHYc_?vES?u$XZrAVA;cpX=`HN z>r!%A=!adJ zlS}chH9!dmu&8~D+Q-W$5r%%FBC#|BOEY+?*`L!4EzR($=5S8K153mMRFzo+j6N#4 zeN)K+)9O?z;TIL7?|u7TyvGSqcVJh*`{>4_$j4p0|rd+^!RlDBOLAad@tUO%b{v=i2) zbeMW1DtL=$Pb-fuj2Xu~zHZJCaWZJAyEJK>Oj9M=DP;QZ6;L;vPS-(p0!^2WpT^ZJ zFd5X9;tC7=pbPqgU8&I&;k7skVnd8gi_nB?VxrQ)bfI{Rbz=0uv7R5E6fO3|?ib`H z_$=Pwi>V<(A{Eahc%S=yq4Y=^^rS~xnourPPGlx$^YpIHX1C%w7sZ#)I7hdSuIu~* D`xNlO literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_lines.sc.bin b/data/shaders/glsl/fs_lines.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..0acc59fe54b88eab94dbe4a8b10020e1564a29e1 GIT binary patch literal 83 zcmZ<@_F#>^b@n3zg9`%#Ls?=`WoBNwLRo6Ei9%U?a(+&Jk%2W=S$<}ULT+Mao`QxZ bS2dS{LV8ZTTTx=VGe};+7D;6-7Z(Enb*vf~ literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_lines_occluded.sc.bin b/data/shaders/glsl/fs_lines_occluded.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..2edf5b95600b40ce08910bf1688069135299c845 GIT binary patch literal 239 zcmY*TJqp4w6wcz3Q@k+|DQR&K)JZ7rjt(I-Z5l|M5<@|xNAvk literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_mesh.bin b/data/shaders/glsl/fs_mesh.bin new file mode 100644 index 0000000000000000000000000000000000000000..e761dfca77eac90fb50f2f3057b49e19b8387e4a GIT binary patch literal 1347 zcmah}&5oNe5GGaI15YuxwX>`Rn4eV9_EL4#dmjLyY&Jp)5G7ecQuQ%X_wl(nR`vSb%=2d6%?Hox%Kf=&HqfnC33SD(-M0I1 z=?|7QE;sGIF1M5AU3-|Ub=CT`^q-sR3408z;l#?edW5>H8W7U|;REezIMzF4E21SX zxOcb*Ls?zc!qH2rc-pq*(bdI+o)~)`+am~v5iq<6RTuz2?jjXR20`A~Vdw#dRz0Fv zfFZb6X9q7x^h;E@1A*cIM65!XUm+wdUjIf?1|wgTl~FXZl?)^$$Xk~^7)B?}xkwyS zI%r8%f5I*@DbR8NZ%!R$YMugptodBR=N`w_v74^-LHlEpaVWIq%sR77mqL$zR8T182ee$wt7u2Y;3oaa1Ef;}7AHuDU57RE7!8mg9nYXMwq5AyY9P4hIe`-YVN`@`nIYluoyZ29hf0hMzlaElx3xeCz_oVyit# W`A5yuS2M*U|8$8^#nS)j``%wa0b(`) literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_sms_mesh.bin b/data/shaders/glsl/fs_sms_mesh.bin new file mode 100644 index 0000000000000000000000000000000000000000..e1d127680bed43069c96f1a81570fb0cc6041fcb GIT binary patch literal 7988 zcmb`M+iu%N5QdeuKnwL9ioK+2M-lf#2|;p`AjnOD0_nY=*s`NSHVw(=AaC6V=s!zR zteF>VA1<)cyQA-&`%$Z-d3ATDc*62& zQjJT#1ZMn9Bi0GesG=Z6v1^p7b~(}tXVM=PEM@0XJAX*cX#8089+s=>Gq^-OCEKkF zyd=_Pa;z?)K=*Z_jmgWfp^L3Wt`{;?bv*7RR+*s5lctYJ>#&z+LE*aOwo7SX)+5|J4k5O4ifs&NT;$!np=g|of;t}Dx_omO_xr>G}1%|ZFQsz zK;VX?dG%`>X{5=cB7Z|vsv})iccl^4AbPAW$vC)1j%x(->7|aeYte|?hDP0Xyo8X_ z)CeW?f|rmkZH0>zGe=!W+DnDRt6vj2@RyJ#!-_@9WRc49u2i8SY=}h0!9|*JkzhXk zh%}Q$GTb*zHz^<`7U@{GGZHBn;?1^7G7>2mUj8N~1w)P%iG-+BNrsbx;iO<9Qb0n} z?U2xqNQS7P-jlmGlHtZ-y0HN%kw`~tBvFGoL=8rw2E)tW#MEF!YCu%fh*N{%)L%82IW^db z8j#S`2nqevk!_&{%WcDUQv*^O8olg=WF=~_hp53y)L?n>+n5@xNDYXJ8gXi{oEmII z4M<=b^+gS~g&Hik4cko(NQpE$*6XYU4fYT;SP2>|FMb5M4T8LCk7W00}_}- zeG!9eAqK}y!*vq_QW_FLofrJ~$VtTD4iSTsh{5yH_c1Xzkr)t_H1eDnJSPSp5d#vM z8X=*dGV(3N;JIt~Zel=6q|vcf=OtqBhls&T#Nc`D`ZP zz6BUE?iyJ)Fd$`LqGR7inFI{kAz;WPV90psXE88jA}}B-NtAJ5$T%=$5ilU3DG?I- zak{Jl4CP0u@S@&*Hh-g1U!D&ApifiH^NTDvOW7>5WBQ&~o^jPd`tI^h-Q*8Au=~0# zk1TQQl;S9goIj4A=-jE9TpvTZaBhi1O*%S4x7LN< fbW9fivpC?rT+csk7MCCB_`Cl2Mi292I2`;BZAUqe literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_sms_mesh.bin.orig b/data/shaders/glsl/fs_sms_mesh.bin.orig new file mode 100644 index 0000000..f13a6e5 --- /dev/null +++ b/data/shaders/glsl/fs_sms_mesh.bin.orig @@ -0,0 +1,503 @@ +static const uint8_t fs_sms_mesh_bin[7988] = +{ + 0x46, 0x53, 0x48, 0x04, 0x08, 0x70, 0x6a, 0x48, 0x03, 0x00, 0x0a, 0x75, 0x5f, 0x6c, 0x69, 0x67, // FSH..pjH...u_lig + 0x68, 0x74, 0x50, 0x6f, 0x73, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x07, 0x75, 0x5f, 0x63, 0x6f, // htPos.......u_co + 0x6c, 0x6f, 0x72, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, // lor.......u_shad + 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0xf4, 0x1e, 0x00, 0x00, 0x76, // owMap..........v + 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x76, 0x5f, 0x6e, 0x6f, // arying vec3 v_no + 0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, // rmal;.varying ve + 0x63, 0x34, 0x20, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, // c4 v_shadowcoord + 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x76, // ;.varying vec3 v + 0x5f, 0x76, 0x69, 0x65, 0x77, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, // _view;.uniform v + 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x50, 0x6f, 0x73, 0x3b, 0x0a, // ec4 u_lightPos;. + 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x63, // uniform vec4 u_c + 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, // olor;.uniform sa + 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x20, 0x75, 0x5f, // mpler2DShadow u_ + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, // shadowMap;.void + 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, // main ().{. vec2 + 0x20, 0x6c, 0x63, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, // lc_1;. vec3 tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // pvar_2;. tmpvar + 0x5f, 0x32, 0x20, 0x3d, 0x20, 0x2d, 0x28, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x65, // _2 = -(normalize + 0x28, 0x75, 0x5f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x50, 0x6f, 0x73, 0x2e, 0x78, 0x79, 0x7a, 0x29, // (u_lightPos.xyz) + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // );. float tmpva + 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x20, // r_3;. tmpvar_3 + 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x76, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x2c, // = dot (v_normal, + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x65, // tmpvar_2);. ve + 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x74, // c2 tmpvar_4;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, // mpvar_4.x = tmpv + 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, // ar_3;. tmpvar_4 + 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, // .y = (((. flo + 0x61, 0x74, 0x28, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x20, 0x3e, 0x3d, 0x20, // at((tmpvar_3 >= + 0x30, 0x2e, 0x30, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, // 0.0)). * . + 0x6d, 0x61, 0x78, 0x20, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x28, // max (0.0, dot (( + 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x28, 0x32, 0x2e, 0x30, 0x20, 0x2a, 0x20, 0x74, // (. (2.0 * t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2a, 0x20, // mpvar_3). * + 0x76, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x29, 0x20, 0x2d, 0x20, 0x74, 0x6d, 0x70, 0x76, // v_normal) - tmpv + 0x61, 0x72, 0x5f, 0x32, 0x29, 0x2c, 0x20, 0x2d, 0x28, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, // ar_2), -(normali + 0x7a, 0x65, 0x28, 0x76, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x29, 0x29, 0x29, 0x29, 0x0a, 0x20, 0x20, // ze(v_view)))). + 0x29, 0x20, 0x2a, 0x20, 0x33, 0x2e, 0x30, 0x29, 0x20, 0x2f, 0x20, 0x38, 0x2e, 0x30, 0x29, 0x3b, // ) * 3.0) / 8.0); + 0x0a, 0x20, 0x20, 0x6c, 0x63, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x6d, 0x61, 0x78, 0x20, 0x28, 0x74, // . lc_1 = max (t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, // mpvar_4, 0.0);. + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x3b, // float tmpvar_5; + 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, // . float result_ + 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // 6;. vec2 tmpvar + 0x5f, 0x37, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x20, 0x3d, // _7;. tmpvar_7 = + 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x2e, // (v_shadowcoord. + 0x78, 0x79, 0x20, 0x2f, 0x20, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, // xy / v_shadowcoo + 0x72, 0x64, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x62, 0x6f, 0x6f, 0x6c, 0x20, 0x74, 0x6d, // rd.w);. bool tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x61, 0x6e, // pvar_8;. if (an + 0x79, 0x28, 0x67, 0x72, 0x65, 0x61, 0x74, 0x65, 0x72, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x28, 0x74, // y(greaterThan (t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, // mpvar_7, vec2(1. + 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x29, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, // 0, 1.0)))) {. + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x20, 0x3d, 0x20, 0x62, 0x6f, 0x6f, 0x6c, // tmpvar_8 = bool + 0x28, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, // (1);. } else {. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x20, 0x3d, 0x20, 0x61, // tmpvar_8 = a + 0x6e, 0x79, 0x28, 0x6c, 0x65, 0x73, 0x73, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x28, 0x74, 0x6d, 0x70, // ny(lessThan (tmp + 0x76, 0x61, 0x72, 0x5f, 0x37, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, // var_7, vec2(0.0, + 0x20, 0x30, 0x2e, 0x30, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, 0x0a, 0x20, 0x20, // 0.0)));. };. + 0x69, 0x66, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x38, 0x29, 0x20, 0x7b, 0x0a, // if (tmpvar_8) {. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x31, // tmpvar_5 = 1 + 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, // .0;. } else {. + 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, // vec2 tmpvar_9 + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x20, 0x3d, // ;. tmpvar_9 = + 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x39, 0x37, 0x36, 0x35, // (vec2(0.0009765 + 0x36, 0x32, 0x35, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x39, 0x37, 0x36, 0x35, 0x36, 0x32, // 625, 0.000976562 + 0x35, 0x29, 0x20, 0x2a, 0x20, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, // 5) * v_shadowcoo + 0x72, 0x64, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, // rd.w);. vec4 + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // tmpvar_10;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, // mpvar_10.zw = ve + 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, // c2(0.0, 0.0);. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x2e, 0x78, 0x79, 0x20, 0x3d, // tmpvar_10.xy = + 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x2d, 0x31, 0x2e, 0x35, 0x2c, 0x20, 0x2d, 0x31, 0x2e, // (vec2(-1.5, -1. + 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, // 5) * tmpvar_9);. + 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // vec4 _shadow + 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, // Coord_11;. _s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x31, 0x20, 0x3d, 0x20, // hadowCoord_11 = + 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, // (v_shadowcoord + + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, // tmpvar_10);. + 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x3b, // vec3 tmpvar_12; + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x20, 0x3d, // . tmpvar_12 = + 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, // (_shadowCoord_1 + 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, // 1.xyz / _shadowC + 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x31, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // oord_11.w);. + 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x3b, 0x0a, // vec3 tmpvar_13;. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x2e, 0x78, 0x79, // tmpvar_13.xy + 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x2e, 0x78, 0x79, 0x3b, // = tmpvar_12.xy; + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x2e, 0x7a, // . tmpvar_13.z + 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x32, 0x2e, 0x7a, 0x20, // = (tmpvar_12.z + 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, // - 0.0001);. r + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // esult_6 = shadow + 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, // 2D (u_shadowMap, + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x33, 0x29, 0x2e, 0x78, 0x3b, 0x0a, 0x20, // tmpvar_13).x;. + 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // vec4 tmpvar_1 + 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x34, // 4;. tmpvar_14 + 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, // .zw = vec2(0.0, + 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // 0.0);. tmpvar + 0x5f, 0x31, 0x34, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x2d, // _14.xy = (vec2(- + 0x31, 0x2e, 0x35, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, // 1.5, -0.5) * tmp + 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, // var_9);. vec4 + 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x35, // _shadowCoord_15 + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, // ;. _shadowCoo + 0x72, 0x64, 0x5f, 0x31, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, // rd_15 = (v_shado + 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // wcoord + tmpvar_ + 0x31, 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, // 14);. vec3 tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, // pvar_16;. tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, // var_16 = (_shado + 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x35, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, // wCoord_15.xyz / + 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x35, 0x2e, // _shadowCoord_15. + 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, // w);. vec3 tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x37, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // var_17;. tmpv + 0x61, 0x72, 0x5f, 0x31, 0x37, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ar_17.xy = tmpva + 0x72, 0x5f, 0x31, 0x36, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, // r_16.xy;. tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x37, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, // var_17.z = (tmpv + 0x61, 0x72, 0x5f, 0x31, 0x36, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, // ar_16.z - 0.0001 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, // );. result_6 + 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, // = (result_6 + sh + 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // adow2D (u_shadow + 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x37, 0x29, 0x2e, // Map, tmpvar_17). + 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, // x);. vec4 tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // var_18;. tmpv + 0x61, 0x72, 0x5f, 0x31, 0x38, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, // ar_18.zw = vec2( + 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // 0.0, 0.0);. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x38, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, // mpvar_18.xy = (v + 0x65, 0x63, 0x32, 0x28, 0x2d, 0x31, 0x2e, 0x35, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2a, // ec2(-1.5, 0.5) * + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // tmpvar_9);. + 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, // vec4 _shadowCoor + 0x64, 0x5f, 0x31, 0x39, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, // d_19;. _shado + 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x39, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, // wCoord_19 = (v_s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, // hadowcoord + tmp + 0x76, 0x61, 0x72, 0x5f, 0x31, 0x38, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, // var_18);. vec + 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, // 3 tmpvar_20;. + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, // tmpvar_20 = (_s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x31, 0x39, 0x2e, 0x78, 0x79, // hadowCoord_19.xy + 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, // z / _shadowCoord + 0x5f, 0x31, 0x39, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, // _19.w);. vec3 + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // tmpvar_21;. + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x31, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, // tmpvar_21.xy = t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x30, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, // mpvar_20.xy;. + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x31, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, // tmpvar_21.z = ( + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x30, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, // tmpvar_20.z - 0. + 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, // 0001);. resul + 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, // t_6 = (result_6 + 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, // + shadow2D (u_sh + 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // adowMap, tmpvar_ + 0x32, 0x31, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, // 21).x);. vec4 + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // tmpvar_22;. + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x32, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, // tmpvar_22.zw = v + 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, // ec2(0.0, 0.0);. + 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x32, 0x2e, 0x78, 0x79, 0x20, // tmpvar_22.xy + 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x2d, 0x31, 0x2e, 0x35, 0x2c, 0x20, 0x31, 0x2e, // = (vec2(-1.5, 1. + 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, // 5) * tmpvar_9);. + 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // vec4 _shadow + 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x32, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, // Coord_23;. _s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x32, 0x33, 0x20, 0x3d, 0x20, // hadowCoord_23 = + 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, // (v_shadowcoord + + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, // tmpvar_22);. + 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x34, 0x3b, // vec3 tmpvar_24; + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x34, 0x20, 0x3d, // . tmpvar_24 = + 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x32, // (_shadowCoord_2 + 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, // 3.xyz / _shadowC + 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x32, 0x33, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // oord_23.w);. + 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x35, 0x3b, 0x0a, // vec3 tmpvar_25;. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x35, 0x2e, 0x78, 0x79, // tmpvar_25.xy + 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x34, 0x2e, 0x78, 0x79, 0x3b, // = tmpvar_24.xy; + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x35, 0x2e, 0x7a, // . tmpvar_25.z + 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x34, 0x2e, 0x7a, 0x20, // = (tmpvar_24.z + 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, // - 0.0001);. r + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, // esult_6 = (resul + 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, // t_6 + shadow2D ( + 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, // u_shadowMap, tmp + 0x76, 0x61, 0x72, 0x5f, 0x32, 0x35, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // var_25).x);. + 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x36, 0x3b, 0x0a, // vec4 tmpvar_26;. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x36, 0x2e, 0x7a, 0x77, // tmpvar_26.zw + 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, // = vec2(0.0, 0.0 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x36, // );. tmpvar_26 + 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x2d, 0x30, 0x2e, 0x35, // .xy = (vec2(-0.5 + 0x2c, 0x20, 0x2d, 0x31, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // , -1.5) * tmpvar + 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, // _9);. vec4 _s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x32, 0x37, 0x3b, 0x0a, 0x20, // hadowCoord_27;. + 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, // _shadowCoord_ + 0x32, 0x37, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, // 27 = (v_shadowco + 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x36, 0x29, // ord + tmpvar_26) + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ;. vec3 tmpva + 0x72, 0x5f, 0x32, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // r_28;. tmpvar + 0x5f, 0x32, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, // _28 = (_shadowCo + 0x6f, 0x72, 0x64, 0x5f, 0x32, 0x37, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, // ord_27.xyz / _sh + 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x32, 0x37, 0x2e, 0x77, 0x29, 0x3b, // adowCoord_27.w); + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // . vec3 tmpvar + 0x5f, 0x32, 0x39, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // _29;. tmpvar_ + 0x32, 0x39, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // 29.xy = tmpvar_2 + 0x38, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // 8.xy;. tmpvar + 0x5f, 0x32, 0x39, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // _29.z = (tmpvar_ + 0x32, 0x38, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, // 28.z - 0.0001);. + 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, // result_6 = ( + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, // result_6 + shado + 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, // w2D (u_shadowMap + 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x39, 0x29, 0x2e, 0x78, 0x29, 0x3b, // , tmpvar_29).x); + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // . vec4 tmpvar + 0x5f, 0x33, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // _30;. tmpvar_ + 0x33, 0x30, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, // 30.zw = vec2(0.0 + 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // , 0.0);. tmpv + 0x61, 0x72, 0x5f, 0x33, 0x30, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, // ar_30.xy = (vec2 + 0x28, 0x2d, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, // (-0.5, -0.5) * t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, // mpvar_9);. ve + 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, // c4 _shadowCoord_ + 0x33, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, // 31;. _shadowC + 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, // oord_31 = (v_sha + 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // dowcoord + tmpva + 0x72, 0x5f, 0x33, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, // r_30);. vec3 + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // tmpvar_32;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, // mpvar_32 = (_sha + 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, // dowCoord_31.xyz + 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, // / _shadowCoord_3 + 0x31, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, // 1.w);. vec3 t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, // mpvar_33;. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x33, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, // pvar_33.xy = tmp + 0x76, 0x61, 0x72, 0x5f, 0x33, 0x32, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // var_32.xy;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x33, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, // mpvar_33.z = (tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x32, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, // pvar_32.z - 0.00 + 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, // 01);. result_ + 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, // 6 = (result_6 + + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, // shadow2D (u_shad + 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x33, // owMap, tmpvar_33 + 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, // ).x);. vec4 t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, // mpvar_34;. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x34, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, // pvar_34.zw = vec + 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, // 2(0.0, 0.0);. + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x34, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, // tmpvar_34.xy = + 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x2d, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x29, // (vec2(-0.5, 0.5) + 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, // * tmpvar_9);. + 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, // vec4 _shadowCo + 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, // ord_35;. _sha + 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x76, // dowCoord_35 = (v + 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, // _shadowcoord + t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, // mpvar_34);. v + 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x36, 0x3b, 0x0a, 0x20, // ec3 tmpvar_36;. + 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x36, 0x20, 0x3d, 0x20, 0x28, // tmpvar_36 = ( + 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x35, 0x2e, // _shadowCoord_35. + 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, // xyz / _shadowCoo + 0x72, 0x64, 0x5f, 0x33, 0x35, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, // rd_35.w);. ve + 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x37, 0x3b, 0x0a, 0x20, 0x20, // c3 tmpvar_37;. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x37, 0x2e, 0x78, 0x79, 0x20, 0x3d, // tmpvar_37.xy = + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x36, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, // tmpvar_36.xy;. + 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x37, 0x2e, 0x7a, 0x20, 0x3d, // tmpvar_37.z = + 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x36, 0x2e, 0x7a, 0x20, 0x2d, 0x20, // (tmpvar_36.z - + 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, // 0.0001);. res + 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, // ult_6 = (result_ + 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, // 6 + shadow2D (u_ + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // shadowMap, tmpva + 0x72, 0x5f, 0x33, 0x37, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, // r_37).x);. ve + 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x38, 0x3b, 0x0a, 0x20, 0x20, // c4 tmpvar_38;. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x38, 0x2e, 0x7a, 0x77, 0x20, 0x3d, // tmpvar_38.zw = + 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, // vec2(0.0, 0.0); + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x38, 0x2e, 0x78, // . tmpvar_38.x + 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x2d, 0x30, 0x2e, 0x35, 0x2c, 0x20, // y = (vec2(-0.5, + 0x31, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, // 1.5) * tmpvar_9) + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, // ;. vec4 _shad + 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x39, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // owCoord_39;. + 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x39, 0x20, // _shadowCoord_39 + 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, // = (v_shadowcoord + 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x38, 0x29, 0x3b, 0x0a, 0x20, // + tmpvar_38);. + 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, // vec3 tmpvar_4 + 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x30, // 0;. tmpvar_40 + 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, // = (_shadowCoord + 0x5f, 0x33, 0x39, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, // _39.xyz / _shado + 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x33, 0x39, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, // wCoord_39.w);. + 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x31, // vec3 tmpvar_41 + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x31, 0x2e, // ;. tmpvar_41. + 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x30, 0x2e, 0x78, // xy = tmpvar_40.x + 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x31, // y;. tmpvar_41 + 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x30, 0x2e, // .z = (tmpvar_40. + 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, // z - 0.0001);. + 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, // result_6 = (res + 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, // ult_6 + shadow2D + 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, // (u_shadowMap, t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x31, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, // mpvar_41).x);. + 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x32, // vec4 tmpvar_42 + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x32, 0x2e, // ;. tmpvar_42. + 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, // zw = vec2(0.0, 0 + 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // .0);. tmpvar_ + 0x34, 0x32, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, // 42.xy = (vec2(0. + 0x35, 0x2c, 0x20, 0x2d, 0x31, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // 5, -1.5) * tmpva + 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, // r_9);. vec4 _ + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x34, 0x33, 0x3b, 0x0a, // shadowCoord_43;. + 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, // _shadowCoord + 0x5f, 0x34, 0x33, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, // _43 = (v_shadowc + 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x32, // oord + tmpvar_42 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, // );. vec3 tmpv + 0x61, 0x72, 0x5f, 0x34, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ar_44;. tmpva + 0x72, 0x5f, 0x34, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, // r_44 = (_shadowC + 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x34, 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, // oord_43.xyz / _s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x34, 0x33, 0x2e, 0x77, 0x29, // hadowCoord_43.w) + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ;. vec3 tmpva + 0x72, 0x5f, 0x34, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // r_45;. tmpvar + 0x5f, 0x34, 0x35, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // _45.xy = tmpvar_ + 0x34, 0x34, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // 44.xy;. tmpva + 0x72, 0x5f, 0x34, 0x35, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // r_45.z = (tmpvar + 0x5f, 0x34, 0x34, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, // _44.z - 0.0001); + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, // . result_6 = + 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, // (result_6 + shad + 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, // ow2D (u_shadowMa + 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x35, 0x29, 0x2e, 0x78, 0x29, // p, tmpvar_45).x) + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ;. vec4 tmpva + 0x72, 0x5f, 0x34, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // r_46;. tmpvar + 0x5f, 0x34, 0x36, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, // _46.zw = vec2(0. + 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, // 0, 0.0);. tmp + 0x76, 0x61, 0x72, 0x5f, 0x34, 0x36, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, // var_46.xy = (vec + 0x32, 0x28, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, // 2(0.5, -0.5) * t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, // mpvar_9);. ve + 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, // c4 _shadowCoord_ + 0x34, 0x37, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, // 47;. _shadowC + 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x34, 0x37, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, // oord_47 = (v_sha + 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // dowcoord + tmpva + 0x72, 0x5f, 0x34, 0x36, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, // r_46);. vec3 + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // tmpvar_48;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, // mpvar_48 = (_sha + 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x34, 0x37, 0x2e, 0x78, 0x79, 0x7a, 0x20, // dowCoord_47.xyz + 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x34, // / _shadowCoord_4 + 0x37, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, // 7.w);. vec3 t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x39, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, // mpvar_49;. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x39, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, // pvar_49.xy = tmp + 0x76, 0x61, 0x72, 0x5f, 0x34, 0x38, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // var_48.xy;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x39, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, // mpvar_49.z = (tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x38, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, // pvar_48.z - 0.00 + 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, // 01);. result_ + 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, // 6 = (result_6 + + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, // shadow2D (u_shad + 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x39, // owMap, tmpvar_49 + 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, // ).x);. vec4 t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, // mpvar_50;. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x30, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, // pvar_50.zw = vec + 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, // 2(0.0, 0.0);. + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x30, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, // tmpvar_50.xy = + 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x20, // (vec2(0.5, 0.5) + 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, // * tmpvar_9);. + 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, // vec4 _shadowCoo + 0x72, 0x64, 0x5f, 0x35, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, // rd_51;. _shad + 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, // owCoord_51 = (v_ + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, // shadowcoord + tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, // pvar_50);. ve + 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x32, 0x3b, 0x0a, 0x20, 0x20, // c3 tmpvar_52;. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x32, 0x20, 0x3d, 0x20, 0x28, 0x5f, // tmpvar_52 = (_ + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, 0x31, 0x2e, 0x78, // shadowCoord_51.x + 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, // yz / _shadowCoor + 0x64, 0x5f, 0x35, 0x31, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, // d_51.w);. vec + 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, // 3 tmpvar_53;. + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x33, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, // tmpvar_53.xy = + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x32, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, // tmpvar_52.xy;. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x33, 0x2e, 0x7a, 0x20, 0x3d, 0x20, // tmpvar_53.z = + 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x32, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, // (tmpvar_52.z - 0 + 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, // .0001);. resu + 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, // lt_6 = (result_6 + 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, // + shadow2D (u_s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // hadowMap, tmpvar + 0x5f, 0x35, 0x33, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, // _53).x);. vec + 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, // 4 tmpvar_54;. + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x34, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, // tmpvar_54.zw = + 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, // vec2(0.0, 0.0);. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x34, 0x2e, 0x78, 0x79, // tmpvar_54.xy + 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x35, 0x2c, 0x20, 0x31, 0x2e, // = (vec2(0.5, 1. + 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, // 5) * tmpvar_9);. + 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // vec4 _shadow + 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, // Coord_55;. _s + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, 0x35, 0x20, 0x3d, 0x20, // hadowCoord_55 = + 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, // (v_shadowcoord + + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x34, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, // tmpvar_54);. + 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x36, 0x3b, // vec3 tmpvar_56; + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x36, 0x20, 0x3d, // . tmpvar_56 = + 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, // (_shadowCoord_5 + 0x35, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, // 5.xyz / _shadowC + 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, 0x35, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // oord_55.w);. + 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x37, 0x3b, 0x0a, // vec3 tmpvar_57;. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x37, 0x2e, 0x78, 0x79, // tmpvar_57.xy + 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x36, 0x2e, 0x78, 0x79, 0x3b, // = tmpvar_56.xy; + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x37, 0x2e, 0x7a, // . tmpvar_57.z + 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x36, 0x2e, 0x7a, 0x20, // = (tmpvar_56.z + 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, // - 0.0001);. r + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, // esult_6 = (resul + 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, // t_6 + shadow2D ( + 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, // u_shadowMap, tmp + 0x76, 0x61, 0x72, 0x5f, 0x35, 0x37, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // var_57).x);. + 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x38, 0x3b, 0x0a, // vec4 tmpvar_58;. + 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x38, 0x2e, 0x7a, 0x77, // tmpvar_58.zw + 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, // = vec2(0.0, 0.0 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x38, // );. tmpvar_58 + 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x35, 0x2c, // .xy = (vec2(1.5, + 0x20, 0x2d, 0x31, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // -1.5) * tmpvar_ + 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, // 9);. vec4 _sh + 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, 0x39, 0x3b, 0x0a, 0x20, 0x20, // adowCoord_59;. + 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, // _shadowCoord_5 + 0x39, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, // 9 = (v_shadowcoo + 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x38, 0x29, 0x3b, // rd + tmpvar_58); + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // . vec3 tmpvar + 0x5f, 0x36, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // _60;. tmpvar_ + 0x36, 0x30, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, // 60 = (_shadowCoo + 0x72, 0x64, 0x5f, 0x35, 0x39, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, // rd_59.xyz / _sha + 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x35, 0x39, 0x2e, 0x77, 0x29, 0x3b, 0x0a, // dowCoord_59.w);. + 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // vec3 tmpvar_ + 0x36, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, // 61;. tmpvar_6 + 0x31, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x30, // 1.xy = tmpvar_60 + 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // .xy;. tmpvar_ + 0x36, 0x31, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, // 61.z = (tmpvar_6 + 0x30, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, // 0.z - 0.0001);. + 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, // result_6 = (r + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // esult_6 + shadow + 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, // 2D (u_shadowMap, + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x31, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, // tmpvar_61).x);. + 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // vec4 tmpvar_ + 0x36, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, // 62;. tmpvar_6 + 0x32, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, // 2.zw = vec2(0.0, + 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // 0.0);. tmpva + 0x72, 0x5f, 0x36, 0x32, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, // r_62.xy = (vec2( + 0x31, 0x2e, 0x35, 0x2c, 0x20, 0x2d, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, // 1.5, -0.5) * tmp + 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, // var_9);. vec4 + 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x36, 0x33, // _shadowCoord_63 + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, // ;. _shadowCoo + 0x72, 0x64, 0x5f, 0x36, 0x33, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, // rd_63 = (v_shado + 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // wcoord + tmpvar_ + 0x36, 0x32, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, // 62);. vec3 tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, // pvar_64;. tmp + 0x76, 0x61, 0x72, 0x5f, 0x36, 0x34, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, // var_64 = (_shado + 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x36, 0x33, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, // wCoord_63.xyz / + 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x36, 0x33, 0x2e, // _shadowCoord_63. + 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, // w);. vec3 tmp + 0x76, 0x61, 0x72, 0x5f, 0x36, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // var_65;. tmpv + 0x61, 0x72, 0x5f, 0x36, 0x35, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ar_65.xy = tmpva + 0x72, 0x5f, 0x36, 0x34, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, // r_64.xy;. tmp + 0x76, 0x61, 0x72, 0x5f, 0x36, 0x35, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, // var_65.z = (tmpv + 0x61, 0x72, 0x5f, 0x36, 0x34, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, // ar_64.z - 0.0001 + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, // );. result_6 + 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, // = (result_6 + sh + 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // adow2D (u_shadow + 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x35, 0x29, 0x2e, // Map, tmpvar_65). + 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, // x);. vec4 tmp + 0x76, 0x61, 0x72, 0x5f, 0x36, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // var_66;. tmpv + 0x61, 0x72, 0x5f, 0x36, 0x36, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, // ar_66.zw = vec2( + 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // 0.0, 0.0);. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x36, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x76, // mpvar_66.xy = (v + 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x35, 0x2c, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x20, 0x2a, 0x20, // ec2(1.5, 0.5) * + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, // tmpvar_9);. v + 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, // ec4 _shadowCoord + 0x5f, 0x36, 0x37, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, // _67;. _shadow + 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x36, 0x37, 0x20, 0x3d, 0x20, 0x28, 0x76, 0x5f, 0x73, 0x68, // Coord_67 = (v_sh + 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, 0x6d, 0x70, 0x76, // adowcoord + tmpv + 0x61, 0x72, 0x5f, 0x36, 0x36, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, // ar_66);. vec3 + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // tmpvar_68;. + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x38, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x73, 0x68, // tmpvar_68 = (_sh + 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x36, 0x37, 0x2e, 0x78, 0x79, 0x7a, // adowCoord_67.xyz + 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, // / _shadowCoord_ + 0x36, 0x37, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, // 67.w);. vec3 + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x39, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // tmpvar_69;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x39, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x74, 0x6d, // mpvar_69.xy = tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x38, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, // pvar_68.xy;. + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x39, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x28, 0x74, // tmpvar_69.z = (t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, 0x38, 0x2e, 0x7a, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x30, // mpvar_68.z - 0.0 + 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, // 001);. result + 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x2b, // _6 = (result_6 + + 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, 0x73, 0x68, 0x61, // shadow2D (u_sha + 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x36, // dowMap, tmpvar_6 + 0x39, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, // 9).x);. vec4 + 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, // tmpvar_70;. t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x30, 0x2e, 0x7a, 0x77, 0x20, 0x3d, 0x20, 0x76, 0x65, // mpvar_70.zw = ve + 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, // c2(0.0, 0.0);. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x30, 0x2e, 0x78, 0x79, 0x20, 0x3d, // tmpvar_70.xy = + 0x20, 0x28, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x35, 0x2c, 0x20, 0x31, 0x2e, 0x35, 0x29, // (vec2(1.5, 1.5) + 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x39, 0x29, 0x3b, 0x0a, 0x20, 0x20, // * tmpvar_9);. + 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, // vec4 _shadowCo + 0x6f, 0x72, 0x64, 0x5f, 0x37, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x73, 0x68, 0x61, // ord_71;. _sha + 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x37, 0x31, 0x20, 0x3d, 0x20, 0x28, 0x76, // dowCoord_71 = (v + 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x20, 0x2b, 0x20, 0x74, // _shadowcoord + t + 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, // mpvar_70);. v + 0x65, 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x32, 0x3b, 0x0a, 0x20, // ec3 tmpvar_72;. + 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x32, 0x20, 0x3d, 0x20, 0x28, // tmpvar_72 = ( + 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x5f, 0x37, 0x31, 0x2e, // _shadowCoord_71. + 0x78, 0x79, 0x7a, 0x20, 0x2f, 0x20, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x43, 0x6f, 0x6f, // xyz / _shadowCoo + 0x72, 0x64, 0x5f, 0x37, 0x31, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, // rd_71.w);. ve + 0x63, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x33, 0x3b, 0x0a, 0x20, 0x20, // c3 tmpvar_73;. + 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x33, 0x2e, 0x78, 0x79, 0x20, 0x3d, // tmpvar_73.xy = + 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x32, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, // tmpvar_72.xy;. + 0x20, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x33, 0x2e, 0x7a, 0x20, 0x3d, // tmpvar_73.z = + 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x32, 0x2e, 0x7a, 0x20, 0x2d, 0x20, // (tmpvar_72.z - + 0x30, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, // 0.0001);. res + 0x75, 0x6c, 0x74, 0x5f, 0x36, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, // ult_6 = (result_ + 0x36, 0x20, 0x2b, 0x20, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x32, 0x44, 0x20, 0x28, 0x75, 0x5f, // 6 + shadow2D (u_ + 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x4d, 0x61, 0x70, 0x2c, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // shadowMap, tmpva + 0x72, 0x5f, 0x37, 0x33, 0x29, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74, 0x6d, // r_73).x);. tm + 0x70, 0x76, 0x61, 0x72, 0x5f, 0x35, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, // pvar_5 = (result + 0x5f, 0x36, 0x20, 0x2f, 0x20, 0x31, 0x36, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x3b, // _6 / 16.0);. }; + 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, // . vec4 tmpvar_7 + 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x34, 0x2e, 0x77, // 4;. tmpvar_74.w + 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // = 1.0;. tmpvar + 0x5f, 0x37, 0x34, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x70, 0x6f, 0x77, 0x20, 0x28, 0x61, // _74.xyz = pow (a + 0x62, 0x73, 0x28, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x28, 0x30, 0x2e, 0x31, 0x20, 0x2a, 0x20, // bs((. (0.1 * + 0x75, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x0a, 0x20, 0x20, 0x20, // u_color.xyz). + 0x2b, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x28, 0x28, 0x28, 0x6c, 0x63, 0x5f, 0x31, 0x2e, 0x78, // + . (((lc_1.x + 0x20, 0x2b, 0x20, 0x6c, 0x63, 0x5f, 0x31, 0x2e, 0x79, 0x29, 0x20, 0x2a, 0x20, 0x75, 0x5f, 0x63, // + lc_1.y) * u_c + 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, // olor.xyz) * tmpv + 0x61, 0x72, 0x5f, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x29, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, // ar_5). )), vec3 + 0x28, 0x30, 0x2e, 0x34, 0x35, 0x34, 0x35, 0x34, 0x35, 0x34, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x35, // (0.4545454, 0.45 + 0x34, 0x35, 0x34, 0x35, 0x34, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x35, 0x34, 0x35, 0x34, 0x35, 0x34, // 45454, 0.4545454 + 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, // ));. gl_FragCol + 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x37, 0x34, 0x3b, 0x0a, // or = tmpvar_74;. + 0x7d, 0x0a, 0x0a, 0x00, // }... +}; diff --git a/data/shaders/glsl/fs_sms_mesh.sc.bin b/data/shaders/glsl/fs_sms_mesh.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..9e4371ee91ac89f7a14e834437c218dd09503d26 GIT binary patch literal 8304 zcmcJVO>f&q5QdeaMGN)RTaSCBYK0c}i!uWDk|4;XKmhkHFt%)~kW538ZP|hUduNtk zJK7OR0}&F~(sFipxbM!(C)|9#`0~qd_y2wQc`$sKEf+Vp+pqcNr+0(FyTPvyv&(#$ zuZwSgJj^z?*;W4ZPj>$`TW6~>>UXalI>FyR#bEH5t)CZnH{x-Asl?;#E?=**<%gly ztf9FW@G{TWS09ECcZ+KX!!BAhxdaznPC@HlZq4;gwz^-=*YeYa%N|CqLm{7haV1vS z;!Z@P;rF4y$)#9c&XNzs7bUirz09+16|KCU z3VL4UTM<=DGOnVe>*%I0XVG3i9q*uLdBGo0$IoyfiXxb`oHvT9IPv$nn8cIO2rvF6 zT*xZhi3l3UMIL2GAtD)1Ag1c-x?ra&(UEvxU6iA7(~N;5h*L0+I2BX)g?Zx=LSk;V z>VC#98NBLlbGDuD=F1CM!kNKF|2uTWm?%o($tkRGEm^Vi;@xNzF0{o_iltxAHxJA0 zEUhOibC_a7^%)nA>_N~EZhq=M>p$vwwP$S5;yv*m@hZ;Fa#%9&Nmx&bf=+Hw-}?!s!ZZ+Z%PYO zLM|9Zrt^1P;x5-&CKFsCA`9+^LJL>4aj`m1P+hH0;%cWEC5d02U?8_7b<&uJ9|9|n zYT&ZHPhv9`_!IY4c{@q5t;(6o96q9P%o10cuz!lgszx`SpR72k2P>A{4OSO;;>xPY z2}?EF8xsp0cF2CKw+hX0u6&!}pn~xhtJ_iVm9Bw~UvS1I-~}o!-1*N=Z6T^14t
  • qJVTm`wH+g8;v- zAm9j!Ny#fFsi#QQsThO=R@mDKW$8IoG2K#QQgMn=Ymg>X4BaenLaBMh%F3@4!}^2~ ztFP!P#0jOPih(oz_!^V;fMV2NBouhZ!wW)u#h|?2^6-+S0a3}OZIY#&WYiiY0>)mE zp|ypQOPd#KLL`F#Qe@yvKVC95;U!blU{p76Ku9QAZ(md#Zz$O!nc{du zQEyNoZz%M(Kr(3Md{I%}P?R@Rz#9S{QP@KrU=KwNMs>3XganH9ev)a9J#-s; zD2_cewFVushi2IWS~N@J-{87`it%64hY#-tiNC!cGx!T zuqlHbmKuW%vBR?10j->1DaDSIVuuZ|0|JO(N5PKt0CuF*Uea#tfRKH`dOyWd4m;8| z>_|E6NU1NRA$FuJc0emD7{!j1Vn-Ta2L$+nLBJ6_G4-&ce81_Q_Vug(Q<2#6g!C2P zp!p{_APjLMBZBw4!;(4xtv$FEM9;AM8=eH-tkuRJM z<8dq;A=40eabH|`-n-zPyIFU>iwC}N2m|wI&MafVV!NRZ}xxZyN@46qYtCs9@e{?T$Miz7$Ms#ly-l*SajjWFb20ED&$pM(H5~G|NuSQf4|kg@ z7>jlktER3l?2_C2EZvGf;cB@KFqUsF*=@49V|+6HK4xe@u9a@GPH z?BDF1o$_L_o7a?A6V9GrUMCamdX?qL-VTtp!4d{v=6lBN?M`hkK?7+8W+GJ^r)JME z(p;z;RI?Yjz&VFm&Ago3e(aBP7R{o`1TX&1sLO5g%s4boi*=ZRjBzoGppP9&LvWB? z=!Bixi()c$cA(%efghM*0%Ii1$v&|q{D=2|I|_@WneDwzX<@Cs(pAeg-92Rc^&DI3 z+p@q0V`hQ(?mQyE0A_ZZo@f={@;tNSmS|&h#dvb}!mqb!vQM}F-X!oKSi@7AlgGGG z@PRkSzQdq$>LpB#CV5QO-&mUM(smb|AWL^UuXVyefC?LSRb~;(#*`YSgtcHVXS(|C ztng~N$QA7mJk>}%idS03LetjUFNn*xTeRoO?pI8cmS*E<_WA^-apK}x!kchrhAuz? z>0qDJcm~trC(dVXZ)HY655vaQ{+KN?(ozm<1=nJL7t`nn!A`($gqf z;=`ncUM^Pn)u528XpUIuIYXbdPa)WO1-CrPPOk`u zNHm2CgXhK$0aDuq4;7wvn=+9CUZ`pcqtWh0&yT^=9@P{^d@VeZ-G)ssy!im|P@nsT zw+Msh1`h#R+XW9Lz5y?oozZA_pNo{(w9#8-&GD8VcGAs#CCP5XrkCBSe|8e}xo37@ zGek9|8$2XvZ3jE((qb1H@ubmcXP+e{@Xp&x#ZDIQVXkOOH$Rr7x(%B?c2W$$4m0n* z*+Ifzz91Zqc+!m>5~Q|^9V&e3ckc^$(nz$s&y?gJVyAq5=cdP!M7Lqn%T5o#4ioRb z*+IS^!p;pH5|p-!9SVGdU8rVCqtNa?Q<8s(-NMJtO^+psZo{UR-EshSn0WWi4)Xl~ zcFGMMs=I6gU7GAd(J5ciL{W}^0G;v`O_ZA*t9H>up{}=H5}>vBmjv}c>L`cuOt2Y* z&W#+ZyRrgZn&?8Ko$}RH)UmpX^3_$8n;WZkT}658D$v?Lx&i7cDy*)e+`yr_>nhNt zh7PE`MCk+MF`jja9p@qP%q#Xzicf0Cg1=R##DO;85Ll73k7p7b=MF`tSJ7^2tlM=J?X9aoYwzsz0Cg3x86uh5jU2kWt^!?}?1Itxsw(K1+tEp%=G1erx zPL8Qj*4yX?sHx}yYARs!kk^?q62d=R}&Kiya0@HiRd0l2|q3 zUY)c1{0WXlzwJ1l+(|gyi}Ad$_?W=!Hsw{tHI4_na4>yBC%m&4I3g_%_cWaa7il+I iQJVgtt@fYA(bjdg{<2N3Kj&G#g@u$0I~%`^$D<$6_6Xhp literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_sms_mesh_textured.sc.bin b/data/shaders/glsl/fs_sms_mesh_textured.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..5924c3c59bc789e17cc9f5643cb4bd66517f9602 GIT binary patch literal 8537 zcmcJV+iu%N5QdckK>_uu=nL#6RV$3RC(1C|n*>2opg@4+USMq65g?m}B*(IYJZ~SP zomrlCxFeDQA|!Cc-Pz;6^Ye?=?>_wXGM4}S{c0z0_nUkx-+pi_hMt>HCP*;rg-I9dD{-5x??g14ew_-OqZFIVRdP{2 zD6zl2hh?uM7Sx}`AEMln^>ZGzD~b-W1usj#gev1ud_Ny@={Po!3#)HFU#Q zqiC<4jt|hXs_;A1@e@=;Q3Rt_<3>>(C;t3HEaJs%hLyhy7jl~&LOwSYL}MyL*amwt2SCw;w-eaD?iPVS8}$F!#BDA28RM_zI1hq0eDx z>@rGR@83ke+2vsf4zS60JGOVHp;Nc)qn=eYiSy2o7KVhmU=$h7KXHkxZf2P*aEFL2 zcpgeETyn?d?l?hpy+4V|owk=Getv|G+?F(x#(DT5u=A(}ZriIQHgkbL@my8QNy=kY zja1Fy4LZ*%aj6OCr<_<_==$>~E6$qE%58U@H3^=$v})&ssTy_q!~};E(k=CNq3zD4 zZ`&PYFfOrPj)F(J2ReSn5!--g$hh$2KRLC9s82YwDc3FE3O`XAV@dQZK9obj_O>dy zoNMQ2hE+1<5{OER(JHy@?5c#PlIEbNlBt#o({8ubrF1*(6g!}LSXL$LpVhWIX9#U~ zOR7>DsI;UirSLdXrKnNtY)G*sDAumMmCQL$JK6JL$<9N`Mk^*OHz2z!ohJ|z@Dw|5 zXWeYEq;??jwLle<3r;a82a*Ms%!eBk8;A--aeUf=Wbl9d5b$(DVRrJQ8c8YBWnC&|#-Ldlk_WQu}-!UXjsLsub^ zK>$fIaHbzGnOg9YDQYlkm^UCKlx(ywDvmdl?2$}yyrHN!sE{`ldRrhFlybhPC~qjr z8!F%p2=FC?fKy0@?9m?A=1r!k!>D2SfRI44@rrTmq59ZEaqOX}H>i+36w4k^$|^?L zLs9ln0ee6IQS2n_p^mVJq6VXe*#klX#YVr$G{+vgk3AH}9-3N%4%tJq>;a{mVw$pt zrtF~u_J9CiF$g$8j_D)pp{c*I^zW56z+nlyZt0 ziXMidhYrvK0*GQKK@W2TJq-01GmIV((p7AI*jH4$E=}lyZt$ z${m(+hYh#`0(`|F-~=gVk8p>j_F{**1407DMw_DLxWo2whvm4#Qe&_ocUYD?pp;dN za)+hdVFT`f0HWAQxWgXd4om&T4s!>DbQK#f7>6CU4?AqiV27o~U_3AsvZ$&0miKE2-`yZ z3d);GdC?r<6|#Zrx$3tM+@S4kU25F@@mYE047bw}-Uq`ScBjFaC@Y>i72d_4^*)!~ n&g#`IVr|?XyjTuDmg~LQtln+2n>YA760nYDT^G}D)9K`YoSP7& literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/fs_sms_shadow.bin b/data/shaders/glsl/fs_sms_shadow.bin new file mode 100644 index 0000000000000000000000000000000000000000..98147ab064acc3c860b1d9c8b6728a0f9f096e56 GIT binary patch literal 76 zcmZ<@_F!QE16v?jmYc-8?&(ELt zXS?5xtA}|aG#Me(#HLkc22GkQp@}MeQnk`$h#RdAP{gVPLh%j5J5d*vy@=e<8iR&4 z98H|mgb?cj5c1`)D=dDn>`Y+_oJraxonBd^D<>}VgCGzhbvO@Z;7jTGjL$&Gez}ZO rO1s`HkG3YxHageFc9YK^^RH%?OM4y2yu;YRy%qO`{HJ^T9b@zYPnk_r literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_cubes.bin b/data/shaders/glsl/vs_cubes.bin new file mode 100644 index 0000000000000000000000000000000000000000..14e430c2852d09f07e8d5f01de881da78ef8316f GIT binary patch literal 295 zcmWFw_F!4k{oa$2fxk39H$NpcCoD6yJfJ8)i-nPafsug;NG6t)6lErrmZU0_r6!vw zB*rJ_=j0a|SaYFB7y~5=@{2P|GV}ASxyllYDl_xaAv((7I!g00)AEaQ6><|xOcc;8 z1Zv99OaV$|<|$}sa#eFFKy;Vn7646)H?#%{z}R}_3bqP{dO$ZIiB(iq0Y#Brp`ehS g6CVI|6i`kB%}NC=xQUt|qhJmN8w2xYEf*I900^C5`~Uy| literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_debug.sc.bin b/data/shaders/glsl/vs_debug.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..150f27f526496253ce3a36683b730ab3b1364d5d GIT binary patch literal 295 zcmWFw_F!Go{oa$2fxk39H$NpcCoD6yJfJ8)i-nPafsug;NG6t)6lErrmZU0_r6!vw zB*rJ_=j0a|SaYFB7y~5=@{2P|GV}ASxyllYDl_xaAv((7I!g00)AEaQ6><|xOcc;8 z1Zv99OaV$|<|$}sa#eFFKy;Vn7646)H?#%{z}R}_3bqP{dO$ZIiB(iq0Y#Brp`ehS g6CVI|6i`kB%}NC=xQUt|qhJmN8w2xYEf*I9013fg{Qv*} literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_hdr_mesh.bin b/data/shaders/glsl/vs_hdr_mesh.bin new file mode 100644 index 0000000000000000000000000000000000000000..1673c9228793e578f0a1822bcf6475e762915f9e GIT binary patch literal 614 zcmZ{hL2kk@5Je4Q(Bi8Z^pCt$>8np>9I+k#ly(FG+5L)V#$iUy(WEp) zG2Kz{03)#F5|hO+L*e*N)-Z-)l3r+=?GLI_oEHID6k^)$g|#Sv@saR+ni%_0&U>*h za3whPPzq335X)|$FmLLhIN`5zMR6uz@vSHxMDasZda*TcqoU~evpA6@X$&v^KJ8Y` NpWltG%W5XB9R)XGb@&Nn8Nh!UGE>fRBx5(`3>3n_Ay#3(qSfckHD?m6F~Z1$b* z{ocD6GA5Bp%5FHF7#nqeZwgs(wJO* z6efl;-f)m2(|IbBi2iHr^+6e>vxt^5KdEe2Pn6xnRk=iTM2k#)q9UZy%%L&0;%t4p z)7tI3=*rI3wh^t>7PV9cu17BvtcN+6bdPWmMp$Uy{t;dv^n+3D`*g;t6nz$eT_SKJ zRW$6mSBrz^PSLYcLmnGwvx*mtc+9VPuG_8^)tDc6Ftg5Ty=Hv_^eR~QROVTcYcd~@ o`HiH!A&--m!rlZ)^^Mgzb}??f+G=3d#UFX#l?M;~{!mK(06`bWCIA2c literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_ibl_skybox.sc.bin b/data/shaders/glsl/vs_ibl_skybox.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..b37bfca960cdeeb721a24916f1fdcdea0ecbc509 GIT binary patch literal 718 zcmZ8fK~BRk5OfPj$g0E_d`u9S#132{4%|2*kb0>qD>R`ps^cnk(lm$%@GG9iI!zjf zn?0i$&(3=O_I&ZHp6<^OE=47?{cE-|(+NTobX5wa(`+*b^rg_B=Pi0!ifvLPYB!xB zG($gAgc4&4`CgigRN0D?L~Qj=8maRbk0=I|$?BEXMHI!@1^r;mu#zbR@~;<^G#j-dUxSC7tY6BQsiZp zJf?NJeY&Kx&mSBoZJIj&xoa}mXLk{#$z4@c^ zjs-njh$T4|uH1cEAM^6QRk7D9_;^!PX#;zd-#jEmR^B%cD|c7so2uTzHfE&y(Vqc6D4|Xl$f8TpS_`9 z7}&)C{o)NhH&?q~8YPxz=@(2Naz6sI(ZNKbm8lqsVa$24cz%l|B`Q4#4D8&(&WErx z6pRfG?9#$66_y4Ev#co;2kD$f3`24Ny@{BN0RNEKd;=cak>0M^O%V7#ydbtix09Qn zvJMf#l?F_Fs`v_7@sug(|I3HE{8@sDL4b;+832nyZ4vj0R!1i31N1$he6TP83AQ_U zlwHAfGX(cIX*(rn#~KZ@PT{K|hRn1${TtXF)fql}m+5qmus>Stwun9w2c*B!HK*dJ zIw$kGEOe&7P1{Ln3t0rT{WbwEyhRWV63m225Sau#kgUb%Adm4@-kV-1V!WB`ALQVV z~b>#EV48O%o7S#0#KH#yztu@F5zuWHofKl*I-#JtV|TxIG8nNpqLdUNVQ z8=+O?>mL#N_nD(buk}5KP)?d;098R;G0=|7>(FntU0GEUi>sX2rrDB_7mTYN@J)-DLGvR(E(J5>2{Pg{u8QIE1hP zV$~Q1m{Dm1su%XAlD9xE%1lRsssB8Kef3$A)Ak1pO0ED&R>E=Zf3|4b1M)Ojz^~gv zWm@R+0o0|FQ6$7jmkq^*a9UXJS)7W<^IevnVA@&B%7G&SJ~M2QoTBn@0`=n84$Xx! z7hrrZ#xTA{^by042!E;8d+@h_^F@4`Zr4%F;A0SZVZ@OUrpVj&2`(u1{-Pw~9Z2Xt zBWi>bC5$McKFof>De~o91f88U8m#I41A839lk_~`+bNCH@jX8|0}IX5b&Z6`h?+79 zQ|}1~fN&6d-eNzy&A2Plt8RX%hV3D4Td!i;QsJ6m-^Db;*OHMlbY2M&BZ?yMhc-EQeh>D`9J xXJ!_0zxz?U`^jit0bS2dVG!)`3W989hdKhjv>#JwumL9Z=C6yzf&IU2TkjOOpJ)I8 literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_sms_mesh.bin b/data/shaders/glsl/vs_sms_mesh.bin new file mode 100644 index 0000000000000000000000000000000000000000..f78b90342e426771a4f54290f299a41dd7d9e2ac GIT binary patch literal 828 zcmZ{iO>ToQ5QUvKi^^T}3bTY(MI@LN>OPxFkt$`2NT7)$z=#;~Q}xz8K*tz@Dd{eG z!<+BTcvc^a=|iz!+>^&D%tV}|E1n#u6GA5B$xxQ1*lU$mVam5V`7Tdd__-q_lCtFM zN+wVz8wOFBi!zJSfDQ^C77B6Tl8Zc`byS{tzEutn>Z`+$8On!U6pQ0Vh%z2oYK$7t zD(9a_gDjE^jL832)G(uJHxyC?kFgui!LsQW1wE6@3XB%c0u;L6&Jo^V=C}jxbiSZ! zP71J1!(}@-)+{5X$^y^Vj<#ym?676bjox$RwYue^Ywox1N`3**XbIc^ literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_sms_mesh.sc.bin b/data/shaders/glsl/vs_sms_mesh.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..cc852af0b93812e3c634e166182973736f5d869d GIT binary patch literal 744 zcmZ`%$!>!%5Oumpm3!zf%n@1@vG|61&!tkNO1UBuC~*WB5d%r8{!2f#5_J<>)W>bJH zj}}95oLNRnl?9$pinfya+u`8h8`{3&T6($2@*UTPSCydW4NJsp{r>qewX}|dxhCp? zp&ndm6DZcCO&h7rUlci)2yDf=EW!*ccEySfR@hJf5qN=7e6(;K*Y)h7t?@VdF!~M8 LSr}gZrj+~wLtpO) literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_sms_mesh_textured.sc.bin b/data/shaders/glsl/vs_sms_mesh_textured.sc.bin new file mode 100644 index 0000000000000000000000000000000000000000..e7e5400388bbb77c457b4698c1980154a51dd845 GIT binary patch literal 827 zcmZ`%$!>!%6m+^=+(Uoi9idebi*Km+s#2v$m2yQiP~r-3M9h*@{px-|`y7@SNNzCW zH*aR_)%(k><^H{1le;p=L=>kh9@jSuLKfs+Lzad3YEfDSDNi=?O*Sp?dqqenWx+p6 z8ABDX8H7PDiY!chIwCwIwqnO67x{#8k&{ zqLKaE}TF}dks$jKC%+&ILqWmltMv&-kpj=`}Nl|7}X-TR=S!%MeLSlSD zesN|=W`3SES7}~mT7FTkLT+M-i2|Ad)?8)znJGZ2%sd4RO|EJ#1(1Fdg_7KYvc#fz zLu;S_jICF$V5?xLXMiGBQCS5PMYc{sAw4HP0BSo>P6N$K1ueLVn$}#kTwDwQCj3St literal 0 HcmV?d00001 diff --git a/data/shaders/glsl/vs_sms_shadow_pd.bin b/data/shaders/glsl/vs_sms_shadow_pd.bin new file mode 100644 index 0000000000000000000000000000000000000000..099732ee31026a6b4683678db7ee41098a6b2821 GIT binary patch literal 277 zcmZ9Gy$*sf6opH|)Wui0BRCL=Y{cD>#Duk}Qpq*6CAENPdLo9d27)s$W-B~MWVTiO5s literal 0 HcmV?d00001 diff --git a/data/shaders/include/shaderlib.sh b/data/shaders/include/shaderlib.sh new file mode 100644 index 0000000..51f9b6a --- /dev/null +++ b/data/shaders/include/shaderlib.sh @@ -0,0 +1,386 @@ +/* + * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +#ifndef __SHADERLIB_SH__ +#define __SHADERLIB_SH__ + +vec4 encodeRE8(float _r) +{ + float exponent = ceil(log2(_r) ); + return vec4(_r / exp2(exponent) + , 0.0 + , 0.0 + , (exponent + 128.0) / 255.0 + ); +} + +float decodeRE8(vec4 _re8) +{ + float exponent = _re8.w * 255.0 - 128.0; + return _re8.x * exp2(exponent); +} + +vec4 encodeRGBE8(vec3 _rgb) +{ + vec4 rgbe8; + float maxComponent = max(max(_rgb.x, _rgb.y), _rgb.z); + float exponent = ceil(log2(maxComponent) ); + rgbe8.xyz = _rgb / exp2(exponent); + rgbe8.w = (exponent + 128.0) / 255.0; + return rgbe8; +} + +vec3 decodeRGBE8(vec4 _rgbe8) +{ + float exponent = _rgbe8.w * 255.0 - 128.0; + vec3 rgb = _rgbe8.xyz * exp2(exponent); + return rgb; +} + +vec3 encodeNormalUint(vec3 _normal) +{ + return _normal * 0.5 + 0.5; +} + +vec3 decodeNormalUint(vec3 _encodedNormal) +{ + return _encodedNormal * 2.0 - 1.0; +} + +vec2 encodeNormalSphereMap(vec3 _normal) +{ + return normalize(_normal.xy) * sqrt(_normal.z * 0.5 + 0.5); +} + +vec3 decodeNormalSphereMap(vec2 _encodedNormal) +{ + float zz = dot(_encodedNormal, _encodedNormal) * 2.0 - 1.0; + return vec3(normalize(_encodedNormal.xy) * sqrt(1.0 - zz*zz), zz); +} + +vec2 octahedronWrap(vec2 _val) +{ + // Reference: + // Octahedron normal vector encoding + // http://kriscg.blogspot.com/2014/04/octahedron-normal-vector-encoding.html + return (1.0 - abs(_val.yx) ) + * mix(vec2_splat(-1.0), vec2_splat(1.0), vec2(greaterThanEqual(_val.xy, vec2_splat(0.0) ) ) ); +} + +vec2 encodeNormalOctahedron(vec3 _normal) +{ + _normal /= abs(_normal.x) + abs(_normal.y) + abs(_normal.z); + _normal.xy = _normal.z >= 0.0 ? _normal.xy : octahedronWrap(_normal.xy); + _normal.xy = _normal.xy * 0.5 + 0.5; + return _normal.xy; +} + +vec3 decodeNormalOctahedron(vec2 _encodedNormal) +{ + _encodedNormal = _encodedNormal * 2.0 - 1.0; + + vec3 normal; + normal.z = 1.0 - abs(_encodedNormal.x) - abs(_encodedNormal.y); + normal.xy = normal.z >= 0.0 ? _encodedNormal.xy : octahedronWrap(_encodedNormal.xy); + return normalize(normal); +} + +vec3 convertRGB2XYZ(vec3 _rgb) +{ + // Reference: + // RGB/XYZ Matrices + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + vec3 xyz; + xyz.x = dot(vec3(0.4124564, 0.3575761, 0.1804375), _rgb); + xyz.y = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + xyz.z = dot(vec3(0.0193339, 0.1191920, 0.9503041), _rgb); + return xyz; +} + +vec3 convertXYZ2RGB(vec3 _xyz) +{ + vec3 rgb; + rgb.x = dot(vec3( 3.2404542, -1.5371385, -0.4985314), _xyz); + rgb.y = dot(vec3(-0.9692660, 1.8760108, 0.0415560), _xyz); + rgb.z = dot(vec3( 0.0556434, -0.2040259, 1.0572252), _xyz); + return rgb; +} + +vec3 convertXYZ2Yxy(vec3 _xyz) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_xyY.html + float inv = 1.0/dot(_xyz, vec3(1.0, 1.0, 1.0) ); + return vec3(_xyz.y, _xyz.x*inv, _xyz.y*inv); +} + +vec3 convertYxy2XYZ(vec3 _Yxy) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_xyY_to_XYZ.html + vec3 xyz; + xyz.x = _Yxy.x*_Yxy.y/_Yxy.z; + xyz.y = _Yxy.x; + xyz.z = _Yxy.x*(1.0 - _Yxy.y - _Yxy.z)/_Yxy.z; + return xyz; +} + +vec3 convertRGB2Yxy(vec3 _rgb) +{ + return convertXYZ2Yxy(convertRGB2XYZ(_rgb) ); +} + +vec3 convertYxy2RGB(vec3 _Yxy) +{ + return convertXYZ2RGB(convertYxy2XYZ(_Yxy) ); +} + +vec3 convertRGB2Yuv(vec3 _rgb) +{ + vec3 yuv; + yuv.x = dot(_rgb, vec3(0.299, 0.587, 0.114) ); + yuv.y = (_rgb.x - yuv.x)*0.713 + 0.5; + yuv.z = (_rgb.z - yuv.x)*0.564 + 0.5; + return yuv; +} + +vec3 convertYuv2RGB(vec3 _yuv) +{ + vec3 rgb; + rgb.x = _yuv.x + 1.403*(_yuv.y-0.5); + rgb.y = _yuv.x - 0.344*(_yuv.y-0.5) - 0.714*(_yuv.z-0.5); + rgb.z = _yuv.x + 1.773*(_yuv.z-0.5); + return rgb; +} + +vec3 convertRGB2YIQ(vec3 _rgb) +{ + vec3 yiq; + yiq.x = dot(vec3(0.299, 0.587, 0.114 ), _rgb); + yiq.y = dot(vec3(0.595716, -0.274453, -0.321263), _rgb); + yiq.z = dot(vec3(0.211456, -0.522591, 0.311135), _rgb); + return yiq; +} + +vec3 convertYIQ2RGB(vec3 _yiq) +{ + vec3 rgb; + rgb.x = dot(vec3(1.0, 0.9563, 0.6210), _yiq); + rgb.y = dot(vec3(1.0, -0.2721, -0.6474), _yiq); + rgb.z = dot(vec3(1.0, -1.1070, 1.7046), _yiq); + return rgb; +} + +vec3 toLinear(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(2.2) ); +} + +vec4 toLinear(vec4 _rgba) +{ + return vec4(toLinear(_rgba.xyz), _rgba.w); +} + +vec3 toLinearAccurate(vec3 _rgb) +{ + vec3 lo = _rgb / 12.92; + vec3 hi = pow( (_rgb + 0.055) / 1.055, vec3_splat(2.4) ); + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.04045) ) ) ); + return rgb; +} + +vec4 toLinearAccurate(vec4 _rgba) +{ + return vec4(toLinearAccurate(_rgba.xyz), _rgba.w); +} + +float toGamma(float _r) +{ + return pow(abs(_r), 1.0/2.2); +} + +vec3 toGamma(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(1.0/2.2) ); +} + +vec4 toGamma(vec4 _rgba) +{ + return vec4(toGamma(_rgba.xyz), _rgba.w); +} + +vec3 toGammaAccurate(vec3 _rgb) +{ + vec3 lo = _rgb * 12.92; + vec3 hi = pow(abs(_rgb), vec3_splat(1.0/2.4) ) * 1.055 - 0.055; + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.0031308) ) ) ); + return rgb; +} + +vec4 toGammaAccurate(vec4 _rgba) +{ + return vec4(toGammaAccurate(_rgba.xyz), _rgba.w); +} + +vec3 toReinhard(vec3 _rgb) +{ + return toGamma(_rgb/(_rgb+vec3_splat(1.0) ) ); +} + +vec4 toReinhard(vec4 _rgba) +{ + return vec4(toReinhard(_rgba.xyz), _rgba.w); +} + +vec3 toFilmic(vec3 _rgb) +{ + _rgb = max(vec3_splat(0.0), _rgb - 0.004); + _rgb = (_rgb*(6.2*_rgb + 0.5) ) / (_rgb*(6.2*_rgb + 1.7) + 0.06); + return _rgb; +} + +vec4 toFilmic(vec4 _rgba) +{ + return vec4(toFilmic(_rgba.xyz), _rgba.w); +} + +vec3 toAcesFilmic(vec3 _rgb) +{ + // Reference: + // ACES Filmic Tone Mapping Curve + // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ + float aa = 2.51f; + float bb = 0.03f; + float cc = 2.43f; + float dd = 0.59f; + float ee = 0.14f; + return saturate( (_rgb*(aa*_rgb + bb) )/(_rgb*(cc*_rgb + dd) + ee) ); +} + +vec4 toAcesFilmic(vec4 _rgba) +{ + return vec4(toAcesFilmic(_rgba.xyz), _rgba.w); +} + +vec3 luma(vec3 _rgb) +{ + float yy = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + return vec3_splat(yy); +} + +vec4 luma(vec4 _rgba) +{ + return vec4(luma(_rgba.xyz), _rgba.w); +} + +vec3 conSatBri(vec3 _rgb, vec3 _csb) +{ + vec3 rgb = _rgb * _csb.z; + rgb = mix(luma(rgb), rgb, _csb.y); + rgb = mix(vec3_splat(0.5), rgb, _csb.x); + return rgb; +} + +vec4 conSatBri(vec4 _rgba, vec3 _csb) +{ + return vec4(conSatBri(_rgba.xyz, _csb), _rgba.w); +} + +vec3 posterize(vec3 _rgb, float _numColors) +{ + return floor(_rgb*_numColors) / _numColors; +} + +vec4 posterize(vec4 _rgba, float _numColors) +{ + return vec4(posterize(_rgba.xyz, _numColors), _rgba.w); +} + +vec3 sepia(vec3 _rgb) +{ + vec3 color; + color.x = dot(_rgb, vec3(0.393, 0.769, 0.189) ); + color.y = dot(_rgb, vec3(0.349, 0.686, 0.168) ); + color.z = dot(_rgb, vec3(0.272, 0.534, 0.131) ); + return color; +} + +vec4 sepia(vec4 _rgba) +{ + return vec4(sepia(_rgba.xyz), _rgba.w); +} + +vec3 blendOverlay(vec3 _base, vec3 _blend) +{ + vec3 lt = 2.0 * _base * _blend; + vec3 gte = 1.0 - 2.0 * (1.0 - _base) * (1.0 - _blend); + return mix(lt, gte, step(vec3_splat(0.5), _base) ); +} + +vec4 blendOverlay(vec4 _base, vec4 _blend) +{ + return vec4(blendOverlay(_base.xyz, _blend.xyz), _base.w); +} + +vec3 adjustHue(vec3 _rgb, float _hue) +{ + vec3 yiq = convertRGB2YIQ(_rgb); + float angle = _hue + atan2(yiq.z, yiq.y); + float len = length(yiq.yz); + return convertYIQ2RGB(vec3(yiq.x, len*cos(angle), len*sin(angle) ) ); +} + +vec4 packFloatToRgba(float _value) +{ + const vec4 shift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0); + const vec4 mask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); + vec4 comp = fract(_value * shift); + comp -= comp.xxyz * mask; + return comp; +} + +float unpackRgbaToFloat(vec4 _rgba) +{ + const vec4 shift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0); + return dot(_rgba, shift); +} + +vec2 packHalfFloat(float _value) +{ + const vec2 shift = vec2(256, 1.0); + const vec2 mask = vec2(0, 1.0 / 256.0); + vec2 comp = fract(_value * shift); + comp -= comp.xx * mask; + return comp; +} + +float unpackHalfFloat(vec2 _rg) +{ + const vec2 shift = vec2(1.0 / 256.0, 1.0); + return dot(_rg, shift); +} + +float random(vec2 _uv) +{ + return fract(sin(dot(_uv.xy, vec2(12.9898, 78.233) ) ) * 43758.5453); +} + +vec3 fixCubeLookup(vec3 _v, float _lod, float _topLevelCubeSize) +{ + // Reference: + // Seamless cube-map filtering + // http://the-witness.net/news/2012/02/seamless-cube-map-filtering/ + float ax = abs(_v.x); + float ay = abs(_v.y); + float az = abs(_v.z); + float vmax = max(max(ax, ay), az); + float scale = 1.0 - exp2(_lod) / _topLevelCubeSize; + if (ax != vmax) { _v.x *= scale; } + if (ay != vmax) { _v.y *= scale; } + if (az != vmax) { _v.z *= scale; } + return _v; +} + +#endif // __SHADERLIB_SH__ diff --git a/data/shaders/lines/Makefile b/data/shaders/lines/Makefile new file mode 100644 index 0000000..80d5f5e --- /dev/null +++ b/data/shaders/lines/Makefile @@ -0,0 +1,5 @@ +all: fs_lines_occluded.sc fs_lines.sc varying.def.sc vs_lines.sc + ../../../build/3rdparty/bgfx/shaderc -f fs_lines.sc -o ../glsl/fs_lines.sc.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f fs_lines_occluded.sc -o ../glsl/fs_lines_occluded.sc.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f vs_lines.sc -o ../glsl/vs_lines.sc.bin --type vertex --platform linux -i ../common --varyingdef -p 120 + diff --git a/data/shaders/lines/fs_lines.sc b/data/shaders/lines/fs_lines.sc new file mode 100644 index 0000000..39a4e4e --- /dev/null +++ b/data/shaders/lines/fs_lines.sc @@ -0,0 +1,13 @@ +$input v_color0, v_path_length + +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_FragColor = v_color0; +} diff --git a/data/shaders/lines/fs_lines_occluded.sc b/data/shaders/lines/fs_lines_occluded.sc new file mode 100644 index 0000000..59b2573 --- /dev/null +++ b/data/shaders/lines/fs_lines_occluded.sc @@ -0,0 +1,16 @@ +$input v_color0, v_path_length + +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + if (mod(v_path_length * 20.0, 2) < 1.0) + discard; + + gl_FragColor = v_color0 * 0.8; +} diff --git a/data/shaders/lines/varying.def.sc b/data/shaders/lines/varying.def.sc new file mode 100644 index 0000000..13291c5 --- /dev/null +++ b/data/shaders/lines/varying.def.sc @@ -0,0 +1,9 @@ +vec4 v_color0 : COLOR = vec4(1.0, 0.0, 1.0, 1.0); +float v_path_length : FOG = 0.0; + +vec3 a_position : POSITION; +vec3 a_texcoord0 : TEXCOORD0 = vec3(1.0, 0.0, 1.0); +vec3 a_texcoord1 : TEXCOORD1 = vec3(1.0, 0.0, 1.0); +vec2 a_texcoord2 : TEXCOORD2 = vec2(0.0, 0.0); +vec4 a_color0 : COLOR0; + diff --git a/data/shaders/lines/vs_lines.sc b/data/shaders/lines/vs_lines.sc new file mode 100644 index 0000000..aaafa37 --- /dev/null +++ b/data/shaders/lines/vs_lines.sc @@ -0,0 +1,71 @@ +$input a_position, a_texcoord0, a_texcoord1, a_texcoord2, a_color0 +$output v_color0, v_path_length + +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform vec4 u_line_params; + +#define thickness u_line_params.x +#define miter u_line_params.y +#define aspect u_line_params.z +#define current_pos a_position +#define prev_pos a_texcoord0 +#define next_pos a_texcoord1 +#define direction a_texcoord2.x +#define path_length a_texcoord2.y + +void main() +{ + vec2 aspect_vec = vec2(aspect, 1.0); + + // clip space + vec4 current_proj = mul(u_modelViewProj, vec4(current_pos, 1.0)); + vec4 prev_proj = mul(u_modelViewProj, vec4(prev_pos, 1.0)); + vec4 next_proj = mul(u_modelViewProj, vec4(next_pos, 1.0)); + + // normalized device coordinates [-1,1]x[-1,1] + vec2 current_screen = current_proj.xy / current_proj.w; + vec2 prev_screen = prev_proj.xy / prev_proj.w; + vec2 next_screen = next_proj.xy / next_proj.w; + + float len = thickness; + // uncomment the following line to get a line width + // independent of distance to screen. + // len *= current_proj.w; + + float orientation = direction; + + vec2 dir = vec2(0.0); + if (current_screen == prev_screen) { + dir = normalize(next_screen - current_screen); + } else if (current_screen == next_screen) { + dir = normalize (current_screen - prev_screen); + } else { + vec2 dirA = normalize (current_screen - prev_screen); + if (miter == 1) { + vec2 dirB = normalize(next_screen - current_screen); + //now compute the miter join normal and length + vec2 tangent = normalize(dirA + dirB); + vec2 perp = vec2(-dirA.y, dirA.x); + vec2 miter_vec = vec2(-tangent.y, tangent.x); + dir = tangent; + len = min (2.5 * thickness, thickness / dot(miter_vec, perp)); + } else { + dir = dirA; + } + } + + vec2 normal = vec2(-dir.y, dir.x); + normal *= len/2.0; + normal.x /= aspect; + + vec4 offset = vec4(normal * orientation, 0.0, 0.0); + gl_Position = current_proj + offset; + v_color0 = a_color0; + v_path_length = path_length; +} diff --git a/data/shaders/scene/Makefile b/data/shaders/scene/Makefile new file mode 100644 index 0000000..85a3718 --- /dev/null +++ b/data/shaders/scene/Makefile @@ -0,0 +1,6 @@ +all: fs_sms_mesh.sc fs_sms_mesh_textured.sc fs_sms_shadow.sh varying.def.sc vs_sms_mesh.sc vs_sms_mesh_textured.sc + ../../../build/3rdparty/bgfx/shaderc -f fs_sms_mesh.sc -o ../glsl/fs_sms_mesh.sc.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f fs_sms_mesh_textured.sc -o ../glsl/fs_sms_mesh_textured.sc.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f vs_sms_mesh.sc -o ../glsl/vs_sms_mesh.sc.bin --type vertex --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f vs_sms_mesh_textured.sc -o ../glsl/vs_sms_mesh_textured.sc.bin --type vertex --platform linux -i ../common --varyingdef -p 120 + diff --git a/data/shaders/scene/fs_sms_mesh.sc b/data/shaders/scene/fs_sms_mesh.sc new file mode 100644 index 0000000..949af40 --- /dev/null +++ b/data/shaders/scene/fs_sms_mesh.sc @@ -0,0 +1,11 @@ +$input v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +#define SHADOW_PACKED_DEPTH 0 +#include "fs_sms_shadow.sh" diff --git a/data/shaders/scene/fs_sms_mesh_textured.sc b/data/shaders/scene/fs_sms_mesh_textured.sc new file mode 100644 index 0000000..20c0bde --- /dev/null +++ b/data/shaders/scene/fs_sms_mesh_textured.sc @@ -0,0 +1,12 @@ +$input v_view, v_normal, v_shadowcoord, v_texcoord0 + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +#define SHADOW_PACKED_DEPTH 0 +#define TEXTURED 1 +#include "fs_sms_shadow.sh" diff --git a/data/shaders/scene/fs_sms_shadow.sh b/data/shaders/scene/fs_sms_shadow.sh new file mode 100644 index 0000000..77e7a23 --- /dev/null +++ b/data/shaders/scene/fs_sms_shadow.sh @@ -0,0 +1,115 @@ +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform vec4 u_lightPos; +uniform vec4 u_color; + +uniform vec4 u_shadowMapParams; +#define u_shadowMapSize u_shadowMapParams.x +#define u_shadowMapBias u_shadowMapParams.y + +#if SHADOW_PACKED_DEPTH +SAMPLER2D(u_shadowMap, 0); +# define Sampler sampler2D +#else +SAMPLER2DSHADOW(u_shadowMap, 0); +# define Sampler sampler2DShadow +#endif // SHADOW_PACKED_DEPTH + +#if TEXTURED +SAMPLER2D(sceneDefaultTexture, 1); +#endif + +vec2 lit(vec3 _ld, vec3 _n, vec3 _vd, float _exp) +{ + //diff + float ndotl = dot(_n, _ld); + + //spec + vec3 r = 2.0*ndotl*_n - _ld; //reflect(_ld, _n); + float rdotv = dot(r, _n); + float spec = step(0.0, ndotl) * pow(max(0.0, rdotv), _exp) * (2.0 + _exp)/8.0; + + return max(vec2(ndotl, spec), 0.0); +} + +float hardShadow(Sampler _sampler, vec4 _shadowCoord, float _bias) +{ + vec3 texCoord = _shadowCoord.xyz/_shadowCoord.w; +#if SHADOW_PACKED_DEPTH + return step(texCoord.z-_bias, unpackRgbaToFloat(texture2D(_sampler, texCoord.xy) ) ); +#else + return shadow2D(_sampler, vec3(texCoord.xy, texCoord.z-_bias) ); +#endif // SHADOW_PACKED_DEPTH +} + +float PCF(Sampler _sampler, vec4 _shadowCoord, float _bias, vec2 _texelSize) +{ + vec2 texCoord = _shadowCoord.xy/_shadowCoord.w; + + bool outside = any(greaterThan(texCoord, vec2_splat(1.0))) + || any(lessThan (texCoord, vec2_splat(0.0))) + ; + + if (outside) + { + return 1.0; + } + + float result = 0.0; + vec2 offset = _texelSize * _shadowCoord.w; + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 1.5) * offset, 0.0, 0.0), _bias); + + return result / 16.0; +} + +void main() +{ + vec3 color = u_color.xyz; + + vec3 v = v_view; + vec3 vd = -normalize(v); + vec3 n = v_normal; + vec3 l = u_lightPos.xyz; + vec3 ld = normalize(l); + + vec2 lc = lit(ld, n, vd, 1.0); + + vec2 texelSize = vec2_splat(1.0/u_shadowMapSize); + float visibility = PCF(u_shadowMap, v_shadowcoord, u_shadowMapBias, texelSize); + + vec3 ambient = 0.05 * color; + vec3 brdf = (lc.x * color + lc.y * color) * visibility; + +#if TEXTURED + vec4 texcolor = toLinear (texture2D(sceneDefaultTexture, v_texcoord0) ); + brdf = brdf * texcolor.xyz; + ambient = ambient * texcolor.xyz; +#endif + vec3 final = toGamma(abs(ambient + brdf) ); + + gl_FragColor = vec4(final, 1.0); +} diff --git a/data/shaders/scene/varying.def.sc b/data/shaders/scene/varying.def.sc new file mode 100644 index 0000000..2bd6633 --- /dev/null +++ b/data/shaders/scene/varying.def.sc @@ -0,0 +1,13 @@ +vec3 v_view : TEXCOORD0 = vec3(0.0, 0.0, 0.0); +vec4 v_shadowcoord : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_position : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec3 v_dir : TEXCOORD3 = vec3(0.0, 0.0, 0.0); +vec2 v_texcoord0 : TEXCOORD4 = vec2(0.0, 0.0); +vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); + +vec3 a_position : POSITION; +vec4 a_normal : NORMAL; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; + diff --git a/data/shaders/scene/vs_sms_mesh.sc b/data/shaders/scene/vs_sms_mesh.sc new file mode 100644 index 0000000..585ed14 --- /dev/null +++ b/data/shaders/scene/vs_sms_mesh.sc @@ -0,0 +1,24 @@ +$input a_position, a_normal +$output v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform mat4 u_lightMtx; + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); + + vec4 normal = a_normal * 2.0 - 1.0; + v_normal = normalize(normal.xyz); + v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz; + + const float shadowMapOffset = 0.001; + vec3 posOffset = a_position + normal.xyz * shadowMapOffset; + v_shadowcoord = mul(u_lightMtx, vec4(posOffset, 1.0) ); +} diff --git a/data/shaders/scene/vs_sms_mesh_textured.sc b/data/shaders/scene/vs_sms_mesh_textured.sc new file mode 100644 index 0000000..ec8c072 --- /dev/null +++ b/data/shaders/scene/vs_sms_mesh_textured.sc @@ -0,0 +1,27 @@ +$input a_position, a_normal, a_texcoord0 +$output v_view, v_normal, v_shadowcoord, v_texcoord0 + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform mat4 u_lightMtx; +uniform vec4 u_lightPos; + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); + + vec4 normal = a_normal * 2.0 - 1.0; + v_normal = normalize(normal.xyz); + v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz; + + const float shadowMapOffset = 0.001; + vec3 posOffset = a_position + normal.xyz * shadowMapOffset; + v_shadowcoord = mul(u_lightMtx, vec4(posOffset, 1.0) ); + + v_texcoord0 = a_texcoord0; +} diff --git a/data/shaders/shadowmap/Makefile b/data/shaders/shadowmap/Makefile new file mode 100644 index 0000000..693e602 --- /dev/null +++ b/data/shaders/shadowmap/Makefile @@ -0,0 +1,3 @@ +all: fs_sms_shadow.sc varying.def.sc vs_sms_mesh.sc + ../../../build/3rdparty/bgfx/shaderc -f fs_sms_shadow.sc -o ../glsl/fs_sms_shadow.sc.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f vs_sms_mesh.sc -o ../glsl/vs_sms_mesh.sc.bin --type vertex --platform linux -i ../common --varyingdef -p 120 diff --git a/data/shaders/shadowmap/fs_sms_shadow.sc b/data/shaders/shadowmap/fs_sms_shadow.sc new file mode 100644 index 0000000..5a9356d --- /dev/null +++ b/data/shaders/shadowmap/fs_sms_shadow.sc @@ -0,0 +1,11 @@ +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_FragColor = vec4_splat(0.0); +} diff --git a/data/shaders/shadowmap/varying.def.sc b/data/shaders/shadowmap/varying.def.sc new file mode 100644 index 0000000..2bd6633 --- /dev/null +++ b/data/shaders/shadowmap/varying.def.sc @@ -0,0 +1,13 @@ +vec3 v_view : TEXCOORD0 = vec3(0.0, 0.0, 0.0); +vec4 v_shadowcoord : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_position : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec3 v_dir : TEXCOORD3 = vec3(0.0, 0.0, 0.0); +vec2 v_texcoord0 : TEXCOORD4 = vec2(0.0, 0.0); +vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); + +vec3 a_position : POSITION; +vec4 a_normal : NORMAL; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; + diff --git a/data/shaders/shadowmap/vs_sms_mesh.sc b/data/shaders/shadowmap/vs_sms_mesh.sc new file mode 100644 index 0000000..585ed14 --- /dev/null +++ b/data/shaders/shadowmap/vs_sms_mesh.sc @@ -0,0 +1,24 @@ +$input a_position, a_normal +$output v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform mat4 u_lightMtx; + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); + + vec4 normal = a_normal * 2.0 - 1.0; + v_normal = normalize(normal.xyz); + v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz; + + const float shadowMapOffset = 0.001; + vec3 posOffset = a_position + normal.xyz * shadowMapOffset; + v_shadowcoord = mul(u_lightMtx, vec4(posOffset, 1.0) ); +} diff --git a/data/shaders/skybox/Makefile b/data/shaders/skybox/Makefile new file mode 100644 index 0000000..bc0253c --- /dev/null +++ b/data/shaders/skybox/Makefile @@ -0,0 +1,3 @@ +all: fs_ibl_skybox.sc shaderlib.sh uniforms.sh varying.def.sc vs_ibl_skybox.sc + ../../../build/3rdparty/bgfx/shaderc -f fs_ibl_skybox.sc -o ../glsl/fs_ibl_skybox.sc.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../../build/3rdparty/bgfx/shaderc -f vs_ibl_skybox.sc -o ../glsl/vs_ibl_skybox.sc.bin --type vertex --platform linux -i ../common --varyingdef -p 120 diff --git a/data/shaders/skybox/fs_ibl_skybox.sc b/data/shaders/skybox/fs_ibl_skybox.sc new file mode 100644 index 0000000..d092038 --- /dev/null +++ b/data/shaders/skybox/fs_ibl_skybox.sc @@ -0,0 +1,33 @@ +$input v_dir + +/* + * Copyright 2014-2016 Dario Manesku. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +#include "bgfx_shader.sh" +#include "shaderlib.sh" +#include "uniforms.sh" + +SAMPLERCUBE(s_texCube, 0); +SAMPLERCUBE(s_texCubeIrr, 1); + +void main() +{ + vec3 dir = normalize(v_dir); + + vec4 color; + if (u_bgType == 7.0) + { + color = toLinear(textureCube(s_texCubeIrr, dir)); + } + else + { + float lod = u_bgType; + dir = fixCubeLookup(dir, lod, 256.0); + color = toLinear(textureCubeLod(s_texCube, dir, lod)); + } + color *= exp2(u_exposure); + + gl_FragColor = toFilmic(color); +} diff --git a/data/shaders/skybox/shaderlib.sh b/data/shaders/skybox/shaderlib.sh new file mode 100644 index 0000000..51f9b6a --- /dev/null +++ b/data/shaders/skybox/shaderlib.sh @@ -0,0 +1,386 @@ +/* + * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +#ifndef __SHADERLIB_SH__ +#define __SHADERLIB_SH__ + +vec4 encodeRE8(float _r) +{ + float exponent = ceil(log2(_r) ); + return vec4(_r / exp2(exponent) + , 0.0 + , 0.0 + , (exponent + 128.0) / 255.0 + ); +} + +float decodeRE8(vec4 _re8) +{ + float exponent = _re8.w * 255.0 - 128.0; + return _re8.x * exp2(exponent); +} + +vec4 encodeRGBE8(vec3 _rgb) +{ + vec4 rgbe8; + float maxComponent = max(max(_rgb.x, _rgb.y), _rgb.z); + float exponent = ceil(log2(maxComponent) ); + rgbe8.xyz = _rgb / exp2(exponent); + rgbe8.w = (exponent + 128.0) / 255.0; + return rgbe8; +} + +vec3 decodeRGBE8(vec4 _rgbe8) +{ + float exponent = _rgbe8.w * 255.0 - 128.0; + vec3 rgb = _rgbe8.xyz * exp2(exponent); + return rgb; +} + +vec3 encodeNormalUint(vec3 _normal) +{ + return _normal * 0.5 + 0.5; +} + +vec3 decodeNormalUint(vec3 _encodedNormal) +{ + return _encodedNormal * 2.0 - 1.0; +} + +vec2 encodeNormalSphereMap(vec3 _normal) +{ + return normalize(_normal.xy) * sqrt(_normal.z * 0.5 + 0.5); +} + +vec3 decodeNormalSphereMap(vec2 _encodedNormal) +{ + float zz = dot(_encodedNormal, _encodedNormal) * 2.0 - 1.0; + return vec3(normalize(_encodedNormal.xy) * sqrt(1.0 - zz*zz), zz); +} + +vec2 octahedronWrap(vec2 _val) +{ + // Reference: + // Octahedron normal vector encoding + // http://kriscg.blogspot.com/2014/04/octahedron-normal-vector-encoding.html + return (1.0 - abs(_val.yx) ) + * mix(vec2_splat(-1.0), vec2_splat(1.0), vec2(greaterThanEqual(_val.xy, vec2_splat(0.0) ) ) ); +} + +vec2 encodeNormalOctahedron(vec3 _normal) +{ + _normal /= abs(_normal.x) + abs(_normal.y) + abs(_normal.z); + _normal.xy = _normal.z >= 0.0 ? _normal.xy : octahedronWrap(_normal.xy); + _normal.xy = _normal.xy * 0.5 + 0.5; + return _normal.xy; +} + +vec3 decodeNormalOctahedron(vec2 _encodedNormal) +{ + _encodedNormal = _encodedNormal * 2.0 - 1.0; + + vec3 normal; + normal.z = 1.0 - abs(_encodedNormal.x) - abs(_encodedNormal.y); + normal.xy = normal.z >= 0.0 ? _encodedNormal.xy : octahedronWrap(_encodedNormal.xy); + return normalize(normal); +} + +vec3 convertRGB2XYZ(vec3 _rgb) +{ + // Reference: + // RGB/XYZ Matrices + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + vec3 xyz; + xyz.x = dot(vec3(0.4124564, 0.3575761, 0.1804375), _rgb); + xyz.y = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + xyz.z = dot(vec3(0.0193339, 0.1191920, 0.9503041), _rgb); + return xyz; +} + +vec3 convertXYZ2RGB(vec3 _xyz) +{ + vec3 rgb; + rgb.x = dot(vec3( 3.2404542, -1.5371385, -0.4985314), _xyz); + rgb.y = dot(vec3(-0.9692660, 1.8760108, 0.0415560), _xyz); + rgb.z = dot(vec3( 0.0556434, -0.2040259, 1.0572252), _xyz); + return rgb; +} + +vec3 convertXYZ2Yxy(vec3 _xyz) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_xyY.html + float inv = 1.0/dot(_xyz, vec3(1.0, 1.0, 1.0) ); + return vec3(_xyz.y, _xyz.x*inv, _xyz.y*inv); +} + +vec3 convertYxy2XYZ(vec3 _Yxy) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_xyY_to_XYZ.html + vec3 xyz; + xyz.x = _Yxy.x*_Yxy.y/_Yxy.z; + xyz.y = _Yxy.x; + xyz.z = _Yxy.x*(1.0 - _Yxy.y - _Yxy.z)/_Yxy.z; + return xyz; +} + +vec3 convertRGB2Yxy(vec3 _rgb) +{ + return convertXYZ2Yxy(convertRGB2XYZ(_rgb) ); +} + +vec3 convertYxy2RGB(vec3 _Yxy) +{ + return convertXYZ2RGB(convertYxy2XYZ(_Yxy) ); +} + +vec3 convertRGB2Yuv(vec3 _rgb) +{ + vec3 yuv; + yuv.x = dot(_rgb, vec3(0.299, 0.587, 0.114) ); + yuv.y = (_rgb.x - yuv.x)*0.713 + 0.5; + yuv.z = (_rgb.z - yuv.x)*0.564 + 0.5; + return yuv; +} + +vec3 convertYuv2RGB(vec3 _yuv) +{ + vec3 rgb; + rgb.x = _yuv.x + 1.403*(_yuv.y-0.5); + rgb.y = _yuv.x - 0.344*(_yuv.y-0.5) - 0.714*(_yuv.z-0.5); + rgb.z = _yuv.x + 1.773*(_yuv.z-0.5); + return rgb; +} + +vec3 convertRGB2YIQ(vec3 _rgb) +{ + vec3 yiq; + yiq.x = dot(vec3(0.299, 0.587, 0.114 ), _rgb); + yiq.y = dot(vec3(0.595716, -0.274453, -0.321263), _rgb); + yiq.z = dot(vec3(0.211456, -0.522591, 0.311135), _rgb); + return yiq; +} + +vec3 convertYIQ2RGB(vec3 _yiq) +{ + vec3 rgb; + rgb.x = dot(vec3(1.0, 0.9563, 0.6210), _yiq); + rgb.y = dot(vec3(1.0, -0.2721, -0.6474), _yiq); + rgb.z = dot(vec3(1.0, -1.1070, 1.7046), _yiq); + return rgb; +} + +vec3 toLinear(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(2.2) ); +} + +vec4 toLinear(vec4 _rgba) +{ + return vec4(toLinear(_rgba.xyz), _rgba.w); +} + +vec3 toLinearAccurate(vec3 _rgb) +{ + vec3 lo = _rgb / 12.92; + vec3 hi = pow( (_rgb + 0.055) / 1.055, vec3_splat(2.4) ); + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.04045) ) ) ); + return rgb; +} + +vec4 toLinearAccurate(vec4 _rgba) +{ + return vec4(toLinearAccurate(_rgba.xyz), _rgba.w); +} + +float toGamma(float _r) +{ + return pow(abs(_r), 1.0/2.2); +} + +vec3 toGamma(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(1.0/2.2) ); +} + +vec4 toGamma(vec4 _rgba) +{ + return vec4(toGamma(_rgba.xyz), _rgba.w); +} + +vec3 toGammaAccurate(vec3 _rgb) +{ + vec3 lo = _rgb * 12.92; + vec3 hi = pow(abs(_rgb), vec3_splat(1.0/2.4) ) * 1.055 - 0.055; + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.0031308) ) ) ); + return rgb; +} + +vec4 toGammaAccurate(vec4 _rgba) +{ + return vec4(toGammaAccurate(_rgba.xyz), _rgba.w); +} + +vec3 toReinhard(vec3 _rgb) +{ + return toGamma(_rgb/(_rgb+vec3_splat(1.0) ) ); +} + +vec4 toReinhard(vec4 _rgba) +{ + return vec4(toReinhard(_rgba.xyz), _rgba.w); +} + +vec3 toFilmic(vec3 _rgb) +{ + _rgb = max(vec3_splat(0.0), _rgb - 0.004); + _rgb = (_rgb*(6.2*_rgb + 0.5) ) / (_rgb*(6.2*_rgb + 1.7) + 0.06); + return _rgb; +} + +vec4 toFilmic(vec4 _rgba) +{ + return vec4(toFilmic(_rgba.xyz), _rgba.w); +} + +vec3 toAcesFilmic(vec3 _rgb) +{ + // Reference: + // ACES Filmic Tone Mapping Curve + // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ + float aa = 2.51f; + float bb = 0.03f; + float cc = 2.43f; + float dd = 0.59f; + float ee = 0.14f; + return saturate( (_rgb*(aa*_rgb + bb) )/(_rgb*(cc*_rgb + dd) + ee) ); +} + +vec4 toAcesFilmic(vec4 _rgba) +{ + return vec4(toAcesFilmic(_rgba.xyz), _rgba.w); +} + +vec3 luma(vec3 _rgb) +{ + float yy = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + return vec3_splat(yy); +} + +vec4 luma(vec4 _rgba) +{ + return vec4(luma(_rgba.xyz), _rgba.w); +} + +vec3 conSatBri(vec3 _rgb, vec3 _csb) +{ + vec3 rgb = _rgb * _csb.z; + rgb = mix(luma(rgb), rgb, _csb.y); + rgb = mix(vec3_splat(0.5), rgb, _csb.x); + return rgb; +} + +vec4 conSatBri(vec4 _rgba, vec3 _csb) +{ + return vec4(conSatBri(_rgba.xyz, _csb), _rgba.w); +} + +vec3 posterize(vec3 _rgb, float _numColors) +{ + return floor(_rgb*_numColors) / _numColors; +} + +vec4 posterize(vec4 _rgba, float _numColors) +{ + return vec4(posterize(_rgba.xyz, _numColors), _rgba.w); +} + +vec3 sepia(vec3 _rgb) +{ + vec3 color; + color.x = dot(_rgb, vec3(0.393, 0.769, 0.189) ); + color.y = dot(_rgb, vec3(0.349, 0.686, 0.168) ); + color.z = dot(_rgb, vec3(0.272, 0.534, 0.131) ); + return color; +} + +vec4 sepia(vec4 _rgba) +{ + return vec4(sepia(_rgba.xyz), _rgba.w); +} + +vec3 blendOverlay(vec3 _base, vec3 _blend) +{ + vec3 lt = 2.0 * _base * _blend; + vec3 gte = 1.0 - 2.0 * (1.0 - _base) * (1.0 - _blend); + return mix(lt, gte, step(vec3_splat(0.5), _base) ); +} + +vec4 blendOverlay(vec4 _base, vec4 _blend) +{ + return vec4(blendOverlay(_base.xyz, _blend.xyz), _base.w); +} + +vec3 adjustHue(vec3 _rgb, float _hue) +{ + vec3 yiq = convertRGB2YIQ(_rgb); + float angle = _hue + atan2(yiq.z, yiq.y); + float len = length(yiq.yz); + return convertYIQ2RGB(vec3(yiq.x, len*cos(angle), len*sin(angle) ) ); +} + +vec4 packFloatToRgba(float _value) +{ + const vec4 shift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0); + const vec4 mask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); + vec4 comp = fract(_value * shift); + comp -= comp.xxyz * mask; + return comp; +} + +float unpackRgbaToFloat(vec4 _rgba) +{ + const vec4 shift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0); + return dot(_rgba, shift); +} + +vec2 packHalfFloat(float _value) +{ + const vec2 shift = vec2(256, 1.0); + const vec2 mask = vec2(0, 1.0 / 256.0); + vec2 comp = fract(_value * shift); + comp -= comp.xx * mask; + return comp; +} + +float unpackHalfFloat(vec2 _rg) +{ + const vec2 shift = vec2(1.0 / 256.0, 1.0); + return dot(_rg, shift); +} + +float random(vec2 _uv) +{ + return fract(sin(dot(_uv.xy, vec2(12.9898, 78.233) ) ) * 43758.5453); +} + +vec3 fixCubeLookup(vec3 _v, float _lod, float _topLevelCubeSize) +{ + // Reference: + // Seamless cube-map filtering + // http://the-witness.net/news/2012/02/seamless-cube-map-filtering/ + float ax = abs(_v.x); + float ay = abs(_v.y); + float az = abs(_v.z); + float vmax = max(max(ax, ay), az); + float scale = 1.0 - exp2(_lod) / _topLevelCubeSize; + if (ax != vmax) { _v.x *= scale; } + if (ay != vmax) { _v.y *= scale; } + if (az != vmax) { _v.z *= scale; } + return _v; +} + +#endif // __SHADERLIB_SH__ diff --git a/data/shaders/skybox/uniforms.sh b/data/shaders/skybox/uniforms.sh new file mode 100644 index 0000000..61354fc --- /dev/null +++ b/data/shaders/skybox/uniforms.sh @@ -0,0 +1,28 @@ +/* + * Copyright 2016 Dario Manesku. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +uniform vec4 u_params[12]; +#define u_mtx0 u_params[0] +#define u_mtx1 u_params[1] +#define u_mtx2 u_params[2] +#define u_mtx3 u_params[3] +#define u_glossiness u_params[4].x +#define u_reflectivity u_params[4].y +#define u_exposure u_params[4].z +#define u_bgType u_params[4].w +#define u_metalOrSpec u_params[5].x +#define u_unused u_params[5].yzw +#define u_doDiffuse u_params[6].x +#define u_doSpecular u_params[6].y +#define u_doDiffuseIbl u_params[6].z +#define u_doSpecularIbl u_params[6].w +#define u_camPos u_params[7].xyz +#define u_unused7 u_params[7].w +#define u_rgbDiff u_params[8] +#define u_rgbSpec u_params[9] +#define u_lightDir u_params[10].xyz +#define u_unused10 u_params[10].w +#define u_lightCol u_params[11].xyz +#define u_unused11 u_params[11].w diff --git a/data/shaders/skybox/varying.def.sc b/data/shaders/skybox/varying.def.sc new file mode 100644 index 0000000..2bd6633 --- /dev/null +++ b/data/shaders/skybox/varying.def.sc @@ -0,0 +1,13 @@ +vec3 v_view : TEXCOORD0 = vec3(0.0, 0.0, 0.0); +vec4 v_shadowcoord : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_position : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec3 v_dir : TEXCOORD3 = vec3(0.0, 0.0, 0.0); +vec2 v_texcoord0 : TEXCOORD4 = vec2(0.0, 0.0); +vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); + +vec3 a_position : POSITION; +vec4 a_normal : NORMAL; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; + diff --git a/data/shaders/skybox/vs_ibl_skybox.sc b/data/shaders/skybox/vs_ibl_skybox.sc new file mode 100644 index 0000000..f3a15e0 --- /dev/null +++ b/data/shaders/skybox/vs_ibl_skybox.sc @@ -0,0 +1,29 @@ +$input a_position, a_texcoord0 +$output v_dir + +/* + * Copyright 2014-2016 Dario Manesku. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +#include "../common/common.sh" +#include "uniforms.sh" + +uniform mat4 u_mtx; + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); + + float fov = radians(45.0); + float height = tan(fov*0.5); + float aspect = height*(u_viewRect.z / u_viewRect.w); + vec2 tex = (2.0*a_texcoord0-1.0) * vec2(aspect, height); + + mat4 mtx; + mtx[0] = u_mtx0; + mtx[1] = u_mtx1; + mtx[2] = u_mtx2; + mtx[3] = u_mtx3; + v_dir = instMul(mtx, vec4(tex, 1.0, 0.0) ).xyz; +} diff --git a/data/shaders/src/Makefile b/data/shaders/src/Makefile new file mode 100644 index 0000000..80711b8 --- /dev/null +++ b/data/shaders/src/Makefile @@ -0,0 +1,5 @@ +all: fs_sms_mesh.sc vs_sms_mesh.sc varying.def.sc fs_sms_shadow.sh + ../../build/shaderc -f fs_sms_mesh.sc -o ../glsl/fs_sms_mesh.bin --type fragment --platform linux -i ../common --varyingdef -p 120 + ../../build/shaderc -f vs_sms_mesh.sc -o ../glsl/vs_sms_mesh.bin --type vertex --platform linux -i ../common --varyingdef -p 120 + ../../build/shaderc -f fs_sms_mesh.sc -o ../glsl/fs_sms_mesh.bin --type fragment --platform linux -i ../common --varyingdef -p 120 --depends + diff --git a/data/shaders/src/bgfx_shader.sh b/data/shaders/src/bgfx_shader.sh new file mode 100644 index 0000000..f607f17 --- /dev/null +++ b/data/shaders/src/bgfx_shader.sh @@ -0,0 +1,466 @@ +/* + * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +#ifndef BGFX_SHADER_H_HEADER_GUARD +#define BGFX_SHADER_H_HEADER_GUARD + +#if !defined(BGFX_CONFIG_MAX_BONES) +# define BGFX_CONFIG_MAX_BONES 32 +#endif // !defined(BGFX_CONFIG_MAX_BONES) + +#ifndef __cplusplus + +#if BGFX_SHADER_LANGUAGE_HLSL > 3 +# define BRANCH [branch] +# define LOOP [loop] +# define UNROLL [unroll] +#else +# define BRANCH +# define LOOP +# define UNROLL +#endif // BGFX_SHADER_LANGUAGE_HLSL > 3 + +#if BGFX_SHADER_LANGUAGE_HLSL > 3 && BGFX_SHADER_TYPE_FRAGMENT +# define EARLY_DEPTH_STENCIL [earlydepthstencil] +#else +# define EARLY_DEPTH_STENCIL +#endif // BGFX_SHADER_LANGUAGE_HLSL > 3 && BGFX_SHADER_TYPE_FRAGMENT + +#if BGFX_SHADER_LANGUAGE_HLSL +# define CONST(_x) static const _x +# define dFdx(_x) ddx(_x) +# define dFdy(_y) ddy(-_y) +# define inversesqrt(_x) rsqrt(_x) +# define fract(_x) frac(_x) + +# define bvec2 bool2 +# define bvec3 bool3 +# define bvec4 bool4 + +# if BGFX_SHADER_LANGUAGE_HLSL > 3 +# if BGFX_SHADER_LANGUAGE_HLSL > 4 +# define dFdxCoarse(_x) ddx_coarse(_x) +# define dFdxFine(_x) ddx_fine(_x) +# define dFdyCoarse(_y) ddy_coarse(-_y) +# define dFdyFine(_y) ddy_fine(-_y) +# endif // BGFX_SHADER_LANGUAGE_HLSL > 4 + +float intBitsToFloat(int _x) { return asfloat(_x); } +vec2 intBitsToFloat(uint2 _x) { return asfloat(_x); } +vec3 intBitsToFloat(uint3 _x) { return asfloat(_x); } +vec4 intBitsToFloat(uint4 _x) { return asfloat(_x); } + +float uintBitsToFloat(uint _x) { return asfloat(_x); } +vec2 uintBitsToFloat(uint2 _x) { return asfloat(_x); } +vec3 uintBitsToFloat(uint3 _x) { return asfloat(_x); } +vec4 uintBitsToFloat(uint4 _x) { return asfloat(_x); } + +uint floatBitsToUint(float _x) { return asuint(_x); } +uvec2 floatBitsToUint(vec2 _x) { return asuint(_x); } +uvec3 floatBitsToUint(vec3 _x) { return asuint(_x); } +uvec4 floatBitsToUint(vec4 _x) { return asuint(_x); } + +int floatBitsToInt(float _x) { return asint(_x); } +ivec2 floatBitsToInt(vec2 _x) { return asint(_x); } +ivec3 floatBitsToInt(vec3 _x) { return asint(_x); } +ivec4 floatBitsToInt(vec4 _x) { return asint(_x); } + +uint bitfieldReverse(uint _x) { return reversebits(_x); } +uint2 bitfieldReverse(uint2 _x) { return reversebits(_x); } +uint3 bitfieldReverse(uint3 _x) { return reversebits(_x); } +uint4 bitfieldReverse(uint4 _x) { return reversebits(_x); } + +uint packHalf2x16(vec2 _x) +{ + return (f32tof16(_x.x)<<16) | f32tof16(_x.y); +} + +vec2 unpackHalf2x16(uint _x) +{ + return vec2(f16tof32(_x >> 16), f16tof32(_x) ); +} + +struct BgfxSampler2D +{ + SamplerState m_sampler; + Texture2D m_texture; +}; + +struct BgfxISampler2D +{ + Texture2D m_texture; +}; + +struct BgfxUSampler2D +{ + Texture2D m_texture; +}; + +struct BgfxSampler2DArray +{ + SamplerState m_sampler; + Texture2DArray m_texture; +}; + +struct BgfxSampler2DShadow +{ + SamplerComparisonState m_sampler; + Texture2D m_texture; +}; + +struct BgfxSampler3D +{ + SamplerState m_sampler; + Texture3D m_texture; +}; + +struct BgfxISampler3D +{ + Texture3D m_texture; +}; + +struct BgfxUSampler3D +{ + Texture3D m_texture; +}; + +struct BgfxSamplerCube +{ + SamplerState m_sampler; + TextureCube m_texture; +}; + +struct BgfxSampler2DMS +{ + Texture2DMS m_texture; +}; + +vec4 bgfxTexture2D(BgfxSampler2D _sampler, vec2 _coord) +{ + return _sampler.m_texture.Sample(_sampler.m_sampler, _coord); +} + +vec4 bgfxTexture2DLod(BgfxSampler2D _sampler, vec2 _coord, float _level) +{ + return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level); +} + +vec4 bgfxTexture2DProj(BgfxSampler2D _sampler, vec3 _coord) +{ + vec2 coord = _coord.xy * rcp(_coord.z); + return _sampler.m_texture.Sample(_sampler.m_sampler, coord); +} + +vec4 bgfxTexture2DProj(BgfxSampler2D _sampler, vec4 _coord) +{ + vec2 coord = _coord.xy * rcp(_coord.w); + return _sampler.m_texture.Sample(_sampler.m_sampler, coord); +} + +vec4 bgfxTexture2DArray(BgfxSampler2DArray _sampler, vec3 _coord) +{ + return _sampler.m_texture.Sample(_sampler.m_sampler, _coord); +} + +vec4 bgfxTexture2DArrayLod(BgfxSampler2DArray _sampler, vec3 _coord, float _lod) +{ + return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _lod); +} + +float bgfxShadow2D(BgfxSampler2DShadow _sampler, vec3 _coord) +{ + return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, _coord.xy, _coord.z); +} + +float bgfxShadow2DProj(BgfxSampler2DShadow _sampler, vec4 _coord) +{ + vec3 coord = _coord.xyz * rcp(_coord.w); + return _sampler.m_texture.SampleCmpLevelZero(_sampler.m_sampler, coord.xy, coord.z); +} + +vec4 bgfxTexture3D(BgfxSampler3D _sampler, vec3 _coord) +{ + return _sampler.m_texture.Sample(_sampler.m_sampler, _coord); +} + +vec4 bgfxTexture3DLod(BgfxSampler3D _sampler, vec3 _coord, float _level) +{ + return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level); +} + +ivec4 bgfxTexture3D(BgfxISampler3D _sampler, vec3 _coord) +{ + ivec3 size; + _sampler.m_texture.GetDimensions(size.x, size.y, size.z); + return _sampler.m_texture.Load(ivec4(_coord * size, 0) ); +} + +uvec4 bgfxTexture3D(BgfxUSampler3D _sampler, vec3 _coord) +{ + uvec3 size; + _sampler.m_texture.GetDimensions(size.x, size.y, size.z); + return _sampler.m_texture.Load(uvec4(_coord * size, 0) ); +} + +vec4 bgfxTextureCube(BgfxSamplerCube _sampler, vec3 _coord) +{ + return _sampler.m_texture.Sample(_sampler.m_sampler, _coord); +} + +vec4 bgfxTextureCubeLod(BgfxSamplerCube _sampler, vec3 _coord, float _level) +{ + return _sampler.m_texture.SampleLevel(_sampler.m_sampler, _coord, _level); +} + +vec4 bgfxTexelFetch(BgfxSampler2D _sampler, ivec2 _coord, int _lod) +{ + return _sampler.m_texture.Load(ivec3(_coord, _lod) ); +} + +ivec4 bgfxTexelFetch(BgfxISampler2D _sampler, ivec2 _coord, int _lod) +{ + return _sampler.m_texture.Load(ivec3(_coord, _lod) ); +} + +uvec4 bgfxTexelFetch(BgfxUSampler2D _sampler, ivec2 _coord, int _lod) +{ + return _sampler.m_texture.Load(ivec3(_coord, _lod) ); +} + +vec4 bgfxTexelFetch(BgfxSampler2DMS _sampler, ivec2 _coord, int _sampleIdx) +{ + return _sampler.m_texture.Load(_coord, _sampleIdx); +} + +vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod) +{ + return _sampler.m_texture.Load(ivec4(_coord, _lod) ); +} + +# define SAMPLER2D(_name, _reg) \ + uniform SamplerState _name ## Sampler : register(s[_reg]); \ + uniform Texture2D _name ## Texture : register(t[_reg]); \ + static BgfxSampler2D _name = { _name ## Sampler, _name ## Texture } +# define ISAMPLER2D(_name, _reg) \ + uniform Texture2D _name ## Texture : register(t[_reg]); \ + static BgfxISampler2D _name = { _name ## Texture } +# define USAMPLER2D(_name, _reg) \ + uniform Texture2D _name ## Texture : register(t[_reg]); \ + static BgfxUSampler2D _name = { _name ## Texture } +# define sampler2D BgfxSampler2D +# define texture2D(_sampler, _coord) bgfxTexture2D(_sampler, _coord) +# define texture2DLod(_sampler, _coord, _level) bgfxTexture2DLod(_sampler, _coord, _level) +# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord) + +# define SAMPLER2DARRAY(_name, _reg) \ + uniform SamplerState _name ## Sampler : register(s[_reg]); \ + uniform Texture2DArray _name ## Texture : register(t[_reg]); \ + static BgfxSampler2DArray _name = { _name ## Sampler, _name ## Texture } +# define sampler2DArray BgfxSampler2DArray +# define texture2DArray(_sampler, _coord) bgfxTexture2DArray(_sampler, _coord) +# define texture2DArrayLod(_sampler, _coord, _lod) bgfxTexture2DArrayLod(_sampler, _coord, _lod) + +# define SAMPLER2DMS(_name, _reg) \ + uniform Texture2DMS _name ## Texture : register(t[_reg]); \ + static BgfxSampler2DMS _name = { _name ## Texture } +# define sampler2DMS BgfxSampler2DMS + +# define SAMPLER2DSHADOW(_name, _reg) \ + uniform SamplerComparisonState _name ## Sampler : register(s[_reg]); \ + uniform Texture2D _name ## Texture : register(t[_reg]); \ + static BgfxSampler2DShadow _name = { _name ## Sampler, _name ## Texture } +# define sampler2DShadow BgfxSampler2DShadow +# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord) +# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord) + +# define SAMPLER3D(_name, _reg) \ + uniform SamplerState _name ## Sampler : register(s[_reg]); \ + uniform Texture3D _name ## Texture : register(t[_reg]); \ + static BgfxSampler3D _name = { _name ## Sampler, _name ## Texture } +# define ISAMPLER3D(_name, _reg) \ + uniform Texture3D _name ## Texture : register(t[_reg]); \ + static BgfxISampler3D _name = { _name ## Texture } +# define USAMPLER3D(_name, _reg) \ + uniform Texture3D _name ## Texture : register(t[_reg]); \ + static BgfxUSampler3D _name = { _name ## Texture } +# define sampler3D BgfxSampler3D +# define texture3D(_sampler, _coord) bgfxTexture3D(_sampler, _coord) +# define texture3DLod(_sampler, _coord, _level) bgfxTexture3DLod(_sampler, _coord, _level) + +# define SAMPLERCUBE(_name, _reg) \ + uniform SamplerState _name ## Sampler : register(s[_reg]); \ + uniform TextureCube _name ## Texture : register(t[_reg]); \ + static BgfxSamplerCube _name = { _name ## Sampler, _name ## Texture } +# define samplerCube BgfxSamplerCube +# define textureCube(_sampler, _coord) bgfxTextureCube(_sampler, _coord) +# define textureCubeLod(_sampler, _coord, _level) bgfxTextureCubeLod(_sampler, _coord, _level) + +# define texelFetch(_sampler, _coord, _lod) bgfxTexelFetch(_sampler, _coord, _lod) +# else + +# define sampler2DShadow sampler2D + +vec4 bgfxTexture2DProj(sampler2D _sampler, vec3 _coord) +{ + return tex2Dproj(_sampler, vec4(_coord.xy, 0.0, _coord.z) ); +} + +vec4 bgfxTexture2DProj(sampler2D _sampler, vec4 _coord) +{ + return tex2Dproj(_sampler, _coord); +} + +float bgfxShadow2D(sampler2DShadow _sampler, vec3 _coord) +{ +#if 0 + float occluder = tex2D(_sampler, _coord.xy).x; + return step(_coord.z, occluder); +#else + return tex2Dproj(_sampler, vec4(_coord.xy, _coord.z, 1.0) ).x; +#endif // 0 +} + +float bgfxShadow2DProj(sampler2DShadow _sampler, vec4 _coord) +{ +#if 0 + vec3 coord = _coord.xyz * rcp(_coord.w); + float occluder = tex2D(_sampler, coord.xy).x; + return step(coord.z, occluder); +#else + return tex2Dproj(_sampler, _coord).x; +#endif // 0 +} + +# define SAMPLER2D(_name, _reg) uniform sampler2D _name : register(s ## _reg) +# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name : register(s ## _reg) +# define texture2D(_sampler, _coord) tex2D(_sampler, _coord) +# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord) + +# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name : register(s ## _reg) +# define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord) +# define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord) + +# define SAMPLER3D(_name, _reg) uniform sampler3D _name : register(s ## _reg) +# define texture3D(_sampler, _coord) tex3D(_sampler, _coord) + +# define SAMPLERCUBE(_name, _reg) uniform samplerCUBE _name : register(s[_reg]) +# define textureCube(_sampler, _coord) texCUBE(_sampler, _coord) + +# if BGFX_SHADER_LANGUAGE_HLSL == 2 +# define texture2DLod(_sampler, _coord, _level) tex2D(_sampler, (_coord).xy) +# define texture3DLod(_sampler, _coord, _level) tex3D(_sampler, (_coord).xyz) +# define textureCubeLod(_sampler, _coord, _level) texCUBE(_sampler, (_coord).xyz) +# else +# define texture2DLod(_sampler, _coord, _level) tex2Dlod(_sampler, vec4( (_coord).xy, 0.0, _level) ) +# define texture3DLod(_sampler, _coord, _level) tex3Dlod(_sampler, vec4( (_coord).xyz, _level) ) +# define textureCubeLod(_sampler, _coord, _level) texCUBElod(_sampler, vec4( (_coord).xyz, _level) ) +# endif // BGFX_SHADER_LANGUAGE_HLSL == 2 + +# endif // BGFX_SHADER_LANGUAGE_HLSL > 3 + +vec3 instMul(vec3 _vec, mat3 _mtx) { return mul(_mtx, _vec); } +vec3 instMul(mat3 _mtx, vec3 _vec) { return mul(_vec, _mtx); } +vec4 instMul(vec4 _vec, mat4 _mtx) { return mul(_mtx, _vec); } +vec4 instMul(mat4 _mtx, vec4 _vec) { return mul(_vec, _mtx); } + +bvec2 lessThan(vec2 _a, vec2 _b) { return _a < _b; } +bvec3 lessThan(vec3 _a, vec3 _b) { return _a < _b; } +bvec4 lessThan(vec4 _a, vec4 _b) { return _a < _b; } + +bvec2 lessThanEqual(vec2 _a, vec2 _b) { return _a <= _b; } +bvec3 lessThanEqual(vec3 _a, vec3 _b) { return _a <= _b; } +bvec4 lessThanEqual(vec4 _a, vec4 _b) { return _a <= _b; } + +bvec2 greaterThan(vec2 _a, vec2 _b) { return _a > _b; } +bvec3 greaterThan(vec3 _a, vec3 _b) { return _a > _b; } +bvec4 greaterThan(vec4 _a, vec4 _b) { return _a > _b; } + +bvec2 greaterThanEqual(vec2 _a, vec2 _b) { return _a >= _b; } +bvec3 greaterThanEqual(vec3 _a, vec3 _b) { return _a >= _b; } +bvec4 greaterThanEqual(vec4 _a, vec4 _b) { return _a >= _b; } + +bvec2 notEqual(vec2 _a, vec2 _b) { return _a != _b; } +bvec3 notEqual(vec3 _a, vec3 _b) { return _a != _b; } +bvec4 notEqual(vec4 _a, vec4 _b) { return _a != _b; } + +bvec2 equal(vec2 _a, vec2 _b) { return _a == _b; } +bvec3 equal(vec3 _a, vec3 _b) { return _a == _b; } +bvec4 equal(vec4 _a, vec4 _b) { return _a == _b; } + +float mix(float _a, float _b, float _t) { return lerp(_a, _b, _t); } +vec2 mix(vec2 _a, vec2 _b, vec2 _t) { return lerp(_a, _b, _t); } +vec3 mix(vec3 _a, vec3 _b, vec3 _t) { return lerp(_a, _b, _t); } +vec4 mix(vec4 _a, vec4 _b, vec4 _t) { return lerp(_a, _b, _t); } + +float mod(float _a, float _b) { return _a - _b * floor(_a / _b); } +vec2 mod(vec2 _a, vec2 _b) { return _a - _b * floor(_a / _b); } +vec3 mod(vec3 _a, vec3 _b) { return _a - _b * floor(_a / _b); } +vec4 mod(vec4 _a, vec4 _b) { return _a - _b * floor(_a / _b); } + +#else +# define CONST(_x) const _x +# define atan2(_x, _y) atan(_x, _y) +# define mul(_a, _b) ( (_a) * (_b) ) +# define saturate(_x) clamp(_x, 0.0, 1.0) +# define SAMPLER2D(_name, _reg) uniform sampler2D _name +# define SAMPLER2DMS(_name, _reg) uniform sampler2DMS _name +# define SAMPLER3D(_name, _reg) uniform sampler3D _name +# define SAMPLERCUBE(_name, _reg) uniform samplerCube _name +# define SAMPLER2DSHADOW(_name, _reg) uniform sampler2DShadow _name + +# define SAMPLER2DARRAY(_name, _reg) uniform sampler2DArray _name +# define SAMPLER2DMSARRAY(_name, _reg) uniform sampler2DMSArray _name +# define SAMPLERCUBEARRAY(_name, _reg) uniform samplerCubeArray _name +# define SAMPLER2DARRAYSHADOW(_name, _reg) uniform sampler2DArrayShadow _name + +# if BGFX_SHADER_LANGUAGE_GLSL >= 130 +# define ISAMPLER2D(_name, _reg) uniform isampler2D _name +# define USAMPLER2D(_name, _reg) uniform usampler2D _name +# define ISAMPLER3D(_name, _reg) uniform isampler3D _name +# define USAMPLER3D(_name, _reg) uniform usampler3D _name + +# define texture2D(_sampler, _coord) texture(_sampler, _coord) +# define texture2DArray(_sampler, _coord) texture(_sampler, _coord) +# define texture3D(_sampler, _coord) texture(_sampler, _coord) +# endif // BGFX_SHADER_LANGUAGE_GLSL >= 130 + +vec3 instMul(vec3 _vec, mat3 _mtx) { return mul(_vec, _mtx); } +vec3 instMul(mat3 _mtx, vec3 _vec) { return mul(_mtx, _vec); } +vec4 instMul(vec4 _vec, mat4 _mtx) { return mul(_vec, _mtx); } +vec4 instMul(mat4 _mtx, vec4 _vec) { return mul(_mtx, _vec); } + +float rcp(float _a) { return 1.0/_a; } +vec2 rcp(vec2 _a) { return vec2(1.0)/_a; } +vec3 rcp(vec3 _a) { return vec3(1.0)/_a; } +vec4 rcp(vec4 _a) { return vec4(1.0)/_a; } +#endif // BGFX_SHADER_LANGUAGE_* + +vec2 vec2_splat(float _x) { return vec2(_x, _x); } +vec3 vec3_splat(float _x) { return vec3(_x, _x, _x); } +vec4 vec4_splat(float _x) { return vec4(_x, _x, _x, _x); } + +#if BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL +uvec2 uvec2_splat(uint _x) { return uvec2(_x, _x); } +uvec3 uvec3_splat(uint _x) { return uvec3(_x, _x, _x); } +uvec4 uvec4_splat(uint _x) { return uvec4(_x, _x, _x, _x); } +#endif // BGFX_SHADER_LANGUAGE_GLSL >= 130 || BGFX_SHADER_LANGUAGE_HLSL + +uniform vec4 u_viewRect; +uniform vec4 u_viewTexel; +uniform mat4 u_view; +uniform mat4 u_invView; +uniform mat4 u_proj; +uniform mat4 u_invProj; +uniform mat4 u_viewProj; +uniform mat4 u_invViewProj; +uniform mat4 u_model[BGFX_CONFIG_MAX_BONES]; +uniform mat4 u_modelView; +uniform mat4 u_modelViewProj; +uniform vec4 u_alphaRef4; +#define u_alphaRef u_alphaRef4.x + +#endif // __cplusplus + +#endif // BGFX_SHADER_H_HEADER_GUARD diff --git a/data/shaders/src/fs_cubes.sc b/data/shaders/src/fs_cubes.sc new file mode 100644 index 0000000..4fc0a0a --- /dev/null +++ b/data/shaders/src/fs_cubes.sc @@ -0,0 +1,13 @@ +$input v_color0 + +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_FragColor = v_color0; +} diff --git a/data/shaders/src/fs_sms_mesh.sc b/data/shaders/src/fs_sms_mesh.sc new file mode 100644 index 0000000..949af40 --- /dev/null +++ b/data/shaders/src/fs_sms_mesh.sc @@ -0,0 +1,11 @@ +$input v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +#define SHADOW_PACKED_DEPTH 0 +#include "fs_sms_shadow.sh" diff --git a/data/shaders/src/fs_sms_mesh_pd.sc b/data/shaders/src/fs_sms_mesh_pd.sc new file mode 100644 index 0000000..ca27f46 --- /dev/null +++ b/data/shaders/src/fs_sms_mesh_pd.sc @@ -0,0 +1,11 @@ +$input v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +#define SHADOW_PACKED_DEPTH 1 +#include "fs_sms_shadow.sh" diff --git a/data/shaders/src/fs_sms_mesh_pd_textured.sc b/data/shaders/src/fs_sms_mesh_pd_textured.sc new file mode 100644 index 0000000..6ab5628 --- /dev/null +++ b/data/shaders/src/fs_sms_mesh_pd_textured.sc @@ -0,0 +1,12 @@ +$input v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +#define SHADOW_PACKED_DEPTH 1 +#define TEXTURED 1 +#include "fs_sms_shadow.sh" diff --git a/data/shaders/src/fs_sms_shadow.sh b/data/shaders/src/fs_sms_shadow.sh new file mode 100644 index 0000000..77e7a23 --- /dev/null +++ b/data/shaders/src/fs_sms_shadow.sh @@ -0,0 +1,115 @@ +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform vec4 u_lightPos; +uniform vec4 u_color; + +uniform vec4 u_shadowMapParams; +#define u_shadowMapSize u_shadowMapParams.x +#define u_shadowMapBias u_shadowMapParams.y + +#if SHADOW_PACKED_DEPTH +SAMPLER2D(u_shadowMap, 0); +# define Sampler sampler2D +#else +SAMPLER2DSHADOW(u_shadowMap, 0); +# define Sampler sampler2DShadow +#endif // SHADOW_PACKED_DEPTH + +#if TEXTURED +SAMPLER2D(sceneDefaultTexture, 1); +#endif + +vec2 lit(vec3 _ld, vec3 _n, vec3 _vd, float _exp) +{ + //diff + float ndotl = dot(_n, _ld); + + //spec + vec3 r = 2.0*ndotl*_n - _ld; //reflect(_ld, _n); + float rdotv = dot(r, _n); + float spec = step(0.0, ndotl) * pow(max(0.0, rdotv), _exp) * (2.0 + _exp)/8.0; + + return max(vec2(ndotl, spec), 0.0); +} + +float hardShadow(Sampler _sampler, vec4 _shadowCoord, float _bias) +{ + vec3 texCoord = _shadowCoord.xyz/_shadowCoord.w; +#if SHADOW_PACKED_DEPTH + return step(texCoord.z-_bias, unpackRgbaToFloat(texture2D(_sampler, texCoord.xy) ) ); +#else + return shadow2D(_sampler, vec3(texCoord.xy, texCoord.z-_bias) ); +#endif // SHADOW_PACKED_DEPTH +} + +float PCF(Sampler _sampler, vec4 _shadowCoord, float _bias, vec2 _texelSize) +{ + vec2 texCoord = _shadowCoord.xy/_shadowCoord.w; + + bool outside = any(greaterThan(texCoord, vec2_splat(1.0))) + || any(lessThan (texCoord, vec2_splat(0.0))) + ; + + if (outside) + { + return 1.0; + } + + float result = 0.0; + vec2 offset = _texelSize * _shadowCoord.w; + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 1.5) * offset, 0.0, 0.0), _bias); + + return result / 16.0; +} + +void main() +{ + vec3 color = u_color.xyz; + + vec3 v = v_view; + vec3 vd = -normalize(v); + vec3 n = v_normal; + vec3 l = u_lightPos.xyz; + vec3 ld = normalize(l); + + vec2 lc = lit(ld, n, vd, 1.0); + + vec2 texelSize = vec2_splat(1.0/u_shadowMapSize); + float visibility = PCF(u_shadowMap, v_shadowcoord, u_shadowMapBias, texelSize); + + vec3 ambient = 0.05 * color; + vec3 brdf = (lc.x * color + lc.y * color) * visibility; + +#if TEXTURED + vec4 texcolor = toLinear (texture2D(sceneDefaultTexture, v_texcoord0) ); + brdf = brdf * texcolor.xyz; + ambient = ambient * texcolor.xyz; +#endif + vec3 final = toGamma(abs(ambient + brdf) ); + + gl_FragColor = vec4(final, 1.0); +} diff --git a/data/shaders/src/fs_sms_shadow.sh.orig b/data/shaders/src/fs_sms_shadow.sh.orig new file mode 100644 index 0000000..b3c7f8b --- /dev/null +++ b/data/shaders/src/fs_sms_shadow.sh.orig @@ -0,0 +1,102 @@ +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +uniform vec4 u_lightPos; +uniform vec4 u_color; +#if SHADOW_PACKED_DEPTH +SAMPLER2D(u_shadowMap, 0); +# define Sampler sampler2D +#else +SAMPLER2DSHADOW(u_shadowMap, 0); +# define Sampler sampler2DShadow +#endif // SHADOW_PACKED_DEPTH + +vec2 lit(vec3 _ld, vec3 _n, vec3 _vd, float _exp) +{ + //diff + float ndotl = dot(_n, _ld); + + //spec + vec3 r = 2.0*ndotl*_n - _ld; //reflect(_ld, _n); + float rdotv = dot(r, _vd); + float spec = step(0.0, ndotl) * pow(max(0.0, rdotv), _exp) * (2.0 + _exp)/8.0; + + return max(vec2(ndotl, spec), 0.0); +} + +float hardShadow(Sampler _sampler, vec4 _shadowCoord, float _bias) +{ + vec3 texCoord = _shadowCoord.xyz/_shadowCoord.w; +#if SHADOW_PACKED_DEPTH + return step(texCoord.z-_bias, unpackRgbaToFloat(texture2D(_sampler, texCoord.xy) ) ); +#else + return shadow2D(_sampler, vec3(texCoord.xy, texCoord.z-_bias) ); +#endif // SHADOW_PACKED_DEPTH +} + +float PCF(Sampler _sampler, vec4 _shadowCoord, float _bias, vec2 _texelSize) +{ + vec2 texCoord = _shadowCoord.xy/_shadowCoord.w; + + bool outside = any(greaterThan(texCoord, vec2_splat(1.0))) + || any(lessThan (texCoord, vec2_splat(0.0))) + ; + + if (outside) + { + return 1.0; + } + + float result = 0.0; + vec2 offset = _texelSize * _shadowCoord.w; + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-1.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(-0.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(0.5, 1.5) * offset, 0.0, 0.0), _bias); + + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -1.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, -0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 0.5) * offset, 0.0, 0.0), _bias); + result += hardShadow(_sampler, _shadowCoord + vec4(vec2(1.5, 1.5) * offset, 0.0, 0.0), _bias); + + return result / 16.0; +} + +void main() +{ + float shadowMapBias = 0.0001; + vec3 color = u_color.xyz; + + vec3 v = v_view; + vec3 vd = -normalize(v); + vec3 n = v_normal; + vec3 l = u_lightPos.xyz; + vec3 ld = -normalize(l); + + vec2 lc = lit(ld, n, vd, 1.0); + + vec2 texelSize = vec2_splat(1.0/1024.0); + float visibility = PCF(u_shadowMap, v_shadowcoord, shadowMapBias, texelSize); +// float visibility = hardShadow(u_shadowMap, v_shadowcoord, shadowMapBias); + + vec3 ambient = 0.1 * color; + vec3 brdf = (lc.x + lc.y) * color * visibility; + + vec3 final = toGamma(abs(ambient + brdf) ); + gl_FragColor = vec4(final, 1.0); +} diff --git a/data/shaders/src/mesh.out b/data/shaders/src/mesh.out new file mode 100644 index 0000000000000000000000000000000000000000..44664dc87eb6210d28a25be5ed51c4aff443aad3 GIT binary patch literal 8825 zcmcJVOOM+&6os84Knr)(f53JncP5I(mplm4O@bhs0s+#!q0A^VF6@zEd!9l5dk?AS z6(uSvpd^@B)aB*lkVoH${_y$Z%U|~YetbEb->tWs>zmW3?D*4*+3dya=ezY~w#^Rt z)o*v}<4tmvJ^Y>QKP87`S492VC`Tpy`~8pE>^?a>ZEmmG4KnW8eR?U_{rWaL?2_%9 zxpPzEW}f^q%MMo^5vKb6CVhA_zq{RhMV>mdWOc`TZrfq>+-nW0j@o7qdv;8A`)zvQ z??2nIqp2z$z05XOY?o|qS+JOYo3px4oNX`H(VJ$GV5i+4BVThXm(mYm9JqLD%%#Z`7zYWfX5zhXTATmyOyod_?`CH_fy%e8P<& z2+&!^Z0kW##<9QNvSqkjEX>V6nGM+`k1RmpdET3%B4Ys$mxw8=+A5|}+1&+uRo>)_ zb21ybk3k%c{Xp_BWEBt51VCEQ|v@I9;<+<%xJ#Tj4>r?ueZa-s&*UH>#UL%2t z34$nGzJ>smzWE{#AJM#R%q$0@f^HQb(&OFsw2oVi7d=~<;_|bZTC(IJHwH$F9&Ec` zvTR${yD&L6Us;gcJ_Xl@G&!Y*e{K@2zcTT8J{XMUoZ*L=JN6Bgs-`c{v`HC6Hv4y$ zZjY%OVj9?{$75%9tFqNU&r$ZO=)^^{xf7JlVCtSh)*OC!YiU-pp}xXH^ar$)ZxV6l(eGMyY27qP!AzCX{b=TQ$Fo3>pH3Rkvi#$$`?EG zt*Cr4E`LzIppx?J2c%r(HrZImwU*Ym>ONl#YkA>nIZ{eqcnO(sZXJbKNJGktUMV>> z6K)oQgYreC8w6e#h{c3aa?tzsq(_I zsFc#PE4k>Gk{SzFu9U_S9aH7fCuQLqrIco0BX4^?08^(Qe5I|y;L9BHwl3w8weXes((M^I-GF6;;fO*10T^3K7u-naKT4(f)7ePQc~~{6numO zJ_sOEP6a-~13rTKlNbgcgg8=;d|Jvb@R2_75&hsJsj)~Gd}Js1ptN5~Nx?@_@R1Jq zAfPEF0;buO(gQw{+LIgxAA~fd{9g}C*#$n*2R^bNd?fW1>4J~!1Rs=oq@>^@DfmbS zd=NmSoCG>MPRa9@)t~DD9V0QSMQc zd!)lX2q02U#XZWyJ&M|s8s;8^w51%Wr0Sv`<)a?ePd$p-igKw(by5#XJxWsQQIvX= zLp=y+Dv5w;{8f3VM^SfD!_Cl&TAQln;7TKlCW-D$0c()d@W)^(aZ9M^Wfe z4)h>^C^;4MC=c`~YEEhxdJxi35+aWOwNiIMkM=>2>W3apT}8XlqdTDorTtQB3O$-a zk9MF30Zl0pFwLga9_Z23o%AsDAjFY!q`&Ge=+Qpt(f!b)sjX-idUPlBpwuHJg&s|z zM?27i03zj7(4#%jqp3aVVdz0fTgtIYb}^6kF^`UWnMYGw(Ju4oPUb;rzmhR!o|rO^ zc9;hNM9Ha`C-yK;Ox-CSW*&sJl^pq`jJud8_AyV~&pa`8mDpvTxRZHM>QRz1PfVF7 zc9;hNO(hX9jlISd^As^CN==FQk!w$C1LIQ->UoW7g$c!kr;;)@(u1<&^U{VYGS$LYQ~LdRDC&g@xw_+*Yc xo5A(Tr?zMCIH1Sjs6bw+>|b--?taW)Ze4HJ9}da&JM$fq`UR>P&G-3y_8->FcIf~B literal 0 HcmV?d00001 diff --git a/data/shaders/src/shaderlib.sh b/data/shaders/src/shaderlib.sh new file mode 100644 index 0000000..51f9b6a --- /dev/null +++ b/data/shaders/src/shaderlib.sh @@ -0,0 +1,386 @@ +/* + * Copyright 2011-2016 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +#ifndef __SHADERLIB_SH__ +#define __SHADERLIB_SH__ + +vec4 encodeRE8(float _r) +{ + float exponent = ceil(log2(_r) ); + return vec4(_r / exp2(exponent) + , 0.0 + , 0.0 + , (exponent + 128.0) / 255.0 + ); +} + +float decodeRE8(vec4 _re8) +{ + float exponent = _re8.w * 255.0 - 128.0; + return _re8.x * exp2(exponent); +} + +vec4 encodeRGBE8(vec3 _rgb) +{ + vec4 rgbe8; + float maxComponent = max(max(_rgb.x, _rgb.y), _rgb.z); + float exponent = ceil(log2(maxComponent) ); + rgbe8.xyz = _rgb / exp2(exponent); + rgbe8.w = (exponent + 128.0) / 255.0; + return rgbe8; +} + +vec3 decodeRGBE8(vec4 _rgbe8) +{ + float exponent = _rgbe8.w * 255.0 - 128.0; + vec3 rgb = _rgbe8.xyz * exp2(exponent); + return rgb; +} + +vec3 encodeNormalUint(vec3 _normal) +{ + return _normal * 0.5 + 0.5; +} + +vec3 decodeNormalUint(vec3 _encodedNormal) +{ + return _encodedNormal * 2.0 - 1.0; +} + +vec2 encodeNormalSphereMap(vec3 _normal) +{ + return normalize(_normal.xy) * sqrt(_normal.z * 0.5 + 0.5); +} + +vec3 decodeNormalSphereMap(vec2 _encodedNormal) +{ + float zz = dot(_encodedNormal, _encodedNormal) * 2.0 - 1.0; + return vec3(normalize(_encodedNormal.xy) * sqrt(1.0 - zz*zz), zz); +} + +vec2 octahedronWrap(vec2 _val) +{ + // Reference: + // Octahedron normal vector encoding + // http://kriscg.blogspot.com/2014/04/octahedron-normal-vector-encoding.html + return (1.0 - abs(_val.yx) ) + * mix(vec2_splat(-1.0), vec2_splat(1.0), vec2(greaterThanEqual(_val.xy, vec2_splat(0.0) ) ) ); +} + +vec2 encodeNormalOctahedron(vec3 _normal) +{ + _normal /= abs(_normal.x) + abs(_normal.y) + abs(_normal.z); + _normal.xy = _normal.z >= 0.0 ? _normal.xy : octahedronWrap(_normal.xy); + _normal.xy = _normal.xy * 0.5 + 0.5; + return _normal.xy; +} + +vec3 decodeNormalOctahedron(vec2 _encodedNormal) +{ + _encodedNormal = _encodedNormal * 2.0 - 1.0; + + vec3 normal; + normal.z = 1.0 - abs(_encodedNormal.x) - abs(_encodedNormal.y); + normal.xy = normal.z >= 0.0 ? _encodedNormal.xy : octahedronWrap(_encodedNormal.xy); + return normalize(normal); +} + +vec3 convertRGB2XYZ(vec3 _rgb) +{ + // Reference: + // RGB/XYZ Matrices + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html + vec3 xyz; + xyz.x = dot(vec3(0.4124564, 0.3575761, 0.1804375), _rgb); + xyz.y = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + xyz.z = dot(vec3(0.0193339, 0.1191920, 0.9503041), _rgb); + return xyz; +} + +vec3 convertXYZ2RGB(vec3 _xyz) +{ + vec3 rgb; + rgb.x = dot(vec3( 3.2404542, -1.5371385, -0.4985314), _xyz); + rgb.y = dot(vec3(-0.9692660, 1.8760108, 0.0415560), _xyz); + rgb.z = dot(vec3( 0.0556434, -0.2040259, 1.0572252), _xyz); + return rgb; +} + +vec3 convertXYZ2Yxy(vec3 _xyz) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_xyY.html + float inv = 1.0/dot(_xyz, vec3(1.0, 1.0, 1.0) ); + return vec3(_xyz.y, _xyz.x*inv, _xyz.y*inv); +} + +vec3 convertYxy2XYZ(vec3 _Yxy) +{ + // Reference: + // http://www.brucelindbloom.com/index.html?Eqn_xyY_to_XYZ.html + vec3 xyz; + xyz.x = _Yxy.x*_Yxy.y/_Yxy.z; + xyz.y = _Yxy.x; + xyz.z = _Yxy.x*(1.0 - _Yxy.y - _Yxy.z)/_Yxy.z; + return xyz; +} + +vec3 convertRGB2Yxy(vec3 _rgb) +{ + return convertXYZ2Yxy(convertRGB2XYZ(_rgb) ); +} + +vec3 convertYxy2RGB(vec3 _Yxy) +{ + return convertXYZ2RGB(convertYxy2XYZ(_Yxy) ); +} + +vec3 convertRGB2Yuv(vec3 _rgb) +{ + vec3 yuv; + yuv.x = dot(_rgb, vec3(0.299, 0.587, 0.114) ); + yuv.y = (_rgb.x - yuv.x)*0.713 + 0.5; + yuv.z = (_rgb.z - yuv.x)*0.564 + 0.5; + return yuv; +} + +vec3 convertYuv2RGB(vec3 _yuv) +{ + vec3 rgb; + rgb.x = _yuv.x + 1.403*(_yuv.y-0.5); + rgb.y = _yuv.x - 0.344*(_yuv.y-0.5) - 0.714*(_yuv.z-0.5); + rgb.z = _yuv.x + 1.773*(_yuv.z-0.5); + return rgb; +} + +vec3 convertRGB2YIQ(vec3 _rgb) +{ + vec3 yiq; + yiq.x = dot(vec3(0.299, 0.587, 0.114 ), _rgb); + yiq.y = dot(vec3(0.595716, -0.274453, -0.321263), _rgb); + yiq.z = dot(vec3(0.211456, -0.522591, 0.311135), _rgb); + return yiq; +} + +vec3 convertYIQ2RGB(vec3 _yiq) +{ + vec3 rgb; + rgb.x = dot(vec3(1.0, 0.9563, 0.6210), _yiq); + rgb.y = dot(vec3(1.0, -0.2721, -0.6474), _yiq); + rgb.z = dot(vec3(1.0, -1.1070, 1.7046), _yiq); + return rgb; +} + +vec3 toLinear(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(2.2) ); +} + +vec4 toLinear(vec4 _rgba) +{ + return vec4(toLinear(_rgba.xyz), _rgba.w); +} + +vec3 toLinearAccurate(vec3 _rgb) +{ + vec3 lo = _rgb / 12.92; + vec3 hi = pow( (_rgb + 0.055) / 1.055, vec3_splat(2.4) ); + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.04045) ) ) ); + return rgb; +} + +vec4 toLinearAccurate(vec4 _rgba) +{ + return vec4(toLinearAccurate(_rgba.xyz), _rgba.w); +} + +float toGamma(float _r) +{ + return pow(abs(_r), 1.0/2.2); +} + +vec3 toGamma(vec3 _rgb) +{ + return pow(abs(_rgb), vec3_splat(1.0/2.2) ); +} + +vec4 toGamma(vec4 _rgba) +{ + return vec4(toGamma(_rgba.xyz), _rgba.w); +} + +vec3 toGammaAccurate(vec3 _rgb) +{ + vec3 lo = _rgb * 12.92; + vec3 hi = pow(abs(_rgb), vec3_splat(1.0/2.4) ) * 1.055 - 0.055; + vec3 rgb = mix(hi, lo, vec3(lessThanEqual(_rgb, vec3_splat(0.0031308) ) ) ); + return rgb; +} + +vec4 toGammaAccurate(vec4 _rgba) +{ + return vec4(toGammaAccurate(_rgba.xyz), _rgba.w); +} + +vec3 toReinhard(vec3 _rgb) +{ + return toGamma(_rgb/(_rgb+vec3_splat(1.0) ) ); +} + +vec4 toReinhard(vec4 _rgba) +{ + return vec4(toReinhard(_rgba.xyz), _rgba.w); +} + +vec3 toFilmic(vec3 _rgb) +{ + _rgb = max(vec3_splat(0.0), _rgb - 0.004); + _rgb = (_rgb*(6.2*_rgb + 0.5) ) / (_rgb*(6.2*_rgb + 1.7) + 0.06); + return _rgb; +} + +vec4 toFilmic(vec4 _rgba) +{ + return vec4(toFilmic(_rgba.xyz), _rgba.w); +} + +vec3 toAcesFilmic(vec3 _rgb) +{ + // Reference: + // ACES Filmic Tone Mapping Curve + // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ + float aa = 2.51f; + float bb = 0.03f; + float cc = 2.43f; + float dd = 0.59f; + float ee = 0.14f; + return saturate( (_rgb*(aa*_rgb + bb) )/(_rgb*(cc*_rgb + dd) + ee) ); +} + +vec4 toAcesFilmic(vec4 _rgba) +{ + return vec4(toAcesFilmic(_rgba.xyz), _rgba.w); +} + +vec3 luma(vec3 _rgb) +{ + float yy = dot(vec3(0.2126729, 0.7151522, 0.0721750), _rgb); + return vec3_splat(yy); +} + +vec4 luma(vec4 _rgba) +{ + return vec4(luma(_rgba.xyz), _rgba.w); +} + +vec3 conSatBri(vec3 _rgb, vec3 _csb) +{ + vec3 rgb = _rgb * _csb.z; + rgb = mix(luma(rgb), rgb, _csb.y); + rgb = mix(vec3_splat(0.5), rgb, _csb.x); + return rgb; +} + +vec4 conSatBri(vec4 _rgba, vec3 _csb) +{ + return vec4(conSatBri(_rgba.xyz, _csb), _rgba.w); +} + +vec3 posterize(vec3 _rgb, float _numColors) +{ + return floor(_rgb*_numColors) / _numColors; +} + +vec4 posterize(vec4 _rgba, float _numColors) +{ + return vec4(posterize(_rgba.xyz, _numColors), _rgba.w); +} + +vec3 sepia(vec3 _rgb) +{ + vec3 color; + color.x = dot(_rgb, vec3(0.393, 0.769, 0.189) ); + color.y = dot(_rgb, vec3(0.349, 0.686, 0.168) ); + color.z = dot(_rgb, vec3(0.272, 0.534, 0.131) ); + return color; +} + +vec4 sepia(vec4 _rgba) +{ + return vec4(sepia(_rgba.xyz), _rgba.w); +} + +vec3 blendOverlay(vec3 _base, vec3 _blend) +{ + vec3 lt = 2.0 * _base * _blend; + vec3 gte = 1.0 - 2.0 * (1.0 - _base) * (1.0 - _blend); + return mix(lt, gte, step(vec3_splat(0.5), _base) ); +} + +vec4 blendOverlay(vec4 _base, vec4 _blend) +{ + return vec4(blendOverlay(_base.xyz, _blend.xyz), _base.w); +} + +vec3 adjustHue(vec3 _rgb, float _hue) +{ + vec3 yiq = convertRGB2YIQ(_rgb); + float angle = _hue + atan2(yiq.z, yiq.y); + float len = length(yiq.yz); + return convertYIQ2RGB(vec3(yiq.x, len*cos(angle), len*sin(angle) ) ); +} + +vec4 packFloatToRgba(float _value) +{ + const vec4 shift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0); + const vec4 mask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); + vec4 comp = fract(_value * shift); + comp -= comp.xxyz * mask; + return comp; +} + +float unpackRgbaToFloat(vec4 _rgba) +{ + const vec4 shift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0); + return dot(_rgba, shift); +} + +vec2 packHalfFloat(float _value) +{ + const vec2 shift = vec2(256, 1.0); + const vec2 mask = vec2(0, 1.0 / 256.0); + vec2 comp = fract(_value * shift); + comp -= comp.xx * mask; + return comp; +} + +float unpackHalfFloat(vec2 _rg) +{ + const vec2 shift = vec2(1.0 / 256.0, 1.0); + return dot(_rg, shift); +} + +float random(vec2 _uv) +{ + return fract(sin(dot(_uv.xy, vec2(12.9898, 78.233) ) ) * 43758.5453); +} + +vec3 fixCubeLookup(vec3 _v, float _lod, float _topLevelCubeSize) +{ + // Reference: + // Seamless cube-map filtering + // http://the-witness.net/news/2012/02/seamless-cube-map-filtering/ + float ax = abs(_v.x); + float ay = abs(_v.y); + float az = abs(_v.z); + float vmax = max(max(ax, ay), az); + float scale = 1.0 - exp2(_lod) / _topLevelCubeSize; + if (ax != vmax) { _v.x *= scale; } + if (ay != vmax) { _v.y *= scale; } + if (az != vmax) { _v.z *= scale; } + return _v; +} + +#endif // __SHADERLIB_SH__ diff --git a/data/shaders/src/uniforms.sh b/data/shaders/src/uniforms.sh new file mode 100644 index 0000000..61354fc --- /dev/null +++ b/data/shaders/src/uniforms.sh @@ -0,0 +1,28 @@ +/* + * Copyright 2016 Dario Manesku. All rights reserved. + * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + */ + +uniform vec4 u_params[12]; +#define u_mtx0 u_params[0] +#define u_mtx1 u_params[1] +#define u_mtx2 u_params[2] +#define u_mtx3 u_params[3] +#define u_glossiness u_params[4].x +#define u_reflectivity u_params[4].y +#define u_exposure u_params[4].z +#define u_bgType u_params[4].w +#define u_metalOrSpec u_params[5].x +#define u_unused u_params[5].yzw +#define u_doDiffuse u_params[6].x +#define u_doSpecular u_params[6].y +#define u_doDiffuseIbl u_params[6].z +#define u_doSpecularIbl u_params[6].w +#define u_camPos u_params[7].xyz +#define u_unused7 u_params[7].w +#define u_rgbDiff u_params[8] +#define u_rgbSpec u_params[9] +#define u_lightDir u_params[10].xyz +#define u_unused10 u_params[10].w +#define u_lightCol u_params[11].xyz +#define u_unused11 u_params[11].w diff --git a/data/shaders/src/varying.def.sc b/data/shaders/src/varying.def.sc new file mode 100644 index 0000000..2bd6633 --- /dev/null +++ b/data/shaders/src/varying.def.sc @@ -0,0 +1,13 @@ +vec3 v_view : TEXCOORD0 = vec3(0.0, 0.0, 0.0); +vec4 v_shadowcoord : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0); +vec4 v_position : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0); +vec3 v_dir : TEXCOORD3 = vec3(0.0, 0.0, 0.0); +vec2 v_texcoord0 : TEXCOORD4 = vec2(0.0, 0.0); +vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); +vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); + +vec3 a_position : POSITION; +vec4 a_normal : NORMAL; +vec4 a_color0 : COLOR0; +vec2 a_texcoord0 : TEXCOORD0; + diff --git a/data/shaders/src/vs_cubes.sc b/data/shaders/src/vs_cubes.sc new file mode 100644 index 0000000..1c69373 --- /dev/null +++ b/data/shaders/src/vs_cubes.sc @@ -0,0 +1,15 @@ +$input a_position, a_color0 +$output v_color0 + +/* + * Copyright 2011-2015 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); + v_color0 = a_color0; +} diff --git a/data/shaders/src/vs_sms_shadow.sc b/data/shaders/src/vs_sms_shadow.sc new file mode 100644 index 0000000..681f3af --- /dev/null +++ b/data/shaders/src/vs_sms_shadow.sc @@ -0,0 +1,13 @@ +$input a_position + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); +} diff --git a/src/Globals.h b/src/Globals.h index a90369b..d11d734 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -3,6 +3,9 @@ #include "math_types.h" #include "Utils.h" +#define USE_DOCKS 1 + + struct Timer; extern Timer* gTimer; diff --git a/src/RuntimeModuleManager.cc b/src/RuntimeModuleManager.cc index b1cc500..b4d1d80 100644 --- a/src/RuntimeModuleManager.cc +++ b/src/RuntimeModuleManager.cc @@ -44,15 +44,13 @@ void RuntimeModuleManager::LoadModule(RuntimeModule* module) { bool stat_result = stat(module->name.c_str(), &attr); if (glfwGetKey(gWindow, GLFW_KEY_F11) == GLFW_PRESS) { - std::cerr << "Module " << module->name << " id = " << module->id - << " mtime " << ctime((time_t *) &module->mtime) << std::endl; + gLog ("Module %s id = %d mtime %d", module->name.c_str(), module->id, module->mtime); } if ( stat_result == 0 && (module->id != attr.st_ino || module->mtime != attr.st_mtime) ) { - std::cout << "Opening module " << module->name - << " (size = " << attr.st_size << ")" << std::endl; + gLog ("Loading module %s (size %d)", module->name.c_str(), attr.st_size); void *handle = dlopen(module->name.c_str(), RTLD_NOW | RTLD_GLOBAL); if (handle) { module->handle = handle; @@ -63,20 +61,19 @@ void RuntimeModuleManager::LoadModule(RuntimeModule* module) { if (api != NULL) { module->api = *api; if (module->state == NULL) { - std::cout << "Initializing module " << module->name << std::endl; + gLog("Initializing module %s", module->name.c_str()); module->state = module->api.init(); } - std::cout << "Reloading module " << module->name << std::endl; + gLog("Reloading module %s", module->name.c_str()); module->api.reload(module->state, gReadSerializer); } else { - std::cerr << "Error: could not find API for module " << module->name << std::endl; + gLog("Loading module failed: Could not find API for module %s", module->name.c_str()); dlclose(module->handle); module->handle = NULL; module->id = 0; } } else { - std::cerr << "Error: could not load module " << module->name << std::endl; - std::cerr << dlerror() << std::endl; + gLog ("Loading module failed: could not load shared library for module %s: %s", module->name.c_str(), dlerror()); module->handle = NULL; module->id = 0; abort(); @@ -143,18 +140,23 @@ void RuntimeModuleManager::UnloadModules() { gLog("Unloading module %s", mModules[i]->name.c_str()); mModules[i]->api.unload(mModules[i]->state, gWriteSerializer); mModules[i]->state = nullptr; - dlclose(mModules[i]->handle); + gLog ("Unloading shared library %s", mModules[i]->name.c_str()); + int unload_result = dlclose(mModules[i]->handle); + if (unload_result != 0) { + gLog ("Unload failed (code %d): %s", unload_result, dlerror()); + } mModules[i]->handle = 0; mModules[i]->id = 0; + gLog("Unloading module %s complete", mModules[i]->name.c_str()); } } - std::cout << "Writing state to file " << state_file << std::endl; + gLog ("Writting state to file %s", state_file); gWriteSerializer->Close(); } void RuntimeModuleManager::LoadModules() { - std::cout << "Reading state from file " << state_file << std::endl; + gLog ("Reading state from file %s", state_file); gReadSerializer->Open(state_file); for (int i = 0; i < mModules.size(); i++) { LoadModule(mModules[i]); diff --git a/src/Utils.cc b/src/Utils.cc new file mode 100644 index 0000000..63f497a --- /dev/null +++ b/src/Utils.cc @@ -0,0 +1,23 @@ +#include "Utils.h" + +#include +#include +#include + +FILE *gLogFile = NULL; + +void LoggingInit() { + // check if protot.log exists and rename it to protot.log.1 if found + std::ifstream source ("protot.log", std::ios::binary); + + if (source.good()) { + std::ofstream destination ("protot.log.1", std::ios::binary | std::ios::trunc); + + destination << source.rdbuf(); + } + + source.close(); + + gLogFile = fopen("protot.log", "w+"); +} + diff --git a/src/Utils.h b/src/Utils.h index edea883..f6088ef 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include +#include #include #include #include @@ -49,11 +53,29 @@ inline double gGetTimeSinceStart () { return gGetCurrentTime() - gTimeAtStart; } +extern FILE *gLogFile; + +void LoggingInit(); + +const int cLogBufferSize = 1024; + inline void gLog (const char* format, ...) { + assert(gLogFile != NULL); + + fprintf (stdout, "%11.6f: ", gGetTimeSinceStart()); + fprintf (gLogFile,"%11.6f: ", gGetTimeSinceStart()); + va_list argptr; + + char buffer[cLogBufferSize]; va_start(argptr, format); - vfprintf(stdout, format, argptr); + vsnprintf(buffer, cLogBufferSize, format, argptr); va_end(argptr); - fprintf (stdout, "\n"); + + fprintf(stdout, "%s\n", buffer); + fprintf(gLogFile, "%s\n", buffer); + + fflush(gLogFile); + } diff --git a/src/main.cc b/src/main.cc index 4bcf67c..e0eb610 100644 --- a/src/main.cc +++ b/src/main.cc @@ -9,9 +9,12 @@ #include #include #include +#include #include "bgfx/platform.h" #include "bx/timer.h" +#include "bx/process.h" +#include "bx/error.h" #include "Timer.h" #include "RuntimeModuleManager.h" #include "imgui/imgui.h" @@ -19,6 +22,7 @@ #include "Globals.h" #include "Serializer.h" +#include "FileModificationObserver.h" Timer* gTimer = nullptr; Renderer* gRenderer = nullptr; @@ -103,6 +107,8 @@ int main(void) gTimeAtStart = gGetCurrentTime(); std::cout << "Time at start: " << gTimeAtStart << std::endl; + LoggingInit(); + WriteSerializer out_serializer; ReadSerializer in_serializer; @@ -127,19 +133,21 @@ int main(void) std::cout << "OpenGL Version: " << glGetString(GL_VERSION) << endl; std::cout << "GLSL Version : " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl; - // Initialize Renderer + // Initialize BGFX bgfx::glfwSetWindow(gWindow); bgfx::renderFrame(); - uint32_t debug = BGFX_DEBUG_TEXT; - uint32_t reset = BGFX_RESET_VSYNC; - bool result = bgfx::init(); if (!result) { std::cerr << "Error: could not initialize renderer!" << std::endl; exit (EXIT_FAILURE); } + uint32_t debug = BGFX_DEBUG_TEXT; + uint32_t reset = BGFX_RESET_VSYNC | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_MSAA_X16; + bgfx::reset (width, height, reset); + bgfx::setDebug(debug); + // imgui initialization. imguiCreate(); GuiInputState gui_input_state; @@ -166,11 +174,16 @@ int main(void) module_manager.LoadModules(); int64_t time_offset = bx::getHPCounter(); + uint64_t frame_counter = 0; while(!glfwWindowShouldClose(gWindow)) { + frame_counter++; + // Start the imgui frame such that widgets can be submitted handle_mouse(); glfwGetWindowSize(gWindow, &width, &height); + bgfx::reset (width, height); + bgfx::touch(0); imguiBeginFrame (gGuiInputState->mouseX, gGuiInputState->mouseY, @@ -183,16 +196,16 @@ int main(void) static int64_t last = bx::getHPCounter(); int64_t pre_module_check = bx::getHPCounter(); - if (module_manager.CheckModulesChanged()) { - std::cout << "Detected module update. Unloading all modules." << std::endl; - module_manager.UnloadModules(); - // We need to sleep to make sure we load the new files - module_manager.LoadModules(); - // We need to update our last timestamp to ignore the delay due - // to reloading of the modules. - last = bx::getHPCounter(); - } - +// if (module_manager.CheckModulesChanged()) { +// gLog("Detected module update at frame %d. Unloading all modules.", frame_counter); +// module_manager.UnloadModules(); +// // We need to sleep to make sure we load the new files +// module_manager.LoadModules(); +// // We need to update our last timestamp to ignore the delay due +// // to reloading of the modules. +// last = bx::getHPCounter(); +// } + // update time that was passed without module reloading int64_t now = bx::getHPCounter(); int64_t module_update = now - pre_module_check; @@ -215,14 +228,47 @@ int main(void) } assert (gTimer->mDeltaTime >= 0.0f); - module_manager.Update(gTimer->mDeltaTime); +#ifdef USE_DOCKS + ImGui::SetNextWindowPos(ImVec2(0.0f, 20.0f)); + int width, height; + glfwGetWindowSize(gWindow, &width, &height); + ImGui::SetNextWindowSize(ImVec2(width, height)); + if (ImGui::Begin("DockArea", NULL, + ImGuiWindowFlags_NoTitleBar + | ImGuiWindowFlags_NoResize + | ImGuiWindowFlags_NoMove + | ImGuiWindowFlags_NoBringToFrontOnFocus + )) { + ImGui::BeginDockspace(); - glfwPollEvents(); + if (ImGui::BeginDock("dock1")) { + ImGui::Text("HEllo 1"); + } + ImGui::EndDock(); +#endif + + module_manager.Update(gTimer->mDeltaTime); + + glfwPollEvents(); +#ifdef USE_DOCKS + ImGui::EndDockspace(); + } + + ImGui::End(); +#endif // submit the imgui widgets imguiEndFrame(); - usleep(16000); + // Advance to next frame. Rendering thread will be kicked to + // process submitted rendering primitives. + bgfx::frame(); + + usleep(16000); + + if (frame_counter > 1) { + gLog ("End of frame %d", frame_counter); + } } module_manager.UnregisterModules(); diff --git a/src/modules/CharacterModule.cc b/src/modules/CharacterModule.cc index e68a476..855bca4 100644 --- a/src/modules/CharacterModule.cc +++ b/src/modules/CharacterModule.cc @@ -152,11 +152,11 @@ CharacterEntity::CharacterEntity() { bool load_result = LoadRig (cRigModelFile); assert (load_result); - cout << "Creating render entity mesh ..." << endl; + gLog ("Creating render entity mesh..."); // mState->character->entity->mesh = bgfxutils::createCuboid (1.f, 1.f, 1.f); // mState->character->entity->mesh = bgfxutils::createCylinder (20); - cout << "Creating render entity mesh ... success!" << endl; + gLog ("Creating render entity mesh... success!"); gLog ("Loading Animation %s", cAnimFile); load_result = mAnimation.Load(cAnimFile); @@ -185,7 +185,7 @@ bool CharacterEntity::LoadRig(const char* filename) { bool load_result = LuaModelReadFromTable (model_table, mRigModel, false); - gLog ("Creating rig model from %s ... %s", filename, load_result ? "success" : "failed!"); +// gLog ("Creating rig model from %s ... %s", filename, load_result ? "success" : "failed!"); gLog ("Rig model has %d degrees of freedom", mRigModel->qdot_size); mRigState.q = VectorNd::Zero (mRigModel->q_size); @@ -681,7 +681,7 @@ void ShowCharacterPropertiesWindow (CharacterEntity* character) { } static struct module_state *module_init() { - std::cout << "Module init called" << std::endl; + gLog ("%s %s called", __FILE__, __FUNCTION__); module_state *state = (module_state*) malloc(sizeof(*state)); return state; } @@ -693,12 +693,12 @@ static void module_serialize ( } static void module_finalize(struct module_state *state) { - std::cout << "Module finalize called" << std::endl; + gLog ("%s %s called (state %p)", __FILE__, __FUNCTION__, state); free(state); } static void module_reload(struct module_state *state, void* read_serializer) { - std::cout << "Module reload called. State: " << state << std::endl; + gLog ("%s %s called (state %p)", __FILE__, __FUNCTION__, state); // load the state of the entity if (read_serializer != nullptr) { module_serialize(state, static_cast(read_serializer)); diff --git a/src/modules/RenderModule.cc b/src/modules/RenderModule.cc index d4211dc..18c950d 100644 --- a/src/modules/RenderModule.cc +++ b/src/modules/RenderModule.cc @@ -5,10 +5,6 @@ #include "3rdparty/ocornut-imgui/imgui_internal.h" #include "imgui/imgui.h" #include "imgui_dock.h" -#define GLFW_EXPOSE_NATIVE_GLX -#define GLFW_EXPOSE_NATIVE_X11 -#include -#include #include "SimpleMath/SimpleMath.h" #include "SimpleMath/SimpleMathMap.h" @@ -56,7 +52,7 @@ struct module_state { }; static struct module_state *module_init() { - gLog ("RenderModule init called."); + gLog ("%s %s called", __FILE__, __FUNCTION__); assert (gWindow != nullptr && "Cannot initialize renderer module without gWindow!"); module_state *state = (module_state*) malloc(sizeof(*state)); @@ -82,7 +78,7 @@ static void module_serialize ( } static void module_finalize(struct module_state *state) { - gLog ("RenderModule finalize called"); + gLog ("%s %s called (state %p)", __FILE__, __FUNCTION__, state); assert (state->renderer != nullptr); delete state->renderer; @@ -91,14 +87,12 @@ static void module_finalize(struct module_state *state) { } static void module_reload(struct module_state *state, void *read_serializer) { - gLog ("RenderModule reload called"); + gLog ("%s %s called (state %p)", __FILE__, __FUNCTION__, state); assert (gWindow != nullptr); - int width, height; - glfwGetWindowSize(gWindow, &width, &height); gLog ("Renderer initialize"); assert (state != nullptr); - state->renderer->initialize(width, height); + state->renderer->initialize(100, 100); gRenderer = state->renderer; // load the state of the module @@ -128,20 +122,12 @@ static void module_unload(struct module_state *state, void* write_serializer) { static bool module_step(struct module_state *state, float dt) { int width, height; assert (gWindow != nullptr); - glfwGetWindowSize(gWindow, &width, &height); state->renderer->updateShaders(); - bgfx::reset (width, height); - - int dock_top_offset = 0.0f; - int dock_width = 0; - - state->renderer->resize (0, dock_top_offset, width - dock_width, height - dock_top_offset); - ImGuizmo::Enable(true); - state->renderer->paintGL(); state->renderer->DrawGui(); + state->renderer->paintGL(); return true; } @@ -203,7 +189,8 @@ namespace IBL { void destroy() { - bgfx::destroy(u_params); + if (bgfx::isValid(u_params)) + bgfx::destroy(u_params); } union @@ -335,6 +322,7 @@ bool RenderProgram::checkModified() const { // early out if we don't have filenames if (vertexShaderFileName == "" || fragmentShaderFileName == "") { + gLog ("Warning! RenderProgram has no shader filenames specified!"); return false; } @@ -379,7 +367,7 @@ bool RenderProgram::reload() { fragmentShaderFileModTime = fragment_mtime; bgfx::ProgramHandle new_handle = - bgfxutils::loadProgramFromFiles ( + bgfxutils::loadProgram ( vertexShaderFileName.c_str(), fragmentShaderFileName.c_str() ); @@ -1058,8 +1046,8 @@ void Renderer::setupShaders() { memcpy(IBL::uniforms.m_lightCol, IBL::settings.m_lightCol, 3*sizeof(float) ); s_renderStates[RenderState::Skybox].m_program = RenderProgram( - "shaders/skybox/vs_ibl_skybox.sc", - "shaders/skybox/fs_ibl_skybox.sc" + "vs_ibl_skybox.sc", + "fs_ibl_skybox.sc" ); // Get renderer capabilities info. @@ -1073,18 +1061,18 @@ void Renderer::setupShaders() { // Depth textures and shadow samplers are supported. s_renderStates[RenderState::ShadowMap].m_program = RenderProgram( - "shaders/shadowmap/vs_sms_mesh.sc", - "shaders/shadowmap/fs_sms_shadow.sc" + "vs_sms_mesh.sc", + "fs_sms_shadow.sc" ); s_renderStates[RenderState::Scene].m_program = RenderProgram( - "shaders/scene/vs_sms_mesh.sc", - "shaders/scene/fs_sms_mesh.sc" + "vs_sms_mesh.sc", + "fs_sms_mesh.sc" ); s_renderStates[RenderState::SceneTextured].m_program = RenderProgram( - "shaders/scene/vs_sms_mesh_textured.sc", - "shaders/scene/fs_sms_mesh_textured.sc" + "vs_sms_mesh_textured.sc", + "fs_sms_mesh_textured.sc" ); // Setup render target for the shadow maps @@ -1106,19 +1094,23 @@ void Renderer::setupShaders() { } s_renderStates[RenderState::Lines].m_program = RenderProgram( - "shaders/lines/vs_lines.sc", - "shaders/lines/fs_lines.sc" + "vs_lines.sc", + "fs_lines.sc" ); s_renderStates[RenderState::LinesOccluded].m_program = RenderProgram( - "shaders/lines/vs_lines.sc", - "shaders/lines/fs_lines_occluded.sc" + "vs_lines.sc", + "fs_lines_occluded.sc" ); s_renderStates[RenderState::Debug].m_program = RenderProgram( - "shaders/debug/vs_debug.sc", - "shaders/debug/fs_debug.sc" + "vs_debug.sc", + "fs_debug.sc" ); + + for (int i = 0, n = RenderState::Count; i < n; ++i) { + s_renderStates[i].m_program.reload(); + } } void Renderer::setupRenderPasses() { @@ -1165,13 +1157,13 @@ void Renderer::setupRenderPasses() { class BGFXCallbacks: public bgfx::CallbackI { virtual void fatal (bgfx::Fatal::Enum _code, const char *_str) { - std::cerr << "Fatal (" << _code << "): " << _str << std::endl; + gLog ("Fatal bgfx error (code %d): %s", _code, _str); } virtual void traceVargs (const char *_filePath, uint16_t _line, const char* _format, va_list _argList) { char output_buffer[255]; vsprintf (output_buffer, _format, _argList); - std::cerr << "Trace " << _filePath << ":" << _line << " : " << output_buffer; + gLog ("bgfx trace: %s:%d:%s", _filePath, _line, output_buffer); } virtual uint32_t cacheReadSize(uint64_t _id) { @@ -1198,47 +1190,17 @@ class BGFXCallbacks: public bgfx::CallbackI { }; }; -namespace bgfx { - inline void glfwSetWindow(GLFWwindow* _window) - { - bgfx::PlatformData pd; -# if BX_PLATFORM_LINUX || BX_PLATFORM_BSD - pd.ndt = glfwGetX11Display(); - pd.nwh = (void*)(uintptr_t)glfwGetGLXWindow(_window); - pd.context = glfwGetGLXContext(_window); -# elif BX_PLATFORM_OSX - pd.ndt = NULL; - pd.nwh = glfwGetCocoaWindow(_window); - pd.context = glfwGetNSGLContext(_window); -# elif BX_PLATFORM_WINDOWS - pd.ndt = NULL; - pd.nwh = glfwGetWin32Window(_window); - pd.context = NULL; -# endif // BX_PLATFORM_WINDOWS - pd.backBuffer = NULL; - pd.backBufferDS = NULL; - bgfx::setPlatformData(pd); - } -} - - void Renderer::initialize(int width, int height) { this->view_width = width; this->view_height = height; - uint32_t debug = BGFX_DEBUG_TEXT; - uint32_t reset = BGFX_RESET_VSYNC; - - reset = BGFX_RESET_VSYNC | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_MSAA_X16; - bgfx::reset(view_width, view_height, reset); - bgfx::setViewClear(0 , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH , 0x303030ff , 1.0f , 0 ); - bgfx::setViewRect(0, view_offset_x, view_offset_y, view_width, view_height); + bgfx::setViewRect(0, 0, 0, view_width, view_height); bgfx::RendererType::Enum renderer = bgfx::getRendererType(); flipV = false @@ -1246,8 +1208,6 @@ void Renderer::initialize(int width, int height) { || renderer == bgfx::RendererType::OpenGLES ; - bgfx::setDebug(debug); - gLog ("Creating Cameras"); cameras.push_back (Camera()); activeCameraIndex = 0; @@ -1266,8 +1226,7 @@ void Renderer::initialize(int width, int height) { mCurrentLightProbe = LightProbe::Bolonga; initialized = true; - resize (view_offset_x, view_offset_y, view_width, view_height); - bgfx::frame(); + resize (view_width, view_height); } void Renderer::shutdown() { @@ -1290,6 +1249,8 @@ void Renderer::shutdown() { bgfx::destroy(u_color); bgfx::destroy(u_line_params); + bgfx::destroy(sceneViewBuffer); + for (uint8_t ii = 0; ii < RenderState::Count; ++ii) { if (bgfx::isValid(s_renderStates[ii].m_program.program)) { bgfx::destroy(s_renderStates[ii].m_program.program); @@ -1319,30 +1280,23 @@ void Renderer::shutdown() { cameras.clear(); } -void Renderer::resize (int x, int y, int width, int height) { +void Renderer::resize (int width, int height) { if (initialized) { - this->view_offset_x = x; - this->view_offset_y = y; - this->view_width = view_texture_width; - this->view_height = view_texture_height; + gLog ("Resizing to size %d,%d view buffer valid?: %d", width, height, bgfx::isValid(sceneViewBuffer)); + assert(width > 0 && height > 0); + this->view_width = width; + this->view_height = height; for (uint32_t i = 0; i < cameras.size(); i++) { - cameras[i].width = static_cast(view_texture_width); - cameras[i].height = static_cast(view_texture_height); - } - - if (bgfx::isValid(sceneViewBuffer)) { - bgfx::setViewFrameBuffer(RenderState::Skybox, sceneViewBuffer); - bgfx::setViewFrameBuffer(RenderState::Scene, sceneViewBuffer); - bgfx::setViewFrameBuffer(RenderState::SceneTextured, sceneViewBuffer); - bgfx::setViewFrameBuffer(RenderState::Lines, sceneViewBuffer); - bgfx::setViewFrameBuffer(RenderState::LinesOccluded, sceneViewBuffer); - bgfx::setViewFrameBuffer(RenderState::Debug, sceneViewBuffer); + cameras[i].width = static_cast(width); + cameras[i].height = static_cast(height); } } } void Renderer::paintGL() { + assert (initialized); + int64_t now = bx::getHPCounter(); static int64_t last = now; const int64_t frameTime = now - last; @@ -1353,6 +1307,19 @@ void Renderer::paintGL() { float time = (float)( (now-m_timeOffset)/double(bx::getHPFrequency() ) ); bgfx::setUniform (u_time, &time); + if (bgfx::isValid(sceneViewBuffer)) { + bgfx::setViewFrameBuffer(RenderState::Skybox, sceneViewBuffer); + bgfx::setViewFrameBuffer(RenderState::Scene, sceneViewBuffer); + bgfx::setViewFrameBuffer(RenderState::SceneTextured, sceneViewBuffer); + bgfx::setViewFrameBuffer(RenderState::Lines, sceneViewBuffer); + bgfx::setViewFrameBuffer(RenderState::LinesOccluded, sceneViewBuffer); + bgfx::setViewFrameBuffer(RenderState::Debug, sceneViewBuffer); + } else { + gLog("Error! sceneViewBuffer is not valid!"); + assert(false); + return; + } + // Use debug font to print information about this example. bgfx::dbgTextClear(); @@ -1360,10 +1327,6 @@ void Renderer::paintGL() { int num_chars = view_width / 8; bgfx::dbgTextPrintf(num_chars - 18, 0, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); - // This dummy draw call is here to make sure that view 0 is cleared - // if no other draw calls are submitted to view 0. - bgfx::touch(0); - // update camera matrices for (uint32_t i = 0; i < cameras.size(); i++) { cameras[i].updateMatrices(); @@ -1428,26 +1391,26 @@ void Renderer::paintGL() { bx::mtxOrthoRh(proj, 0.f, 1.f, 1.f, 0.f, 0.f, 100.0f, 0.0, bgfx::getCaps()->homogeneousDepth ); - bgfx::setViewRect(RenderState::Skybox, view_offset_x, view_offset_y, view_width, view_height); + bgfx::setViewRect(RenderState::Skybox, 0, 0, view_width, view_height); bgfx::setViewTransform(RenderState::Skybox, view, proj); bgfx::setViewRect(RenderState::ShadowMap, 0, 0, lights[0].shadowMapSize, lights[0].shadowMapSize); bgfx::setViewFrameBuffer(RenderState::ShadowMap, lights[0].shadowMapFB); bgfx::setViewTransform(RenderState::ShadowMap, lights[0].mtxView, lights[0].mtxProj); - bgfx::setViewRect(RenderState::Scene, view_offset_x, view_offset_y, view_width, view_height); + bgfx::setViewRect(RenderState::Scene, 0, 0, view_width, view_height); bgfx::setViewTransform(RenderState::Scene, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj); - bgfx::setViewRect(RenderState::SceneTextured, view_offset_x, view_offset_y, view_width, view_height); + bgfx::setViewRect(RenderState::SceneTextured, 0, 0, view_width, view_height); bgfx::setViewTransform(RenderState::SceneTextured, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj); - bgfx::setViewRect(RenderState::Lines, view_offset_x, view_offset_y, view_width, view_height); + bgfx::setViewRect(RenderState::Lines, 0, 0, view_width, view_height); bgfx::setViewTransform(RenderState::Lines, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj); - bgfx::setViewRect(RenderState::LinesOccluded, view_offset_x, view_offset_y, view_width, view_height); + bgfx::setViewRect(RenderState::LinesOccluded, 0, 0, view_width, view_height); bgfx::setViewTransform(RenderState::LinesOccluded, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj); - bgfx::setViewRect(RenderState::Debug, view_offset_x, view_offset_y, view_width, view_height); + bgfx::setViewRect(RenderState::Debug, 0, 0, view_width, view_height); bgfx::setViewTransform(RenderState::Debug, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj); @@ -1479,10 +1442,10 @@ void Renderer::paintGL() { , 0x303030ff, 1.0f, 0 ); -// bgfx::setViewClear(RenderState::Scene -// , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH -// , 0x303030ff, 1.0f, 0 -// ); + bgfx::setViewClear(RenderState::Scene + , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH + , 0x303030ff, 1.0f, 0 + ); bgfx::touch(RenderState::Scene); bgfx::touch(RenderState::Skybox); @@ -1751,94 +1714,86 @@ void Renderer::paintGL() { // ImGui::EndDock(); - // Advance to next frame. Rendering thread will be kicked to - // process submitted rendering primitives. - bgfx::frame(); - // clear debug commands as they have to be issued every frame debugCommands.clear(); } void Renderer::DrawGui() { - static float docking_offset_x = 600.0f; +// static float docking_offset_x = 600.0f; - ImGuiStyle& style = ImGui::GetStyle(); - if (ImGui::GetIO().DisplaySize.y > 0) { - ImVec2 pos = ImVec2(docking_offset_x, 25); - ImVec2 size = ImGui::GetIO().DisplaySize; - size.x -= pos.x; - size.y -= pos.y; - // TODO(martin): init dock - - // Draw status bar (no docking) - ImGui::SetNextWindowSize(ImVec2(size.x, 25.0f), ImGuiCond_Always); - ImGui::SetNextWindowPos(ImVec2(0, size.y - 32.0f), ImGuiCond_Always); - ImGui::Begin("statusbar", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoResize); - ImGui::Text("FPS: %f", ImGui::GetIO().Framerate); - ImGui::End(); - } +// ImGuiStyle& style = ImGui::GetStyle(); +// if (ImGui::GetIO().DisplaySize.y > 0) { +// ImVec2 pos = ImVec2(docking_offset_x, 25); +// ImVec2 size = ImGui::GetIO().DisplaySize; +// size.x -= pos.x; +// size.y -= pos.y; +// // TODO(martin): init dock +// +// // Draw status bar (no docking) +// ImGui::SetNextWindowSize(ImVec2(size.x, 25.0f), ImGuiCond_Always); +// ImGui::SetNextWindowPos(ImVec2(0, size.y - 32.0f), ImGuiCond_Always); +// ImGui::Begin("statusbar", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoResize); +// ImGui::Text("FPS: %f", ImGui::GetIO().Framerate); +// ImGui::End(); +// } // if (ImGui::BeginDock("Dock Info", &sDockInfoDock)) { // ImGui::Print(); // } // ImGui::EndDock(); -// if (ImGui::BeginDock("Scene", &sSceneDock)) { -// ImVec2 size = ImGui::GetContentRegionAvail(); -// ImVec2 pos = ImGui::GetWindowPos(); -// -// if ((size.x > 0 && size.y > 0) && -// (view_texture_width != size.x || view_texture_height != size.y)) { -// if (bgfx::isValid(sceneViewBuffer)) { -// gLog("Destroying old view frame buffer of size %f, %f", -// view_texture_width, view_texture_height); -// bgfx::destroy(sceneViewBuffer); -// } -// -// sceneViewTexture = bgfx::createTexture2D( -// size.x, size.y, -// false, 1, -// bgfx::TextureFormat::RGBA8 -// ); -// sceneDepthTexture = bgfx::createTexture2D( -// size.x, size.y, -// false, 1, -// bgfx::TextureFormat::D16 -// ); -// -// view_texture_width = size.x; -// view_texture_height = size.y; -// view_offset_x = pos.x; -// view_offset_y = pos.y; -// view_width = size.x; -// view_height = size.y; -// -// assert(view_texture_width > 0.0f); -// assert(view_texture_height > 0.0f); -// -// gLog("Creating view frame buffer of size %f, %f", -// view_texture_width, view_texture_height); -// -// bgfx::TextureHandle fbtextures[] = { sceneViewTexture, sceneDepthTexture }; -// -// sceneViewBuffer = bgfx::createFrameBuffer( -// BX_COUNTOF(fbtextures), fbtextures, true -// ); -// -// ImGuizmo::SetRect( -// view_offset_x, view_offset_y, -// view_texture_width, view_texture_height -// ); -// } else { -// -// ImGui::Image(sceneViewTexture, -// size, -// ImVec2(0.0f, 1.0f), -// ImVec2(1.0f, 0.0f) -// ); -// } -// } -// ImGui::EndDock(); +#ifdef USE_DOCKS + if (ImGui::BeginDock("Scene", &sSceneDock)) { +#endif + ImVec2 size = ImGui::GetContentRegionAvail(); + ImVec2 pos = ImGui::GetWindowPos(); + + if ( (size.x > 0 && size.y > 0) && + (view_width != size.x || view_height != size.y)) { + gLog ("Creating scene render frame buffer: size %4.0f, %4.0f", size.x, size.y); + if (bgfx::isValid(sceneViewBuffer)) { + gLog("Destroying old view frame buffer of size %f, %f", + view_width, view_height); + bgfx::destroy(sceneViewBuffer); + } + + sceneViewTexture = bgfx::createTexture2D( + size.x, size.y, + false, 1, + bgfx::TextureFormat::RGBA8 + ); + sceneDepthTexture = bgfx::createTexture2D( + size.x, size.y, + false, 1, + bgfx::TextureFormat::D16 + ); + + resize(size.x, size.y); + + gLog("Creating view frame buffer of size %d, %d", + view_width, view_height); + + bgfx::TextureHandle fbtextures[] = { sceneViewTexture, sceneDepthTexture }; + + sceneViewBuffer = bgfx::createFrameBuffer( + BX_COUNTOF(fbtextures), fbtextures, true + ); + + ImGuizmo::SetRect( + pos.x, pos.y, + size.x, size.y + ); + } else { + ImGui::Image(sceneViewTexture, + size, + ImVec2(0.0f, 1.0f), + ImVec2(1.0f, 0.0f) + ); + } +#ifdef USE_DOCKS + } + ImGui::EndDock(); +#endif } bool Renderer::updateShaders() { diff --git a/src/modules/RenderModule.h b/src/modules/RenderModule.h index 41ed60b..0c04c68 100644 --- a/src/modules/RenderModule.h +++ b/src/modules/RenderModule.h @@ -376,16 +376,12 @@ struct Renderer { bool drawDebug; bool drawFloor = true; bool drawSkybox = true; - uint32_t view_offset_x = 0; - uint32_t view_offset_y = 0; uint32_t view_width = 1; uint32_t view_height = 1; bgfx::UniformHandle sceneDefaultTextureSampler; bgfx::TextureHandle sceneDefaultTexture; - float view_texture_width = 1; - float view_texture_height = 1; bgfx::TextureHandle sceneViewTexture; bgfx::TextureHandle sceneDepthTexture; bgfx::FrameBufferHandle sceneViewBuffer; @@ -426,7 +422,7 @@ struct Renderer { void shutdown(); void paintGL(); void DrawGui(); - void resize (int x, int y, int width, int height); + void resize (int width, int height); // check whether shader files were modified and reload them. Returns // true on success, otherwise false diff --git a/src/modules/RenderUtils.cc b/src/modules/RenderUtils.cc index 931c029..a57789e 100644 --- a/src/modules/RenderUtils.cc +++ b/src/modules/RenderUtils.cc @@ -15,6 +15,7 @@ namespace stl = tinystl; #include #include #include +#include #include #include #include "entry/dbg.h" @@ -160,29 +161,68 @@ int compileShader(bx::CommandLine& _cmdLine, bx::ReaderSeekerI* _reader, bx::Wri } +int compileShader(const char* filename, const char* shader_type) +{ + bx::Error error; + bx::ProcessReader process_reader; + + const int cCommandMaxLen = 1024; + char command[cCommandMaxLen]; + + const char* shaderc_binary = "3rdparty/bgfx/shaderc"; + + bx::snprintf(command, cCommandMaxLen, "-f %s -o %s.bin -i \"shaders/common\" --type %s --platform linux", filename, filename, shader_type); + + gLog("Compiling shader '%s'...", filename); + + if (!process_reader.open(shaderc_binary, command, &error)) { + fprintf(stderr, "Error compiling shader: could not spawn %s", shaderc_binary); + } else if (!error.isOk()) { + fprintf(stderr, "Unable to compile shader file '%s': %s", filename, error.getMessage().getPtr()); + } + + const int cMessageMaxLen = 2048; + char buffer[cMessageMaxLen]; + int32_t message_len = process_reader.read(buffer, cMessageMaxLen, &error); + process_reader.close(); + int32_t result = process_reader.getExitCode(); + + if (result != 0) { + fprintf(stderr, "Unable to compile shader file '%s':\n%s\n", filename, error.getMessage().getPtr()); + fprintf(stderr, "%s", buffer); + } else { + gLog("Successfully compiled shader '%s'!", filename); + } + + return result; +} + + + + static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name) { char filePath[512]; - const char* shaderPath = "shaders/dx9/"; + const char* shaderPath = "data/shaders/dx9/"; switch (bgfx::getRendererType() ) { case bgfx::RendererType::Direct3D11: case bgfx::RendererType::Direct3D12: - shaderPath = "shaders/dx11/"; + shaderPath = "data/shaders/dx11/"; break; case bgfx::RendererType::OpenGL: - shaderPath = "shaders/glsl/"; + shaderPath = "data/shaders/glsl/"; break; case bgfx::RendererType::Metal: - shaderPath = "shaders/metal/"; + shaderPath = "data/shaders/metal/"; break; case bgfx::RendererType::OpenGLES: - shaderPath = "shaders/gles/"; + shaderPath = "data/shaders/gles/"; break; default: @@ -193,6 +233,8 @@ static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name strcat(filePath, _name); strcat(filePath, ".bin"); + gLog ("Loading shader %s", filePath); + return bgfx::createShader(loadMem(_reader, filePath) ); } @@ -215,89 +257,10 @@ bgfx::ProgramHandle loadProgram(bx::FileReaderI* _reader, const char* _vsName, c bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName) { + gLog ("Loading program from %s and %s", _vsName, _fsName); return loadProgram(entry::getFileReader(), _vsName, _fsName); } -bgfx::ProgramHandle loadProgramFromFiles(const char *_vsFileName, const char *_fsFileName) { - gLog ("Loading shader %s", _vsFileName); - const char* argv[10]; - argv[0] = "--type"; - argv[1] = "vertex"; - argv[2] = "--platform"; - argv[3] = "linux"; - argv[4] = "-i"; - argv[5] = "shaders/common"; - argv[6] = "-p"; - argv[7] = "120"; - argv[8] = "-f"; - argv[9] = _vsFileName; - -// argv[6] = "--varyingdef"; -// argv[7] = "-p"; -// argv[8] = "120"; -// argv[9] = "-f"; -// argv[10] = _vsFileName; - - bx::CommandLine cmdLine (10, argv); - - const bgfx::Memory* vs_source_memory = loadMem(entry::getFileReader(), _vsFileName); - bx::ReaderSeekerI* vs_source_reader = new bx::MemoryReader (vs_source_memory->data, vs_source_memory->size); - - bx::MemoryBlock* vs_compiled_memory = new bx::MemoryBlock (entry::getAllocator()); - bx::MemoryWriter* vs_compiled_writer = new bx::MemoryWriter (vs_compiled_memory); - - setlocale(LC_NUMERIC, "C"); - int result = compileShader (cmdLine, vs_source_reader, vs_compiled_writer); - if (result != EXIT_SUCCESS) { - std::cerr << "Error compiling shader " << _vsFileName << std::endl; - return BGFX_INVALID_HANDLE; - } - - uint32_t size = vs_compiled_writer->seek(0, bx::Whence::End); - const bgfx::Memory* mem = bgfx::alloc(size+1); - bx::ReaderSeekerI* vs_compiled_reader = new bx::MemoryReader ((uint8_t*) vs_compiled_memory->more(), size); - bx::read(vs_compiled_reader, mem->data, size); - delete vs_compiled_reader; - mem->data[mem->size-1] = '\0'; - bgfx::ShaderHandle vsh = bgfx::createShader(mem); - - delete vs_source_reader; - delete vs_compiled_writer; - delete vs_compiled_memory; - - bgfx::ShaderHandle fsh = BGFX_INVALID_HANDLE; - - if (_fsFileName != NULL) { - argv[1] = "fragment"; - - const bgfx::Memory* fs_source_memory = loadMem(entry::getFileReader(), _fsFileName); - bx::ReaderSeekerI* fs_source_reader = new bx::MemoryReader (fs_source_memory->data, fs_source_memory->size); - - bx::MemoryBlock* fs_compiled_memory = new bx::MemoryBlock (entry::getAllocator()); - bx::MemoryWriter* fs_compiled_writer = new bx::MemoryWriter (fs_compiled_memory); - - result = compileShader (cmdLine, fs_source_reader, fs_compiled_writer); - if (result != EXIT_SUCCESS) { - std::cerr << "Error compiling shader " << _fsFileName << std::endl; - return BGFX_INVALID_HANDLE; - } - - uint32_t size = fs_compiled_writer->seek(0, bx::Whence::End); - const bgfx::Memory* mem = bgfx::alloc(size+1); - bx::ReaderSeekerI* fs_compiled_reader = new bx::MemoryReader ((uint8_t*) fs_compiled_memory->more(), size); - bx::read(fs_compiled_reader, mem->data, size); - delete fs_compiled_reader; - mem->data[mem->size-1] = '\0'; - fsh = bgfx::createShader(mem); - - delete fs_source_reader; - delete fs_compiled_writer; - delete fs_compiled_memory; - } - - return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */); -} - typedef unsigned char stbi_uc; extern "C" stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); diff --git a/src/modules/TestModule.cc b/src/modules/TestModule.cc index 37f0676..bd6d966 100644 --- a/src/modules/TestModule.cc +++ b/src/modules/TestModule.cc @@ -173,7 +173,7 @@ void update_character(module_state* state, float dt) { } static struct module_state *module_init() { - std::cout << "Module init called" << std::endl; + gLog ("%s %s called", __FILE__, __FUNCTION__); module_state *state = (module_state*) malloc(sizeof(*state)); state->modules_window_selected_index = -1; @@ -195,14 +195,14 @@ static void module_serialize ( } static void module_finalize(struct module_state *state) { - std::cout << "Module finalize called" << std::endl; + gLog ("%s %s called (state %p)", __FILE__, __FUNCTION__, state); free(state); } static void module_reload(struct module_state *state, void* read_serializer) { - std::cout << "Module reload called. State: " << state << std::endl; + gLog ("%s %s called (state %p)", __FILE__, __FUNCTION__, state); - cout << "Creating render entity ..." << endl; + gLog ("Creating render entity"); state->character = new CharacterEntity; state->character->mPosition = Vector3f (0.f, 0.f, 0.f); @@ -214,16 +214,17 @@ static void module_reload(struct module_state *state, void* read_serializer) { } static void module_unload(struct module_state *state, void* write_serializer) { + gLog ("%s %s called (state %p)", __FILE__, __FUNCTION__, state); // serialize the state of the entity if (write_serializer != nullptr) { + gLog ("Serializing state"); module_serialize(state, static_cast(write_serializer)); } // clean up state->character->mEntity = nullptr; delete state->character; - - std::cout << "TestModule unloaded. State: " << state << std::endl; + gLog ("Cleanup complete"); } void ShowModulesWindow(struct module_state *state) { @@ -297,6 +298,7 @@ static bool module_step(struct module_state *state, float dt) { { ImGui::Checkbox("Modules", &state->modules_window_visible); ImGui::Checkbox("ImGui Demo", &state->imgui_demo_window_visible); + gLog ("show demo: %d", state->imgui_demo_window_visible == true); ImGui::Checkbox("Character", &state->character_properties_window_visible); ImGui::EndMenu(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9eef5e6..d2732d8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,17 +5,18 @@ set (GOOGLETEST_DIR include_directories ( ${GOOGLETEST_DIR}/include ${CMAKE_SOURCE_DIR}/3rdparty/bx/include + ${CMAKE_SOURCE_DIR}/3rdparty/bx/3rdparty ) set (TEST_SRCS RenderModuleTests.cc ${GOOGLETEST_DIR}/src/gtest_main.cc - ${CMAKE_SOURCE_DIR}/3rdparty/bx/src/math.cpp - ${CMAKE_SOURCE_DIR}/3rdparty/bx/src/bx.cpp + ${CMAKE_SOURCE_DIR}/3rdparty/bx/src/amalgamated.cpp ) add_executable ( runtests ${TEST_SRCS} ) target_link_libraries (runtests + ${CMAKE_DL_LIBS} gtest )