mirror of https://github.com/bkaradzic/bgfx
33-pom: Fixed shaders.
This commit is contained in:
parent
8ca270a449
commit
42f6fe1430
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue