<div dir="ltr">Wiki link: <a href="https://wiki.blender.org/index.php/User:Geraldine/GSoC_2018/Reports#Week_2">https://wiki.blender.org/index.php/User:Geraldine/GSoC_2018/Reports#Week_2</a><br><div><br>Unfortunately was not able to do much this week, thanks to some personal stuff happening.<br><br><b>Notes on Last Week's Report</b><br><br>On advice from Brecht:<br><br>* Conversion from dense to sparse grid should be done in <i>render/image.cpp</i> after image manipulation such as scaling. I was mistaken in thinking that there will be a performance issue otherwise.<br><br>* Check out <i>device/device_memory.h</i> for memory handling and <i>kernel/kernels/<device>/kernel_<device>_image.h</i> files to see how volumes are read.<br><br>* Don't use std::map for sparse grid (see below).  <br><br>* Overestimated timeline, will probably not get to Voxel primitive until next week at the earliest.<br><br><b>Sparse Grid Data Structure</b><br><br>Sparse grids should, instead of using map, have an auxiliary array to keep track of active and inactive tile indexes. Tentatively the structure should be something similar to this:<br><br>struct VolumeTile {<br>    float4 voxels[CUBE_SIZE * CUBE_SIZE * CUBE_SIZE];<br>}<br>VolumeTile *grid;   /* array of active tiles */<br>int *indexes; <br>/* maps the index of a tile in the original volume to its index in the sparse volume<br> * e.g. indexes[A] = B means a tile at orig_vol[A] is now at grid[B]<br> * tiles not in grid (inactive tiles) have index -1. */<br><br>Since <i>VolumeTile</i> is just an array of floats, it may be better to forgo the struct and just make grid a float array and make indexes keep track of the start of each "tile". This will make the code more difficult to read though, and I am not sure about the performance difference.<br><br><b>Other progress</b><br><br>I have written functions for generating and looking up in the sparse grid, but most of the code has problems like inconsistent typing because I am not yet certain of how the volume will be called during rendering, so I cannot properly write the functions yet. I have spent most of this week tracing the rendering process.<br><br>Since the volume textures will be stored as <i>device_memory</i>, I needed to trace what <i>device_memory</i> was converted to after <i>device_update</i> completed (seems to be <i>ShaderData</i>), and from there figure out how voxels are looked up.<br><br>From what I can tell, the lookup change should be inserted in the functions in <i>kernel/kernel_volume.h</i> that call <i>ccl_device_inline bool volume_shader_sample()</i>, but I will need to investigate further to be sure.<br><br>On an unrelated note, it may be worth templating the separate float/float3 functions in <i>geom/geom_primitive.h</i> and <i>geom/geom_volume.h</i> since most of the code is identical.<br><br><b>To-do next week</b><br><br>* Finish tracking the whole volume rendering process.<br>* Finalize data structure of sparse volume and insert the creation and lookup functions where appropriate.<br>* Testing code, compare performance.<br>* Create a Git branch, upload changes.<br><br></div></div>