📜  glsl raymarching - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:10.436000             🧑  作者: Mango

代码示例1
float rayMarch(vec3 rayOrigin, vec3 rayDirection) {
    float dist = 0.;
    
    for (int i = 0; i < MAX_STEPS; i++) {
        // map(vec3 point) return the min. dist from the scene
        float step = map(rayDirection * step + rayOrigin);
        d += step;

        // collision check || no-collision check
        if (step < .01 || dist > 100.)
            break;
    }

    return dist;
}