Files
Noita-GPU-Vulkan/shaders/lua_native_terrain.glsl
2026-10-19 20:59:15 +02:00

16 lines
626 B
GLSL

// Same half-cell samples and last-free result as the engine's CPU raytrace.
// ngp_solid_at supplies terrain only; rigid bodies are outside this API.
bool ngp_solid_at(vec2 position);
vec3 ngp_surface(vec2 start, vec2 end) {
float distance=length(end-start);
if(isnan(distance)||isinf(distance)||distance>512.0) return vec3(start, -1.0);
int steps=max(1,int(ceil(distance*2.0)));
vec2 previous=start;
for(int k=1;k<=steps;++k) {
vec2 point=start+(end-start)*float(k)/float(steps);
if(ngp_solid_at(point))return vec3(previous,1.0);
previous=point;
}
return vec3(end,0.0);
}