| @@ -2,18 +2,25 @@ | |||||
| in vec4 gl_FragCoord; | in vec4 gl_FragCoord; | ||||
| out vec4 Color; | |||||
| layout (std140, binding = 0) uniform Camera { | |||||
| mat4 projection; | |||||
| mat4 view; | |||||
| } camera; | |||||
| out vec4 color; | |||||
| const float NOISE_RANGE = 0.05; | const float NOISE_RANGE = 0.05; | ||||
| const float NOISE_BASE = 0.05; | const float NOISE_BASE = 0.05; | ||||
| float random(vec4 seed) { | |||||
| return fract(sin(dot(seed, vec4(12.9898, 78.233, 45.164, 53.1324))) * 43758.5453); | |||||
| float random (vec2 st) { | |||||
| return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123); | |||||
| } | } | ||||
| void main() { | void main() { | ||||
| float rnd = random(gl_FragCoord); | |||||
| vec3 rbg = vec3(NOISE_BASE + NOISE_RANGE * rnd); | |||||
| vec4 pos = inverse(camera.view) * gl_FragCoord; | |||||
| vec2 ipos = floor(pos.xy); | |||||
| vec3 rbg = vec3(NOISE_BASE + NOISE_RANGE * random(ipos)); | |||||
| Color = vec4(rbg, 1.0); | |||||
| color = vec4(rbg, 1.0); | |||||
| } | } | ||||
| @@ -1,7 +1,7 @@ | |||||
| #version 450 core | #version 450 core | ||||
| layout (location = 0) in vec3 Position; | |||||
| layout (location = 0) in vec3 position; | |||||
| void main() { | void main() { | ||||
| gl_Position = vec4(Position, 1.0); | |||||
| gl_Position = vec4(2.0 * position, 1.0); | |||||
| } | } | ||||
| @@ -14,6 +14,6 @@ out FragmentData { | |||||
| } data; | } data; | ||||
| void main() { | void main() { | ||||
| data.color = vec3((position.xy + vec2(1.0)) / 2.0, 0.0); | |||||
| data.color = vec3((position.xy + vec2(0.5)), 0.0); | |||||
| gl_Position = camera.projection * camera.view * model * vec4(position, 1.0); | gl_Position = camera.projection * camera.view * model * vec4(position, 1.0); | ||||
| } | } | ||||
| @@ -37,10 +37,10 @@ struct Vertex { | |||||
| fn create_quad_array() -> Result<VertexArray, Error> { | fn create_quad_array() -> Result<VertexArray, Error> { | ||||
| let vertices = &[ | let vertices = &[ | ||||
| Vertex { x: -1.0, y: -1.0 }, | |||||
| Vertex { x: 1.0, y: -1.0 }, | |||||
| Vertex { x: 1.0, y: 1.0 }, | |||||
| Vertex { x: -1.0, y: 1.0 }, | |||||
| Vertex { x: -0.5, y: -0.5 }, | |||||
| Vertex { x: 0.5, y: -0.5 }, | |||||
| Vertex { x: 0.5, y: 0.5 }, | |||||
| Vertex { x: -0.5, y: 0.5 }, | |||||
| ]; | ]; | ||||
| const STRIDE_POS: gl::GLsizei = size_of::<Vertex>() as gl::GLsizei; | const STRIDE_POS: gl::GLsizei = size_of::<Vertex>() as gl::GLsizei; | ||||