top of page
  • Writer's pictureThiago Araujo

Houdini Bake Burn Sim to Texture

Updated: Sep 12, 2023

Houdini is indeed impressive. However, as many of us are aware, some of its most powerful techniques aren't immediately applicable to game development. Making these techniques work effectively requires adjustments to convert the data Houdini generates into formats usable within a game engine.

A strategy to tackle this challenge involves baking data into textures and exploiting dynamic shaders to mimic certain simulation effects. This specific project adopts this strategy, baking a Pyro Spread simulation into a texture ready for integration into a game. You're welcome to download the .hip for this project here.

 

Entagma's Bake Attributes to Texture setup:


The project I'm presenting here employs the Point Attributes To Textures technique presented by Entagma. This technique enables us to translate point attributes into textures using an object's UV coordinates.

The concept behind this approach is ingenious, and here's a succinct breakdown of its key components:


- Setup:

- Import the object that will receive the baked data along with its UV coordinates.

- Construct your point cloud, incorporating any desired information.

- Generate a 2k by 2k by 1 VBD (effectively an image presented as a volume).


- Bake:

- Iterate through each voxel within the VBD and use its coordinates to reverse-sample the object's UV map.

- This reverse-sampling yields a world coordinate corresponding to the presence of that UV point on the object surface.

- Retrieve the nearest point within the point cloud and assign the value of that point to the corresponding VBD voxel.


- Render:

- Utilize a COP2 network to render your VDB as an image.


First time I saw this amazing technique I was dazzled, I had to implement it into something fun, so in this project, I am using it to bake Burn Spread simulation into a reveal texture that can then be used in an animated shader.

 

Burn Simulation Bake:


Let's delve into the burn simulation bake implementation process:


First, import your object, then create a pyro source from it and set up its temperature and diffrate. This initial setup is quite standard for a Pyro Spread configuration.


However, the specific information we're after is the frame at which each particle was burned. Unfortunately, the Pyro Spread solver doesn't inherently provide this data. Therefore, we need to devise a method to extract this information from it.


Here's a straightforward approach to achieving this:


1. Create a point attribute named @f to store the precise frame when a particle was burned. Initialize it to -1 for now.


2. Then go inside the Pyro Spread Solver and insert a point wrangle between the Last Frame and output0 nodes.


3. Add the following script within the point wrangle:

if (@f == -1.0 && @burn == 1.0)     
	@f = @Frame;

In essence, this script operates as follows: For each point, if the @f attribute has not been set yet (it still remains at -1) and the @burn attribute is 1 (indicating the point has been completely consumed by Pyro Spread), update @f to the current frame value.


With this adjustment, the solver will now output the frame at which each point was burned into the attribute @f.









Next, to address the remaining unburned points and @f normalization. Insert another point wrangle after the Pyro Spread and apply the following script:

# Obtain the total frame count of the animation 
int frame_range = chi("frame_range");

# If the point's f attribute is still set to -1
if (@f == -1.0)
	# Set it to burn at the end of the animation
	@f = frame_range + 1;

# Normalize f by the frame_range value
@f /= frame_range;

# Invert the f value
@f = 1 - @f;

This script performs the following tasks:


If a particle has not yet been burned, set its @f attribute to correspond with the end of the animation.


Then since textures usually can only carry values between 0.0 to 1.0, the @f value is then normalized by the frame_range value.


For my shader afterwards, I utilize white to represent items that were burned earlier. Consequently, the resulting gradient generates a ramp from white to black. This is why the inversion of @f at the end is necessary.








 

Final output:


The resulting output is a texture that transitions from black to white, effectively depicting the evolution achieved through the burn simulation.


It's important to note that the capture quality of this texture improves with a greater number of points in your point cloud. For heightened resolution, consider increasing the size of the VDB.


Importantly, while this texture depicts the burn transition, the other channels of the output texture remain available for alternative uses. This versatility enables us to potentially bake different types of data from our simulation into this texture.


With this texture in hand, the possibilities are expansive. It can be seamlessly integrated into any shader of your choice, allowing for precise control over the transition between two materials.

To illustrate, I've created a straightforward shader example within Blender that smoothly transitions from the object's original texture to a solid black material.


Comments


bottom of page