Link to this tutorial https://bit.ly/cassi-vis-doc This doc builds up from the very nice tutorial by Kazewong ([GitHub repo](https://github.com/kazewong/Blender_volume_tutorial)) ## Motivation: In this tutorial, we show you how to visulazir your research data in 3D using Blender. The doc says: > Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing and motion tracking, even video editing and game creation. Blender is licensed as GNU GPL, owned by its contributors. For that reason Blender is Free and Open Source software, forever. Following this tutorials, you can make 3D render of any volumetric data you may generate for your resrach. Here, we visualize a comological hydrodynamic simualtion which models the distribution of stars, gas, black holes and etc. in a alrge volume of our universe. Example: Lyman Alpha Tomography IMACS Survey: <iframe width="800" height="412"src="https://www.youtube.com/embed/VqVgtj38VuI"> </iframe> ## Dowloading the simulation In particular, today, we visulaize a small version of [ASTRID](https://arxiv.org/abs/2111.01160) simulation. The output of these snapshots are usualyy a list of particles (dark matter, gas,, black holes nad etc.). To visulaize the spatial distribution of thse partilces, we a density map of these particles. The values on a density map simply shows how many particles (normalized for sake of simplicity) per pixel. We skip this step here and provide you with a set of density maps on the link below. Please, download these density maps from here http://bit.ly/cassi_vis . *.vdb format*: `.vdb` files are a specific encoding of volumeteric data which is optimized for real-time rendering. Read this (Adding later) tutorial to learn how to convert your 3D numpy array into this format. Installing the requird python package might be slightly tricky, so if you get stuck fell free to contact us. ## Install Blender We need to dlownload Blender, the softwrew we use to visualize our volumetric data. Go to this (https://www.blender.org/download/) web page and dowload the software for your opertaing system. ## Basics of Blender: When you open Blender, you should see the `3D Viewport` like the one below. This window illustrates a raw visualization of your data. ![](https://hackmd.io/_uploads/ry5Qp4sYh.png) - Delete the cube by clickign on it and pressing `del` button. - Pt_512_60_Nmesh128.vdb` from the list of the files you just downloaded. ![](https://hackmd.io/_uploads/HJNnpEjY2.png) This file contains a few different density maps, to find the list click on the tab with logo of a cloud on the properties tab: ![](https://hackmd.io/_uploads/H1SoCNiFn.png) Under grids, you see the density maps we have made from this simulation snapshot. The fields are described as below: `Z`: Metallicity, it tells us how much metal (anything heavier than Helium) we have at each voxel `Stars`: This is a density map of the stars fromed within galaixes. So this should be a tracer of where the galxies are. `cdm`: This is a density map of Dark Matter. `black holes`: This is a density map of the super-Mssive Black holes (SMBH) formed at the center of the galaxies. `gas`: A density map of all the particles which are not stars, dark matter or black hole. We expect the gas trace galaxies but due to it's pressure be a bit spread in-between galaxies. Try to select different fields and see how the raw visualaization changes. > Note: if yiou don't see anything, increase the `Desnity` paramter on the properties window. This parameter re-scales the dnesity, so it becomes larger. ![](https://hackmd.io/_uploads/SJWaWrjKh.png) ## Adding colors to the fields: - Now, we want to do more than a raw rendering of our data. Click on the top right corner of your `3D viewport` and drag it to the left to make a vertical split. Now, you should have 2 identical `3D viewport`: ![](https://hackmd.io/_uploads/H18KQroth.png) - We are going to chnage the right window to a `Sahder Editor` by goinf to the top left corner of that window: ![](https://hackmd.io/_uploads/S18JEriFh.png) - The `shader editor` is where we tell Blender how to add color to our data set. Press `New` on the top rwo of the `Shader Editor`: ![](https://hackmd.io/_uploads/H173EBjY3.png) - Now, two boxes are popped out in the `shader editor`. As you see the shader works like a graph. It performes a set of opertaions on the field you're studying. Each box is called a node; that is why peaople call this editor a `node-based shader`. ![](https://hackmd.io/_uploads/ryHGHrit3.png) - The flow of these operations are from left to right. So, it makes sense that the first node on the left be your inout density filed. To add such node, press `shift+a` on the `shader editor` and in the search box, type `Attributes`. ![](https://hackmd.io/_uploads/H1H58SjYh.png) - As you see in the figure above, on the `Attributes` node, you can type the name of the field you want to work on. I nthis case, I have chosen `gas`. - To see the chnages you make on the shading in real-time, change the left window from `3D viewport` to `viewport shader` by clicking on that shiny sphere on the top right corner of the left window: ![](https://hackmd.io/_uploads/Sy_tDBsYn.png) > At the moment, you wont see rendering on the left window since we have not yet completed our graph on the editor. - We need to do a few more nodes to the shader editor. - Again, press `shift+a` on the` shader editor` (the right window) and this time search for `Math`. ![](https://hackmd.io/_uploads/SkLvuSsY2.png) - This type of node, applies some mathematical operations on the inpur field before showing the full render. - Change `Add` to `Power` from the drop-down menue. - Then connect the `Attributes` output to the `input` of this newly created node according to the figure below: ![](https://hackmd.io/_uploads/ByNNFroYn.png) - You need anothjer node on the `shader editor`, so press`shift+a` again and search for `Math` and this type change `Add` to `Multiply`. Then connect this node to `Power` on the left and `Emmision Strength` from the `Pricipled volume` node on the right: ![](https://hackmd.io/_uploads/r1mpKBjY2.png) > Exercise: Play around with the `Exponent` and `value` on the `Power` and `Multiply` nodes. also, change the imput filed from `gas` to whatever else you like. - So far, we have not added any color to the our rendered volume yet. Now were are gonna do that. Again, press `shift+a` on the `shader editor` and search for `ColorRamp`. ![](https://hackmd.io/_uploads/BkipqriFn.png) - Play around with the colormap to pick whatever you like better. We also add similar `Attributes`, `Power` and `Multiply` nodes to this node. But, this time, the `ColorRamp` is connected to the `Emission color` on the `Principled Volume` node. ![](https://hackmd.io/_uploads/HyKNnSsKn.png) > Try to turn all the nubs we have on these nodes and see what you can do with the redndering