From 42f6fe14301362cc0ad078fdfbef6aa02a10b4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 4 Apr 2017 22:41:21 -0700 Subject: [PATCH] 33-pom: Fixed shaders. --- examples/33-pom/fs_pom.sc | 13 +++++++++++-- examples/33-pom/pom.cpp | 2 +- examples/33-pom/vs_pom.sc | 6 +++--- examples/runtime/shaders/dx9/fs_pom.bin | Bin 5654 -> 5654 bytes examples/runtime/shaders/essl/vs_pom.bin | Bin 1490 -> 1490 bytes examples/runtime/shaders/glsl/vs_pom.bin | Bin 1370 -> 1370 bytes examples/runtime/shaders/metal/vs_pom.bin | Bin 1868 -> 1868 bytes 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/33-pom/fs_pom.sc b/examples/33-pom/fs_pom.sc index 19365b7cd..805a2f8c8 100644 --- a/examples/33-pom/fs_pom.sc +++ b/examples/33-pom/fs_pom.sc @@ -60,6 +60,15 @@ vec2 parallax_uv(vec2 uv, vec3 view_dir) } } +vec2 texture2DBc4(sampler2D _sampler, vec2 _uv) +{ +#if BGFX_SHADER_LANGUAGE_HLSL && BGFX_SHADER_LANGUAGE_HLSL <= 3 + return texture2D(_sampler, _uv).yx; +#else + return texture2D(_sampler, _uv).xy; +#endif +} + void main() { vec3 light_dir = normalize(v_ts_light_pos - v_ts_frag_pos); @@ -88,8 +97,8 @@ void main() } else { - normal.xy = texture2D(s_texNormal, uv).xy * 2.0 - 1.0; - normal.z = sqrt(1.0 - dot(normal.xy, normal.xy) ); + normal.xy = texture2DBc4(s_texNormal, uv) * 2.0 - 1.0; + normal.z = sqrt(1.0 - dot(normal.xy, normal.xy) ); } float diffuse = max(dot(light_dir, normal), 0.0); diff --git a/examples/33-pom/pom.cpp b/examples/33-pom/pom.cpp index a4d1bf64d..54a25e4d9 100644 --- a/examples/33-pom/pom.cpp +++ b/examples/33-pom/pom.cpp @@ -307,7 +307,7 @@ class ExamplePom : public entry::AppI bx::mtxRotateY(a, time * 0.4f); bx::mtxRotateX(b, 0.4f); bx::mtxMul(c, a, b); - bx::mtxTranslate(d, 0, 0, 4); + bx::mtxTranslate(d, 0.0f, 0.0f, 4.0f); bx::mtxMul(mtx, c, d); // Set transform for draw call. diff --git a/examples/33-pom/vs_pom.sc b/examples/33-pom/vs_pom.sc index c4411ffb6..225c4cb0f 100644 --- a/examples/33-pom/vs_pom.sc +++ b/examples/33-pom/vs_pom.sc @@ -20,10 +20,10 @@ void main() vec3 n = normalize(mul(u_norm_mtx, vec4(normal, 0.0) ).xyz); mat3 tbn = mat3(t, b, n); - v_ts_light_pos = mul(tbn, u_light_pos.xyz); + v_ts_light_pos = instMul(u_light_pos.xyz, tbn); // Our camera is always at the origin - v_ts_view_pos = mul(tbn, vec3_splat(0.0) ); - v_ts_frag_pos = mul(tbn, wpos); + v_ts_view_pos = instMul(vec3_splat(0.0), tbn); + v_ts_frag_pos = instMul(wpos, tbn); v_texcoord0 = a_texcoord0; } diff --git a/examples/runtime/shaders/dx9/fs_pom.bin b/examples/runtime/shaders/dx9/fs_pom.bin index db8c58c192c36b4a0b6eb6904645a582de00dbc7..53d0353f2b9dcdfe688a1f51b45435dec10bfe5d 100644 GIT binary patch delta 13 UcmbQHGfiiMxhUhq$rhsb03yc)ApigX delta 13 UcmbQHGfiiMxhUh4$rhsb03y}}Bme*a diff --git a/examples/runtime/shaders/essl/vs_pom.bin b/examples/runtime/shaders/essl/vs_pom.bin index 4608870237745098e2c254076e56807a2d902036..193bc301aad2dad4d87877a8dc9ec32bc9ebb503 100644 GIT binary patch delta 114 zcmcb_eTjR6IjdA@d`@P1MoD}@ez9IfWtD=KLP>5xSz=MV<>WwCG5506WMd5jJp&yD n7@>)zMAMo}L7^w0fusk@G@87QRRsWAlq6{Y diff --git a/examples/runtime/shaders/glsl/vs_pom.bin b/examples/runtime/shaders/glsl/vs_pom.bin index b94563288be3b274cc2dac9018ba63f18b12fdb8..aa1cd25a77a4d6534bc94b072b66cdc0d7afa00c 100644 GIT binary patch delta 107 zcmcb`b&G4meipyd_?*o2jFR|*{9?U|$|?mdg_7KYvc#fzOHFGo1%Pj5Q4O40IG=gy!U%Y$`k;GoT8MCUdeo0|2=tAIAUy