Draw fixes
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
|
||||
#[set(everything)]
|
||||
const constants: {
|
||||
W: float3x3;
|
||||
pos: float4; // xywh
|
||||
tex: float4; // xywh
|
||||
col: float4;
|
||||
@@ -30,7 +29,6 @@ fun draw_image_vert(input: vert_in): vert_out {
|
||||
var ctex: float4 = constants.tex;
|
||||
|
||||
output.pos = float4(input.pos, 0.0, 1.0);
|
||||
output.pos.xyz = constants.W * output.pos.xyz;
|
||||
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy;
|
||||
output.pos.xy = output.pos.xy * 2.0 - 1.0;
|
||||
output.pos.y = -output.pos.y;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
#[set(everything)]
|
||||
const constants: {
|
||||
pos: float4; // xywh
|
||||
tex: float4; // xywh
|
||||
col: float4;
|
||||
W: float3x3;
|
||||
};
|
||||
|
||||
#[set(everything)]
|
||||
const sampler_linear: sampler;
|
||||
|
||||
#[set(everything)]
|
||||
const tex: tex2d;
|
||||
|
||||
struct vert_in {
|
||||
pos: float2;
|
||||
}
|
||||
|
||||
struct vert_out {
|
||||
pos: float4;
|
||||
tex: float2;
|
||||
col: float4;
|
||||
}
|
||||
|
||||
fun draw_image_vert(input: vert_in): vert_out {
|
||||
var output: vert_out;
|
||||
|
||||
var cpos: float4 = constants.pos;
|
||||
var ctex: float4 = constants.tex;
|
||||
|
||||
output.pos = float4(input.pos, 1.0, 1.0);
|
||||
output.pos.xyz = constants.W * output.pos.xyz;
|
||||
output.pos.z = 0.0;
|
||||
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy;
|
||||
output.pos.xy = output.pos.xy * 2.0 - 1.0;
|
||||
output.pos.y = -output.pos.y;
|
||||
output.tex = input.pos * ctex.zw + ctex.xy;
|
||||
output.col = constants.col;
|
||||
return output;
|
||||
}
|
||||
|
||||
fun draw_image_frag(input: vert_out): float4 {
|
||||
var texcolor: float4 = sample(tex, sampler_linear, input.tex) * input.col;
|
||||
texcolor.rgb = texcolor.rgb * texcolor.a * input.col.a;
|
||||
return texcolor;
|
||||
}
|
||||
|
||||
#[pipe]
|
||||
struct pipe {
|
||||
vertex = draw_image_vert;
|
||||
fragment = draw_image_frag;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#[set(everything)]
|
||||
const constants: {
|
||||
W: float3x3;
|
||||
pos: float4; // xywh
|
||||
col: float4;
|
||||
};
|
||||
@@ -21,7 +20,6 @@ fun draw_rect_vert(input: vert_in): vert_out {
|
||||
var cpos: float4 = constants.pos;
|
||||
|
||||
output.pos = float4(input.pos, 0.0, 1.0);
|
||||
// output.pos.xyz = constants.W * output.pos.xyz;
|
||||
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy;
|
||||
output.pos.xy = output.pos.xy * 2.0 - 1.0;
|
||||
output.pos.y = -output.pos.y;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#[set(everything)]
|
||||
const constants: {
|
||||
W: float3x3;
|
||||
pos: float4; // xywh
|
||||
tex: float4; // xywh
|
||||
col: float4;
|
||||
@@ -30,7 +29,6 @@ fun draw_text_vert(input: vert_in): vert_out {
|
||||
var ctex: float4 = constants.tex;
|
||||
|
||||
output.pos = float4(input.pos, 0.0, 1.0);
|
||||
// output.pos.xyz = constants.W * output.pos.xyz;
|
||||
output.pos.xy = output.pos.xy * cpos.zw + cpos.xy;
|
||||
output.pos.xy = output.pos.xy * 2.0 - 1.0;
|
||||
output.pos.y = -output.pos.y;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#[set(everything)]
|
||||
const constants: {
|
||||
W: float3x3;
|
||||
pos0: float2;
|
||||
pos1: float2;
|
||||
pos2: float2;
|
||||
@@ -28,7 +27,6 @@ fun draw_tris_vert(input: vert_in): vert_out {
|
||||
else if (vertex_id() == 2) {
|
||||
output.pos = float4(constants.pos2, 0.0, 1.0);
|
||||
}
|
||||
// output.pos.xyz = constants.W * output.pos.xyz;
|
||||
output.pos.xy = output.pos.xy * 2.0 - 1.0;
|
||||
output.pos.y = -output.pos.y;
|
||||
output.col = constants.col;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#[set(everything)]
|
||||
const constants: {
|
||||
W: float3x3;
|
||||
pos: float4; // xywh
|
||||
tex: float4; // xywh
|
||||
col: float4;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
#[set(everything)]
|
||||
const constants: {
|
||||
W: float3x3;
|
||||
pos: float4; // xywh
|
||||
tex: float4; // xywh
|
||||
col: float4;
|
||||
|
||||
Reference in New Issue
Block a user