Platform
Resources
Pricing
Sign in
Get started
Sumant Pattanaik
Workspace
Fork
Published
Ray Tracing
By
Sumant Pattanaik
Edited
Apr 4, 2022
ISC
3
Ray Tracing
Ray Tracing Template
Mandelbrot Set
WebGL2: GLSL
Vectors and vector Algebra
Barycentric Coordinates
Ray
Ray-Box intersection
Ray Tracing AABB
Ray-Sphere (in 2D) intersection
Uniform Grid Acceleration
WebGL Volume Rendering
Specular lighting Model
Diffuse lighting: Lambert Cosine Model.
Ray-Scene (2D) intersection
Ray Tracing Template for 3D Scalar Field Rendering
Sampling Disc
Sampling
Random Number Generator Testing.
Schlick's approximation
Rendering 2D Scalar Field
Bounds and Intersections
Ray Intersection Point on a triangular approximation of a curved surface
Numerical Integration/Quadrature
Thin Lens in Ray Tracing
Sampling: Deterministic, Random, Stratified, QuasiRandom
Ping Pong Approach for Progressive Rendering
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
slice
=
new
Array
(
volume
.
width
*
volume
.
height
)
.
fill
(
0
)
Insert cell
canvasImageData
=
ctx
.
createImageData
(
volume
.
width
,
volume
.
height
)
Insert cell
mutable
eyeVector
=
[
0
,
0
,
1
]
Insert cell
mutable
uniforms
=
0
Insert cell
deg2rad
=
deg
=>
(
deg
*
Math
.
PI
)
/
180
Insert cell
ctx
=
myCanvas
.
getContext
(
"2d"
)
Insert cell
md
`### Volume data and related functions`
Insert cell
volume
=
volumes
[
volChoice
]
Insert cell
volumes
=
(
{
bucky
:
buckyVolume
,
skull
:
skullVolume
,
foot
:
footVolume
,
//frog: frogVolume,
//brain: brainVolume
}
)
Insert cell
Insert cell
Insert cell
footVolume
=
getVolumeFromRawData
(
await
FileAttachment
(
"Foot.vol"
)
.
arrayBuffer
(
)
,
125
,
255
,
183
)
Insert cell
new
Uint8Array
(
await
FileAttachment
(
"Foot.vol"
)
.
arrayBuffer
(
)
)
.
slice
(
0
,
28
)
Insert cell
getVolumeFromRawData
=
(
data
,
width
,
height
,
depth
,
offset
)
=>
(
{
width
,
height
,
depth
,
data
:
new
Uint8Array
(
data
.
slice
(
offset
===
0
?
0
:
28
)
)
}
)
Insert cell
md
`### Local Helper Functions`
Insert cell
hex2rgb
=
hex
=>
(
hex
=
hex
.
replace
(
'#'
,
''
)
)
.
match
(
new
RegExp
(
'(.{'
+
hex
.
length
/
3
+
'})'
,
'g'
)
)
.
map
(
l
=>
parseInt
(
hex
.
length
%
2
?
l
+
l
:
l
,
16
)
/
255
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
volChoice
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sliceID
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
viewType
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
myCanvas
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
slice
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
canvasImageData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
eyeVector
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
uniforms
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
deg2rad
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ctx
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
volume
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
volumes
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
buckyVolume
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
skullVolume
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
footVolume
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getVolumeFromRawData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
hex2rgb
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML