2016-03-16 13:33:06 -04:00
|
|
|
uniform sampler2DArray textures;
|
|
|
|
|
|
|
|
in vec3 vColor;
|
|
|
|
in vec4 vTextureInfo;
|
|
|
|
in vec2 vTextureOffset;
|
|
|
|
in float vAtlas;
|
|
|
|
in vec3 vLighting;
|
|
|
|
|
|
|
|
#ifndef alpha
|
|
|
|
out vec4 fragColor;
|
|
|
|
#else
|
Use web-sys for web backend (#444)
A small step for #446 🕸️ Web support, use web-sys to interface to the web.
Previously, we would try to use glutin on the web, which is not supported;
now glutin is only used on native: fixes #171 could not find Context in platform_impl.
winit is still used on both, but the GL context is created with web-sys and glow
(on the web), and created with glutin and used with glow (on native). stdweb is
no longer used, being replaced by web-sys.
Substantial refactoring to allow reusing the code between web/native:
* settings: use VirtualKeyCode from winit, not reexported from glutin
* std_or_web: remove broken localstoragefs/stdweb, add File placeholder
* render: disable skin_thread on wasm since we don't have threads
* gl: use glow types in gl wrapper (integers in native, but Web*Key in web)
* gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't
* gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web
* gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper
* glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2
* shaders: add explicit float/int type conversions, required for WebGL
* shaders: specify mediump precision, required for WebGL
* shaders: specify fragment shader output locations for WebGL
* main: refactor handle_window_event to take a winit window, not glutin context
* main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this)
* main: use winit events in handle_window_event not reexported glutin events
* main: refactor game loop handling into tick_all()
* main: create winit window for WebGL, and use winit_window from glutin
* main: restore console_error_panic_hook, mistakingly removed in (#260)
* main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web
* www: index.js: fix wasm import path
* www: npm update, npm audit fix
* www: update readme to link to status on #446 🕸️ Web support
2020-12-26 16:42:37 -05:00
|
|
|
|
|
|
|
#ifdef ES
|
|
|
|
layout(location = 1) out vec4 accum;
|
|
|
|
layout(location = 2) out float revealage;
|
|
|
|
#else
|
2016-03-16 13:33:06 -04:00
|
|
|
out vec4 accum;
|
|
|
|
out float revealage;
|
|
|
|
#endif
|
|
|
|
|
Use web-sys for web backend (#444)
A small step for #446 🕸️ Web support, use web-sys to interface to the web.
Previously, we would try to use glutin on the web, which is not supported;
now glutin is only used on native: fixes #171 could not find Context in platform_impl.
winit is still used on both, but the GL context is created with web-sys and glow
(on the web), and created with glutin and used with glow (on native). stdweb is
no longer used, being replaced by web-sys.
Substantial refactoring to allow reusing the code between web/native:
* settings: use VirtualKeyCode from winit, not reexported from glutin
* std_or_web: remove broken localstoragefs/stdweb, add File placeholder
* render: disable skin_thread on wasm since we don't have threads
* gl: use glow types in gl wrapper (integers in native, but Web*Key in web)
* gl: web-sys WebGlUniformLocation does not implement Copy trait, so glow::UniformLocation doesn't so gl::Uniform can't
* gl: refactor context initialization, pass glow::Context to gl::init for consistency between native/web
* gl: update to glow with panicking tex_image_2d_multisample web-sys wrapper
* glsl: use shader version in GLSL for WebGL 2 and OpenGL 3.2
* shaders: add explicit float/int type conversions, required for WebGL
* shaders: specify mediump precision, required for WebGL
* shaders: specify fragment shader output locations for WebGL
* main: refactor handle_window_event to take a winit window, not glutin context
* main: handle resize outside of handle_window_event since it updates the glutin window (the only event which does this)
* main: use winit events in handle_window_event not reexported glutin events
* main: refactor game loop handling into tick_all()
* main: create winit window for WebGL, and use winit_window from glutin
* main: restore console_error_panic_hook, mistakingly removed in (#260)
* main: remove force setting env RUST_BACKTRACE=1, no longer can set env on web
* www: index.js: fix wasm import path
* www: npm update, npm audit fix
* www: update readme to link to status on #446 🕸️ Web support
2020-12-26 16:42:37 -05:00
|
|
|
#endif
|
|
|
|
|
2016-03-16 13:33:06 -04:00
|
|
|
#include lookup_texture
|
|
|
|
|
|
|
|
void main() {
|
2016-03-20 16:17:21 -04:00
|
|
|
vec4 col = atlasTexture();
|
|
|
|
#ifndef alpha
|
|
|
|
if (col.a < 0.5) discard;
|
|
|
|
#endif
|
|
|
|
col *= vec4(vColor, 1.0);
|
|
|
|
col.rgb *= vLighting;
|
2016-03-16 13:33:06 -04:00
|
|
|
|
2016-03-20 16:17:21 -04:00
|
|
|
#ifndef alpha
|
|
|
|
fragColor = col;
|
|
|
|
#else
|
|
|
|
float z = gl_FragCoord.z;
|
|
|
|
float al = col.a;
|
|
|
|
float weight = pow(al + 0.01f, 4.0f) +
|
|
|
|
max(0.01f, min(3000.0f, 0.3f / (0.00001f + pow(abs(z) / 800.0f, 4.0f))));
|
|
|
|
accum = vec4(col.rgb * al * weight, al);
|
|
|
|
revealage = weight * al;
|
|
|
|
#endif
|
2016-03-16 13:33:06 -04:00
|
|
|
}
|