danielsvane
danielsvane

Reputation: 613

Volume ray tracing using three.js without textures

I'm trying to visualize hydrogen wave functions, and would like to do this using volume ray tracing/casting. All guides online for creating volume rendering is based on having 2D textures from some medical imaging. In my case, I don't have any data as images, but instead the 3D data is already in memory (I'm using them to generate particles right now).

Do I really need to convert all my 3D data to 2D textures, only to load them in again, and fake a 3D texture? If not, how can it be done without textures?

Upvotes: 1

Views: 427

Answers (1)

Holger Ludvigsen
Holger Ludvigsen

Reputation: 2546

Yes, from your link I understand that you have a function that takes a 3D coordinate and returns a propability between 0 and 1. You can use this directly during the evaluation of each ray.

For each ray, 
    for each distance ∆ along the ray
        calculate the coordinates at distance ∆ from the camera
        calculate the propability at those coordinates using your function
        add the probability to the ray's accumulated color

Using this method, you skip the particle positions that you have rendered in the linked example, and use the function directly.

Upvotes: 2

Related Questions