Fixed LOD shader.
This commit is contained in:
parent
bed490bd53
commit
6752a421a2
@ -48,7 +48,7 @@ vec3 calcLight(int _idx, mat3 _tbn, vec3 _wpos, vec3 _normal, vec3 _view)
|
|||||||
vec3 lightDir = mul(_tbn, normalize(lp) );
|
vec3 lightDir = mul(_tbn, normalize(lp) );
|
||||||
vec2 bln = blinn(lightDir, _normal, _view);
|
vec2 bln = blinn(lightDir, _normal, _view);
|
||||||
vec4 lc = lit(bln.x, bln.y, 1.0);
|
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;
|
return rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,16 +23,19 @@ void main()
|
|||||||
{
|
{
|
||||||
vec2 viewport = (u_viewRect.zw - u_viewRect.xy) * vec2(1.0/8.0, 1.0/4.0);
|
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);
|
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;
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
vec3 lightDir = vec3(0.0, 0.0, -1.0);
|
vec3 lightDir = vec3(0.0, 0.0, -1.0);
|
||||||
vec3 normal = normalize(v_normal);
|
vec3 normal = normalize(v_normal);
|
||||||
vec3 view = normalize(v_view);
|
vec3 view = normalize(v_view);
|
||||||
vec2 bln = blinn(lightDir, normal, 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);
|
gl_FragColor = toGamma(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,12 +481,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
|
|
||||||
bgfx::setTexture(0, u_texColor, textureBark);
|
bgfx::setTexture(0, u_texColor, textureBark);
|
||||||
bgfx::setTexture(1, u_texStipple, textureStipple);
|
bgfx::setTexture(1, u_texStipple, textureStipple);
|
||||||
bgfx::setUniform(u_stipple, stipple, 1);
|
bgfx::setUniform(u_stipple, stipple);
|
||||||
mesh_trunk[mainLOD].submit(program, mtx, false);
|
mesh_trunk[mainLOD].submit(program, mtx, false);
|
||||||
|
|
||||||
bgfx::setTexture(0, u_texColor, textureLeafs);
|
bgfx::setTexture(0, u_texColor, textureLeafs);
|
||||||
bgfx::setTexture(1, u_texStipple, textureStipple);
|
bgfx::setTexture(1, u_texStipple, textureStipple);
|
||||||
bgfx::setUniform(u_stipple, stipple, 1);
|
bgfx::setUniform(u_stipple, stipple);
|
||||||
mesh_top[mainLOD].submit(program, mtx, true);
|
mesh_top[mainLOD].submit(program, mtx, true);
|
||||||
|
|
||||||
if (transitions
|
if (transitions
|
||||||
@ -494,12 +494,12 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||||||
{
|
{
|
||||||
bgfx::setTexture(0, u_texColor, textureBark);
|
bgfx::setTexture(0, u_texColor, textureBark);
|
||||||
bgfx::setTexture(1, u_texStipple, textureStipple);
|
bgfx::setTexture(1, u_texStipple, textureStipple);
|
||||||
bgfx::setUniform(u_stipple, stippleInv, 1);
|
bgfx::setUniform(u_stipple, stippleInv);
|
||||||
mesh_trunk[targetLOD].submit(program, mtx, false);
|
mesh_trunk[targetLOD].submit(program, mtx, false);
|
||||||
|
|
||||||
bgfx::setTexture(0, u_texColor, textureLeafs);
|
bgfx::setTexture(0, u_texColor, textureLeafs);
|
||||||
bgfx::setTexture(1, u_texStipple, textureStipple);
|
bgfx::setTexture(1, u_texStipple, textureStipple);
|
||||||
bgfx::setUniform(u_stipple, stippleInv, 1);
|
bgfx::setUniform(u_stipple, stippleInv);
|
||||||
mesh_top[targetLOD].submit(program, mtx, true);
|
mesh_top[targetLOD].submit(program, mtx, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user