From 6752a421a25f1c1577ad2cb611049bbe006b7fc7 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sat, 18 May 2013 22:55:43 -0700 Subject: [PATCH] Fixed LOD shader. --- examples/06-bump/fs_bump.sc | 2 +- examples/12-lod/fs_tree.sc | 9 ++++++--- examples/12-lod/lod.cpp | 8 ++++---- examples/runtime/shaders/dx11/fs_tree.bin | Bin 2095 -> 2327 bytes examples/runtime/shaders/dx9/fs_tree.bin | Bin 718 -> 982 bytes examples/runtime/shaders/gles/fs_bump.bin | Bin 4132 -> 4088 bytes examples/runtime/shaders/gles/fs_tree.bin | Bin 1123 -> 1130 bytes examples/runtime/shaders/glsl/fs_bump.bin | Bin 4093 -> 4049 bytes examples/runtime/shaders/glsl/fs_tree.bin | Bin 1084 -> 1091 bytes 9 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/06-bump/fs_bump.sc b/examples/06-bump/fs_bump.sc index a27ed1b07..9f1c27c5f 100644 --- a/examples/06-bump/fs_bump.sc +++ b/examples/06-bump/fs_bump.sc @@ -48,7 +48,7 @@ vec3 calcLight(int _idx, mat3 _tbn, vec3 _wpos, vec3 _normal, vec3 _view) vec3 lightDir = mul(_tbn, normalize(lp) ); vec2 bln = blinn(lightDir, _normal, _view); vec4 lc = lit(bln.x, bln.y, 1.0); - vec3 rgb = u_lightRgbInnerR[_idx].xyz*max(0.0, saturate(lc.y) ) * attn; + vec3 rgb = u_lightRgbInnerR[_idx].xyz * saturate(lc.y) * attn; return rgb; } diff --git a/examples/12-lod/fs_tree.sc b/examples/12-lod/fs_tree.sc index b431da9a5..c7be20c97 100644 --- a/examples/12-lod/fs_tree.sc +++ b/examples/12-lod/fs_tree.sc @@ -23,16 +23,19 @@ void main() { vec2 viewport = (u_viewRect.zw - u_viewRect.xy) * vec2(1.0/8.0, 1.0/4.0); vec2 stippleUV = viewport*(v_pos.xy*0.5 + 0.5); - if ((u_stipple.x - texture2D(u_texStipple,stippleUV).r)*u_stipple.y > u_stipple.z) + vec4 color = texture2D(u_texColor, v_texcoord0); + if ((u_stipple.x - texture2D(u_texStipple,stippleUV).r)*u_stipple.y > u_stipple.z || color.w < 0.5) + { discard; + } vec3 lightDir = vec3(0.0, 0.0, -1.0); vec3 normal = normalize(v_normal); vec3 view = normalize(v_view); vec2 bln = blinn(lightDir, normal, view); - float l = max(0.0, saturate(bln.y) ); + float l = saturate(bln.y); - vec4 color = toLinear(abs(texture2D(u_texColor, v_texcoord0))*l); + color.xyz = toLinear(color.xyz)*l; gl_FragColor = toGamma(color); } diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index 9021c305d..4a9b750af 100644 --- a/examples/12-lod/lod.cpp +++ b/examples/12-lod/lod.cpp @@ -481,12 +481,12 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::setTexture(0, u_texColor, textureBark); bgfx::setTexture(1, u_texStipple, textureStipple); - bgfx::setUniform(u_stipple, stipple, 1); + bgfx::setUniform(u_stipple, stipple); mesh_trunk[mainLOD].submit(program, mtx, false); bgfx::setTexture(0, u_texColor, textureLeafs); bgfx::setTexture(1, u_texStipple, textureStipple); - bgfx::setUniform(u_stipple, stipple, 1); + bgfx::setUniform(u_stipple, stipple); mesh_top[mainLOD].submit(program, mtx, true); if (transitions @@ -494,12 +494,12 @@ int _main_(int /*_argc*/, char** /*_argv*/) { bgfx::setTexture(0, u_texColor, textureBark); bgfx::setTexture(1, u_texStipple, textureStipple); - bgfx::setUniform(u_stipple, stippleInv, 1); + bgfx::setUniform(u_stipple, stippleInv); mesh_trunk[targetLOD].submit(program, mtx, false); bgfx::setTexture(0, u_texColor, textureLeafs); bgfx::setTexture(1, u_texStipple, textureStipple); - bgfx::setUniform(u_stipple, stippleInv, 1); + bgfx::setUniform(u_stipple, stippleInv); mesh_top[targetLOD].submit(program, mtx, true); } diff --git a/examples/runtime/shaders/dx11/fs_tree.bin b/examples/runtime/shaders/dx11/fs_tree.bin index 1f92301eae1106fe8ccddfe88f529f8b94d3fc08..f7cdb6b32535fa0b5e8f5ce328da812d375ea81e 100644 GIT binary patch delta 402 zcmZ24FkNVZjmZrTmk1|kslPj1<4cd7OB4r5G6}&td6eWS*?fx_NRDyUgTEtR1?B3=Hf_3<5xD1_mo2 z4Kk0>0mNglw*krtLFJ@C^kjdw*^Eq+U$a&FF##3m1Fd}om1pCG=(S*A;DU*T@j=XG zasVm@g0p9M9AH=yNpBe6K8)&v!UdC?B&%is{lkP@ICIUojxnixnwI2<7?pb8+Lak3zX^yE+MB4Dh* K!9Q7ngAD*40Xv!i delta 197 zcmbO(v|eC>jmZagmk1~4;GZ0m^@To1b-pl_v7F6V%gDgM@PVCyffY!b0C5E~1A`0; z14951m#}XvP-5Yd0SY+)rH(U9p2O0`$TV4V+1=UM`|Q4En{)T3!I&+kH1-FQ1~NkR>Oh#;Lqv`^ghqDK delta 161 zcmXAiAr1mT5Cm&?xZJu60zp9H2rodv4-h2qn?++Tx!~suyZ{6mi9qi^mcEd5XENPA z)1UU;^y}#HzS)M^^8k&}Igo{iCc`bf7AKfMCy{L6#?f~Wqzy}(pCi>35L#ubST4rb iR}h0Vqx1=MIvu?n#J%>QpHUvEcr*Ix-y#26tJ;3Xjv~ka diff --git a/examples/runtime/shaders/gles/fs_bump.bin b/examples/runtime/shaders/gles/fs_bump.bin index b1296e55fe7e05b31ac8af992a99437f63b64ee3..7f6e14e1c5861dd53b6bbaf777294b07b85a2e19 100644 GIT binary patch delta 65 zcmZ3Y@I!t>6t7HjPGW9>f<{ShL0Mu^yrF?!rH+Duo`H^np`O9yM&5wQw|V6z|Kbgr V9L6U%xs)$x@qHMNFqmpB9D24kwi@ShrxLnevI#*F3S8l~~YC7A^UIjMRT3c4_r#*+^)DvBx8)F@~m^eWgW80eX5PJY0s z%4-5L2r6YVS%^tp))Yy^6liBkehFN&$>cC5^~sgY{Nf15Ageca}sk4;A+kEDs_NPH_%Zq Z)HBf3oP3s9lO1aGV` delta 387 zcmaFG@t9+S45LU%Zb4aMQM{owmx2O}J$Wu;l~`$faY<%DK~Ab(g@P_ZN{>l#avGBg zuMv_4qsh~m)Mbs4M2r<|6;kp`6f~el8cn{e^GveG4EtsUb)FJynZstIf=Oi3K}K31!ajv@rLGll{yLrdImZQhI$5*FY<;= V*5{L(?8g^0c@>}B=97FTi~z#`6pR1> delta 106 zcmca8|5tv4F|T@VVugZ+fu4bmLUK-GZh?YENp3+|Vo|)IfnKGK0$9RO&p>msKW_jh hT?1YSbvmFNd3Mqz4q#0R@V&hLN6;jslF(1eubYlbBloS8JwMsRQ(dfsTTqo`I(3 U` delta 343 zcmX@iv4>;ASCNw3g0jS-ctdM01qB#;av5XQ4Dqj3SIClNp%}d5tv{v|x4^O}1y2k}pe5 zHc^N#N>56RHw9^gG8JqUG!m1FH73h2D%XQFt?KIJ=)KLJ7 z8|oQoYHEVa0GkPQlNpk0%=9WMtAHjK40cefLSp4KC=~qqrjpJ0BMP3D*ylh