mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Various changes, fixes and features
This commit is contained in:
parent
b6c099073f
commit
4b88a32c1c
17 changed files with 409 additions and 261 deletions
|
@ -8,7 +8,7 @@ varying mediump vec2 varTexCoord;
|
|||
|
||||
void main (void)
|
||||
{
|
||||
vec2 uv = varTexCoord;
|
||||
vec2 uv = varTexCoord.st;
|
||||
|
||||
//texture sampling rate
|
||||
float step = 1.0 / mapSize;
|
||||
|
@ -20,19 +20,17 @@ void main (void)
|
|||
float b = texture2D(normalTexture, vec2(uv.x, uv.y - step)).r;
|
||||
float bl = texture2D(normalTexture, vec2(uv.x - step, uv.y - step)).r;
|
||||
float l = texture2D(normalTexture, vec2(uv.x - step, uv.y )).r;
|
||||
float c = texture2D(normalTexture, vec2(uv.x , uv.y )).r;
|
||||
float AO = 50.0 * (clamp(t - c, -0.001, 0.001) + clamp(b - c, -0.001, 0.001) + clamp(r - c, -0.001, 0.001) + clamp(l - c, -0.001, 0.001));
|
||||
float dX = 4.0 * (l - r);
|
||||
float dY = 4.0 * (t - b);
|
||||
vec3 bump = normalize(vec3 (dX, dY, 0.1));
|
||||
float dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
|
||||
float dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
|
||||
vec4 bump = vec4 (normalize(vec3 (dX, dY, 0.1)),1.0);
|
||||
float height = 2.0 * texture2D(normalTexture, vec2(uv.x, uv.y)).r - 1.0;
|
||||
vec4 base = texture2D(baseTexture, uv).rgba;
|
||||
vec3 L = normalize(vec3(0.0, 0.0, 1.0));
|
||||
vec3 L = normalize(vec3(0.0, 0.75, 1.0));
|
||||
float specular = pow(clamp(dot(reflect(L, bump.xyz), yawVec), 0.0, 1.0), 1.0);
|
||||
float diffuse = dot(yawVec, bump);
|
||||
float diffuse = dot(yawVec, bump.xyz);
|
||||
|
||||
vec3 color = (1.1 * diffuse + 0.05 * height + 0.5 * specular + AO) * base.rgb;
|
||||
vec4 col = vec4(color, base.a);
|
||||
vec3 color = (1.1 * diffuse + 0.05 * height + 0.5 * specular) * base.rgb;
|
||||
vec4 col = vec4(color.rgb, base.a);
|
||||
col *= varColor;
|
||||
gl_FragColor = vec4(col.rgb, base.a);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue