Answers for "raymarching tutorial gls"

1

glsl raymarching

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;
}
Posted by: Guest on February-15-2021

Browse Popular Code Answers by Language