diff --git a/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc b/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc index ea2e6490..7b351933 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_color_lightning.sc @@ -1,4 +1,4 @@ -$input v_normal, v_view, v_pos +$input v_normal, v_view /* * Copyright 2013-2014 Dario Manesku. All rights reserved. @@ -67,8 +67,7 @@ void main() vec3 viewDir = -normalize(v_view); vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass; - vec2 ndc = ((v_pos.xy / v_pos.w) + 1.0) / 2.0; - ndc += u_viewTexel.xy * u_texelHalf; + vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf; vec4 texcolor = texture2D(u_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 c99e1bf0..eea20d8f 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_color_texture.sc @@ -19,4 +19,4 @@ void main() } gl_FragColor = toGamma(tcolor + u_color); -} +} diff --git a/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc b/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc index 49f34ac1..0bb27a04 100644 --- a/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc +++ b/examples/14-shadowvolumes/fs_shadowvolume_texture_lightning.sc @@ -1,4 +1,4 @@ -$input v_normal, v_view, v_texcoord0, v_pos +$input v_normal, v_view, v_texcoord0 /* * Copyright 2013-2014 Dario Manesku. All rights reserved. @@ -68,8 +68,7 @@ void main() vec3 viewDir = -normalize(v_view); vec3 lightColor = calcLight(v_view, normal, viewDir) * u_lightningPass; - vec2 ndc = ((v_pos.xy / v_pos.w) + 1.0) / 2.0; - ndc += u_viewTexel.xy * u_texelHalf; + vec2 ndc = gl_FragCoord.xy * u_viewTexel.xy + u_viewTexel.xy * u_texelHalf; vec4 texcolor = texture2D(u_texStencil, ndc); float s = (texcolor.x - texcolor.y) + 2.0 * (texcolor.z - texcolor.w); s *= u_useStencilTex; diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 6391c07a..f19e1617 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -109,7 +109,6 @@ static const uint16_t s_planeIndices[] = }; static const char* s_shaderPath = NULL; -static bool s_flipV = false; static float s_texelHalf = 0.0f; static uint32_t s_viewMask = 0; @@ -269,8 +268,6 @@ struct Uniforms m_time = 0.0f; - m_flipV = float(s_flipV) * 2.0f - 1.0f; - m_lightPosRadius[0] = 0.0f; m_lightPosRadius[1] = 0.0f; m_lightPosRadius[2] = 0.0f; @@ -294,7 +291,6 @@ struct Uniforms u_fog = bgfx::createUniform("u_fog", bgfx::UniformType::Uniform4fv); u_color = bgfx::createUniform("u_color", bgfx::UniformType::Uniform4fv); u_time = bgfx::createUniform("u_time", bgfx::UniformType::Uniform1f ); - u_flipV = bgfx::createUniform("u_flipV", bgfx::UniformType::Uniform1f ); u_lightPosRadius = bgfx::createUniform("u_lightPosRadius", bgfx::UniformType::Uniform4fv); u_lightRgbInnerR = bgfx::createUniform("u_lightRgbInnerR", bgfx::UniformType::Uniform4fv); u_virtualLightPos_extrusionDist = bgfx::createUniform("u_virtualLightPos_extrusionDist", bgfx::UniformType::Uniform4fv); @@ -307,7 +303,6 @@ struct Uniforms bgfx::setUniform(u_diffuse, &m_diffuse); bgfx::setUniform(u_specular_shininess, &m_specular_shininess); bgfx::setUniform(u_fog, &m_fog); - bgfx::setUniform(u_flipV, &m_flipV); } //call this once per frame @@ -337,7 +332,6 @@ struct Uniforms bgfx::destroyUniform(u_fog); bgfx::destroyUniform(u_color); bgfx::destroyUniform(u_time); - bgfx::destroyUniform(u_flipV); bgfx::destroyUniform(u_lightPosRadius); bgfx::destroyUniform(u_lightRgbInnerR); bgfx::destroyUniform(u_virtualLightPos_extrusionDist); @@ -367,7 +361,6 @@ struct Uniforms float m_fog[4]; float m_color[4]; float m_time; - float m_flipV; float m_lightPosRadius[4]; float m_lightRgbInnerR[4]; float m_virtualLightPos_extrusionDist[4]; @@ -392,7 +385,6 @@ struct Uniforms bgfx::UniformHandle u_fog; bgfx::UniformHandle u_color; bgfx::UniformHandle u_time; - bgfx::UniformHandle u_flipV; bgfx::UniformHandle u_lightPosRadius; bgfx::UniformHandle u_lightRgbInnerR; bgfx::UniformHandle u_virtualLightPos_extrusionDist; @@ -1910,7 +1902,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) uint32_t debug = BGFX_DEBUG_TEXT; uint32_t reset = BGFX_RESET_VSYNC; - bgfx::init(); + bgfx::init(bgfx::RendererType::OpenGL); bgfx::reset(viewState.m_width, viewState.m_height, reset); // Enable debug text. @@ -1932,12 +1924,10 @@ int _main_(int /*_argc*/, char** /*_argv*/) case bgfx::RendererType::OpenGL: s_shaderPath = "shaders/glsl/"; - s_flipV = true; break; case bgfx::RendererType::OpenGLES: s_shaderPath = "shaders/gles/"; - s_flipV = true; break; } diff --git a/examples/14-shadowvolumes/varying.def.sc b/examples/14-shadowvolumes/varying.def.sc index 8ba3a028..4adeb88b 100644 --- a/examples/14-shadowvolumes/varying.def.sc +++ b/examples/14-shadowvolumes/varying.def.sc @@ -1,5 +1,4 @@ vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0); -vec4 v_pos : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 1.0); vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); vec3 v_view : TEXCOORD2 = vec3(0.0, 0.0, 0.0); vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0); diff --git a/examples/14-shadowvolumes/vs_shadowvolume_color_lightning.sc b/examples/14-shadowvolumes/vs_shadowvolume_color_lightning.sc index 98bd9acb..3405902f 100644 --- a/examples/14-shadowvolumes/vs_shadowvolume_color_lightning.sc +++ b/examples/14-shadowvolumes/vs_shadowvolume_color_lightning.sc @@ -1,14 +1,12 @@ $input a_position, a_color0, a_normal, a_texcoord0 -$output v_normal, v_view, v_pos +$output v_normal, v_view /* * Copyright 2013-2014 Dario Manesku. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ -#include "../common/common.sh" - -uniform float u_flipV; +#include "../common/common.sh" void main() { @@ -17,7 +15,4 @@ void main() vec4 normal = a_normal * 2.0f - 1.0f; v_normal = mul(u_modelView, vec4(normal.xyz, 0.0)).xyz; v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz; - - v_pos = gl_Position; - v_pos.y *= u_flipV; } diff --git a/examples/14-shadowvolumes/vs_shadowvolume_texture_lightning.sc b/examples/14-shadowvolumes/vs_shadowvolume_texture_lightning.sc index e18232b1..31d4ac6c 100644 --- a/examples/14-shadowvolumes/vs_shadowvolume_texture_lightning.sc +++ b/examples/14-shadowvolumes/vs_shadowvolume_texture_lightning.sc @@ -1,14 +1,12 @@ $input a_position, a_normal, a_texcoord0 -$output v_normal, v_view, v_texcoord0, v_pos +$output v_normal, v_view, v_texcoord0 /* * Copyright 2013-2014 Dario Manesku. All rights reserved. * License: http://www.opensource.org/licenses/BSD-2-Clause */ -#include "../common/common.sh" - -uniform float u_flipV; +#include "../common/common.sh" void main() { @@ -19,7 +17,4 @@ void main() v_view = mul(u_modelView, vec4(a_position, 1.0)).xyz; v_texcoord0 = a_texcoord0; - - v_pos = gl_Position; - v_pos.y *= u_flipV; } diff --git a/examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/dx11/fs_shadowvolume_color_lightning.bin index fe26f8b4..fc7e0c2f 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 f306c930..d4a8efef 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/dx11/vs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/dx11/vs_shadowvolume_color_lightning.bin index 6fc10ae3..1870336f 100644 Binary files a/examples/runtime/shaders/dx11/vs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/dx11/vs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/dx11/vs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/dx11/vs_shadowvolume_texture_lightning.bin index 97fb013a..7ad773ce 100644 Binary files a/examples/runtime/shaders/dx11/vs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/dx11/vs_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 a0487c20..86385795 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_texture_lightning.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin index 5bbe835c..7ecdb591 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/dx9/vs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/dx9/vs_shadowvolume_color_lightning.bin index 9f6d3409..aa9c0642 100644 Binary files a/examples/runtime/shaders/dx9/vs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/dx9/vs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/dx9/vs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/dx9/vs_shadowvolume_texture_lightning.bin index 6d9277a6..ddb9079e 100644 Binary files a/examples/runtime/shaders/dx9/vs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/dx9/vs_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 d56dd64e..f9258313 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_texture_lightning.bin b/examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin index 569067f5..04165088 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/gles/vs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/gles/vs_shadowvolume_color_lightning.bin index a36fe4e4..6856f44c 100644 Binary files a/examples/runtime/shaders/gles/vs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/gles/vs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/gles/vs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/gles/vs_shadowvolume_texture_lightning.bin index 05b11016..55044807 100644 Binary files a/examples/runtime/shaders/gles/vs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/gles/vs_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 07a1f70d..75a552e0 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_texture_lightning.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin index 86341ae5..b84c32b4 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 diff --git a/examples/runtime/shaders/glsl/vs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/glsl/vs_shadowvolume_color_lightning.bin index 23c623c3..3d3c9dc3 100644 Binary files a/examples/runtime/shaders/glsl/vs_shadowvolume_color_lightning.bin and b/examples/runtime/shaders/glsl/vs_shadowvolume_color_lightning.bin differ diff --git a/examples/runtime/shaders/glsl/vs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/glsl/vs_shadowvolume_texture_lightning.bin index fdc3e73f..b1345004 100644 Binary files a/examples/runtime/shaders/glsl/vs_shadowvolume_texture_lightning.bin and b/examples/runtime/shaders/glsl/vs_shadowvolume_texture_lightning.bin differ