parent
e80d426872
commit
4939fd7068
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 9.7 KiB |
@ -1,14 +1,15 @@ |
||||
#version 330 |
||||
#version 330 core |
||||
|
||||
// viewsize.x = viewport width in pixels; viewsize.y = viewport height in pixels |
||||
uniform vec2 viewsize; |
||||
// texture uv coordinate in texture space |
||||
in vec2 texture_coord; |
||||
uniform sampler2D texture_sampler; |
||||
uniform ivec2 viewsize; |
||||
uniform ivec2 texturesize; |
||||
|
||||
out vec4 color; |
||||
// texture uv coordinate in texture space |
||||
in vec2 uv; |
||||
uniform sampler2D ts; |
||||
|
||||
void main() |
||||
{ |
||||
color = mix(vec4(0.0f,0.0f,0.0f,1.0f), vec4(1.0f,1.0f,1.0f,1.0f), texture(texture_sampler, texture_coord)) + vec4(1.0f,0.0f,0.0f,1.0f); |
||||
//gl_FragColor = vec4(1.0f,0.0f,0.0f,1.0f); |
||||
gl_FragColor = texture(ts, uv); |
||||
} |
||||
|
@ -1,20 +1,23 @@ |
||||
#version 330 core |
||||
|
||||
// viewsize.x = viewport width in pixels; viewsize.y = viewport height in pixels |
||||
uniform vec2 viewsize; |
||||
uniform ivec2 viewsize; |
||||
uniform ivec2 texturesize; |
||||
|
||||
// both position and and uv are in pixels |
||||
// both position and and uv are in pixels, they where converted to floats when |
||||
// passed to the shader |
||||
layout(location = 0) in vec2 position; |
||||
layout(location = 1) in vec2 uv; |
||||
layout(location = 1) in vec2 txcoord; |
||||
|
||||
out vec2 texture_coord; |
||||
out vec2 uv; |
||||
|
||||
void main() |
||||
{ |
||||
vec4 pos = vec4(position.x, position.y, 0.0f, 1.0f); |
||||
vec2 v = viewsize / 2; |
||||
pos.xy = (pos.xy - v) / v; |
||||
vec2 hsize = vec2(float(viewsize.x)/2.0f, float(viewsize.y)/2.0f); |
||||
|
||||
pos.xy = (pos.xy - hsize) / hsize; |
||||
|
||||
gl_Position = pos; |
||||
texture_coord = uv / viewsize; |
||||
uv = txcoord / float(texturesize); |
||||
} |
||||
|
Binary file not shown.
Loading…
Reference in new issue