diff --git a/examples/15-shadowmaps-simple/fs_sms_mesh.sc b/examples/15-shadowmaps-simple/fs_sms_mesh.sc new file mode 100644 index 00000000..949af404 --- /dev/null +++ b/examples/15-shadowmaps-simple/fs_sms_mesh.sc @@ -0,0 +1,11 @@ +$input v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +#define SHADOW_PACKED_DEPTH 0 +#include "fs_sms_shadow.sh" diff --git a/examples/15-shadowmaps-simple/fs_sms_mesh_pd.sc b/examples/15-shadowmaps-simple/fs_sms_mesh_pd.sc new file mode 100644 index 00000000..ca27f46f --- /dev/null +++ b/examples/15-shadowmaps-simple/fs_sms_mesh_pd.sc @@ -0,0 +1,11 @@ +$input v_view, v_normal, v_shadowcoord + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +#define SHADOW_PACKED_DEPTH 1 +#include "fs_sms_shadow.sh" diff --git a/examples/15-shadowmaps-simple/fs_sms_shadow.sc b/examples/15-shadowmaps-simple/fs_sms_shadow.sc new file mode 100644 index 00000000..5a9356d8 --- /dev/null +++ b/examples/15-shadowmaps-simple/fs_sms_shadow.sc @@ -0,0 +1,11 @@ +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_FragColor = vec4_splat(0.0); +} diff --git a/examples/15-shadowmaps-simple/fs_smsimple_draw.sc b/examples/15-shadowmaps-simple/fs_sms_shadow.sh similarity index 80% rename from examples/15-shadowmaps-simple/fs_smsimple_draw.sc rename to examples/15-shadowmaps-simple/fs_sms_shadow.sh index 7cf8c2fb..50c6d01c 100644 --- a/examples/15-shadowmaps-simple/fs_smsimple_draw.sc +++ b/examples/15-shadowmaps-simple/fs_sms_shadow.sh @@ -1,5 +1,3 @@ -$input v_view, v_normal, v_shadowcoord - /* * Copyright 2013-2014 Dario Manesku. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause @@ -8,7 +6,13 @@ $input v_view, v_normal, v_shadowcoord #include "../common/common.sh" uniform vec4 u_lightPos; +#if SHADOW_PACKED_DEPTH SAMPLER2D(u_shadowMap, 4); +# define Sampler sampler2D +#else +SAMPLER2DSHADOW(u_shadowMap, 4); +# define Sampler sampler2DShadow +#endif // SHADOW_PACKED_DEPTH vec2 lit(vec3 _ld, vec3 _n, vec3 _vd, float _exp) { @@ -23,7 +27,17 @@ vec2 lit(vec3 _ld, vec3 _n, vec3 _vd, float _exp) return max(vec2(ndotl, spec), 0.0); } -float hardShadow(sampler2D _sampler, vec4 _shadowCoord, float _bias) +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; @@ -36,15 +50,6 @@ float hardShadow(sampler2D _sampler, vec4 _shadowCoord, float _bias) return 1.0; } - float receiver = (_shadowCoord.z-_bias)/_shadowCoord.w; - float occluder = unpackRgbaToFloat(texture2D(_sampler, texCoord) ); - - float visibility = step(receiver, occluder); - return visibility; -} - -float PCF(sampler2D _sampler, vec4 _shadowCoord, float _bias, vec2 _texelSize) -{ float result = 0.0; vec2 offset = _texelSize * _shadowCoord.w; @@ -73,8 +78,8 @@ float PCF(sampler2D _sampler, vec4 _shadowCoord, float _bias, vec2 _texelSize) void main() { - const float shadowMapBias = 0.005; - const vec3 color = vec3_splat(1.0); + float shadowMapBias = 0.005; + vec3 color = vec3_splat(1.0); vec3 v = v_view; vec3 vd = -normalize(v); @@ -91,6 +96,5 @@ void main() vec3 brdf = (lc.x + lc.y) * color * visibility; vec3 final = toGamma(abs(ambient + brdf) ); - gl_FragColor.xyz = final; - gl_FragColor.w = 1.0; + gl_FragColor = vec4(final, 1.0); } diff --git a/examples/15-shadowmaps-simple/fs_smsimple_packdepth.sc b/examples/15-shadowmaps-simple/fs_sms_shadow_pd.sc similarity index 99% rename from examples/15-shadowmaps-simple/fs_smsimple_packdepth.sc rename to examples/15-shadowmaps-simple/fs_sms_shadow_pd.sc index 5433f91b..86dc0391 100644 --- a/examples/15-shadowmaps-simple/fs_smsimple_packdepth.sc +++ b/examples/15-shadowmaps-simple/fs_sms_shadow_pd.sc @@ -12,4 +12,3 @@ void main() float depth = v_position.z/v_position.w * 0.5 + 0.5; gl_FragColor = packFloatToRgba(depth); } - diff --git a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index f81d3249..225b2e2c 100644 --- a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp @@ -462,10 +462,6 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::UniformHandle u_lightPos = bgfx::createUniform("u_lightPos", bgfx::UniformType::Uniform4fv); bgfx::UniformHandle u_lightMtx = bgfx::createUniform("u_lightMtx", bgfx::UniformType::Uniform4x4fv); - // Programs. - bgfx::ProgramHandle progPackDepth = loadProgram("vs_smsimple_packdepth", "fs_smsimple_packdepth"); - bgfx::ProgramHandle progDraw = loadProgram("vs_smsimple_draw", "fs_smsimple_draw"); - // Vertex declarations. bgfx::VertexDecl PosNormalDecl; PosNormalDecl.begin(); @@ -486,12 +482,41 @@ int _main_(int /*_argc*/, char** /*_argv*/) // Render targets. uint16_t shadowMapSize = 512; - bgfx::TextureHandle fbtextures[] = + // Get renderer capabilities info. + //const bgfx::Caps* caps = bgfx::getCaps(); + // Shadow samplers are supported at least partially supported if texture + // compare less equal feature is supported. + bool shadowSamplerSupported = false; //0 != (caps->supported & BGFX_CAPS_TEXTURE_COMPARE_LEQUAL); + + bgfx::ProgramHandle progShadow; + bgfx::ProgramHandle progMesh; + + if (shadowSamplerSupported) { - bgfx::createTexture2D(shadowMapSize, shadowMapSize, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_RT), - bgfx::createTexture2D(shadowMapSize, shadowMapSize, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_BUFFER_ONLY), - }; - s_shadowMapFB = bgfx::createFrameBuffer(BX_COUNTOF(fbtextures), fbtextures, true); + // Depth textures and shadow samplers are supported. + progShadow = loadProgram("vs_sms_shadow", "fs_sms_shadow"); + progMesh = loadProgram("vs_sms_mesh", "fs_sms_mesh"); + + bgfx::TextureHandle fbtextures[] = + { + bgfx::createTexture2D(shadowMapSize, shadowMapSize, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_COMPARE_LEQUAL), + }; + s_shadowMapFB = bgfx::createFrameBuffer(BX_COUNTOF(fbtextures), fbtextures, true); + } + else + { + // Depth textures and shadow samplers are not supported. Use float + // depth packing into color buffer instead. + progShadow = loadProgram("vs_sms_shadow_pd", "fs_sms_shadow_pd"); + progMesh = loadProgram("vs_sms_mesh", "fs_sms_mesh_pd"); + + bgfx::TextureHandle fbtextures[] = + { + bgfx::createTexture2D(shadowMapSize, shadowMapSize, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_RT), + bgfx::createTexture2D(shadowMapSize, shadowMapSize, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_BUFFER_ONLY), + }; + s_shadowMapFB = bgfx::createFrameBuffer(BX_COUNTOF(fbtextures), fbtextures, true); + } // Set view and projection matrices. float view[16]; @@ -527,7 +552,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) // Use debug font to print information about this example. bgfx::dbgTextClear(); bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/15-shadowmaps-simple"); - bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Shadow maps example."); + bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Shadow maps example (technique: %s).", shadowSamplerSupported ? "depth texture and shadow samplers" : "shadow depth packed into color texture"); bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); // Setup lights. @@ -569,11 +594,6 @@ int _main_(int /*_argc*/, char** /*_argv*/) ); // Define matrices. - float screenView[16]; - float screenProj[16]; - mtxIdentity(screenView); - mtxOrtho(screenProj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f); - float lightView[16]; float lightProj[16]; @@ -601,7 +621,6 @@ int _main_(int /*_argc*/, char** /*_argv*/) , BGFX_CLEAR_COLOR_BIT | BGFX_CLEAR_DEPTH_BIT , 0x303030ff, 1.0f, 0 ); - bgfx::submitMask(RENDER_SHADOW_PASS_BIT|RENDER_SCENE_PASS_BIT); // Render. float mtxShadow[16]; @@ -623,26 +642,26 @@ int _main_(int /*_argc*/, char** /*_argv*/) // Floor. mtxMul(lightMtx, mtxFloor, mtxShadow); bgfx::setUniform(u_lightMtx, lightMtx); - hplaneMesh.submit(RENDER_SCENE_PASS_ID, mtxFloor, progDraw); - hplaneMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxFloor, progPackDepth); + hplaneMesh.submit(RENDER_SCENE_PASS_ID, mtxFloor, progMesh); + hplaneMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxFloor, progShadow); // Bunny. mtxMul(lightMtx, mtxBunny, mtxShadow); bgfx::setUniform(u_lightMtx, lightMtx); - bunnyMesh.submit(RENDER_SCENE_PASS_ID, mtxBunny, progDraw); - bunnyMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxBunny, progPackDepth); + bunnyMesh.submit(RENDER_SCENE_PASS_ID, mtxBunny, progMesh); + bunnyMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxBunny, progShadow); // Hollow cube. mtxMul(lightMtx, mtxHollowcube, mtxShadow); bgfx::setUniform(u_lightMtx, lightMtx); - hollowcubeMesh.submit(RENDER_SCENE_PASS_ID, mtxHollowcube, progDraw); - hollowcubeMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxHollowcube, progPackDepth); + hollowcubeMesh.submit(RENDER_SCENE_PASS_ID, mtxHollowcube, progMesh); + hollowcubeMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxHollowcube, progShadow); // Cube. mtxMul(lightMtx, mtxCube, mtxShadow); bgfx::setUniform(u_lightMtx, lightMtx); - cubeMesh.submit(RENDER_SCENE_PASS_ID, mtxCube, progDraw); - cubeMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxCube, progPackDepth); + cubeMesh.submit(RENDER_SCENE_PASS_ID, mtxCube, progMesh); + cubeMesh.submitShadow(RENDER_SHADOW_PASS_ID, mtxCube, progShadow); // Advance to next frame. Rendering thread will be kicked to // process submitted rendering primitives. @@ -655,8 +674,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) hollowcubeMesh.unload(); hplaneMesh.unload(); - bgfx::destroyProgram(progPackDepth); - bgfx::destroyProgram(progDraw); + bgfx::destroyProgram(progShadow); + bgfx::destroyProgram(progMesh); bgfx::destroyFrameBuffer(s_shadowMapFB); diff --git a/examples/15-shadowmaps-simple/vs_smsimple_draw.sc b/examples/15-shadowmaps-simple/vs_sms_mesh.sc similarity index 100% rename from examples/15-shadowmaps-simple/vs_smsimple_draw.sc rename to examples/15-shadowmaps-simple/vs_sms_mesh.sc diff --git a/examples/15-shadowmaps-simple/vs_sms_shadow.sc b/examples/15-shadowmaps-simple/vs_sms_shadow.sc new file mode 100644 index 00000000..681f3afb --- /dev/null +++ b/examples/15-shadowmaps-simple/vs_sms_shadow.sc @@ -0,0 +1,13 @@ +$input a_position + +/* + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#include "../common/common.sh" + +void main() +{ + gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) ); +} diff --git a/examples/15-shadowmaps-simple/vs_smsimple_packdepth.sc b/examples/15-shadowmaps-simple/vs_sms_shadow_pd.sc similarity index 100% rename from examples/15-shadowmaps-simple/vs_smsimple_packdepth.sc rename to examples/15-shadowmaps-simple/vs_sms_shadow_pd.sc diff --git a/examples/runtime/shaders/dx11/fs_sms_mesh.bin b/examples/runtime/shaders/dx11/fs_sms_mesh.bin new file mode 100644 index 00000000..5abb7235 Binary files /dev/null and b/examples/runtime/shaders/dx11/fs_sms_mesh.bin differ diff --git a/examples/runtime/shaders/dx11/fs_sms_mesh_pd.bin b/examples/runtime/shaders/dx11/fs_sms_mesh_pd.bin new file mode 100644 index 00000000..fcba9c93 Binary files /dev/null and b/examples/runtime/shaders/dx11/fs_sms_mesh_pd.bin differ diff --git a/examples/runtime/shaders/dx11/fs_sms_shadow.bin b/examples/runtime/shaders/dx11/fs_sms_shadow.bin new file mode 100644 index 00000000..7d106862 Binary files /dev/null and b/examples/runtime/shaders/dx11/fs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/dx11/fs_smsimple_packdepth.bin b/examples/runtime/shaders/dx11/fs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/dx11/fs_smsimple_packdepth.bin rename to examples/runtime/shaders/dx11/fs_sms_shadow_pd.bin diff --git a/examples/runtime/shaders/dx11/fs_smsimple_draw.bin b/examples/runtime/shaders/dx11/fs_smsimple_draw.bin deleted file mode 100644 index 24df8154..00000000 Binary files a/examples/runtime/shaders/dx11/fs_smsimple_draw.bin and /dev/null differ diff --git a/examples/runtime/shaders/dx11/vs_smsimple_draw.bin b/examples/runtime/shaders/dx11/vs_sms_mesh.bin similarity index 100% rename from examples/runtime/shaders/dx11/vs_smsimple_draw.bin rename to examples/runtime/shaders/dx11/vs_sms_mesh.bin diff --git a/examples/runtime/shaders/dx11/vs_sms_shadow.bin b/examples/runtime/shaders/dx11/vs_sms_shadow.bin new file mode 100644 index 00000000..5e84b920 Binary files /dev/null and b/examples/runtime/shaders/dx11/vs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/dx11/vs_smsimple_packdepth.bin b/examples/runtime/shaders/dx11/vs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/dx11/vs_smsimple_packdepth.bin rename to examples/runtime/shaders/dx11/vs_sms_shadow_pd.bin diff --git a/examples/runtime/shaders/dx9/fs_sms_mesh.bin b/examples/runtime/shaders/dx9/fs_sms_mesh.bin new file mode 100644 index 00000000..ac9606e3 Binary files /dev/null and b/examples/runtime/shaders/dx9/fs_sms_mesh.bin differ diff --git a/examples/runtime/shaders/dx9/fs_sms_mesh_pd.bin b/examples/runtime/shaders/dx9/fs_sms_mesh_pd.bin new file mode 100644 index 00000000..be52b4ec Binary files /dev/null and b/examples/runtime/shaders/dx9/fs_sms_mesh_pd.bin differ diff --git a/examples/runtime/shaders/dx9/fs_sms_shadow.bin b/examples/runtime/shaders/dx9/fs_sms_shadow.bin new file mode 100644 index 00000000..bc17a168 Binary files /dev/null and b/examples/runtime/shaders/dx9/fs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/dx9/fs_smsimple_packdepth.bin b/examples/runtime/shaders/dx9/fs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/dx9/fs_smsimple_packdepth.bin rename to examples/runtime/shaders/dx9/fs_sms_shadow_pd.bin diff --git a/examples/runtime/shaders/dx9/fs_smsimple_draw.bin b/examples/runtime/shaders/dx9/fs_smsimple_draw.bin deleted file mode 100644 index 4ac0f0d6..00000000 Binary files a/examples/runtime/shaders/dx9/fs_smsimple_draw.bin and /dev/null differ diff --git a/examples/runtime/shaders/dx9/vs_smsimple_draw.bin b/examples/runtime/shaders/dx9/vs_sms_mesh.bin similarity index 100% rename from examples/runtime/shaders/dx9/vs_smsimple_draw.bin rename to examples/runtime/shaders/dx9/vs_sms_mesh.bin diff --git a/examples/runtime/shaders/dx9/vs_sms_shadow.bin b/examples/runtime/shaders/dx9/vs_sms_shadow.bin new file mode 100644 index 00000000..2402ba96 Binary files /dev/null and b/examples/runtime/shaders/dx9/vs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/dx9/vs_smsimple_packdepth.bin b/examples/runtime/shaders/dx9/vs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/dx9/vs_smsimple_packdepth.bin rename to examples/runtime/shaders/dx9/vs_sms_shadow_pd.bin diff --git a/examples/runtime/shaders/gles/fs_sms_mesh.bin b/examples/runtime/shaders/gles/fs_sms_mesh.bin new file mode 100644 index 00000000..95a00ccd Binary files /dev/null and b/examples/runtime/shaders/gles/fs_sms_mesh.bin differ diff --git a/examples/runtime/shaders/gles/fs_sms_mesh_pd.bin b/examples/runtime/shaders/gles/fs_sms_mesh_pd.bin new file mode 100644 index 00000000..e13152f0 Binary files /dev/null and b/examples/runtime/shaders/gles/fs_sms_mesh_pd.bin differ diff --git a/examples/runtime/shaders/gles/fs_sms_shadow.bin b/examples/runtime/shaders/gles/fs_sms_shadow.bin new file mode 100644 index 00000000..d66f79aa Binary files /dev/null and b/examples/runtime/shaders/gles/fs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/gles/fs_smsimple_packdepth.bin b/examples/runtime/shaders/gles/fs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/gles/fs_smsimple_packdepth.bin rename to examples/runtime/shaders/gles/fs_sms_shadow_pd.bin diff --git a/examples/runtime/shaders/gles/fs_smsimple_draw.bin b/examples/runtime/shaders/gles/fs_smsimple_draw.bin deleted file mode 100644 index ea789329..00000000 --- a/examples/runtime/shaders/gles/fs_smsimple_draw.bin +++ /dev/null @@ -1,389 +0,0 @@ -FSHpjHvarying vec3 v_normal; -varying vec4 v_shadowcoord; -varying vec3 v_view; -uniform vec4 u_lightPos; -uniform sampler2D u_shadowMap; -void main () -{ - vec2 lc_1; - vec3 tmpvar_2; - tmpvar_2 = -(normalize(u_lightPos.xyz)); - float tmpvar_3; - tmpvar_3 = dot (v_normal, tmpvar_2); - vec2 tmpvar_4; - tmpvar_4.x = tmpvar_3; - tmpvar_4.y = ((( - float((tmpvar_3 >= 0.0)) - * - pow (max (0.0, dot (( - ((2.0 * tmpvar_3) * v_normal) - - tmpvar_2), -( - normalize(v_view) - ))), 1.0) - ) * 3.0) / 8.0); - lc_1 = max (tmpvar_4, 0.0); - lowp float result_5; - result_5 = 0.0; - vec2 tmpvar_6; - tmpvar_6 = (vec2(0.00195313, 0.00195313) * v_shadowcoord.w); - vec4 tmpvar_7; - tmpvar_7.zw = vec2(0.0, 0.0); - tmpvar_7.xy = (vec2(-1.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_8; - _shadowCoord_8 = (v_shadowcoord + tmpvar_7); - lowp float tmpvar_9; - vec2 tmpvar_10; - tmpvar_10 = (_shadowCoord_8.xy / _shadowCoord_8.w); - bool tmpvar_11; - if (any(greaterThan (tmpvar_10, vec2(1.0, 1.0)))) { - tmpvar_11 = bool(1); - } else { - tmpvar_11 = any(lessThan (tmpvar_10, vec2(0.0, 0.0))); - }; - if (tmpvar_11) { - tmpvar_9 = 1.0; - } else { - tmpvar_9 = float((dot (texture2D (u_shadowMap, tmpvar_10), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_8.z - 0.005) - / _shadowCoord_8.w))); - }; - result_5 = tmpvar_9; - vec4 tmpvar_12; - tmpvar_12.zw = vec2(0.0, 0.0); - tmpvar_12.xy = (vec2(-1.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_13; - _shadowCoord_13 = (v_shadowcoord + tmpvar_12); - lowp float tmpvar_14; - vec2 tmpvar_15; - tmpvar_15 = (_shadowCoord_13.xy / _shadowCoord_13.w); - bool tmpvar_16; - if (any(greaterThan (tmpvar_15, vec2(1.0, 1.0)))) { - tmpvar_16 = bool(1); - } else { - tmpvar_16 = any(lessThan (tmpvar_15, vec2(0.0, 0.0))); - }; - if (tmpvar_16) { - tmpvar_14 = 1.0; - } else { - tmpvar_14 = float((dot (texture2D (u_shadowMap, tmpvar_15), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_13.z - 0.005) - / _shadowCoord_13.w))); - }; - result_5 = (tmpvar_9 + tmpvar_14); - vec4 tmpvar_17; - tmpvar_17.zw = vec2(0.0, 0.0); - tmpvar_17.xy = (vec2(-1.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_18; - _shadowCoord_18 = (v_shadowcoord + tmpvar_17); - lowp float tmpvar_19; - vec2 tmpvar_20; - tmpvar_20 = (_shadowCoord_18.xy / _shadowCoord_18.w); - bool tmpvar_21; - if (any(greaterThan (tmpvar_20, vec2(1.0, 1.0)))) { - tmpvar_21 = bool(1); - } else { - tmpvar_21 = any(lessThan (tmpvar_20, vec2(0.0, 0.0))); - }; - if (tmpvar_21) { - tmpvar_19 = 1.0; - } else { - tmpvar_19 = float((dot (texture2D (u_shadowMap, tmpvar_20), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_18.z - 0.005) - / _shadowCoord_18.w))); - }; - result_5 = (result_5 + tmpvar_19); - vec4 tmpvar_22; - tmpvar_22.zw = vec2(0.0, 0.0); - tmpvar_22.xy = (vec2(-1.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_23; - _shadowCoord_23 = (v_shadowcoord + tmpvar_22); - lowp float tmpvar_24; - vec2 tmpvar_25; - tmpvar_25 = (_shadowCoord_23.xy / _shadowCoord_23.w); - bool tmpvar_26; - if (any(greaterThan (tmpvar_25, vec2(1.0, 1.0)))) { - tmpvar_26 = bool(1); - } else { - tmpvar_26 = any(lessThan (tmpvar_25, vec2(0.0, 0.0))); - }; - if (tmpvar_26) { - tmpvar_24 = 1.0; - } else { - tmpvar_24 = float((dot (texture2D (u_shadowMap, tmpvar_25), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_23.z - 0.005) - / _shadowCoord_23.w))); - }; - result_5 = (result_5 + tmpvar_24); - vec4 tmpvar_27; - tmpvar_27.zw = vec2(0.0, 0.0); - tmpvar_27.xy = (vec2(-0.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_28; - _shadowCoord_28 = (v_shadowcoord + tmpvar_27); - lowp float tmpvar_29; - vec2 tmpvar_30; - tmpvar_30 = (_shadowCoord_28.xy / _shadowCoord_28.w); - bool tmpvar_31; - if (any(greaterThan (tmpvar_30, vec2(1.0, 1.0)))) { - tmpvar_31 = bool(1); - } else { - tmpvar_31 = any(lessThan (tmpvar_30, vec2(0.0, 0.0))); - }; - if (tmpvar_31) { - tmpvar_29 = 1.0; - } else { - tmpvar_29 = float((dot (texture2D (u_shadowMap, tmpvar_30), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_28.z - 0.005) - / _shadowCoord_28.w))); - }; - result_5 = (result_5 + tmpvar_29); - vec4 tmpvar_32; - tmpvar_32.zw = vec2(0.0, 0.0); - tmpvar_32.xy = (vec2(-0.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_33; - _shadowCoord_33 = (v_shadowcoord + tmpvar_32); - lowp float tmpvar_34; - vec2 tmpvar_35; - tmpvar_35 = (_shadowCoord_33.xy / _shadowCoord_33.w); - bool tmpvar_36; - if (any(greaterThan (tmpvar_35, vec2(1.0, 1.0)))) { - tmpvar_36 = bool(1); - } else { - tmpvar_36 = any(lessThan (tmpvar_35, vec2(0.0, 0.0))); - }; - if (tmpvar_36) { - tmpvar_34 = 1.0; - } else { - tmpvar_34 = float((dot (texture2D (u_shadowMap, tmpvar_35), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_33.z - 0.005) - / _shadowCoord_33.w))); - }; - result_5 = (result_5 + tmpvar_34); - vec4 tmpvar_37; - tmpvar_37.zw = vec2(0.0, 0.0); - tmpvar_37.xy = (vec2(-0.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_38; - _shadowCoord_38 = (v_shadowcoord + tmpvar_37); - lowp float tmpvar_39; - vec2 tmpvar_40; - tmpvar_40 = (_shadowCoord_38.xy / _shadowCoord_38.w); - bool tmpvar_41; - if (any(greaterThan (tmpvar_40, vec2(1.0, 1.0)))) { - tmpvar_41 = bool(1); - } else { - tmpvar_41 = any(lessThan (tmpvar_40, vec2(0.0, 0.0))); - }; - if (tmpvar_41) { - tmpvar_39 = 1.0; - } else { - tmpvar_39 = float((dot (texture2D (u_shadowMap, tmpvar_40), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_38.z - 0.005) - / _shadowCoord_38.w))); - }; - result_5 = (result_5 + tmpvar_39); - vec4 tmpvar_42; - tmpvar_42.zw = vec2(0.0, 0.0); - tmpvar_42.xy = (vec2(-0.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_43; - _shadowCoord_43 = (v_shadowcoord + tmpvar_42); - lowp float tmpvar_44; - vec2 tmpvar_45; - tmpvar_45 = (_shadowCoord_43.xy / _shadowCoord_43.w); - bool tmpvar_46; - if (any(greaterThan (tmpvar_45, vec2(1.0, 1.0)))) { - tmpvar_46 = bool(1); - } else { - tmpvar_46 = any(lessThan (tmpvar_45, vec2(0.0, 0.0))); - }; - if (tmpvar_46) { - tmpvar_44 = 1.0; - } else { - tmpvar_44 = float((dot (texture2D (u_shadowMap, tmpvar_45), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_43.z - 0.005) - / _shadowCoord_43.w))); - }; - result_5 = (result_5 + tmpvar_44); - vec4 tmpvar_47; - tmpvar_47.zw = vec2(0.0, 0.0); - tmpvar_47.xy = (vec2(0.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_48; - _shadowCoord_48 = (v_shadowcoord + tmpvar_47); - lowp float tmpvar_49; - vec2 tmpvar_50; - tmpvar_50 = (_shadowCoord_48.xy / _shadowCoord_48.w); - bool tmpvar_51; - if (any(greaterThan (tmpvar_50, vec2(1.0, 1.0)))) { - tmpvar_51 = bool(1); - } else { - tmpvar_51 = any(lessThan (tmpvar_50, vec2(0.0, 0.0))); - }; - if (tmpvar_51) { - tmpvar_49 = 1.0; - } else { - tmpvar_49 = float((dot (texture2D (u_shadowMap, tmpvar_50), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_48.z - 0.005) - / _shadowCoord_48.w))); - }; - result_5 = (result_5 + tmpvar_49); - vec4 tmpvar_52; - tmpvar_52.zw = vec2(0.0, 0.0); - tmpvar_52.xy = (vec2(0.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_53; - _shadowCoord_53 = (v_shadowcoord + tmpvar_52); - lowp float tmpvar_54; - vec2 tmpvar_55; - tmpvar_55 = (_shadowCoord_53.xy / _shadowCoord_53.w); - bool tmpvar_56; - if (any(greaterThan (tmpvar_55, vec2(1.0, 1.0)))) { - tmpvar_56 = bool(1); - } else { - tmpvar_56 = any(lessThan (tmpvar_55, vec2(0.0, 0.0))); - }; - if (tmpvar_56) { - tmpvar_54 = 1.0; - } else { - tmpvar_54 = float((dot (texture2D (u_shadowMap, tmpvar_55), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_53.z - 0.005) - / _shadowCoord_53.w))); - }; - result_5 = (result_5 + tmpvar_54); - vec4 tmpvar_57; - tmpvar_57.zw = vec2(0.0, 0.0); - tmpvar_57.xy = (vec2(0.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_58; - _shadowCoord_58 = (v_shadowcoord + tmpvar_57); - lowp float tmpvar_59; - vec2 tmpvar_60; - tmpvar_60 = (_shadowCoord_58.xy / _shadowCoord_58.w); - bool tmpvar_61; - if (any(greaterThan (tmpvar_60, vec2(1.0, 1.0)))) { - tmpvar_61 = bool(1); - } else { - tmpvar_61 = any(lessThan (tmpvar_60, vec2(0.0, 0.0))); - }; - if (tmpvar_61) { - tmpvar_59 = 1.0; - } else { - tmpvar_59 = float((dot (texture2D (u_shadowMap, tmpvar_60), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_58.z - 0.005) - / _shadowCoord_58.w))); - }; - result_5 = (result_5 + tmpvar_59); - vec4 tmpvar_62; - tmpvar_62.zw = vec2(0.0, 0.0); - tmpvar_62.xy = (vec2(0.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_63; - _shadowCoord_63 = (v_shadowcoord + tmpvar_62); - lowp float tmpvar_64; - vec2 tmpvar_65; - tmpvar_65 = (_shadowCoord_63.xy / _shadowCoord_63.w); - bool tmpvar_66; - if (any(greaterThan (tmpvar_65, vec2(1.0, 1.0)))) { - tmpvar_66 = bool(1); - } else { - tmpvar_66 = any(lessThan (tmpvar_65, vec2(0.0, 0.0))); - }; - if (tmpvar_66) { - tmpvar_64 = 1.0; - } else { - tmpvar_64 = float((dot (texture2D (u_shadowMap, tmpvar_65), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_63.z - 0.005) - / _shadowCoord_63.w))); - }; - result_5 = (result_5 + tmpvar_64); - vec4 tmpvar_67; - tmpvar_67.zw = vec2(0.0, 0.0); - tmpvar_67.xy = (vec2(1.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_68; - _shadowCoord_68 = (v_shadowcoord + tmpvar_67); - lowp float tmpvar_69; - vec2 tmpvar_70; - tmpvar_70 = (_shadowCoord_68.xy / _shadowCoord_68.w); - bool tmpvar_71; - if (any(greaterThan (tmpvar_70, vec2(1.0, 1.0)))) { - tmpvar_71 = bool(1); - } else { - tmpvar_71 = any(lessThan (tmpvar_70, vec2(0.0, 0.0))); - }; - if (tmpvar_71) { - tmpvar_69 = 1.0; - } else { - tmpvar_69 = float((dot (texture2D (u_shadowMap, tmpvar_70), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_68.z - 0.005) - / _shadowCoord_68.w))); - }; - result_5 = (result_5 + tmpvar_69); - vec4 tmpvar_72; - tmpvar_72.zw = vec2(0.0, 0.0); - tmpvar_72.xy = (vec2(1.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_73; - _shadowCoord_73 = (v_shadowcoord + tmpvar_72); - lowp float tmpvar_74; - vec2 tmpvar_75; - tmpvar_75 = (_shadowCoord_73.xy / _shadowCoord_73.w); - bool tmpvar_76; - if (any(greaterThan (tmpvar_75, vec2(1.0, 1.0)))) { - tmpvar_76 = bool(1); - } else { - tmpvar_76 = any(lessThan (tmpvar_75, vec2(0.0, 0.0))); - }; - if (tmpvar_76) { - tmpvar_74 = 1.0; - } else { - tmpvar_74 = float((dot (texture2D (u_shadowMap, tmpvar_75), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_73.z - 0.005) - / _shadowCoord_73.w))); - }; - result_5 = (result_5 + tmpvar_74); - vec4 tmpvar_77; - tmpvar_77.zw = vec2(0.0, 0.0); - tmpvar_77.xy = (vec2(1.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_78; - _shadowCoord_78 = (v_shadowcoord + tmpvar_77); - lowp float tmpvar_79; - vec2 tmpvar_80; - tmpvar_80 = (_shadowCoord_78.xy / _shadowCoord_78.w); - bool tmpvar_81; - if (any(greaterThan (tmpvar_80, vec2(1.0, 1.0)))) { - tmpvar_81 = bool(1); - } else { - tmpvar_81 = any(lessThan (tmpvar_80, vec2(0.0, 0.0))); - }; - if (tmpvar_81) { - tmpvar_79 = 1.0; - } else { - tmpvar_79 = float((dot (texture2D (u_shadowMap, tmpvar_80), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_78.z - 0.005) - / _shadowCoord_78.w))); - }; - result_5 = (result_5 + tmpvar_79); - vec4 tmpvar_82; - tmpvar_82.zw = vec2(0.0, 0.0); - tmpvar_82.xy = (vec2(1.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_83; - _shadowCoord_83 = (v_shadowcoord + tmpvar_82); - lowp float tmpvar_84; - vec2 tmpvar_85; - tmpvar_85 = (_shadowCoord_83.xy / _shadowCoord_83.w); - bool tmpvar_86; - if (any(greaterThan (tmpvar_85, vec2(1.0, 1.0)))) { - tmpvar_86 = bool(1); - } else { - tmpvar_86 = any(lessThan (tmpvar_85, vec2(0.0, 0.0))); - }; - if (tmpvar_86) { - tmpvar_84 = 1.0; - } else { - tmpvar_84 = float((dot (texture2D (u_shadowMap, tmpvar_85), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_83.z - 0.005) - / _shadowCoord_83.w))); - }; - lowp float tmpvar_87; - tmpvar_87 = (result_5 + tmpvar_84); - result_5 = tmpvar_87; - gl_FragColor.xyz = pow (abs((vec3(0.1, 0.1, 0.1) + - (vec3((lc_1.x + lc_1.y)) * (tmpvar_87 / 16.0)) - )), vec3(0.454545, 0.454545, 0.454545)); - gl_FragColor.w = 1.0; -} - - \ No newline at end of file diff --git a/examples/runtime/shaders/gles/vs_smsimple_draw.bin b/examples/runtime/shaders/gles/vs_sms_mesh.bin similarity index 100% rename from examples/runtime/shaders/gles/vs_smsimple_draw.bin rename to examples/runtime/shaders/gles/vs_sms_mesh.bin diff --git a/examples/runtime/shaders/gles/vs_sms_shadow.bin b/examples/runtime/shaders/gles/vs_sms_shadow.bin new file mode 100644 index 00000000..bb6aab4f Binary files /dev/null and b/examples/runtime/shaders/gles/vs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/gles/vs_smsimple_packdepth.bin b/examples/runtime/shaders/gles/vs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/gles/vs_smsimple_packdepth.bin rename to examples/runtime/shaders/gles/vs_sms_shadow_pd.bin diff --git a/examples/runtime/shaders/glsl/fs_sms_mesh.bin b/examples/runtime/shaders/glsl/fs_sms_mesh.bin new file mode 100644 index 00000000..453872ce Binary files /dev/null and b/examples/runtime/shaders/glsl/fs_sms_mesh.bin differ diff --git a/examples/runtime/shaders/glsl/fs_sms_mesh_pd.bin b/examples/runtime/shaders/glsl/fs_sms_mesh_pd.bin new file mode 100644 index 00000000..6ca76e3e Binary files /dev/null and b/examples/runtime/shaders/glsl/fs_sms_mesh_pd.bin differ diff --git a/examples/runtime/shaders/glsl/fs_sms_shadow.bin b/examples/runtime/shaders/glsl/fs_sms_shadow.bin new file mode 100644 index 00000000..d66f79aa Binary files /dev/null and b/examples/runtime/shaders/glsl/fs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/glsl/fs_smsimple_packdepth.bin b/examples/runtime/shaders/glsl/fs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/glsl/fs_smsimple_packdepth.bin rename to examples/runtime/shaders/glsl/fs_sms_shadow_pd.bin diff --git a/examples/runtime/shaders/glsl/fs_smsimple_draw.bin b/examples/runtime/shaders/glsl/fs_smsimple_draw.bin deleted file mode 100644 index ab0eb5eb..00000000 --- a/examples/runtime/shaders/glsl/fs_smsimple_draw.bin +++ /dev/null @@ -1,389 +0,0 @@ -FSHpjHvarying vec3 v_normal; -varying vec4 v_shadowcoord; -varying vec3 v_view; -uniform vec4 u_lightPos; -uniform sampler2D u_shadowMap; -void main () -{ - vec2 lc_1; - vec3 tmpvar_2; - tmpvar_2 = -(normalize(u_lightPos.xyz)); - float tmpvar_3; - tmpvar_3 = dot (v_normal, tmpvar_2); - vec2 tmpvar_4; - tmpvar_4.x = tmpvar_3; - tmpvar_4.y = ((( - float((tmpvar_3 >= 0.0)) - * - pow (max (0.0, dot (( - ((2.0 * tmpvar_3) * v_normal) - - tmpvar_2), -( - normalize(v_view) - ))), 1.0) - ) * 3.0) / 8.0); - lc_1 = max (tmpvar_4, 0.0); - float result_5; - result_5 = 0.0; - vec2 tmpvar_6; - tmpvar_6 = (vec2(0.00195313, 0.00195313) * v_shadowcoord.w); - vec4 tmpvar_7; - tmpvar_7.zw = vec2(0.0, 0.0); - tmpvar_7.xy = (vec2(-1.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_8; - _shadowCoord_8 = (v_shadowcoord + tmpvar_7); - float tmpvar_9; - vec2 tmpvar_10; - tmpvar_10 = (_shadowCoord_8.xy / _shadowCoord_8.w); - bool tmpvar_11; - if (any(greaterThan (tmpvar_10, vec2(1.0, 1.0)))) { - tmpvar_11 = bool(1); - } else { - tmpvar_11 = any(lessThan (tmpvar_10, vec2(0.0, 0.0))); - }; - if (tmpvar_11) { - tmpvar_9 = 1.0; - } else { - tmpvar_9 = float((dot (texture2D (u_shadowMap, tmpvar_10), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_8.z - 0.005) - / _shadowCoord_8.w))); - }; - result_5 = tmpvar_9; - vec4 tmpvar_12; - tmpvar_12.zw = vec2(0.0, 0.0); - tmpvar_12.xy = (vec2(-1.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_13; - _shadowCoord_13 = (v_shadowcoord + tmpvar_12); - float tmpvar_14; - vec2 tmpvar_15; - tmpvar_15 = (_shadowCoord_13.xy / _shadowCoord_13.w); - bool tmpvar_16; - if (any(greaterThan (tmpvar_15, vec2(1.0, 1.0)))) { - tmpvar_16 = bool(1); - } else { - tmpvar_16 = any(lessThan (tmpvar_15, vec2(0.0, 0.0))); - }; - if (tmpvar_16) { - tmpvar_14 = 1.0; - } else { - tmpvar_14 = float((dot (texture2D (u_shadowMap, tmpvar_15), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_13.z - 0.005) - / _shadowCoord_13.w))); - }; - result_5 = (tmpvar_9 + tmpvar_14); - vec4 tmpvar_17; - tmpvar_17.zw = vec2(0.0, 0.0); - tmpvar_17.xy = (vec2(-1.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_18; - _shadowCoord_18 = (v_shadowcoord + tmpvar_17); - float tmpvar_19; - vec2 tmpvar_20; - tmpvar_20 = (_shadowCoord_18.xy / _shadowCoord_18.w); - bool tmpvar_21; - if (any(greaterThan (tmpvar_20, vec2(1.0, 1.0)))) { - tmpvar_21 = bool(1); - } else { - tmpvar_21 = any(lessThan (tmpvar_20, vec2(0.0, 0.0))); - }; - if (tmpvar_21) { - tmpvar_19 = 1.0; - } else { - tmpvar_19 = float((dot (texture2D (u_shadowMap, tmpvar_20), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_18.z - 0.005) - / _shadowCoord_18.w))); - }; - result_5 = (result_5 + tmpvar_19); - vec4 tmpvar_22; - tmpvar_22.zw = vec2(0.0, 0.0); - tmpvar_22.xy = (vec2(-1.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_23; - _shadowCoord_23 = (v_shadowcoord + tmpvar_22); - float tmpvar_24; - vec2 tmpvar_25; - tmpvar_25 = (_shadowCoord_23.xy / _shadowCoord_23.w); - bool tmpvar_26; - if (any(greaterThan (tmpvar_25, vec2(1.0, 1.0)))) { - tmpvar_26 = bool(1); - } else { - tmpvar_26 = any(lessThan (tmpvar_25, vec2(0.0, 0.0))); - }; - if (tmpvar_26) { - tmpvar_24 = 1.0; - } else { - tmpvar_24 = float((dot (texture2D (u_shadowMap, tmpvar_25), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_23.z - 0.005) - / _shadowCoord_23.w))); - }; - result_5 = (result_5 + tmpvar_24); - vec4 tmpvar_27; - tmpvar_27.zw = vec2(0.0, 0.0); - tmpvar_27.xy = (vec2(-0.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_28; - _shadowCoord_28 = (v_shadowcoord + tmpvar_27); - float tmpvar_29; - vec2 tmpvar_30; - tmpvar_30 = (_shadowCoord_28.xy / _shadowCoord_28.w); - bool tmpvar_31; - if (any(greaterThan (tmpvar_30, vec2(1.0, 1.0)))) { - tmpvar_31 = bool(1); - } else { - tmpvar_31 = any(lessThan (tmpvar_30, vec2(0.0, 0.0))); - }; - if (tmpvar_31) { - tmpvar_29 = 1.0; - } else { - tmpvar_29 = float((dot (texture2D (u_shadowMap, tmpvar_30), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_28.z - 0.005) - / _shadowCoord_28.w))); - }; - result_5 = (result_5 + tmpvar_29); - vec4 tmpvar_32; - tmpvar_32.zw = vec2(0.0, 0.0); - tmpvar_32.xy = (vec2(-0.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_33; - _shadowCoord_33 = (v_shadowcoord + tmpvar_32); - float tmpvar_34; - vec2 tmpvar_35; - tmpvar_35 = (_shadowCoord_33.xy / _shadowCoord_33.w); - bool tmpvar_36; - if (any(greaterThan (tmpvar_35, vec2(1.0, 1.0)))) { - tmpvar_36 = bool(1); - } else { - tmpvar_36 = any(lessThan (tmpvar_35, vec2(0.0, 0.0))); - }; - if (tmpvar_36) { - tmpvar_34 = 1.0; - } else { - tmpvar_34 = float((dot (texture2D (u_shadowMap, tmpvar_35), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_33.z - 0.005) - / _shadowCoord_33.w))); - }; - result_5 = (result_5 + tmpvar_34); - vec4 tmpvar_37; - tmpvar_37.zw = vec2(0.0, 0.0); - tmpvar_37.xy = (vec2(-0.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_38; - _shadowCoord_38 = (v_shadowcoord + tmpvar_37); - float tmpvar_39; - vec2 tmpvar_40; - tmpvar_40 = (_shadowCoord_38.xy / _shadowCoord_38.w); - bool tmpvar_41; - if (any(greaterThan (tmpvar_40, vec2(1.0, 1.0)))) { - tmpvar_41 = bool(1); - } else { - tmpvar_41 = any(lessThan (tmpvar_40, vec2(0.0, 0.0))); - }; - if (tmpvar_41) { - tmpvar_39 = 1.0; - } else { - tmpvar_39 = float((dot (texture2D (u_shadowMap, tmpvar_40), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_38.z - 0.005) - / _shadowCoord_38.w))); - }; - result_5 = (result_5 + tmpvar_39); - vec4 tmpvar_42; - tmpvar_42.zw = vec2(0.0, 0.0); - tmpvar_42.xy = (vec2(-0.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_43; - _shadowCoord_43 = (v_shadowcoord + tmpvar_42); - float tmpvar_44; - vec2 tmpvar_45; - tmpvar_45 = (_shadowCoord_43.xy / _shadowCoord_43.w); - bool tmpvar_46; - if (any(greaterThan (tmpvar_45, vec2(1.0, 1.0)))) { - tmpvar_46 = bool(1); - } else { - tmpvar_46 = any(lessThan (tmpvar_45, vec2(0.0, 0.0))); - }; - if (tmpvar_46) { - tmpvar_44 = 1.0; - } else { - tmpvar_44 = float((dot (texture2D (u_shadowMap, tmpvar_45), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_43.z - 0.005) - / _shadowCoord_43.w))); - }; - result_5 = (result_5 + tmpvar_44); - vec4 tmpvar_47; - tmpvar_47.zw = vec2(0.0, 0.0); - tmpvar_47.xy = (vec2(0.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_48; - _shadowCoord_48 = (v_shadowcoord + tmpvar_47); - float tmpvar_49; - vec2 tmpvar_50; - tmpvar_50 = (_shadowCoord_48.xy / _shadowCoord_48.w); - bool tmpvar_51; - if (any(greaterThan (tmpvar_50, vec2(1.0, 1.0)))) { - tmpvar_51 = bool(1); - } else { - tmpvar_51 = any(lessThan (tmpvar_50, vec2(0.0, 0.0))); - }; - if (tmpvar_51) { - tmpvar_49 = 1.0; - } else { - tmpvar_49 = float((dot (texture2D (u_shadowMap, tmpvar_50), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_48.z - 0.005) - / _shadowCoord_48.w))); - }; - result_5 = (result_5 + tmpvar_49); - vec4 tmpvar_52; - tmpvar_52.zw = vec2(0.0, 0.0); - tmpvar_52.xy = (vec2(0.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_53; - _shadowCoord_53 = (v_shadowcoord + tmpvar_52); - float tmpvar_54; - vec2 tmpvar_55; - tmpvar_55 = (_shadowCoord_53.xy / _shadowCoord_53.w); - bool tmpvar_56; - if (any(greaterThan (tmpvar_55, vec2(1.0, 1.0)))) { - tmpvar_56 = bool(1); - } else { - tmpvar_56 = any(lessThan (tmpvar_55, vec2(0.0, 0.0))); - }; - if (tmpvar_56) { - tmpvar_54 = 1.0; - } else { - tmpvar_54 = float((dot (texture2D (u_shadowMap, tmpvar_55), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_53.z - 0.005) - / _shadowCoord_53.w))); - }; - result_5 = (result_5 + tmpvar_54); - vec4 tmpvar_57; - tmpvar_57.zw = vec2(0.0, 0.0); - tmpvar_57.xy = (vec2(0.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_58; - _shadowCoord_58 = (v_shadowcoord + tmpvar_57); - float tmpvar_59; - vec2 tmpvar_60; - tmpvar_60 = (_shadowCoord_58.xy / _shadowCoord_58.w); - bool tmpvar_61; - if (any(greaterThan (tmpvar_60, vec2(1.0, 1.0)))) { - tmpvar_61 = bool(1); - } else { - tmpvar_61 = any(lessThan (tmpvar_60, vec2(0.0, 0.0))); - }; - if (tmpvar_61) { - tmpvar_59 = 1.0; - } else { - tmpvar_59 = float((dot (texture2D (u_shadowMap, tmpvar_60), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_58.z - 0.005) - / _shadowCoord_58.w))); - }; - result_5 = (result_5 + tmpvar_59); - vec4 tmpvar_62; - tmpvar_62.zw = vec2(0.0, 0.0); - tmpvar_62.xy = (vec2(0.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_63; - _shadowCoord_63 = (v_shadowcoord + tmpvar_62); - float tmpvar_64; - vec2 tmpvar_65; - tmpvar_65 = (_shadowCoord_63.xy / _shadowCoord_63.w); - bool tmpvar_66; - if (any(greaterThan (tmpvar_65, vec2(1.0, 1.0)))) { - tmpvar_66 = bool(1); - } else { - tmpvar_66 = any(lessThan (tmpvar_65, vec2(0.0, 0.0))); - }; - if (tmpvar_66) { - tmpvar_64 = 1.0; - } else { - tmpvar_64 = float((dot (texture2D (u_shadowMap, tmpvar_65), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_63.z - 0.005) - / _shadowCoord_63.w))); - }; - result_5 = (result_5 + tmpvar_64); - vec4 tmpvar_67; - tmpvar_67.zw = vec2(0.0, 0.0); - tmpvar_67.xy = (vec2(1.5, -1.5) * tmpvar_6); - vec4 _shadowCoord_68; - _shadowCoord_68 = (v_shadowcoord + tmpvar_67); - float tmpvar_69; - vec2 tmpvar_70; - tmpvar_70 = (_shadowCoord_68.xy / _shadowCoord_68.w); - bool tmpvar_71; - if (any(greaterThan (tmpvar_70, vec2(1.0, 1.0)))) { - tmpvar_71 = bool(1); - } else { - tmpvar_71 = any(lessThan (tmpvar_70, vec2(0.0, 0.0))); - }; - if (tmpvar_71) { - tmpvar_69 = 1.0; - } else { - tmpvar_69 = float((dot (texture2D (u_shadowMap, tmpvar_70), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_68.z - 0.005) - / _shadowCoord_68.w))); - }; - result_5 = (result_5 + tmpvar_69); - vec4 tmpvar_72; - tmpvar_72.zw = vec2(0.0, 0.0); - tmpvar_72.xy = (vec2(1.5, -0.5) * tmpvar_6); - vec4 _shadowCoord_73; - _shadowCoord_73 = (v_shadowcoord + tmpvar_72); - float tmpvar_74; - vec2 tmpvar_75; - tmpvar_75 = (_shadowCoord_73.xy / _shadowCoord_73.w); - bool tmpvar_76; - if (any(greaterThan (tmpvar_75, vec2(1.0, 1.0)))) { - tmpvar_76 = bool(1); - } else { - tmpvar_76 = any(lessThan (tmpvar_75, vec2(0.0, 0.0))); - }; - if (tmpvar_76) { - tmpvar_74 = 1.0; - } else { - tmpvar_74 = float((dot (texture2D (u_shadowMap, tmpvar_75), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_73.z - 0.005) - / _shadowCoord_73.w))); - }; - result_5 = (result_5 + tmpvar_74); - vec4 tmpvar_77; - tmpvar_77.zw = vec2(0.0, 0.0); - tmpvar_77.xy = (vec2(1.5, 0.5) * tmpvar_6); - vec4 _shadowCoord_78; - _shadowCoord_78 = (v_shadowcoord + tmpvar_77); - float tmpvar_79; - vec2 tmpvar_80; - tmpvar_80 = (_shadowCoord_78.xy / _shadowCoord_78.w); - bool tmpvar_81; - if (any(greaterThan (tmpvar_80, vec2(1.0, 1.0)))) { - tmpvar_81 = bool(1); - } else { - tmpvar_81 = any(lessThan (tmpvar_80, vec2(0.0, 0.0))); - }; - if (tmpvar_81) { - tmpvar_79 = 1.0; - } else { - tmpvar_79 = float((dot (texture2D (u_shadowMap, tmpvar_80), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_78.z - 0.005) - / _shadowCoord_78.w))); - }; - result_5 = (result_5 + tmpvar_79); - vec4 tmpvar_82; - tmpvar_82.zw = vec2(0.0, 0.0); - tmpvar_82.xy = (vec2(1.5, 1.5) * tmpvar_6); - vec4 _shadowCoord_83; - _shadowCoord_83 = (v_shadowcoord + tmpvar_82); - float tmpvar_84; - vec2 tmpvar_85; - tmpvar_85 = (_shadowCoord_83.xy / _shadowCoord_83.w); - bool tmpvar_86; - if (any(greaterThan (tmpvar_85, vec2(1.0, 1.0)))) { - tmpvar_86 = bool(1); - } else { - tmpvar_86 = any(lessThan (tmpvar_85, vec2(0.0, 0.0))); - }; - if (tmpvar_86) { - tmpvar_84 = 1.0; - } else { - tmpvar_84 = float((dot (texture2D (u_shadowMap, tmpvar_85), vec4(5.96046e-008, 1.52588e-005, 0.00390625, 1.0)) >= ( - (_shadowCoord_83.z - 0.005) - / _shadowCoord_83.w))); - }; - float tmpvar_87; - tmpvar_87 = (result_5 + tmpvar_84); - result_5 = tmpvar_87; - gl_FragColor.xyz = pow (abs((vec3(0.1, 0.1, 0.1) + - (vec3((lc_1.x + lc_1.y)) * (tmpvar_87 / 16.0)) - )), vec3(0.454545, 0.454545, 0.454545)); - gl_FragColor.w = 1.0; -} - - \ No newline at end of file diff --git a/examples/runtime/shaders/glsl/vs_smsimple_draw.bin b/examples/runtime/shaders/glsl/vs_sms_mesh.bin similarity index 100% rename from examples/runtime/shaders/glsl/vs_smsimple_draw.bin rename to examples/runtime/shaders/glsl/vs_sms_mesh.bin diff --git a/examples/runtime/shaders/glsl/vs_sms_shadow.bin b/examples/runtime/shaders/glsl/vs_sms_shadow.bin new file mode 100644 index 00000000..bb6aab4f Binary files /dev/null and b/examples/runtime/shaders/glsl/vs_sms_shadow.bin differ diff --git a/examples/runtime/shaders/glsl/vs_smsimple_packdepth.bin b/examples/runtime/shaders/glsl/vs_sms_shadow_pd.bin similarity index 100% rename from examples/runtime/shaders/glsl/vs_smsimple_packdepth.bin rename to examples/runtime/shaders/glsl/vs_sms_shadow_pd.bin diff --git a/src/bgfx_shader.sh b/src/bgfx_shader.sh index 39e96909..a9bad18d 100644 --- a/src/bgfx_shader.sh +++ b/src/bgfx_shader.sh @@ -55,13 +55,13 @@ struct BgfxSampler2DShadow float bgfxShadow2D(BgfxSampler2DShadow _sampler, vec3 _coord) { - return _sampler.m_texture.SampleCmp(_sampler.m_sampler, _coord.xy, _coord.z); + return _sampler.m_texture.SampleCmp(_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.SampleCmp(_sampler.m_sampler, coord.xy, coord.z); + return _sampler.m_texture.SampleCmp(_sampler.m_sampler, coord.xy, coord.z * 2.0 - 1.0); } struct BgfxSampler3D @@ -144,15 +144,23 @@ vec4 bgfxTexture2DProj(sampler2D _sampler, vec4 _coord) float bgfxShadow2D(sampler2DShadow _sampler, vec3 _coord) { +#if 0 float occluder = tex2D(_sampler, _coord.xy).x; - return step(_coord.z, occluder); + 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, occluder); + 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) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index e3ecbbd0..8e010ecc 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1510,8 +1510,15 @@ namespace bgfx s_renderCtx->m_currentProgram = &program; deviceCtx->VSSetShader( (ID3D11VertexShader*)program.m_vsh->m_ptr, NULL, 0); deviceCtx->VSSetConstantBuffers(0, 0, NULL); - deviceCtx->PSSetShader( (ID3D11PixelShader*)program.m_fsh->m_ptr, NULL, 0); - deviceCtx->PSSetConstantBuffers(0, 0, NULL); + if (NULL != s_renderCtx->m_currentColor) + { + deviceCtx->PSSetShader( (ID3D11PixelShader*)program.m_fsh->m_ptr, NULL, 0); + deviceCtx->PSSetConstantBuffers(0, 0, NULL); + } + else + { + deviceCtx->PSSetShader(NULL, NULL, 0); + } VertexBuffer& vb = s_renderCtx->m_vertexBuffers[m_vb->handle.idx]; VertexDecl& vertexDecl = s_renderCtx->m_vertexDecls[m_vb->decl.idx]; @@ -2418,8 +2425,8 @@ namespace bgfx { s_renderCtx->m_currentProgram = NULL; - deviceCtx->VSSetShader(NULL, 0, 0); - deviceCtx->PSSetShader(NULL, 0, 0); + deviceCtx->VSSetShader(NULL, NULL, 0); + deviceCtx->PSSetShader(NULL, NULL, 0); } else { @@ -2429,8 +2436,16 @@ namespace bgfx deviceCtx->VSSetShader( (ID3D11VertexShader*)program.m_vsh->m_ptr, NULL, 0); deviceCtx->VSSetConstantBuffers(0, 1, &program.m_vsh->m_buffer); - deviceCtx->PSSetShader( (ID3D11PixelShader*)program.m_fsh->m_ptr, NULL, 0); - deviceCtx->PSSetConstantBuffers(0, 1, &program.m_fsh->m_buffer); + if (NULL != s_renderCtx->m_currentColor) + { + const Shader* fsh = program.m_fsh; + deviceCtx->PSSetShader( (ID3D11PixelShader*)fsh->m_ptr, NULL, 0); + deviceCtx->PSSetConstantBuffers(0, 1, &fsh->m_buffer); + } + else + { + deviceCtx->PSSetShader(NULL, NULL, 0); + } } programChanged = diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index 0aec6ea2..c0de07a2 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -203,13 +203,13 @@ namespace bgfx { BX_CHECK(NULL != _vsh.m_ptr, "Vertex shader doesn't exist."); m_vsh = &_vsh; + memcpy(&m_predefined[0], _vsh.m_predefined, _vsh.m_numPredefined*sizeof(PredefinedUniform) ); + m_numPredefined = _vsh.m_numPredefined; BX_CHECK(NULL != _fsh.m_ptr, "Fragment shader doesn't exist."); m_fsh = &_fsh; - - memcpy(&m_predefined[0], _vsh.m_predefined, _vsh.m_numPredefined*sizeof(PredefinedUniform) ); - memcpy(&m_predefined[_vsh.m_numPredefined], _fsh.m_predefined, _fsh.m_numPredefined*sizeof(PredefinedUniform) ); - m_numPredefined = _vsh.m_numPredefined + _fsh.m_numPredefined; + memcpy(&m_predefined[m_numPredefined], _fsh.m_predefined, _fsh.m_numPredefined*sizeof(PredefinedUniform) ); + m_numPredefined += _fsh.m_numPredefined; } void destroy() diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 54549b18..bab965db 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2086,6 +2086,9 @@ namespace bgfx writeString(&writer, "#define varying in\n"); writeString(&writer, "#define texture2D texture\n"); writeString(&writer, "#define texture2DLod textureLod\n"); + writeString(&writer, "#define texture2DProj textureProj\n"); + writeString(&writer, "#define shadow2D(_sampler, _coord) vec2(textureProj(_sampler, vec4(_coord, 1.0) ) )\n"); + writeString(&writer, "#define shadow2DProj(_sampler, _coord) vec2(textureProj(_sampler, _coord) ) )\n"); writeString(&writer, "#define texture3D texture\n"); writeString(&writer, "#define texture3DLod textureLod\n"); writeString(&writer, "#define textureCube texture\n"); @@ -2143,7 +2146,7 @@ namespace bgfx void FrameBuffer::create(uint8_t _num, const TextureHandle* _handles) { GL_CHECK(glGenFramebuffers(1, &m_fbo[0]) ); - GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo[0]) ); + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[0]) ); bool needResolve = false; @@ -2172,7 +2175,7 @@ namespace bgfx if (0 != texture.m_rbo) { - GL_CHECK(glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER + GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER , attachment , GL_RENDERBUFFER , texture.m_rbo @@ -2180,7 +2183,7 @@ namespace bgfx } else { - GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER + GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER , attachment , texture.m_target , texture.m_id @@ -2192,15 +2195,15 @@ namespace bgfx } } - BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) + BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER) , "glCheckFramebufferStatus failed 0x%08x" - , glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) + , glCheckFramebufferStatus(GL_FRAMEBUFFER) ); if (needResolve) { GL_CHECK(glGenFramebuffers(1, &m_fbo[1]) ); - GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo[1]) ); + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo[1]) ); for (uint32_t ii = 0, colorIdx = 0; ii < _num; ++ii) { @@ -2219,7 +2222,7 @@ namespace bgfx else { ++colorIdx; - GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER + GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER , attachment , texture.m_target , texture.m_id @@ -2832,6 +2835,7 @@ namespace bgfx ; s_renderCtx->m_depthTextureSupport = !!(BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3) + || s_extension[Extension::ANGLE_depth_texture].m_supported || s_extension[Extension::CHROMIUM_depth_texture].m_supported || s_extension[Extension::GOOGLE_depth_texture].m_supported || s_extension[Extension::OES_depth_texture].m_supported @@ -3044,7 +3048,8 @@ namespace bgfx void Context::rendererCreateProgram(ProgramHandle _handle, VertexShaderHandle _vsh, FragmentShaderHandle _fsh) { - s_renderCtx->m_program[_handle.idx].create(s_renderCtx->m_vertexShaders[_vsh.idx], s_renderCtx->m_fragmentShaders[_fsh.idx]); + Shader dummyFragmentShader; + s_renderCtx->m_program[_handle.idx].create(s_renderCtx->m_vertexShaders[_vsh.idx], isValid(_fsh) ? s_renderCtx->m_fragmentShaders[_fsh.idx] : dummyFragmentShader); } void Context::rendererDestroyProgram(FragmentShaderHandle _handle) diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 8ca1b7f6..4c43a812 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -611,6 +611,8 @@ namespace bgfx { Shader() : m_id(0) + , m_type(0) + , m_hash(0) { } diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index e9a56166..460ae346 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -1847,6 +1847,16 @@ int main(int _argc, const char* _argv[]) "#define ivec4 vec4\n" ); + if (0 == gles) + { + // bgfx shadow2D/Proj behave like EXT_shadow_samplers + // not as GLSL language 1.2 specs shadow2D/Proj. + preprocessor.writef( + "#define shadow2D(_sampler, _coord) bgfxShadow2D(_sampler, _coord).x\n" + "#define shadow2DProj(_sampler, _coord) bgfxShadow2DProj(_sampler, _coord).x\n" + ); + } + for (InOut::const_iterator it = shaderInputs.begin(), itEnd = shaderInputs.end(); it != itEnd; ++it) { VaryingMap::const_iterator varyingIt = varyingMap.find(*it); @@ -2132,6 +2142,11 @@ int main(int _argc, const char* _argv[]) bx::stringPrintf(code, "#version %s\n", profile); int32_t version = atoi(profile); + bx::stringPrintf(code + , "#define bgfxShadow2D shadow2D\n" + "#define bgfxShadow2DProj shadow2DProj\n" + ); + if (hasTextureLod && 130 > version) {