Page MenuHome

Rendering: add access to the smoke velocity and heat fields.
AbandonedPublic

Authored by Kévin Dietrich (kevindietrich) on Mar 25 2015, 2:37 PM.

Details

Summary

This adds access to the velocity and heat fields from the smoke simulation to Cycles and the viewport.

As the velocity fields do not exist in the high resolution part of the simulator, the velocities for the high res grids are sampled from the low res grid ones, I stay confident that we shouldn't get too blocky of a result.

For the heat field, judging from the fact that heat is based on a linear interpolation of the ignition temperature and maximum temperature based on the value of the flame field at the current voxel, such field was added to the high res solver (as we already have the flame one and it is computed the same way as the low res one).

Diff Detail

Repository
rB Blender
Branch
cycles_smoke

Event Timeline

Kévin Dietrich (kevindietrich) retitled this revision from to Cycles smoke rendering: add access to the velocity and heat fields..
Kévin Dietrich (kevindietrich) updated this object.

Quick example for the velocity field:

Direction of the patch seems fine, however, there are some unclearness going on. Namely, it seems you're just exposing some attributes to Cycles, without way to even preview them in viewport?

And ideally BI should also become aware of this.

Also adding @Daniel Genrich (genscher) as a reviewer, intern/smoke is more of his area.

Direction of the patch seems fine, however, there are some unclearness going on. Namely, it seems you're just exposing some attributes to Cycles, without way to even preview them in viewport?

You mean draw heat and velocity in the viewport? If yes, then there is some code to draw heat and velocity in the viewport, but it is hidden behing a debug flag. Maybe we could expose an option in the UI to draw them.

See https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/space_view3d/drawvolume.c$524

And ideally BI should also become aware of this.

Seems fine.

if it's inside a debug flag then it's not really clean integration into blender and should be done much cleaner. Giving artists nice feedback and visualization about what's going on.

Daniel Genrich (genscher) edited edge metadata.EditedMar 25 2015, 3:04 PM

@ sergey: Thanks for adding me :-) I totally agree with your comments.

Direction of the patch seems fine, however, there are some unclearness going on. Namely, it seems you're just exposing some attributes to Cycles, without way to even preview them in viewport?

You mean draw heat and velocity in the viewport? If yes, then there is some code to draw heat and velocity in the viewport, but it is hidden behing a debug flag. Maybe we could expose an option in the UI to draw them.

And ideally BI should also become aware of this.

Seems fine.

a) The code should contain the viewport drawing code for heat + velocity as well.
b) Blender Internal "Seems fine"? I cannot see a single line of code where you add suport for velocity + heat for the Blender Internal render. Please add support for Blender internal, thanks!

Overall, this is a nice patch (starting point) which was requested already by many people but I hadn't yet the time to do.

@Daniel Genrich (genscher), I meant that it seems fine to add support for this for BI as well :)

eh, sorry for the mail spam, but as far as I can tell BI already has access to heat and velocity (through voxel data textures): https://developer.blender.org/diffusion/B/browse/master/source/blender/render/intern/source/voxeldata.c$254

kevindietrich is right for bi its already done

also there was never a way to visualize heat or velocity in blender - the drawing features are from one of miikas google summer of code (it doesnt work at the moment - just crashes) would be nice to have of course! :)

more important projects would be to allow motion blur for smoke and rendering only low res smoke (if high res exist)

Kévin Dietrich (kevindietrich) edited edge metadata.
  • Add support to draw velocity and heat in the viewport.
  • Update viewport when changing draw type.

When it comes to drawing certain fields in the viewport, the biggest problem I find is the fact that the shaders are written in assembly. This complicates branching a fair tad, at least I couldn't find a good way to draw a given field and not the others. Therefore I've decided to write separate shaders for the velocity, heat, as well as one for fire. Eventually this whole viewport volume drawing needs to be reconsidered (perhaps alongside the viewport project?). But that goes for another patch I guess, unless you guys have really strong objections. Also the fields are drawn based on where the density is.

@Ronny G (nutel), those functions were for debugging purposes, also only one crashes and it does so because it tries to access non-allocated memory (and for completeness, they have some unused variables).

Kévin Dietrich (kevindietrich) retitled this revision from Cycles smoke rendering: add access to the velocity and heat fields. to Rendering: add access to the smoke velocity and heat fields..Mar 26 2015, 3:02 AM
Kévin Dietrich (kevindietrich) updated this object.

Smoke simulator was introduced as a proof of concept, a goodie for voxel data texture in Farsthary's 2.4x branch about volume rendering for BI.

Genscher made it in 2.5x for Sintel.
Only Density was shown in viewport and user had to control colors through colorramps of others Voxel Data textures using other attributes.
Texture preview is rendering these attriutes for BI.

MikaH added Adaptative Domain, Flames, simpler UI and color in Viewport.
He introduced Color as a property of smoke flow emitter.

So, color shown in viewport is only relative to this attribute or to flame.
It does not correspond to an accurate preview of smoke shader that would be rendered.
For this, it should take into account colorramps that can be used in material.

Adding @Antonis Ryakiotakis (psy-fi) since the code touches the viewport.

Not so much fan of the way to the visualization tbh. Ideally viewport should use shading closer to the actual material. Current approach with selecting what exactly you want to display in the viewport is a bit... 90ies.But here it'll be nice to have some inputs from @Antonis Ryakiotakis (psy-fi) about what's he thinks is best approach to the problem.

Changes to Cycles seems fine to me. And changes to smoke still needs approval from Daniel.

Just some extra feedback: seems the array in turbulence structure gets allocated regardless whether heat map is needed or not, which is not friendly from memory usage point of view at all.

Closing this for the time being.