diff --git a/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc b/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc index e7199cd10..9ed8d7a63 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc @@ -15,7 +15,7 @@ uniform vec4 u_specular_shininess; uniform vec4 u_fog; uniform vec4 u_lightPosRadius; uniform vec4 u_lightRgbInnerR; -SAMPLER2D(u_texStencil, 7); +SAMPLER2D(s_texStencil, 1); #define u_ambientPass u_params.x #define u_lightningPass u_params.y @@ -68,7 +68,7 @@ void main() vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass; vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf; - vec4 texcolor = texture2D(u_texStencil, ndc); + vec4 texcolor = texture2D(s_texStencil, ndc); float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w); s *= u_useStencilTex; diff --git a/examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc b/examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc index eea20d8ff..2a2ab4107 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc @@ -7,11 +7,11 @@ $input v_texcoord0 #include "../common/common.sh" uniform vec4 u_color; -SAMPLER2D(u_texColor, 0); +SAMPLER2D(s_texColor, 0); void main() { - vec4 tcolor = toLinear(texture2D(u_texColor, v_texcoord0)); + vec4 tcolor = toLinear(texture2D(s_texColor, v_texcoord0)); if (tcolor.x < 0.1) //OK for now. { diff --git a/examples/14-shadowvolumes/fs_shadowvolume_svbacktex1.sc b/examples/14-shadowvolumes/fs_shadowvolume_svbacktex1.sc index 7c8bdd9d1..652f83810 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_svbacktex1.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_svbacktex1.sc @@ -11,14 +11,16 @@ vec4 stencilColor(float _k) , float(abs(_k + 1.0) < 0.0001)/255.0 , float(abs(_k - 2.0) < 0.0001)/255.0 , float(abs(_k + 2.0) < 0.0001)/255.0 - ); + ); } void main() { float k = 1.0; if (!gl_FrontFacing) + { k = -k; + } gl_FragColor = stencilColor(k); } diff --git a/examples/14-shadowvolumes/fs_shadowvolume_svbacktex2.sc b/examples/14-shadowvolumes/fs_shadowvolume_svbacktex2.sc index ba281a41b..efc14e5df 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_svbacktex2.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_svbacktex2.sc @@ -11,14 +11,16 @@ vec4 stencilColor(float _k) , float(abs(_k + 1.0) < 0.0001)/255.0 , float(abs(_k - 2.0) < 0.0001)/255.0 , float(abs(_k + 2.0) < 0.0001)/255.0 - ); + ); } void main() { float k = 2.0; if (!gl_FrontFacing) + { k = -k; + } gl_FragColor = stencilColor(k); } diff --git a/examples/14-shadowvolumes/fs_shadowvolume_svfronttex1.sc b/examples/14-shadowvolumes/fs_shadowvolume_svfronttex1.sc index 7623b254e..51c02371f 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_svfronttex1.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_svfronttex1.sc @@ -1,24 +1,26 @@ /* -* Copyright 2013-2014 Dario Manesku. All rights reserved. -* License: http://www.opensource.org/licenses/BSD-2-Clause -*/ + * Copyright 2013-2014 Dario Manesku. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ #include "../common/common.sh" vec4 stencilColor(float _k) { - return vec4(float(abs(_k - 1.0) < 0.0001)/255.0 - , float(abs(_k + 1.0) < 0.0001)/255.0 - , float(abs(_k - 2.0) < 0.0001)/255.0 - , float(abs(_k + 2.0) < 0.0001)/255.0 - ); + return vec4(float(abs(_k - 1.0) < 0.0001)/255.0 + , float(abs(_k + 1.0) < 0.0001)/255.0 + , float(abs(_k - 2.0) < 0.0001)/255.0 + , float(abs(_k + 2.0) < 0.0001)/255.0 + ); } void main() { - float k = -1.0; - if (gl_FrontFacing) - k = -k; + float k = -1.0; + if (gl_FrontFacing) + { + k = -k; + } - gl_FragColor = stencilColor(k); + gl_FragColor = stencilColor(k); } diff --git a/examples/14-shadowvolumes/fs_shadowvolume_svside.sc b/examples/14-shadowvolumes/fs_shadowvolume_svside.sc index 1e2948283..400d1b312 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_svside.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_svside.sc @@ -11,7 +11,9 @@ void main() { float k = v_k; if (!gl_FrontFacing) + { k = -k; + } gl_FragColor.xyzw = vec4( float(abs(k - 1.0) < 0.0001)/255.0 diff --git a/examples/14-shadowvolumes/fs_shadowvolume_texture.sc b/examples/14-shadowvolumes/fs_shadowvolume_texture.sc index 42c278142..0f33138b7 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_texture.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_texture.sc @@ -6,9 +6,9 @@ $input v_texcoord0 */ #include "../common/common.sh" -SAMPLER2D(u_texColor, 0); +SAMPLER2D(s_texColor, 0); void main() { - gl_FragColor = texture2D(u_texColor, v_texcoord0); + gl_FragColor = texture2D(s_texColor, v_texcoord0); } diff --git a/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc b/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc index 66866a514..d22c0ddc2 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc @@ -14,8 +14,8 @@ uniform vec4 u_specular_shininess; uniform vec4 u_fog; uniform vec4 u_lightPosRadius; uniform vec4 u_lightRgbInnerR; -SAMPLER2D(u_texColor, 0); -SAMPLER2D(u_texStencil, 7); +SAMPLER2D(s_texColor, 0); +SAMPLER2D(s_texStencil, 1); #define u_ambientPass u_params.x #define u_lightningPass u_params.y @@ -68,7 +68,7 @@ void main() vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass; vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf; - vec4 texcolor = texture2D(u_texStencil, ndc); + vec4 texcolor = texture2D(s_texStencil, ndc); float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w); s *= u_useStencilTex; @@ -77,7 +77,7 @@ void main() float fogFactor = 1.0/exp2(u_fogDensity*u_fogDensity*z*z*LOG2); fogFactor = clamp(fogFactor, 0.0, 1.0); - vec3 color = toLinear(texture2D(u_texColor, v_texcoord0)).xyz; + vec3 color = toLinear(texture2D(s_texColor, v_texcoord0)).xyz; vec3 ambient = toGamma(ambientColor * color); vec3 diffuse = toGamma(lightColor * color); diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index f9e4afa77..1613f8ef4 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -116,8 +116,8 @@ static float s_texelHalf = 0.0f; static uint32_t s_viewMask = 0; -static bgfx::UniformHandle u_texColor; -static bgfx::UniformHandle u_texStencil; +static bgfx::UniformHandle s_texColor; +static bgfx::UniformHandle s_texStencil; static bgfx::FrameBufferHandle s_stencilFb; void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) @@ -1175,9 +1175,9 @@ struct Model // Set textures if (bgfx::invalidHandle != m_texture.idx) { - bgfx::setTexture(0, u_texColor, m_texture); + bgfx::setTexture(0, s_texColor, m_texture); } - bgfx::setTexture(7, u_texStencil, s_stencilFb); + bgfx::setTexture(1, s_texStencil, s_stencilFb); // Apply render state ::setRenderState(_renderState); @@ -1897,8 +1897,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) }; s_stencilFb = bgfx::createFrameBuffer(BX_COUNTOF(fbtextures), fbtextures, true); - u_texColor = bgfx::createUniform("u_texColor", bgfx::UniformType::Int1); - u_texStencil = bgfx::createUniform("u_texStencil", bgfx::UniformType::Int1); + s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1); + s_texStencil = bgfx::createUniform("s_texStencil", bgfx::UniformType::Int1); bgfx::ProgramHandle programTextureLightning = loadProgram("vs_shadowvolume_texture_lightning", "fs_shadowvolume_texture_lightning"); bgfx::ProgramHandle programColorLightning = loadProgram("vs_shadowvolume_color_lightning", "fs_shadowvolume_color_lightning" ); @@ -2843,8 +2843,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) s_uniforms.destroy(); - bgfx::destroyUniform(u_texColor); - bgfx::destroyUniform(u_texStencil); + bgfx::destroyUniform(s_texColor); + bgfx::destroyUniform(s_texStencil); bgfx::destroyFrameBuffer(s_stencilFb); bgfx::destroyTexture(figureTex); diff --git a/examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin index e0023030b..24be2189d 100644 Binary files a/examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/dx11/fs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/dx11/fs_shadowvolume_texture_lightning.bin index e7eb1e8dc..fbdf3c6f1 100644 Binary files a/examples/runtime/shaders/dx11/fs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/dx11/fs_shadowvolume_texture_lightning.bin differ diff --git a/examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin index b1ea22d4d..d67099d1e 100644 Binary files a/examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/dx9/fs_shadowvolume_color_texture.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_color_texture.bin index 54c092386..907eea12f 100644 Binary files a/examples/runtime/shaders/dx9/fs_shadowvolume_color_texture.bin and b/examples/runtime/shaders/dx9/fs_shadowvolume_color_texture.bin differ diff --git a/examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin index 9d269aaf1..1334b0e8a 100644 Binary files a/examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin and b/examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin differ diff --git a/examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin index 22d5d9725..0664ba3e2 100644 Binary files a/examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin differ diff --git a/examples/runtime/shaders/gles/fs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/gles/fs_shadowvolume_color_lightning.bin index e5a81b952..a96ffde0b 100644 Binary files a/examples/runtime/shaders/gles/fs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/gles/fs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin b/examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin index 885640dda..d843710a8 100644 Binary files a/examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin and b/examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin differ diff --git a/examples/runtime/shaders/gles/fs_shadowvolume_texture.bin b/examples/runtime/shaders/gles/fs_shadowvolume_texture.bin index f021c8507..18195420f 100644 Binary files a/examples/runtime/shaders/gles/fs_shadowvolume_texture.bin and b/examples/runtime/shaders/gles/fs_shadowvolume_texture.bin differ diff --git a/examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin index 86c48f074..5e59912ab 100644 Binary files a/examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin differ diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin index 636bcb908..1dd99786c 100644 Binary files a/examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin index 08ec2bbf4..16e982ef8 100644 Binary files a/examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin and b/examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin differ diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin index fafb0e900..d9bf2d2c4 100644 Binary files a/examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin and b/examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin differ diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin index a5b9dcc1d..4d517df71 100644 Binary files a/examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin differ