CabinGame/Luxe/shaders/upscale.emsl

50 lines
1.2 KiB
Text
Raw Normal View History

2020-08-16 13:59:43 +00:00
input View {
mat4 mvp,
mat4 proj,
mat4 proj_inverse,
mat4 view,
mat4 world, //geometry.world atm
float2 fov, //fov.x, fov.y
float2 resolution,
float4 target_region,
float4 target_region_size
}
input UniformShaderData {
#0 image2D image,
float4 rect,
bool flipy
}
stage vertex vert_layer_pass(
input {},
vertex in {
#0 float2 pos,
#1 float2 uv
},
fragment out { float2 uv }
) {
out.uv = in.uv;
stage.pos = float4(in.pos, 0.0, 1.0);
}
stage fragment upscale_top_center(
input { View view, UniformShaderData pass },
fragment in { float2 uv }
) {
//this is the uv in the full screen area
float y = in.uv.y;
if(input.pass.flipy) { y = 1.0 - y; }
float2 uv = float2(in.uv.x, y);
float2 dest_size = floor(input.view.target_region_size.zw);
float4 local_rect = float4(input.pass.rect.xy / dest_size, input.pass.rect.zw / dest_size);
float2 local_uv = (uv - local_rect.xy) / local_rect.zw;
stage.color[0] = texture(input.pass.image, local_uv);
if(local_uv.x < 0.0 || local_uv.y < 0.0 || local_uv.x > 1.0 || local_uv.y > 1.0){
stage.color[0] = float4(0, 0, 0, 1);
}
return;
}