created stage atlas+meshes, simplifying models and materials
This commit is contained in:
committed by
Diego Marcos
parent
30c3abd2da
commit
8c98df87e2
28
assets/shaders/stage.js
Normal file
28
assets/shaders/stage.js
Normal 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;
|
||||
}
|
||||
`
|
||||
};
|
||||
Reference in New Issue
Block a user