diff --git a/CMakeLists.txt b/CMakeLists.txt index 0daf4e7..8a7a9fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,10 @@ SUBDIRS ( 3rdparty/googletest ) +SET (GLFW_BUILD_DOCS OFF) +SET (GLFW_BUILD_EXAMPLES OFF) +SET (GLFW_BUILD_TESTS OFF) + SET ( protot_SRCS src/RuntimeModuleManager.cc src/Utils.cc diff --git a/data/shaders/Makefile b/data/shaders/Makefile deleted file mode 100644 index 9c49196..0000000 --- a/data/shaders/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 8b8948c..0000000 --- a/data/shaders/common/bgfx_shader.sh +++ /dev/null @@ -1,322 +0,0 @@ -/* - * 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 deleted file mode 100644 index e42c20e..0000000 --- a/data/shaders/common/common.sh +++ /dev/null @@ -1,7 +0,0 @@ -/* - * 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 deleted file mode 100644 index b8915d1..0000000 --- a/data/shaders/common/shaderlib.sh +++ /dev/null @@ -1,352 +0,0 @@ -/* - * 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 deleted file mode 100644 index 48c5f94..0000000 --- a/data/shaders/debug/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 8f9d731..0000000 --- a/data/shaders/debug/fs_debug.sc +++ /dev/null @@ -1,14 +0,0 @@ -$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 deleted file mode 100644 index 5639a2d..0000000 Binary files a/data/shaders/debug/fs_debug.sc.bin and /dev/null differ diff --git a/data/shaders/debug/varying.def.sc b/data/shaders/debug/varying.def.sc deleted file mode 100644 index 2bd6633..0000000 --- a/data/shaders/debug/varying.def.sc +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 1c69373..0000000 --- a/data/shaders/debug/vs_debug.sc +++ /dev/null @@ -1,15 +0,0 @@ -$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/fs_simple.glsl b/data/shaders/fs_simple.glsl new file mode 100644 index 0000000..3e3e66c --- /dev/null +++ b/data/shaders/fs_simple.glsl @@ -0,0 +1,7 @@ +#version 330 core + +out vec3 color; + +void main() { + color = vec3(1, 0, 0); +} diff --git a/data/shaders/glsl/fs_cubes.bin b/data/shaders/glsl/fs_cubes.bin deleted file mode 100644 index 6f8e3df..0000000 Binary files a/data/shaders/glsl/fs_cubes.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_debug.sc.bin b/data/shaders/glsl/fs_debug.sc.bin deleted file mode 100644 index bce1283..0000000 Binary files a/data/shaders/glsl/fs_debug.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_hdr_mesh.bin b/data/shaders/glsl/fs_hdr_mesh.bin deleted file mode 100644 index 6a3d077..0000000 Binary files a/data/shaders/glsl/fs_hdr_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_ibl_mesh.bin b/data/shaders/glsl/fs_ibl_mesh.bin deleted file mode 100644 index 2e35f1e..0000000 Binary files a/data/shaders/glsl/fs_ibl_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_ibl_skybox.sc.bin b/data/shaders/glsl/fs_ibl_skybox.sc.bin deleted file mode 100644 index 8161447..0000000 Binary files a/data/shaders/glsl/fs_ibl_skybox.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_lines.sc.bin b/data/shaders/glsl/fs_lines.sc.bin deleted file mode 100644 index 0acc59f..0000000 Binary files a/data/shaders/glsl/fs_lines.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_lines_occluded.sc.bin b/data/shaders/glsl/fs_lines_occluded.sc.bin deleted file mode 100644 index 2edf5b9..0000000 Binary files a/data/shaders/glsl/fs_lines_occluded.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_mesh.bin b/data/shaders/glsl/fs_mesh.bin deleted file mode 100644 index e761dfc..0000000 Binary files a/data/shaders/glsl/fs_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_sms_mesh.bin b/data/shaders/glsl/fs_sms_mesh.bin deleted file mode 100644 index e1d1276..0000000 Binary files a/data/shaders/glsl/fs_sms_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_sms_mesh.bin.orig b/data/shaders/glsl/fs_sms_mesh.bin.orig deleted file mode 100644 index f13a6e5..0000000 --- a/data/shaders/glsl/fs_sms_mesh.bin.orig +++ /dev/null @@ -1,503 +0,0 @@ -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 deleted file mode 100644 index 9e4371e..0000000 Binary files a/data/shaders/glsl/fs_sms_mesh.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_sms_mesh_pd.bin b/data/shaders/glsl/fs_sms_mesh_pd.bin deleted file mode 100644 index e18e85f..0000000 Binary files a/data/shaders/glsl/fs_sms_mesh_pd.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_sms_mesh_textured.sc.bin b/data/shaders/glsl/fs_sms_mesh_textured.sc.bin deleted file mode 100644 index 5924c3c..0000000 Binary files a/data/shaders/glsl/fs_sms_mesh_textured.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_sms_shadow.bin b/data/shaders/glsl/fs_sms_shadow.bin deleted file mode 100644 index 98147ab..0000000 Binary files a/data/shaders/glsl/fs_sms_shadow.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_sms_shadow.sc.bin b/data/shaders/glsl/fs_sms_shadow.sc.bin deleted file mode 100644 index 29069e6..0000000 Binary files a/data/shaders/glsl/fs_sms_shadow.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/fs_sms_shadow_pd.bin b/data/shaders/glsl/fs_sms_shadow_pd.bin deleted file mode 100644 index 6148b43..0000000 Binary files a/data/shaders/glsl/fs_sms_shadow_pd.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_cubes.bin b/data/shaders/glsl/vs_cubes.bin deleted file mode 100644 index 14e430c..0000000 Binary files a/data/shaders/glsl/vs_cubes.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_debug.sc.bin b/data/shaders/glsl/vs_debug.sc.bin deleted file mode 100644 index 150f27f..0000000 Binary files a/data/shaders/glsl/vs_debug.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_hdr_mesh.bin b/data/shaders/glsl/vs_hdr_mesh.bin deleted file mode 100644 index 1673c92..0000000 Binary files a/data/shaders/glsl/vs_hdr_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_ibl_mesh.bin b/data/shaders/glsl/vs_ibl_mesh.bin deleted file mode 100644 index 172605c..0000000 Binary files a/data/shaders/glsl/vs_ibl_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_ibl_skybox.sc.bin b/data/shaders/glsl/vs_ibl_skybox.sc.bin deleted file mode 100644 index b37bfca..0000000 Binary files a/data/shaders/glsl/vs_ibl_skybox.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_lines.sc.bin b/data/shaders/glsl/vs_lines.sc.bin deleted file mode 100644 index 6b65cd8..0000000 Binary files a/data/shaders/glsl/vs_lines.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_mesh.bin b/data/shaders/glsl/vs_mesh.bin deleted file mode 100644 index 4402482..0000000 Binary files a/data/shaders/glsl/vs_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_sms_mesh.bin b/data/shaders/glsl/vs_sms_mesh.bin deleted file mode 100644 index f78b903..0000000 Binary files a/data/shaders/glsl/vs_sms_mesh.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_sms_mesh.sc.bin b/data/shaders/glsl/vs_sms_mesh.sc.bin deleted file mode 100644 index cc852af..0000000 Binary files a/data/shaders/glsl/vs_sms_mesh.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_sms_mesh_textured.sc.bin b/data/shaders/glsl/vs_sms_mesh_textured.sc.bin deleted file mode 100644 index e7e5400..0000000 Binary files a/data/shaders/glsl/vs_sms_mesh_textured.sc.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_sms_shadow.bin b/data/shaders/glsl/vs_sms_shadow.bin deleted file mode 100644 index 1e0b06b..0000000 Binary files a/data/shaders/glsl/vs_sms_shadow.bin and /dev/null differ diff --git a/data/shaders/glsl/vs_sms_shadow_pd.bin b/data/shaders/glsl/vs_sms_shadow_pd.bin deleted file mode 100644 index 099732e..0000000 Binary files a/data/shaders/glsl/vs_sms_shadow_pd.bin and /dev/null differ diff --git a/data/shaders/include/shaderlib.sh b/data/shaders/include/shaderlib.sh deleted file mode 100644 index 51f9b6a..0000000 --- a/data/shaders/include/shaderlib.sh +++ /dev/null @@ -1,386 +0,0 @@ -/* - * 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 deleted file mode 100644 index 80d5f5e..0000000 --- a/data/shaders/lines/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 39a4e4e..0000000 --- a/data/shaders/lines/fs_lines.sc +++ /dev/null @@ -1,13 +0,0 @@ -$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 deleted file mode 100644 index 59b2573..0000000 --- a/data/shaders/lines/fs_lines_occluded.sc +++ /dev/null @@ -1,16 +0,0 @@ -$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 deleted file mode 100644 index 13291c5..0000000 --- a/data/shaders/lines/varying.def.sc +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index aaafa37..0000000 --- a/data/shaders/lines/vs_lines.sc +++ /dev/null @@ -1,71 +0,0 @@ -$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 deleted file mode 100644 index 85a3718..0000000 --- a/data/shaders/scene/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 949af40..0000000 --- a/data/shaders/scene/fs_sms_mesh.sc +++ /dev/null @@ -1,11 +0,0 @@ -$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 deleted file mode 100644 index 20c0bde..0000000 --- a/data/shaders/scene/fs_sms_mesh_textured.sc +++ /dev/null @@ -1,12 +0,0 @@ -$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 deleted file mode 100644 index 77e7a23..0000000 --- a/data/shaders/scene/fs_sms_shadow.sh +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2bd6633..0000000 --- a/data/shaders/scene/varying.def.sc +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 585ed14..0000000 --- a/data/shaders/scene/vs_sms_mesh.sc +++ /dev/null @@ -1,24 +0,0 @@ -$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 deleted file mode 100644 index ec8c072..0000000 --- a/data/shaders/scene/vs_sms_mesh_textured.sc +++ /dev/null @@ -1,27 +0,0 @@ -$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 deleted file mode 100644 index 693e602..0000000 --- a/data/shaders/shadowmap/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 5a9356d..0000000 --- a/data/shaders/shadowmap/fs_sms_shadow.sc +++ /dev/null @@ -1,11 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2bd6633..0000000 --- a/data/shaders/shadowmap/varying.def.sc +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 585ed14..0000000 --- a/data/shaders/shadowmap/vs_sms_mesh.sc +++ /dev/null @@ -1,24 +0,0 @@ -$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 deleted file mode 100644 index bc0253c..0000000 --- a/data/shaders/skybox/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index d092038..0000000 --- a/data/shaders/skybox/fs_ibl_skybox.sc +++ /dev/null @@ -1,33 +0,0 @@ -$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 deleted file mode 100644 index 51f9b6a..0000000 --- a/data/shaders/skybox/shaderlib.sh +++ /dev/null @@ -1,386 +0,0 @@ -/* - * 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 deleted file mode 100644 index 61354fc..0000000 --- a/data/shaders/skybox/uniforms.sh +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2bd6633..0000000 --- a/data/shaders/skybox/varying.def.sc +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index f3a15e0..0000000 --- a/data/shaders/skybox/vs_ibl_skybox.sc +++ /dev/null @@ -1,29 +0,0 @@ -$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 deleted file mode 100644 index 80711b8..0000000 --- a/data/shaders/src/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index f607f17..0000000 --- a/data/shaders/src/bgfx_shader.sh +++ /dev/null @@ -1,466 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4fc0a0a..0000000 --- a/data/shaders/src/fs_cubes.sc +++ /dev/null @@ -1,13 +0,0 @@ -$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 deleted file mode 100644 index 949af40..0000000 --- a/data/shaders/src/fs_sms_mesh.sc +++ /dev/null @@ -1,11 +0,0 @@ -$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 deleted file mode 100644 index ca27f46..0000000 --- a/data/shaders/src/fs_sms_mesh_pd.sc +++ /dev/null @@ -1,11 +0,0 @@ -$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 deleted file mode 100644 index 6ab5628..0000000 --- a/data/shaders/src/fs_sms_mesh_pd_textured.sc +++ /dev/null @@ -1,12 +0,0 @@ -$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 deleted file mode 100644 index 77e7a23..0000000 --- a/data/shaders/src/fs_sms_shadow.sh +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 deleted file mode 100644 index b3c7f8b..0000000 --- a/data/shaders/src/fs_sms_shadow.sh.orig +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 deleted file mode 100644 index 44664dc..0000000 Binary files a/data/shaders/src/mesh.out and /dev/null differ diff --git a/data/shaders/src/shaderlib.sh b/data/shaders/src/shaderlib.sh deleted file mode 100644 index 51f9b6a..0000000 --- a/data/shaders/src/shaderlib.sh +++ /dev/null @@ -1,386 +0,0 @@ -/* - * 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 deleted file mode 100644 index 61354fc..0000000 --- a/data/shaders/src/uniforms.sh +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2bd6633..0000000 --- a/data/shaders/src/varying.def.sc +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 1c69373..0000000 --- a/data/shaders/src/vs_cubes.sc +++ /dev/null @@ -1,15 +0,0 @@ -$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 deleted file mode 100644 index 681f3af..0000000 --- a/data/shaders/src/vs_sms_shadow.sc +++ /dev/null @@ -1,13 +0,0 @@ -$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/data/shaders/vs_simple.glsl b/data/shaders/vs_simple.glsl new file mode 100644 index 0000000..fbdc8c1 --- /dev/null +++ b/data/shaders/vs_simple.glsl @@ -0,0 +1,9 @@ +#version 150 core +#extension GL_ARB_explicit_uniform_location : require + +in vec3 vertexPosition_modelspace; + +void main() { + gl_Position.xyz = vertexPosition_modelspace; + gl_Position.w = 1.0; +} diff --git a/src/Serializer.h b/src/Serializer.h index f32b82b..f27900e 100644 --- a/src/Serializer.h +++ b/src/Serializer.h @@ -82,7 +82,7 @@ struct ReadSerializer { size_t key_size; size_t block_size; - while (!stream.eof()) { + while (!stream.eof() && stream.peek() != std::ifstream::traits_type::eof()) { // read key size stream.read(reinterpret_cast(&key_size), sizeof(size_t)); // std::cout << "read key size " << key_size << std::endl; diff --git a/src/Utils.h b/src/Utils.h index f6088ef..d254566 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -8,6 +8,7 @@ #include #include #include +#include struct GuiInputState { int32_t mousedX; diff --git a/src/main.cc b/src/main.cc index d82ce77..d599f69 100644 --- a/src/main.cc +++ b/src/main.cc @@ -2,6 +2,8 @@ #include #include +#include "Globals.h" + #include #include @@ -16,9 +18,7 @@ #include "imgui_dock.h" #include "imgui_impl_glfw_gl3.h" -#include "Globals.h" #include "Serializer.h" -#include "FileModificationObserver.h" Timer* gTimer = nullptr; Renderer* gRenderer = nullptr; @@ -95,7 +95,7 @@ int main(void) glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_SAMPLES, 16); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); @@ -157,8 +157,7 @@ int main(void) glfwGetWindowSize(gWindow, &width, &height); glfwPollEvents(); - ImGui_ImplGlfwGL3_NewFrame(); - +// ImGui_ImplGlfwGL3_NewFrame(); // imguiBeginFrame (gGuiInputState->mouseX, // gGuiInputState->mouseY, @@ -187,47 +186,47 @@ int main(void) } assert (gTimer->mDeltaTime >= 0.0f); -#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(); - - if (ImGui::BeginDock("dock1")) { - ImGui::Text("HEllo 1"); - } - ImGui::EndDock(); - - if (ImGui::BeginDock("dock2")) { - ImGui::Text("HEllo2"); - } - ImGui::EndDock(); - - if (ImGui::BeginDock("dock3")) { - ImGui::Text("HEllo3"); - } - ImGui::EndDock(); - - -#endif +//#ifdef USE_DOCKS +// ImGui::SetNextWindowPos(ImVec2(0.0f, 20.0f)); +// ImGui::SetNextWindowSize(ImVec2(width, height)); +// if (ImGui::Begin("DockArea", NULL, +// ImGuiWindowFlags_NoTitleBar +// | ImGuiWindowFlags_NoResize +// | ImGuiWindowFlags_NoMove +// | ImGuiWindowFlags_NoBringToFrontOnFocus +// )) { +// ImGui::BeginDockspace(); +// +// if (ImGui::BeginDock("dock1")) { +// ImGui::Text("HEllo 1"); +// } +// ImGui::EndDock(); +// +// if (ImGui::BeginDock("dock2")) { +// ImGui::Text("HEllo2"); +// } +// ImGui::EndDock(); +// +// if (ImGui::BeginDock("dock3")) { +// ImGui::Text("HEllo3"); +// } +// ImGui::EndDock(); +// +// +//#endif module_manager.Update(gTimer->mDeltaTime); -#ifdef USE_DOCKS - ImGui::EndDockspace(); - } - - ImGui::End(); -#endif - - ImGui::Render(); +// #ifdef USE_DOCKS +// ImGui::EndDockspace(); +// } +// +// ImGui::End(); +// #endif +// +// ImGui::Render(); usleep(16000); diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 661fbe4..dbf9ae7 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -4,6 +4,7 @@ INCLUDE_DIRECTORIES ( ADD_LIBRARY (RenderModule SHARED RenderModule.cc + RenderUtils.cc ) # ADD_LIBRARY (TestModule SHARED diff --git a/src/modules/RenderModule.cc b/src/modules/RenderModule.cc index 2842e62..f36f22a 100644 --- a/src/modules/RenderModule.cc +++ b/src/modules/RenderModule.cc @@ -4,6 +4,12 @@ struct Renderer; +static const GLfloat g_vertex_buffer_data[] = { + -1.0f, -1.0f, 0.0f, + 1.0f, -1.0f, 0.0f, + 0.0f, 1.0f, 0.0f +}; + // // Module // @@ -53,6 +59,7 @@ static void module_reload(struct module_state *state, void *read_serializer) { gLog ("Renderer initialize"); assert (state != nullptr); state->renderer->Initialize(100, 100); + gRenderer = state->renderer; // load the state of the module @@ -99,7 +106,6 @@ const struct module_api MODULE_API = { // Camera // void Camera::updateMatrices() { - assert(false); } @@ -107,19 +113,41 @@ void Camera::updateMatrices() { // Camera // void Renderer::Initialize(int width, int height) { - assert(false); + glGenVertexArrays(1, &mMesh.mVertexArrayId); + glBindVertexArray(mMesh.mVertexArrayId); + glGenBuffers(1, &mMesh.mVertexBuffer); + glBindBuffer(GL_ARRAY_BUFFER, mMesh.mVertexBuffer); +glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW); + + mProgram = RenderProgram("data/shaders/vs_simple.glsl", "data/shaders/fs_simple.glsl"); + bool load_result = mProgram.Load(); + assert(load_result); } void Renderer::Shutdown() { - assert(false); + glDeleteVertexArrays(1, &mMesh.mVertexArrayId); } void Renderer::RenderGl() { - gLog("blaa"); - assert(false); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glUseProgram(mProgram.mProgramId); + + glEnableVertexAttribArray(0); + glBindBuffer(GL_ARRAY_BUFFER, mMesh.mVertexBuffer); + glVertexAttribPointer( + 0, // attribute 0 + 3, // size + GL_FLOAT, // type + GL_FALSE, // normalized? + 0, // stride + (void*)0 // offset + ); + + glDrawArrays(GL_TRIANGLES, 0, 3); // starting from vertex 0; 3 vertices total + glDisableVertexAttribArray(0); } void Renderer::RenderGui() { - assert(false); } void Renderer::Resize (int width, int height) { diff --git a/src/modules/RenderModule.h b/src/modules/RenderModule.h index 5f7dbb2..684c534 100644 --- a/src/modules/RenderModule.h +++ b/src/modules/RenderModule.h @@ -7,7 +7,10 @@ #include "math_types.h" +#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you. + #include "Globals.h" +#include "RenderUtils.h" struct Camera { Vector3f eye; @@ -98,124 +101,9 @@ struct Light { } }; -struct Transform { - Quaternion rotation = Quaternion (0.0f, 0.0f, 0.0f, 1.0f); - Vector3f translation = Vector3f (0.0f, 0.0f, 0.0f); - Vector3f scale = Vector3f (1.0f, 1.0f, 1.0f); - - Transform () {}; - - Transform ( - const Vector3f &translation, - const Quaternion &rotation, - const Vector3f &scale) - : - translation(translation), - rotation(rotation), - scale(scale) - {} - - Transform (const Matrix44f& mat) { - fromMatrix(mat); - } - - Matrix44f toMatrix() const { - Matrix44f result; - - Matrix33f scale_mat ( - scale[0], 0.0f, 0.0f, - 0.0f, scale[1], 0.0f, - 0.0f, 0.0f, scale[2] - ); - result.block<3,3>(0,0) = scale_mat * rotation.toMatrix(); - result.block<1,3>(3,0) = translation.transpose(); - result.block<3,1>(0,3) = Vector3f::Zero(); - result(3,3) = 1.0f; - - return result; - } - - void fromMatrix(const Matrix44f &matrix) { - // Extract rotation matrix and the quaternion - Matrix33f rot_matrix (matrix.block<3,3>(0,0)); - - Vector3f row0 = rot_matrix.block<1,3>(0,0).transpose(); - Vector3f row1 = rot_matrix.block<1,3>(1,0).transpose(); - Vector3f row2 = rot_matrix.block<1,3>(2,0).transpose(); - - scale.set( - row0.norm(), - row1.norm(), - row2.norm() - ); - - rot_matrix.block<1,3>(0,0) = (row0 / scale[0]).transpose(); - rot_matrix.block<1,3>(1,0) = (row1 / scale[1]).transpose(); - rot_matrix.block<1,3>(2,0) = (row2 / scale[2]).transpose(); - - rotation = Quaternion::fromMatrix(rot_matrix).normalize(); - - row0 = rot_matrix.block<1,3>(0,0).transpose(); - row1 = rot_matrix.block<1,3>(1,0).transpose(); - row2 = rot_matrix.block<1,3>(2,0).transpose(); - - Vector3f trans ( - matrix(3,0), - matrix(3,1), - matrix(3,2) - ); - - translation = trans; - } - Transform operator*(const Transform &other) const { - Matrix44f this_mat (toMatrix()); - Matrix44f other_mat (other.toMatrix()); - - return Transform(this_mat * other_mat); - } - Vector3f operator*(const Vector3f &vec) const { - assert(false); - return Vector3f::Zero(); - } - - static Transform fromTrans( - const Vector3f &translation - ) { - return Transform ( - translation, - Quaternion(0.0f, 0.0f, 0.0f, 1.0f), - Vector3f(1.0f, 1.0f, 1.0f) - ); - } - - static Transform fromTransRot( - const Vector3f &translation, - const Quaternion &rotation - ) { - return Transform ( - translation, - rotation, - Vector3f(1.0f, 1.0f, 1.0f) - ); - } - - static Transform fromTransRot( - const Vector3f &translation, - const Matrix33f &rotation - ) { - return Transform ( - translation, - Quaternion::fromMatrix(rotation), - Vector3f(1.0f, 1.0f, 1.0f) - ); - } - static Transform fromTransRotScale( - const Vector3f &translation, - const Quaternion &rotation, - const Vector3f &scale - ) { - return Transform (translation, rotation, scale); - } +struct Mesh { + GLuint mVertexArrayId = -1; + GLuint mVertexBuffer = -1; }; struct Renderer { @@ -224,6 +112,8 @@ struct Renderer { uint32_t view_height = 1; std::vector cameras; + Mesh mMesh; + RenderProgram mProgram; Renderer() : initialized(false), diff --git a/src/modules/RenderUtils.cc b/src/modules/RenderUtils.cc index a57789e..6872fb7 100644 --- a/src/modules/RenderUtils.cc +++ b/src/modules/RenderUtils.cc @@ -1,25 +1,8 @@ -#include "GLFW/glfw3.h" - #include // strlen #include #include -#include "common.h" - -#include -#include -#include -namespace stl = tinystl; - -#include -#include -#include -#include -#include -#include -#include -#include "entry/dbg.h" -#include +#include #include "RenderModule.h" #include "RenderUtils.h" @@ -27,1239 +10,103 @@ namespace stl = tinystl; using namespace SimpleMath; -void *load(const char *_filePath, uint32_t *_size = NULL); - -void unload(void *_ptr); - - -namespace bgfx -{ -// int32_t read(bx::ReaderI* _reader, bgfx::VertexDecl& _decl); -// int32_t read(bx::ReaderI* _reader, bgfx::VertexDecl& _decl, bx::Error* _err = NULL); +RenderProgram::~RenderProgram() { + if (mProgramId > 0) + glDeleteProgram(mProgramId); } -namespace bgfxutils { +bool RenderProgram::Load() { + // Create the shaders + GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER); + GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); -namespace entry { - static bx::FileReaderI* s_fileReader = NULL; - static bx::FileWriterI* s_fileWriter = NULL; - - bx::AllocatorI* getDefaultAllocator() - { - BX_PRAGMA_DIAGNOSTIC_PUSH(); - BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4459); // warning C4459: declaration of 's_allocator' hides global declaration - BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wshadow"); - static bx::DefaultAllocator s_allocator; - return &s_allocator; - BX_PRAGMA_DIAGNOSTIC_POP(); - } - static bx::AllocatorI* s_allocator = getDefaultAllocator(); - - bx::FileReaderI* getFileReader() - { - if (s_fileReader == NULL) { - s_fileReader = new bx::FileReader; - } - return s_fileReader; + // Read the Vertex Shader code from the file + std::string VertexShaderCode; + std::ifstream VertexShaderStream(mVertexShaderFilename.c_str(), std::ios::in); + if(VertexShaderStream.is_open()){ + std::stringstream sstr; + sstr << VertexShaderStream.rdbuf(); + VertexShaderCode = sstr.str(); + VertexShaderStream.close(); + }else{ + gLog("Impossible to open %s. Are you in the right directory ? Don't forget to read the FAQ !\n", mVertexShaderFilename.c_str()); + getchar(); + return false; } - bx::FileWriterI* getFileWriter() - { - if (s_fileWriter == NULL) { - s_fileWriter = new bx::FileWriter; - } - return s_fileWriter; + // Read the Fragment Shader code from the file + std::string FragmentShaderCode; + std::ifstream FragmentShaderStream(mFragmentShaderFilename.c_str(), std::ios::in); + if(FragmentShaderStream.is_open()){ + std::stringstream sstr; + sstr << FragmentShaderStream.rdbuf(); + FragmentShaderCode = sstr.str(); + FragmentShaderStream.close(); } - bx::AllocatorI* getAllocator() - { - return s_allocator; - } -} + GLint Result = GL_FALSE; + int InfoLogLength; -void* load(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _filePath, uint32_t* _size) -{ - if (0 == bx::open(_reader, _filePath) ) - { - uint32_t size = (uint32_t)bx::getSize(_reader); - void* data = BX_ALLOC(_allocator, size); - bx::read(_reader, data, size); - bx::close(_reader); - if (NULL != _size) - { - *_size = size; - } - return data; - } - else - { - DBG("Failed to open: %s.", _filePath); + + // Compile Vertex Shader + gLog("Compiling shader : %s\n", mVertexShaderFilename.c_str()); + char const * VertexSourcePointer = VertexShaderCode.c_str(); + glShaderSource(VertexShaderID, 1, &VertexSourcePointer , NULL); + glCompileShader(VertexShaderID); + + // Check Vertex Shader + glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result); + glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength); + if ( InfoLogLength > 0 ){ + std::vector VertexShaderErrorMessage(InfoLogLength+1); + glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]); + gLog("%s\n", &VertexShaderErrorMessage[0]); } - if (NULL != _size) - { - *_size = 0; - } - return NULL; -} -void* load(const char* _filePath, uint32_t* _size) -{ - return load(entry::getFileReader(), entry::getAllocator(), _filePath, _size); -} -void unload(void* _ptr) -{ - BX_FREE(entry::getAllocator(), _ptr); -} + // Compile Fragment Shader + gLog("Compiling shader : %s\n", mFragmentShaderFilename.c_str()); + char const * FragmentSourcePointer = FragmentShaderCode.c_str(); + glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer , NULL); + glCompileShader(FragmentShaderID); -static const bgfx::Memory* loadMem(bx::FileReaderI* _reader, const char* _filePath) -{ - bx::Error err; - bool file_ok = _reader->open(_filePath, &err); - if (file_ok) - { - uint32_t size = (uint32_t)bx::getSize(_reader); - const bgfx::Memory* mem = bgfx::alloc(size+1); - bx::read(_reader, mem->data, size); - bx::close(_reader); - mem->data[mem->size-1] = '\0'; - return mem; - } else { - std::cerr << "Error opening file " << _filePath << std::endl; - abort(); + // Check Fragment Shader + glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result); + glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength); + if ( InfoLogLength > 0 ){ + std::vector FragmentShaderErrorMessage(InfoLogLength+1); + glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]); + gLog("%s\n", &FragmentShaderErrorMessage[0]); } - return NULL; -} -static void* loadMem(bx::FileReaderI* _reader, bx::AllocatorI* _allocator, const char* _filePath, uint32_t* _size) -{ - bx::Error err; - bool file_ok = _reader->open(_filePath, &err); - if (file_ok) - { - uint32_t size = (uint32_t)bx::getSize(_reader); - void* data = BX_ALLOC(_allocator, size); - bx::read(_reader, data, size); - bx::close(_reader); - if (NULL != _size) - { - *_size = size; - } - return data; + // Link the program + gLog("Linking program\n"); + GLuint ProgramID = glCreateProgram(); + glAttachShader(ProgramID, VertexShaderID); + glAttachShader(ProgramID, FragmentShaderID); + glLinkProgram(ProgramID); + + // Check the program + glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result); + glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength); + if ( InfoLogLength > 0 ){ + std::vector ProgramErrorMessage(InfoLogLength+1); + glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &ProgramErrorMessage[0]); + gLog("%s\n", &ProgramErrorMessage[0]); } - DBG("Failed to load %s.", _filePath); - return NULL; -} -int compileShader(bx::CommandLine& _cmdLine, bx::ReaderSeekerI* _reader, bx::WriterI* _writer) { - assert(false); - return -1; + glDetachShader(ProgramID, VertexShaderID); + glDetachShader(ProgramID, FragmentShaderID); + + glDeleteShader(VertexShaderID); + glDeleteShader(FragmentShaderID); + + mProgramId = ProgramID; + return true; } -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 = "data/shaders/dx9/"; - - switch (bgfx::getRendererType() ) - { - case bgfx::RendererType::Direct3D11: - case bgfx::RendererType::Direct3D12: - shaderPath = "data/shaders/dx11/"; - break; - - case bgfx::RendererType::OpenGL: - shaderPath = "data/shaders/glsl/"; - break; - - case bgfx::RendererType::Metal: - shaderPath = "data/shaders/metal/"; - break; - - case bgfx::RendererType::OpenGLES: - shaderPath = "data/shaders/gles/"; - break; - - default: - break; - } - - strcpy(filePath, shaderPath); - strcat(filePath, _name); - strcat(filePath, ".bin"); - - gLog ("Loading shader %s", filePath); - - return bgfx::createShader(loadMem(_reader, filePath) ); -} - -bgfx::ShaderHandle loadShader(const char* _name) -{ - return loadShader(entry::getFileReader(), _name); -} - -bgfx::ProgramHandle loadProgram(bx::FileReaderI* _reader, const char* _vsName, const char* _fsName) -{ - bgfx::ShaderHandle vsh = loadShader(_reader, _vsName); - bgfx::ShaderHandle fsh = BGFX_INVALID_HANDLE; - if (NULL != _fsName) - { - fsh = loadShader(_reader, _fsName); - } - - return bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */); -} - -bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName) -{ - gLog ("Loading program from %s and %s", _vsName, _fsName); - return loadProgram(entry::getFileReader(), _vsName, _fsName); -} - -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); - -bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _name, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info) -{ - char filePath[512] = { '\0' }; - if (NULL == strchr(_name, '/') ) - { - strcpy(filePath, "data/textures/"); - } - - strcat(filePath, _name); - - gLog ("Loading texture %s", filePath); - - if (NULL != bx::strFindI(_name, ".dds") - || NULL != bx::strFindI(_name, ".pvr") - || NULL != bx::strFindI(_name, ".ktx") ) - { - const bgfx::Memory* mem = loadMem(_reader, filePath); - if (NULL != mem) - { - return bgfx::createTexture(mem, _flags, _skip, _info); - } - - bgfx::TextureHandle handle = BGFX_INVALID_HANDLE; - DBG("Failed to load %s.", filePath); - return handle; - } - - bgfx::TextureHandle handle = BGFX_INVALID_HANDLE; - bx::AllocatorI* allocator = entry::getAllocator(); - - uint32_t size = 0; - void* data = loadMem(_reader, allocator, filePath, &size); - if (NULL != data) - { - int width = 0; - int height = 0; - int comp = 0; - - uint8_t* img = NULL; - img = stbi_load_from_memory( (uint8_t*)data, size, &width, &height, &comp, 4); - - BX_FREE(allocator, data); - - if (NULL != img) - { - handle = bgfx::createTexture2D(uint16_t(width), uint16_t(height), - false, - 1, - bgfx::TextureFormat::RGBA8, - _flags, - bgfx::copy(img, width*height*4) - ); - - free(img); - - if (NULL != _info) - { - bgfx::calcTextureSize(*_info - , uint16_t(width) - , uint16_t(height) - , 0 - , false - , false - , 1 - , bgfx::TextureFormat::RGBA8 - ); - } - } - } - else - { - DBG("Failed to load %s.", filePath); - } - - return handle; -} - -bgfx::TextureHandle loadTexture(const char* _name, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info) -{ - return loadTexture(entry::getFileReader(), _name, _flags, _skip, _info); -} - -struct Aabb -{ - float m_min[3]; - float m_max[3]; -}; - -struct Obb -{ - float m_mtx[16]; -}; - -struct Sphere -{ - float m_center[3]; - float m_radius; -}; - -struct Primitive -{ - uint32_t m_startIndex; - uint32_t m_numIndices; - uint32_t m_startVertex; - uint32_t m_numVertices; - - Sphere m_sphere; - Aabb m_aabb; - Obb m_obb; -}; - -typedef stl::vector PrimitiveArray; - -struct Group -{ - Group() - { - reset(); - } - - void reset() - { - m_vbh.idx = BGFX_INVALID_HANDLE; - m_ibh.idx = BGFX_INVALID_HANDLE; - m_prims.clear(); - } - - bgfx::VertexBufferHandle m_vbh; - bgfx::IndexBufferHandle m_ibh; - Sphere m_sphere; - Aabb m_aabb; - Obb m_obb; - PrimitiveArray m_prims; -}; - - -struct Mesh -{ - void load(bx::ReaderSeekerI* _reader) - { -#define BGFX_CHUNK_MAGIC_VB BX_MAKEFOURCC('V', 'B', ' ', 0x1) -#define BGFX_CHUNK_MAGIC_IB BX_MAKEFOURCC('I', 'B', ' ', 0x0) -#define BGFX_CHUNK_MAGIC_IBC BX_MAKEFOURCC('I', 'B', 'C', 0x0) -#define BGFX_CHUNK_MAGIC_PRI BX_MAKEFOURCC('P', 'R', 'I', 0x0) - - using namespace bx; - using namespace bgfx; - - Group group; - - bx::AllocatorI* allocator = entry::getAllocator(); - - uint32_t chunk; - while (4 == bx::read(_reader, chunk) ) - { - switch (chunk) - { - case BGFX_CHUNK_MAGIC_VB: - { - read(_reader, group.m_sphere); - read(_reader, &group.m_aabb, sizeof(Aabb)); - read(_reader, &group.m_obb, sizeof(Obb)); - - read(_reader, &m_decl, sizeof(bgfx::VertexDecl)); - - uint16_t stride = m_decl.getStride(); - - uint16_t numVertices; - read(_reader, numVertices); - const bgfx::Memory* mem = bgfx::alloc(numVertices*stride); - read(_reader, mem->data, mem->size); - - group.m_vbh = bgfx::createVertexBuffer(mem, m_decl); - } - break; - - case BGFX_CHUNK_MAGIC_IB: - { - uint32_t numIndices; - read(_reader, numIndices); - const bgfx::Memory* mem = bgfx::alloc(numIndices*2); - read(_reader, mem->data, mem->size); - group.m_ibh = bgfx::createIndexBuffer(mem); - } - break; - - case BGFX_CHUNK_MAGIC_IBC: - { - uint32_t numIndices; - bx::read(_reader, numIndices); - - const bgfx::Memory* mem = bgfx::alloc(numIndices*2); - - uint32_t compressedSize; - bx::read(_reader, compressedSize); - - void* compressedIndices = BX_ALLOC(allocator, compressedSize); - - bx::read(_reader, compressedIndices, compressedSize); - - ReadBitstream rbs( (const uint8_t*)compressedIndices, compressedSize); - DecompressIndexBuffer( (uint16_t*)mem->data, numIndices / 3, rbs); - - BX_FREE(allocator, compressedIndices); - - group.m_ibh = bgfx::createIndexBuffer(mem); - } - break; - - case BGFX_CHUNK_MAGIC_PRI: - { - uint16_t len; - read(_reader, len); - - stl::string material; - material.resize(len); - read(_reader, const_cast(material.c_str() ), len); - - uint16_t num; - read(_reader, num); - - for (uint32_t ii = 0; ii < num; ++ii) - { - read(_reader, len); - - stl::string name; - name.resize(len); - read(_reader, const_cast(name.c_str() ), len); - - Primitive prim; - read(_reader, prim.m_startIndex); - read(_reader, prim.m_numIndices); - read(_reader, prim.m_startVertex); - read(_reader, prim.m_numVertices); - read(_reader, prim.m_sphere); - read(_reader, prim.m_aabb); - read(_reader, prim.m_obb); - - group.m_prims.push_back(prim); - } - - m_groups.push_back(group); - group.reset(); - } - break; - - default: - DBG("%08x at %d", chunk, bx::skip(_reader, 0) ); - break; - } - } - } - - void unload() - { - for (GroupArray::const_iterator it = m_groups.begin(), itEnd = m_groups.end(); it != itEnd; ++it) - { - const Group& group = *it; - bgfx::destroy(group.m_vbh); - - if (bgfx::isValid(group.m_ibh) ) - { - bgfx::destroy(group.m_ibh); - } - } - m_groups.clear(); - } - - void submit(uint8_t _id, bgfx::ProgramHandle _program, const float* _mtx, uint64_t _state) const - { - if (BGFX_STATE_MASK == _state) - { - _state = 0 - | BGFX_STATE_RGB_WRITE - | BGFX_STATE_ALPHA_WRITE - | BGFX_STATE_DEPTH_WRITE - | BGFX_STATE_DEPTH_TEST_LESS - | BGFX_STATE_CULL_CCW - | BGFX_STATE_MSAA - ; - } - - uint32_t cached = bgfx::setTransform(_mtx); - - for (GroupArray::const_iterator it = m_groups.begin(), itEnd = m_groups.end(); it != itEnd; ++it) - { - const Group& group = *it; - - bgfx::setTransform(cached); - bgfx::setIndexBuffer(group.m_ibh); - bgfx::setVertexBuffer(0, group.m_vbh); - bgfx::setState(_state); - bgfx::submit(_id, _program); - } - } - - void submit(const RenderState* _state, uint8_t _numPasses, const float* _mtx, uint16_t _numMatrices) const - { - uint32_t cached = bgfx::setTransform(_mtx, _numMatrices); - - for (uint32_t pass = 0; pass < _numPasses; ++pass) - { - const RenderState& state = _state[pass]; - - for (GroupArray::const_iterator it = m_groups.begin(), itEnd = m_groups.end(); it != itEnd; ++it) - { - const Group& group = *it; - - bgfx::setTransform(cached, _numMatrices); - for (uint8_t tex = 0; tex < state.m_numTextures; ++tex) - { - const RenderState::Texture& texture = state.m_textures[tex]; - bgfx::setTexture(texture.m_stage - , texture.m_sampler - , texture.m_texture - , texture.m_flags - ); - } - bgfx::setIndexBuffer(group.m_ibh); - bgfx::setVertexBuffer(0, group.m_vbh); - bgfx::setState(state.m_state); - bgfx::submit(state.m_viewId, state.m_program.program); - } - } - } - - bgfx::VertexDecl m_decl; - typedef stl::vector GroupArray; - GroupArray m_groups; -}; - -Mesh* meshLoad(bx::ReaderSeekerI* _reader) -{ - Mesh* mesh = new Mesh; - mesh->load(_reader); - return mesh; -} - -Mesh* meshLoad(const char* _filePath) -{ - bx::FileReaderI* reader = entry::getFileReader(); - bx::open(reader, _filePath); - Mesh* mesh = meshLoad(reader); - bx::close(reader); - return mesh; -} - -void meshUnload(Mesh* _mesh) -{ - _mesh->unload(); - delete _mesh; -} - -void meshSubmit(const Mesh* _mesh, uint8_t _id, bgfx::ProgramHandle _program, const float* _mtx, uint64_t _state) -{ - _mesh->submit(_id, _program, _mtx, _state); -} - -void meshSubmit(const Mesh* _mesh, const RenderState* _state, uint8_t _numPasses, const float* _mtx, uint16_t _numMatrices) -{ - _mesh->submit(_state, _numPasses, _mtx, _numMatrices); -} - -uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w) -{ - union - { - uint32_t ui32; - uint8_t arr[4]; - } un; - - un.arr[0] = _x; - un.arr[1] = _y; - un.arr[2] = _z; - un.arr[3] = _w; - - return un.ui32; -} - -uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f) -{ - const uint8_t xx = uint8_t(_x*127.0f + 128.0f); - const uint8_t yy = uint8_t(_y*127.0f + 128.0f); - const uint8_t zz = uint8_t(_z*127.0f + 128.0f); - const uint8_t ww = uint8_t(_w*127.0f + 128.0f); - return packUint32(xx, yy, zz, ww); -} - -struct PosNormalColorVertex { - float m_x; - float m_y; - float m_z; - uint32_t m_normal; - uint32_t m_rgba; - - static void init() { - ms_decl - .begin() - .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) - .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) - .add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true, true) - .end(); - } - - static bgfx::VertexDecl ms_decl; -}; - -bgfx::VertexDecl PosNormalColorVertex::ms_decl; - -struct PosNormalTexcoordVertex -{ - float m_x; - float m_y; - float m_z; - uint32_t m_normal; - - static void init() - { - ms_decl - .begin() - .add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float) - .add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true) - .end(); - } - - static bgfx::VertexDecl ms_decl; -}; - -bgfx::VertexDecl PosNormalTexcoordVertex::ms_decl; - -static const PosNormalTexcoordVertex s_cubeVertices[] = -{ - { -1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f)}, - { 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 1.0f, 0.0f)}, - { -1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f)}, - { 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 1.0f, 0.0f)}, - { -1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f)}, - { 1.0f, -1.0f, 1.0f, packF4u( 0.0f, -1.0f, 0.0f)}, - { -1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f)}, - { 1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f, 0.0f)}, - { 1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f)}, - { 1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f)}, - { -1.0f, -1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f)}, - { -1.0f, 1.0f, 1.0f, packF4u( 0.0f, 0.0f, 1.0f)}, - { 1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f)}, - { 1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f)}, - { -1.0f, -1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f)}, - { -1.0f, 1.0f, -1.0f, packF4u( 0.0f, 0.0f, -1.0f)}, - { 1.0f, 1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f)}, - { 1.0f, 1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f)}, - { 1.0f, -1.0f, -1.0f, packF4u( 1.0f, 0.0f, 0.0f)}, - { 1.0f, -1.0f, 1.0f, packF4u( 1.0f, 0.0f, 0.0f)}, - { -1.0f, 1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f)}, - { -1.0f, 1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f)}, - { -1.0f, -1.0f, -1.0f, packF4u(-1.0f, 0.0f, 0.0f)}, - { -1.0f, -1.0f, 1.0f, packF4u(-1.0f, 0.0f, 0.0f)}, -}; - -static const uint16_t s_cubeIndices[] = -{ - 0, 1, 2, - 1, 3, 2, - 4, 6, 5, - 5, 6, 7, - - 8, 9, 10, - 9, 11, 10, - 12, 14, 13, - 13, 14, 15, - - 16, 17, 18, - 17, 19, 18, - 20, 22, 21, - 21, 22, 23, -}; - -void mesh_load(Mesh* mesh, const void* _vertices, uint32_t _numVertices, const bgfx::VertexDecl _decl - , const uint16_t* _indices, uint32_t _numIndices) -{ - Group group; - const bgfx::Memory* mem; - uint32_t size; - - size = _numVertices*_decl.getStride(); - mem = bgfx::makeRef(_vertices, size); - group.m_vbh = bgfx::createVertexBuffer(mem, _decl); - - size = _numIndices*2; - mem = bgfx::makeRef(_indices, size); - group.m_ibh = bgfx::createIndexBuffer(mem); - - //TODO: - // group.m_sphere = ... - // group.m_aabb = ... - // group.m_obb = ... - // group.m_prims = ... - - mesh->m_groups.push_back(group); -} - -// Mesh *createMeshFromVBO (const MeshVBO& mesh_buffer) { -// PosNormalTexcoordVertex::init(); -// Mesh* result = new Mesh(); -// -// const std::vector& vertices = mesh_buffer.vertices; -// const std::vector& normals = mesh_buffer.normals; -// const std::vector& colors = mesh_buffer.colors; -// -// bool have_normals = mesh_buffer.normals.size() > 0; -// bool have_colors = mesh_buffer.colors.size() > 0; -// -// PosNormalColorVertex::init(); -// -// uint16_t stride = PosNormalColorVertex::ms_decl.getStride(); -// const bgfx::Memory* vb_mem = bgfx::alloc (vertices.size() * stride); -// PosNormalColorVertex* mesh_vb = (PosNormalColorVertex*) vb_mem; -// -// const bgfx::Memory* ib_mem = bgfx::alloc (sizeof(uint16_t) * vertices.size()); -// uint16_t* mesh_ib = (uint16_t*) ib_mem; -// -// for (unsigned int i = 0; i < mesh_buffer.vertices.size(); i++) { -// mesh_vb[i].m_x = vertices[i][0]; -// mesh_vb[i].m_y = vertices[i][1]; -// mesh_vb[i].m_z = vertices[i][2]; -// -// if (have_normals) { -// mesh_vb[i].m_normal = packF4u (-normals[i][0], -normals[i][1], -normals[i][2]); -// } else { -// mesh_vb[i].m_normal = 0; -// } -// -// if (have_colors) { -// mesh_vb[i].m_rgba = packF4u (colors[i][0], colors[i][1], colors[i][2], colors[i][3]); -// } else { -// mesh_vb[i].m_rgba = packF4u (1.f, 1.f, 1.f, 1.f); -// } -// -// mesh_ib[i] = i; -// } -// -// mesh_load(result, mesh_vb, vertices.size(), PosNormalColorVertex::ms_decl, mesh_ib, vertices.size()); -// -// return result; -// } - -Mesh *createMeshFromStdVectors ( - const std::vector &vertices, - const std::vector &normals, - const std::vector &colors - ) { - // create and copy the data into the actual mesh - Mesh* result = new Mesh(); - PosNormalColorVertex::init(); - bool have_normals = normals.size() > 0; - bool have_colors = colors.size() > 0; - - uint16_t stride = PosNormalColorVertex::ms_decl.getStride(); - const bgfx::Memory* vb_mem = bgfx::alloc (vertices.size() * stride); - PosNormalColorVertex* mesh_vb = (PosNormalColorVertex*) vb_mem; - - const bgfx::Memory* ib_mem = bgfx::alloc (sizeof(uint16_t) * vertices.size()); - uint16_t* mesh_ib = (uint16_t*) ib_mem; - - for (unsigned int i = 0; i < vertices.size(); i++) { - mesh_vb[i].m_x = vertices[i][0]; - mesh_vb[i].m_y = vertices[i][1]; - mesh_vb[i].m_z = vertices[i][2]; - - if (have_normals) { - mesh_vb[i].m_normal = packF4u (normals[i][0], normals[i][1], normals[i][2]); - } else { - mesh_vb[i].m_normal = 0; - } - - if (have_colors) { - mesh_vb[i].m_rgba = packF4u (colors[i][0], colors[i][1], colors[i][2], colors[i][3]); - } else { - mesh_vb[i].m_rgba = packF4u (1.f, 1.f, 1.f, 1.f); - } - - mesh_ib[i] = i; - } - - mesh_load(result, mesh_vb, vertices.size(), PosNormalColorVertex::ms_decl, mesh_ib, vertices.size()); - - return result; -} - -void meshTransform (Mesh* mesh, const float *mtx) { -// void bgfx::vertexPack(const float _input[4], bool _inputNormalized, Attrib::Enum _attr, const VertexDecl &_decl, void *_data, uint32_t _index = 0) - -} - - - -} - -Mesh::~Mesh() { - if (mBgfxMesh != nullptr) { - mBgfxMesh->unload(); - delete mBgfxMesh; - mBgfxMesh = nullptr; - } -} - -void Mesh::Update() { - if (mBgfxMesh != nullptr) { - mBgfxMesh->unload(); - delete mBgfxMesh; - mBgfxMesh = nullptr; - } - - mBgfxMesh = bgfxutils::createMeshFromStdVectors (mVertices, mNormals, mColors); -} - -void Mesh::UpdateBounds() { - if (mVertices.size() == 0) { - mBoundsMin = Vector3f (0.f, 0.f, 0.f); - mBoundsMax = Vector3f (0.f, 0.f, 0.f); - - gLog ("Error: updating bounds for mesh with zero vertices"); - abort(); - } - - mBoundsMin = mVertices[0].block<3,1>(0,0); - mBoundsMax = mVertices[0].block<3,1>(0,0); - - for (int i = 0; i < mVertices.size(); i++) { - for (int j = 0; j < 3; j++) { - mBoundsMin[j] = mBoundsMin[j] < mVertices[i][j] - ? mBoundsMin[j] :mVertices[i][j]; - mBoundsMax[j] = mBoundsMax[j] > mVertices[i][j] - ? mBoundsMax[j] :mVertices[i][j]; - } - } -} - -void Mesh::Merge (const Mesh& other, const Matrix44f &transform) { - for (int i = 0; i < other.mVertices.size(); ++i) { - mVertices.push_back (transform.transpose() * other.mVertices[i]); - mNormals.push_back (Matrix33f(transform.block<3,3>(0,0)).transpose() * other.mNormals[i]); - - if (other.mColors.size() == other.mVertices.size()) - mColors.push_back(other.mColors[i]); - } -} - -void Mesh::Submit (const RenderState *state, const float* matrix) const { - bgfxutils::meshSubmit ( - mBgfxMesh, - state, - 1, - matrix); -} - -void Mesh::Transform(const Matrix44f &transform) { - for (int i = 0; i < mVertices.size(); ++i) { - mVertices[i] = (transform.transpose() * mVertices[i]); - mNormals[i] = (Matrix33f(transform.block<3,3>(0,0)).transpose() * mNormals[i]); - } -} - -Mesh* Mesh::sCreateCuboid (float width, float height, float depth) { - Mesh* result = new Mesh(); - - // work arrays that we fill with data - std::vector &vertices = result->mVertices; - std::vector &normals = result->mNormals; - std::vector &colors = result->mColors; - - Vector4f v0 ( 0.5 * width, -0.5 * height, 0.5 * depth, 1.f); - Vector4f v1 ( 0.5 * width, -0.5 * height, -0.5 * depth, 1.f); - Vector4f v2 ( 0.5 * width, 0.5 * height, -0.5 * depth, 1.f); - Vector4f v3 ( 0.5 * width, 0.5 * height, 0.5 * depth, 1.f); - - Vector4f v4 ( -0.5 * width, -0.5 * height, 0.5 * depth, 1.f); - Vector4f v5 ( -0.5 * width, -0.5 * height, -0.5 * depth, 1.f); - Vector4f v6 ( -0.5 * width, 0.5 * height, -0.5 * depth, 1.f); - Vector4f v7 ( -0.5 * width, 0.5 * height, 0.5 * depth, 1.f); - - Vector3f normal; - // +x - normal = Vector3f (1., 0., 0.); - vertices.push_back(v0); - normals.push_back(normal); - vertices.push_back(v1); - normals.push_back(normal); - vertices.push_back(v2); - normals.push_back(normal); - - vertices.push_back(v2); - normals.push_back(normal); - vertices.push_back(v3); - normals.push_back(normal); - vertices.push_back(v0); - normals.push_back(normal); - - // +y - normal = Vector3f (0., 1., 0.); - vertices.push_back(v3); - normals.push_back(normal); - vertices.push_back(v2); - normals.push_back(normal); - vertices.push_back(v6); - normals.push_back(normal); - - vertices.push_back(v6); - normals.push_back(normal); - vertices.push_back(v7); - normals.push_back(normal); - vertices.push_back(v3); - normals.push_back(normal); - - // +z - normal = Vector3f (0., 0., 1.); - vertices.push_back(v4); - normals.push_back(normal); - vertices.push_back(v0); - normals.push_back(normal); - vertices.push_back(v3); - normals.push_back(normal); - - vertices.push_back(v3); - normals.push_back(normal); - vertices.push_back(v7); - normals.push_back(normal); - vertices.push_back(v4); - normals.push_back(normal); - - // -x - normal = Vector3f (-1., 0., 0.); - vertices.push_back(v5); - normals.push_back(normal); - vertices.push_back(v4); - normals.push_back(normal); - vertices.push_back(v7); - normals.push_back(normal); - - vertices.push_back(v7); - normals.push_back(normal); - vertices.push_back(v6); - normals.push_back(normal); - vertices.push_back(v5); - normals.push_back(normal); - - // -y - normal = Vector3f (0., -1., 0.); - vertices.push_back(v0); - normals.push_back(normal); - vertices.push_back(v4); - normals.push_back(normal); - vertices.push_back(v5); - normals.push_back(normal); - - vertices.push_back(v5); - normals.push_back(normal); - vertices.push_back(v1); - normals.push_back(normal); - vertices.push_back(v0); - normals.push_back(normal); - - // -z - normal = Vector3f (0., 0., -1.); - vertices.push_back(v1); - normals.push_back(normal); - vertices.push_back(v5); - normals.push_back(normal); - vertices.push_back(v6); - normals.push_back(normal); - - vertices.push_back(v6); - normals.push_back(normal); - vertices.push_back(v2); - normals.push_back(normal); - vertices.push_back(v1); - normals.push_back(normal); - - result->Update(); - - return result; -} - -Mesh* Mesh::sCreateUVSphere (int rows, int segments, float radius) { - Mesh* result = new Mesh(); - - // work arrays that we fill with data - std::vector &vertices = result->mVertices; - std::vector &normals = result->mNormals; - std::vector &colors = result->mColors; - - // fill arrays - float row_d = 1. / (rows); - float angle_d = 2 * M_PI / static_cast(segments); - - for (unsigned int j = 0; j < rows; j++) { - float alpha0 = j * row_d * M_PI; - float alpha1 = (j + 1) * row_d * M_PI; - - float r0 = sin (alpha0) * 0.5f * radius; - float r1 = sin (alpha1) * 0.5f * radius; - - float h0 = cos (alpha0) * 0.5f * radius; - float h1 = cos (alpha1) * 0.5f * radius; - - for (unsigned int i = 0; i < segments; i++) { - Vector3f v0, v1, v2, v3; - float a0 = (i - 0.5) * angle_d; - float a1 = (i + 0.5) * angle_d; - - v0 = Vector3f (r1 * cos(a0), h1, r1 * sin (a0)); - v1 = Vector3f (r1 * cos(a1), h1, r1 * sin (a1)); - v2 = Vector3f (r0 * cos(a1), h0, r0 * sin (a1)); - v3 = Vector3f (r0 * cos(a0), h0, r0 * sin (a0)); - - vertices.push_back (Vector4f(v0[0], v0[1], v0[2], 1.f)); - normals.push_back (v0 * 1.f/ v0.norm()); - - vertices.push_back (Vector4f(v2[0], v2[1], v2[2], 1.f)); - normals.push_back (v2 * 1.f/ v2.norm()); - - vertices.push_back (Vector4f(v1[0], v1[1], v1[2], 1.f)); - normals.push_back (v1 * 1.f/ v1.norm()); - - vertices.push_back (Vector4f(v0[0], v0[1], v0[2], 1.f)); - normals.push_back (v0 * 1.f/ v0.norm()); - - vertices.push_back (Vector4f(v3[0], v3[1], v3[2], 1.f)); - normals.push_back (v3 * 1.f/ v3.norm()); - - vertices.push_back (Vector4f(v2[0], v2[1], v2[2], 1.f)); - normals.push_back (v2 * 1.f/ v2.norm()); - } - } - - result->Update(); - - return result; -} - -Mesh* Mesh::sCreateCylinder (int segments) { - Mesh* result = new Mesh(); - - // work arrays that we fill with data - std::vector &vertices = result->mVertices; - std::vector &normals = result->mNormals; - std::vector &colors = result->mColors; - - float delta = 2. * M_PI / static_cast(segments); - for (unsigned int i = 0; i < segments; i++) { - float r0 = (i - 0.5) * delta; - float r1 = (i + 0.5) * delta; - - float c0 = cos (r0); - float s0 = sin (r0); - - float c1 = cos (r1); - float s1 = sin (r1); - - Vector3f normal0 (-c0, -s0, 0.f); - Vector3f normal1 (-c1, -s1, 0.f); - - Vector4f normal0_4 (-c0, -s0, 0.f, 0.f); - Vector4f normal1_4 (-c1, -s1, 0.f, 0.f); - - Vector4f p0 = normal0_4 + Vector4f (0., 0., 0.5f, 1.0f); - Vector4f p1 = normal0_4 + Vector4f (0., 0., -0.5f, 1.0f); - Vector4f p2 = normal1_4 + Vector4f (0., 0., 0.5f, 1.0f); - Vector4f p3 = normal1_4 + Vector4f (0., 0., -0.5f, 1.0f); - - // side triangle 1 - vertices.push_back(p0); - normals.push_back(normal0); - - vertices.push_back(p1); - normals.push_back(normal0); - - vertices.push_back(p2); - normals.push_back(normal1); - - // side triangle 2 - vertices.push_back(p2); - normals.push_back(normal1); - - vertices.push_back(p1); - normals.push_back(normal0); - - vertices.push_back(p3); - normals.push_back(normal1); - - // upper end triangle - Vector3f normal (0.f, 0.f, 1.f); - - vertices.push_back(p0); - normals.push_back(normal); - - vertices.push_back(p2); - normals.push_back(normal); - - vertices.push_back(Vector4f (0.f, 0.f, 0.5f, 1.0f)); - normals.push_back(normal); - - // lower end triangle - normal = Vector3f(0.f, 0.f, -1.f); - - vertices.push_back(p3); - normals.push_back(normal); - - vertices.push_back(p1); - normals.push_back(normal); - - vertices.push_back(Vector4f (0.f, 0.f, -0.5f, 1.0f)); - normals.push_back(normal); - } - - result->Update(); - - return result; -} - -Mesh* Mesh::sCreateCapsule (int rows, int segments, float length, float radius) { - Mesh* result = new Mesh(); - - // work arrays that we fill with data - std::vector &vertices = result->mVertices; - std::vector &normals = result->mNormals; - std::vector &colors = result->mColors; - - float delta = 2. * M_PI / static_cast(segments); - for (unsigned int i = 0; i < segments; i++) { - float r0 = (i - 0.5) * delta; - float r1 = (i + 0.5) * delta; - - float c0 = cos (r0); - float s0 = sin (r0); - - float c1 = cos (r1); - float s1 = sin (r1); - - Vector3f normal0 (-c0, -s0, 0.f); - Vector3f normal1 (-c1, -s1, 0.f); - - Vector4f normal0_4 (-c0, -s0, 0.f, 0.f); - Vector4f normal1_4 (-c1, -s1, 0.f, 0.f); - - Vector4f p0 = normal0_4 + Vector4f (0., 0., 0.5f, 1.0f); - Vector4f p1 = normal0_4 + Vector4f (0., 0., -0.5f, 1.0f); - Vector4f p2 = normal1_4 + Vector4f (0., 0., 0.5f, 1.0f); - Vector4f p3 = normal1_4 + Vector4f (0., 0., -0.5f, 1.0f); - - // side triangle 1 - vertices.push_back(p0); - normals.push_back(normal0); - - vertices.push_back(p1); - normals.push_back(normal0); - - vertices.push_back(p2); - normals.push_back(normal1); - - // side triangle 2 - vertices.push_back(p2); - normals.push_back(normal1); - - vertices.push_back(p1); - normals.push_back(normal0); - - vertices.push_back(p3); - normals.push_back(normal1); - - // upper end triangle - Vector3f normal (0.f, 0.f, 1.f); - - vertices.push_back(p0); - normals.push_back(normal); - - vertices.push_back(p2); - normals.push_back(normal); - - vertices.push_back(Vector4f (0.f, 0.f, 0.5f, 1.0f)); - normals.push_back(normal); - - // lower end triangle - normal = Vector3f(0.f, 0.f, -1.f); - - vertices.push_back(p3); - normals.push_back(normal); - - vertices.push_back(p1); - normals.push_back(normal); - - vertices.push_back(Vector4f (0.f, 0.f, -0.5f, 1.0f)); - normals.push_back(normal); - } - - result->Update(); - - return result; -}; - diff --git a/src/modules/RenderUtils.h b/src/modules/RenderUtils.h index be7f088..b1a397e 100644 --- a/src/modules/RenderUtils.h +++ b/src/modules/RenderUtils.h @@ -3,66 +3,146 @@ #pragma once -#include "GLFW/glfw3.h" -#include +#include // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you. -// Forward declarations -struct RenderState; +struct Transform { + Quaternion rotation = Quaternion (0.0f, 0.0f, 0.0f, 1.0f); + Vector3f translation = Vector3f (0.0f, 0.0f, 0.0f); + Vector3f scale = Vector3f (1.0f, 1.0f, 1.0f); -namespace bgfxutils { -struct Mesh; -} + Transform () {}; -struct Mesh { - bgfxutils::Mesh* mBgfxMesh = nullptr; - std::vector mVertices; - std::vector mNormals; - std::vector mColors; - Vector3f mBoundsMin = Vector3f(0.f, 0.f, 0.f); - Vector3f mBoundsMax = Vector3f(0.f, 0.f, 0.f); + Transform ( + const Vector3f &translation, + const Quaternion &rotation, + const Vector3f &scale) + : + translation(translation), + rotation(rotation), + scale(scale) + {} - ~Mesh(); - void Update(); - void UpdateBounds (); - void Merge (const Mesh& other, - const Matrix44f &transform = Matrix44f::Identity()); - void Submit (const RenderState *state, const float* matrix) const; - void Transform (const Matrix44f &mat); + Transform (const Matrix44f& mat) { + fromMatrix(mat); + } + + Matrix44f toMatrix() const { + Matrix44f result; - static Mesh *sCreateCuboid (float width, float height, float depth); - static Mesh *sCreateUVSphere (int rows, int segments, float radius = 1.0f); - static Mesh *sCreateCylinder (int segments); - static Mesh *sCreateCapsule (int rows, int segments, float length, float radius); + Matrix33f scale_mat ( + scale[0], 0.0f, 0.0f, + 0.0f, scale[1], 0.0f, + 0.0f, 0.0f, scale[2] + ); + result.block<3,3>(0,0) = scale_mat * rotation.toMatrix(); + result.block<1,3>(3,0) = translation.transpose(); + result.block<3,1>(0,3) = Vector3f::Zero(); + result(3,3) = 1.0f; + + return result; + } + + void fromMatrix(const Matrix44f &matrix) { + // Extract rotation matrix and the quaternion + Matrix33f rot_matrix (matrix.block<3,3>(0,0)); + + Vector3f row0 = rot_matrix.block<1,3>(0,0).transpose(); + Vector3f row1 = rot_matrix.block<1,3>(1,0).transpose(); + Vector3f row2 = rot_matrix.block<1,3>(2,0).transpose(); + + scale.set( + row0.norm(), + row1.norm(), + row2.norm() + ); + + rot_matrix.block<1,3>(0,0) = (row0 / scale[0]).transpose(); + rot_matrix.block<1,3>(1,0) = (row1 / scale[1]).transpose(); + rot_matrix.block<1,3>(2,0) = (row2 / scale[2]).transpose(); + + rotation = Quaternion::fromMatrix(rot_matrix).normalize(); + + row0 = rot_matrix.block<1,3>(0,0).transpose(); + row1 = rot_matrix.block<1,3>(1,0).transpose(); + row2 = rot_matrix.block<1,3>(2,0).transpose(); + + Vector3f trans ( + matrix(3,0), + matrix(3,1), + matrix(3,2) + ); + + translation = trans; + } + Transform operator*(const Transform &other) const { + Matrix44f this_mat (toMatrix()); + Matrix44f other_mat (other.toMatrix()); + + return Transform(this_mat * other_mat); + } + Vector3f operator*(const Vector3f &vec) const { + assert(false); + return Vector3f::Zero(); + } + + static Transform fromTrans( + const Vector3f &translation + ) { + return Transform ( + translation, + Quaternion(0.0f, 0.0f, 0.0f, 1.0f), + Vector3f(1.0f, 1.0f, 1.0f) + ); + } + + static Transform fromTransRot( + const Vector3f &translation, + const Quaternion &rotation + ) { + return Transform ( + translation, + rotation, + Vector3f(1.0f, 1.0f, 1.0f) + ); + } + + static Transform fromTransRot( + const Vector3f &translation, + const Matrix33f &rotation + ) { + return Transform ( + translation, + Quaternion::fromMatrix(rotation), + Vector3f(1.0f, 1.0f, 1.0f) + ); + } + static Transform fromTransRotScale( + const Vector3f &translation, + const Quaternion &rotation, + const Vector3f &scale + ) { + return Transform (translation, rotation, scale); + } }; -namespace bgfxutils { - bgfx::ShaderHandle loadShader(const char *_name); +struct RenderProgram { + std::string mVertexShaderFilename; + std::string mFragmentShaderFilename; - bgfx::ProgramHandle loadProgram(const char *_vsName, const char *_fsName); + GLuint mProgramId = -1; - bgfx::ProgramHandle loadProgramFromFiles(const char *_vsFileName, const char *_fsFileName); + RenderProgram() + {} - bgfx::TextureHandle loadTexture(const char *_name, uint32_t _flags = BGFX_TEXTURE_NONE, uint8_t _skip = 0, - bgfx::TextureInfo *_info = NULL); + RenderProgram(const std::string& vs, const std::string& fs) : + mVertexShaderFilename(vs), + mFragmentShaderFilename(fs) + {} - void calcTangents(void *_vertices, uint16_t _numVertices, bgfx::VertexDecl _decl, const uint16_t *_indices, - uint32_t _numIndices); + ~RenderProgram(); - Mesh *meshLoad(const char *_filePath); + bool Load(); +}; - void meshUnload(Mesh *_mesh); - - void meshSubmit(const Mesh *_mesh, uint8_t _id, bgfx::ProgramHandle _program, const float *_mtx, - uint64_t _state = BGFX_STATE_MASK); - - void meshSubmit(const Mesh *_mesh, const RenderState*_state, uint8_t _numPasses, const float *_mtx, - uint16_t _numMatrices = 1); - - // Loads the mesh data from a VBO into a bgfx Mesh -// Mesh *createMeshFromVBO (const MeshVBO& mesh_buffer); - - void meshTransform (Mesh* mesh, const float *mtx); - -} #endif