diff --git a/README.md b/README.md index a9800968..355ad7b9 100644 --- a/README.md +++ b/README.md @@ -249,10 +249,11 @@ Building Premake 4.4 beta5 ([prebuilt binaries are part of bx](https://github.com/bkaradzic/bx/tree/master/tools/bin)) [http://industriousone.com/premake/download](http://industriousone.com/premake/download) -GNU make and CoreUtils -Windows users download GNU utilities from: +Windows users download GnuWin32 utilities from: [http://gnuwin32.sourceforge.net/packages/make.htm](http://gnuwin32.sourceforge.net/packages/make.htm) -[http://gnuwin32.sourceforge.net/packages/coreutils.htm](http://gnuwin32.sourceforge.net/packages/coreutils.htm) +[http://gnuwin32.sourceforge.net/packages/coreutils.htm](http://gnuwin32.sourceforge.net/packages/coreutils.htm) +[http://gnuwin32.sourceforge.net/packages/libiconv.htm](http://gnuwin32.sourceforge.net/packages/libiconv.htm) +[http://gnuwin32.sourceforge.net/packages/libintl.htm](http://gnuwin32.sourceforge.net/packages/libintl.htm) ### Getting source diff --git a/examples/21-deferred/deferred.cpp b/examples/21-deferred/deferred.cpp index 558e1dd6..4b4fbe8d 100644 --- a/examples/21-deferred/deferred.cpp +++ b/examples/21-deferred/deferred.cpp @@ -277,8 +277,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::UniformHandle s_depth = bgfx::createUniform("s_depth", bgfx::UniformType::Uniform1iv); bgfx::UniformHandle s_light = bgfx::createUniform("s_light", bgfx::UniformType::Uniform1iv); - bgfx::UniformHandle u_mtx = bgfx::createUniform("u_mtx", bgfx::UniformType::Uniform4x4fv); - + bgfx::UniformHandle u_mtx = bgfx::createUniform("u_mtx", bgfx::UniformType::Uniform4x4fv); bgfx::UniformHandle u_lightPosRadius = bgfx::createUniform("u_lightPosRadius", bgfx::UniformType::Uniform4fv); bgfx::UniformHandle u_lightRgbInnerR = bgfx::createUniform("u_lightRgbInnerR", bgfx::UniformType::Uniform4fv); diff --git a/examples/common/shaderlib.sh b/examples/common/shaderlib.sh index 199d1723..aea15288 100644 --- a/examples/common/shaderlib.sh +++ b/examples/common/shaderlib.sh @@ -49,6 +49,44 @@ 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