WebGL rotating F: Difference between revisions

Content added Content deleted
m (→‎{{header|J}}: ... use javascript syntax highlight here)
Line 19: Line 19:
Here, we'll use ray marching as that "feels sort of like J":
Here, we'll use ray marching as that "feels sort of like J":


<syntaxhighlight lang=J>webgl_close=: {{ wd'pclose'}}
<syntaxhighlight lang=javascript>webgl_close=: {{ wd'pclose'}}
wd {{)n
wd {{)n
pc webgl; cc w webview;
pc webgl; cc w webview;
Line 95: Line 95:
float sd= rayMarch(ro, rd, MIN_DIST, MAX_DIST); // closest object
float sd= rayMarch(ro, rd, MIN_DIST, MAX_DIST); // closest object
if (sd > MAX_DIST) {
if (sd > MAX_DIST) {
color= backgroundColor; // ray didn't hit anything
color= backgroundColor; // ray did not hit anything
} else {
} else {
vec3 p= ro + rd * sd; // point on cube we discovered from ray marching
vec3 p= ro + rd * sd; // point on cube we discovered from ray marching