mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-28 08:53:26 +03:00
glsl 300 isnt working on mac. go back to 140 on native, and only use 300 for wasm. [rebuild]
This commit is contained in:
parent
d17be067e0
commit
0f19cbab55
@ -1,7 +1,4 @@
|
|||||||
#version 300 es
|
#version 140
|
||||||
|
|
||||||
precision mediump float;
|
|
||||||
precision mediump sampler2DArray;
|
|
||||||
|
|
||||||
// (x offset, y offset, zoom)
|
// (x offset, y offset, zoom)
|
||||||
uniform vec3 transform;
|
uniform vec3 transform;
|
||||||
|
41
ezgui/src/assets/fragment_300.glsl
Normal file
41
ezgui/src/assets/fragment_300.glsl
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#version 300 es
|
||||||
|
|
||||||
|
precision mediump float;
|
||||||
|
precision mediump sampler2DArray;
|
||||||
|
|
||||||
|
// (x offset, y offset, zoom)
|
||||||
|
uniform vec3 transform;
|
||||||
|
// (window width, window height, _)
|
||||||
|
uniform vec3 window;
|
||||||
|
|
||||||
|
in vec4 pass_style;
|
||||||
|
out vec4 f_color;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// See actually_upload in drawing.rs to understand the different things encoded.
|
||||||
|
if (pass_style[0] == 100.0) {
|
||||||
|
// The hatching should be done in map-space, so panning/zooming doesn't move the stripes.
|
||||||
|
// This is screen_to_map, also accounting for the y-inversion done by the vertex shader.
|
||||||
|
float map_x = (gl_FragCoord.x + transform[0]) / transform[2];
|
||||||
|
float map_y = (window[1] - gl_FragCoord.y + transform[1]) / transform[2];
|
||||||
|
if (mod(map_x + map_y, 2.0) <= 0.1) {
|
||||||
|
f_color = vec4(0.0, 1.0, 1.0, 1.0);
|
||||||
|
} else if (mod(map_x - map_y, 2.0) <= 0.1) {
|
||||||
|
f_color = vec4(0.0, 1.0, 1.0, 1.0);
|
||||||
|
} else {
|
||||||
|
// Let the polygon with its original colors show instead.
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
} else if (pass_style[0] == 101.0) {
|
||||||
|
float map_x = (gl_FragCoord.x + transform[0]) / transform[2];
|
||||||
|
float map_y = (window[1] - gl_FragCoord.y + transform[1]) / transform[2];
|
||||||
|
if (mod(map_x + map_y, 2.0) <= 0.5) {
|
||||||
|
f_color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
} else {
|
||||||
|
// Let the polygon with its original colors show instead.
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
f_color = pass_style;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,12 @@
|
|||||||
#version 300 es
|
#version 140
|
||||||
|
|
||||||
precision mediump float;
|
|
||||||
|
|
||||||
// (x offset, y offset, zoom)
|
// (x offset, y offset, zoom)
|
||||||
uniform vec3 transform;
|
uniform vec3 transform;
|
||||||
// (window width, window height, z value)
|
// (window width, window height, z value)
|
||||||
uniform vec3 window;
|
uniform vec3 window;
|
||||||
|
|
||||||
layout (location = 0) in vec2 position;
|
in vec2 position;
|
||||||
layout (location = 1) in vec4 style;
|
in vec4 style;
|
||||||
out vec4 pass_style;
|
out vec4 pass_style;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
26
ezgui/src/assets/vertex_300.glsl
Normal file
26
ezgui/src/assets/vertex_300.glsl
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#version 300 es
|
||||||
|
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
// (x offset, y offset, zoom)
|
||||||
|
uniform vec3 transform;
|
||||||
|
// (window width, window height, z value)
|
||||||
|
uniform vec3 window;
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 position;
|
||||||
|
layout (location = 1) in vec4 style;
|
||||||
|
out vec4 pass_style;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
pass_style = style;
|
||||||
|
|
||||||
|
// This is map_to_screen
|
||||||
|
float screen_x = (position[0] * transform[2]) - transform[0];
|
||||||
|
float screen_y = (position[1] * transform[2]) - transform[1];
|
||||||
|
// Translate that to clip-space or whatever it's called
|
||||||
|
float x = (screen_x / window[0] * 2.0) - 1.0;
|
||||||
|
float y = (screen_y / window[1] * 2.0) - 1.0;
|
||||||
|
|
||||||
|
// Note the y inversion
|
||||||
|
gl_Position = vec4(x, -y, window[2], 1.0);
|
||||||
|
}
|
@ -39,10 +39,10 @@ pub fn setup(
|
|||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let shaders = [
|
let shaders = [
|
||||||
(glow::VERTEX_SHADER, include_str!("assets/vertex_140.glsl")),
|
(glow::VERTEX_SHADER, include_str!("assets/vertex_300.glsl")),
|
||||||
(
|
(
|
||||||
glow::FRAGMENT_SHADER,
|
glow::FRAGMENT_SHADER,
|
||||||
include_str!("assets/fragment_140.glsl"),
|
include_str!("assets/fragment_300.glsl"),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user