created stage atlas+meshes, simplifying models and materials

This commit is contained in:
Diego F. Goberna
2018-11-30 20:33:05 +01:00
committed by Diego Marcos
parent 30c3abd2da
commit 8c98df87e2
18 changed files with 2627 additions and 40 deletions

28
assets/shaders/stage.js Normal file
View File

@@ -0,0 +1,28 @@
module.exports = {
vertexShader : `
varying vec2 uvs;
varying vec3 worldPos;
void main() {
uvs.xy = uv.xy;
vec4 p = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
worldPos = (modelMatrix * vec4( position, 1.0 )).xyz;
gl_Position = p;
}
`,
fragmentShader: `
#define FOG_RADIUS 50.0
#define FOG_FALLOFF 45.0
varying vec2 uvs;
varying vec3 worldPos;
uniform vec3 color;
uniform vec3 fogColor;
uniform sampler2D src;
void main() {
vec4 col = texture2D(src, uvs);
col.xyz = mix(fogColor, col.xyz, clamp(distance(worldPos, vec3(0., 0., -FOG_RADIUS)) / FOG_FALLOFF, 0., 1.));
gl_FragColor = col;
}
`
};