fixing shader execution
All checks were successful
Build / build (push) Successful in 1m6s
Test / build (push) Successful in 6m15s

This commit is contained in:
2026-01-24 15:18:57 +01:00
parent 96ad7f12f9
commit dbf963a3c9
12 changed files with 118 additions and 91 deletions

View File

@@ -16,24 +16,24 @@ struct FragOut
[entry(frag)]
fn main(input: FragIn) -> FragOut
{
const I: i32 = 128;
const I: i32 = 32;
const A: f32 = 7.5;
const MA: f32 = 100.0;
const MA: f32 = 2.0;
const MI: f32 = 0.001;
let uv0 = input.pos / input.res * 2.0 - vec2[f32](1.0, 1.0);
let uv = vec2[f32](uv0.x * (input.res.x / input.res.y), uv0.y);
let col = vec3[f32](0.0, 0.0, 0.0);
let ro = vec3[f32](0.0, 0.0, -2.0);
let rd = vec3[f32](uv.x, uv.y, 1.0);
let col = vec4[f32](0.0, 0.0, 0.0, 0.0);
let ro = vec4[f32](0.0, 0.0, -2.0, 0.0);
let rd = vec4[f32](uv.x, uv.y, 1.0, 0.0);
let dt = 0.0;
let ds = 0.0;
let dm = -1.0;
let p = ro;
let c = vec3[f32](0.0, 0.0, 0.0);
let c = vec4[f32](0.0, 0.0, 0.0, 0.0);
let l = vec3[f32](0.0, sin(input.time * 0.2) * 4.0, cos(input.time * 0.2) * 4.0);
let l = vec4[f32](0.0, sin(input.time * 0.2) * 4.0, cos(input.time * 0.2) * 4.0, 0.0);
for i in 0 -> I
{
@@ -46,26 +46,23 @@ fn main(input: FragIn) -> FragOut
if (ds <= MI)
{
let value = max(dot(normalize(c - p), normalize(p - l)) - 0.35, 0.0);
col = vec3[f32](value, value, value);
let value = max(dot(normalize(c - p), normalize(p - l)), 0.0);
col = vec4[f32](value, value, value, 1.0);
break;
}
if (ds >= MA)
{
if (dot(normalize(rd), normalize(l - ro)) <= 1.0)
if (dot(normalize(rd), normalize(l - ro)) < 1.0)
{
let value = max(dot(normalize(rd), normalize(l - ro)) + 0.15, 0.05)/ 1.15 * (1.0 - dm * A);
col = vec3[f32](value, value, value);
let value = max(dot(normalize(rd), normalize(l - ro)) + 0.15, 0.0) / 1.15 * max(1.0 - dm * A, 0.0);
col = vec4[f32](value, value, value, 1.0);
}
break;
}
}
//if (col == vec3[f32](0.0, 0.0, 0.0))
// discard;
let output: FragOut;
output.color = vec4[f32](col.x, col.y, col.z, 1.0);
output.color = col;
return output;
}