From 9ebcfab447f72b5c19aadb2abc5242a935879851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sun, 7 Jun 2015 21:28:36 -0700 Subject: [PATCH] Cleanup. --- .../fs_shadowvolume_color_lightning.sc | 4 +-- .../fs_shadowvolume_color_texture.sc | 4 +-- .../fs_shadowvolume_svbacktex1.sc | 4 ++- .../fs_shadowvolume_svbacktex2.sc | 4 ++- .../fs_shadowvolume_svfronttex1.sc | 26 ++++++++++-------- .../fs_shadowvolume_svside.sc | 2 ++ .../fs_shadowvolume_texture.sc | 4 +-- .../fs_shadowvolume_texture_lightning.sc | 8 +++--- examples/14-shadowvolumes/shadowvolumes.cpp | 16 +++++------ .../dx11/fs_shadowvolume_color_lightning.bin | Bin 2438 -> 2438 bytes .../fs_shadowvolume_texture_lightning.bin | Bin 2600 -> 2600 bytes .../dx9/fs_shadowvolume_color_lightning.bin | Bin 1887 -> 1891 bytes .../dx9/fs_shadowvolume_color_texture.bin | Bin 555 -> 555 bytes .../shaders/dx9/fs_shadowvolume_texture.bin | Bin 201 -> 201 bytes .../dx9/fs_shadowvolume_texture_lightning.bin | Bin 2025 -> 2025 bytes .../gles/fs_shadowvolume_color_lightning.bin | Bin 2327 -> 2327 bytes .../gles/fs_shadowvolume_color_texture.bin | Bin 687 -> 687 bytes .../shaders/gles/fs_shadowvolume_texture.bin | Bin 211 -> 211 bytes .../fs_shadowvolume_texture_lightning.bin | Bin 2558 -> 2558 bytes .../glsl/fs_shadowvolume_color_lightning.bin | Bin 2098 -> 2098 bytes .../glsl/fs_shadowvolume_color_texture.bin | Bin 602 -> 602 bytes .../shaders/glsl/fs_shadowvolume_texture.bin | Bin 160 -> 160 bytes .../fs_shadowvolume_texture_lightning.bin | Bin 2320 -> 2320 bytes 23 files changed, 40 insertions(+), 32 deletions(-) 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 e0023030ba5d74d1028ffcf2b2a441c085ab091a..24be2189d823b604df12d4c688e4863014de3ae3 100644 GIT binary patch delta 60 zcmZn@ZWEqxNx=8mN~wd(qp$x^UcFdLsK0ySqZho43=9kr5)3R11p*9=o3AsvvvPuj M7!p8Sb@q5B0ICWR#sB~S delta 60 zcmZn@ZWEqxNkHJ>%zYAlEaz%I{}V8lYuz{T(FvO;9S5rLiiLoOUCVd$BVEGu{O{>CXAukbK3GERQTD9y;Y`7h&fR!&9+AV?5k LVBCC`J(>vsgUl0Z delta 55 zcmZ1>vO;9S5rLng0cOP!nE{k{n^_zX;6&^-L_Q?+!r5V{b|7ASR%E`_E1PKBR L?3>TBM>7EcUbGUU diff --git a/examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_color_lightning.bin index b1ea22d4d9443d30459ddde6eeb6ef77b9a39d59..d67099d1e9ba2754ed497fbf44a805a9996b1d09 100644 GIT binary patch delta 345 zcmcc5_n2?OnffVg49x%k|NGy};2h%UB*VbKaGeoI0L6HK6o}6-k%8d?P>ctNnHd;? zkc~kGqy`9dfHV^WJ5Y>)!2&Ag0T$y#5eoo|aiEArfyC+=xKRWXzzTU##0tS;yeMK# zU@=w{v2L&!7mC;duoxSP*lMsC0|N`t(PmqK91u7H7GyzDSR7xHS`l25nwOlJ!?1ew oY8D2N!$5HI1IBi?vdq+ShSifhnKm*qZnkFjW@coZ+|G6b02#3;Pyhe` delta 340 zcmaFNcb{*;2h%UB*VbKaG4QE0L6HK6o}6-k%8e1P>ctNnHbm^ zK++N*0ths~Vw@;q24FD`6frBX7&nTT14yi%fd@q}5Uh|FMJx#{#)=}A4Hn}<5o-X8 zv7v}{1I3uZj+SGX0c3-~3a~l`1{NS&Yy(vA09cR(s(BJqyHZJNMQ}-KUUFs*P$kHf gAP51a@nxB*Nv&|s&&e-hSk1z~1C#?n V2q=wD21_t9FayO{Hcp+!2mmBF4PF2M delta 48 vcmZ3@vYKUrn=BIp0|O%v`v5Tr!~iif5Hm6`F=R}vmuD=Um@U0=UN0j6po9nn diff --git a/examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_texture.bin index 9d269aaf1e8a54815266423553dc36ff6dc99ad9..1334b0e8a26ee3519af01704dbe6f441be6cf90a 100644 GIT binary patch delta 11 ScmX@fc#?5~2V?O>&jtV*2Lw9+ delta 11 ScmX@fc#?5~2V?0(&jtV*4+K2` diff --git a/examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/dx9/fs_shadowvolume_texture_lightning.bin index 22d5d97252d511d048ad5bdcc27d54394f521a38..0664ba3e2834f2038d52ac89eaeeb0b8618a00d9 100644 GIT binary patch delta 279 zcmaFK|B`>gn|fvj1_nk3CI$&cAOi?AfHX5ugpq-b!2&Ag0i>B2*nwgU3?Wdl6tEZv zidY_4j0;7q1T4mlBGw8P;{l1e!3~@S7Gyw${W@dBLtPBJoXj%D7=%*Z%dko^V# Dzjz*N delta 272 zcmaFK|B`>gn|dY&b_PZU1_lWb0R$RAnu&n}Ma&2+#)Tqg0T$y%5%UC#@t}xBfyG!+ z#FD{coFFkbxWyG%SF>@lC1xj0gk8%=l}o! delta 26 gcmbO(G+k)IS;o?h=XNtPmTvB1>SF>@lC1xj0gm(u?f?J) diff --git a/examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin b/examples/runtime/shaders/gles/fs_shadowvolume_color_texture.bin index 885640dda0a9bfff823f796317c1c21efd1c2ec3..d843710a8b0c4a0e541e9aed02fd46d8fd2106ae 100644 GIT binary patch delta 22 ccmZ3_x}J4{BxCVJsYD=ABJxpATiql0DhMUegFUf diff --git a/examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/gles/fs_shadowvolume_texture_lightning.bin index 86c48f0745766ca5bd91c65e20ebdb1ce1821526..5e59912aba7f0bc0ae657b261ec6504f07563155 100644 GIT binary patch delta 55 zcmew-{7-noexc&{lGF<4{G9wE21W)T;wj#EaX%wt@#Kk2vW&%>*E97o0XcT8oj}eB HRx=g=EGH6) delta 55 zcmew-{7-noexcI%lGF<4{G9wE21W)T;wjyDaX%wt>Eww_vW%sh*E97o0XcT8oj}eB HRx=g=EkP2M diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_color_lightning.bin index 636bcb908cc7b2d1a432877800f8a6f48f85eb93..1dd99786c681a204d45316fa31b2f6b0027290fc 100644 GIT binary patch delta 26 fcmdlaut{LTS;pdx=W-bti#OXa{RUAMEWelmkCF-m delta 26 fcmdlaut{LTS;o?h=W-btOE=pv{RUAMEWelmkKPIj diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_color_texture.bin index 08ec2bbf4717fc2201cc9469a88821b2b5d786cd..16e982ef81c4cc3e256f34e24e86656a50052753 100644 GIT binary patch delta 22 ccmcb`a*JhxBxCVJsZbzM;LKROamzAB09&;P5&!@I delta 22 ccmcb`a*JhxBxC7BsZbzM;LKRMamzAB09)}07ytkO diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_texture.bin index fafb0e9002a64fb6d47b066cdda745f28f092a5d..d9bf2d2c4a0c8b567f67669d4544f0167049b66c 100644 GIT binary patch delta 56 zcmZ3$xPXzzE!cx4U(U{kk%6mtB9A>|@kAdpx#IYe)C%YPoctmkg)$I3IX}NB#X!@V JtCow40RX;O5EK9a delta 56 zcmZ3$xPXzzE!cx4U(U{kk%6mpB9A>|=|mqhxzhNO)C%YPoctmkg)$I3IX}NB#X!@V JtCow40RX=$5E=jg diff --git a/examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin b/examples/runtime/shaders/glsl/fs_shadowvolume_texture_lightning.bin index a5b9dcc1def24051da258d6cab264f501d5b17de..4d517df717d53eee1f53b687fa6b1ea4e0518473 100644 GIT binary patch delta 79 zcmbOrG(l*>exc&{lGF<4{G9wE21W)T;wj#Ev5-+7A#BZ6nwOcDUzDp*oS0jXlUiit aqENg!k?A)hWAWrzmK}`6o5fgvF#`ZMvl~$W delta 79 zcmbOrG(l*>excI%lGF<4{G9wE21W)T;wjyDv5-+7A#BZ6nwOcDUzDp*oS0jXlUiit aqENayk?A)hW9j5rmK}_xo5fgvF#`ZOT^n5h