Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] Bug Reporting => Topic started by: cecofuli on 2018-05-22, 15:24:25

Title: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 15:24:25
Hello,
I have a very small experience with .vdb file.
With PhoenixFD I have created a simple exploadion (with the preset tool), inport the .vdb file in Corona and try to play.

(http://www.francescolegrenzi.com/Temp/Corona/0237_VDB_Shadow.jpg)

As you can see:

(*) there is a problem with the shadow
(*) I'm not able to create a nice "emission" shader

Here you can download the files:

--- DOWNLOAD---  (http://www.francescolegrenzi.com/Temp/Corona/0237_VDB_Shadow.rar)

Where is the problem?  =)



Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 15:39:13
This looks like a bug I noticed (and reported internally) yesterday - if there is a light inside the CoronaVolumeGrid object (the bounding box for it, not necessarily inside the part with voxels) and if there is an object (such as a plane) also inside the CoronaVolumeGrid, then lighting seems to be incorrect.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 15:43:50
Thank you TOm. And, what about shader? Are you able to create a nice "Explosion Emission light"? =)
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 16:28:17
Well, there's no shader in the conventional sense, it's all built into the CoronaVolumeGrid object. I've had it working fine, just need to select the correct data to use to drive the Emission, Temperature being the most likely one to use (the hotter it is, the more it glows). Then adjusting the Scale and maybe the gradient in the Grid mapping if you want to adjust the colors and how they fade off. Of course you could drive it using Density, Velocity, or any of the other parameters too, but Temperature is the one that would work best for Emission.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 16:44:29
Hi Tom, yes, I knew this, but thank you for the explanation =) It will be useful. But, if you open my file (you will find .max file and .vdb file) I' not able to create a "nice" result", even if I use temperature channel or other channels for the Emission. Only with Smoke_phx channel (llok at the image above) I have a nice and correct preview (point clouds viewport), but the rendering is awful :/ . Feel free to "play" ;-)
PS: the "Velocity" channel look like completely broken.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 16:56:13
Ok, the problem of the shadows, tt's not a bug.The plane and the CoronaVolumeGrid object are both exactly on 0.00. If you move the CoronaVolumeGrid object at 0.01, the "bug" is solved =)
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 16:57:23
Never tested with Phoenix FD output, just the free OpenVDB files from over on the OpenVDB site - the explosion from there worked as expected for me. Will see if I get time to take a look at the scene, but can't promise, as the next Academy is coming up and looking into how Phoenix saves OpenVDB files could be complex ;) My first thought would be to check the Scale, as not sure if different applications write different high / low values for their metadata.
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 16:58:23
On the bug, yes, if the plane (or presumably any object) intersects the OpenVDB, then this happens - does sound like the one I reported internally. Have added a note there to point at this forum post as another example of it, btw!
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 17:15:30
Ok, I tried to download the explosion from

http://www.openvdb.org/download/

And the Temperature channel is ok.
I think something is wrong inside the PhoenixFD .vdb file... But I don't know where it can be the problem. I'm not expert in VFX ^_^

(http://www.francescolegrenzi.com/Temp/Corona/0238_VDB.jpg)

Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 17:18:45
Join the club :) I did want to try creating something from Phoenix, as I wanted to test an animated OpenVDB and I can't find an example anywhere online (if anyone knows of one, let me know!) - but I have no idea how Phoenix FD exports to OpenVDB nor the details of what export settings there are, and how that changes how we import it - all new territory since the functionality has never existed for us before haha!

If anyone knows more about exporting to OpenVDB from various applications (should be possible from Blender and Houdini too for example), feel free to share info, knowledge and experiences! And to test CoronaVolumeGrid of course!
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 17:25:43
Ohh.. with PhonexiFD is very simple:

(*) Select a teapot and use PhoenixFD toolbar by pressing the  "Explosion Sim" button. PhoenixFd will do everything for us.
(*) Select the Grid and, in the rollout "Grid" decrease the resolution (to speed-up the test).
(*) In the rollout "Output" select the directory and the .vdb format"
(*) In the Simulation rollout, click... "Simulate".
(*) If you prefer to see the point clouds, in the "Preview" rollout, press "GPU Preview".

That's all =)
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 17:55:36
Ok,
here we can download a very simple and fast (low res) .vdb sequence of explosion created with PhoenixFD with default settings.
Try to obtain a nice rendering with CoronaVolumeGrid, if you can ^_^.

--- DOWNLOAD --- (http://www.francescolegrenzi.com/Temp/Corona/0239_VDB_Test_v0.2_vdb_file.rar)

(http://www.francescolegrenzi.com/Temp/Corona/0240_VDB_Test_v0.2_vdb_file_Frame_15.jpg)







Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 18:39:27
So did some testing on a sim from Phoenix FD here, and it is indeed the scaling of the Temperature. Not sure if there's a way to adjust it on export from Phoenix, but on import I had to use very small values in the Emission Scale, and in the Input Scaling (I ran Auto-scale first too), and fairly dark colors, and very low positions on the grid - see attached image.

Since it works in a much more "expected" way with the sample OpenVDB files, and can be made to work by adjusting the settings for a Phoenix FD exported OpenVDB, I am thinking this is related to how Phoenix is writing out the temperature rather than a bug or issue with CoronaVolumeGrid.
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 18:41:36
PS - without that 0 level point in the Grid at above the halfway mark that keeps everything at the zero until quite far along the scale, the non-flame parts of the CoronaVolumeGrid will also emit light and ruin the effect - so again seems to be how the Temperature is being scaled from the Phoenix FD export.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-22, 18:53:43
Thank you so much Tom. Maybe it's a bug in the way how Corona reads Phoenix temperature's value. I don't think it's Phoenix problem =)
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-22, 19:03:46
I'll ask the devs and find out one way or the other :)
Title: Re: VDB - Shadow bug and emission question
Post by: martinsik on 2018-05-23, 09:14:18
As for the missing shadow in the first image of this thread, this is an old Corona issue, which is related to all volumes (not only OpenVDB). This will be difficult to fix, unfortunately. For now, just make sure that objects don't intersect the volume grid bounding box (they either lie completely outside or completely inside the volume).

As for the PhoenixFD temperature, it is for some reason stored as very high numbers compared to temperature exported from other software (FumeFx or Blender etc..)
The only thing I can do about this is set the input scaling automatically when I somehow detect that the OpenVDB file was created by PhoenixFD.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-23, 12:55:17
Hi martinsik,
thank you for the explanation. I think that you should find a solution for a better compatibility with PhoenixFD.
Not it's very difficult to create some good Emission shader with the Temperature channel.
Maybe you can ask help to Chaosgroup

Have you tried my .vdb sequence? Even with very low Scale value, it's impossible to obtain what I had directly with PhoenixFD.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-23, 14:44:33
Speaking with Martin:

"We will be redoing the UI of CoronaVolumeGrid and we will also address the issue with the temperature".

Great support, as usual. ^_^

Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-25, 17:37:43
Looks like the Emission from Phoenix FD should be fixed in the latest daily (it was related to how Phoenix does black body radiation by the look of the comment in the changelog):

"emission data can now be optionally interpreted as temperature (calculating black body radiation color) + associated temperature scaling - this is automatically detected for Phoenix FD files and for others containing "temperature" channel"
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-27, 19:09:20
Ok, I tried again with the last Corona Daily and PhoenixFD v3.10 (no daily)
It's very, very uncomfortable to work with PhoenixFD file.
I have to use very too low value (Scale= 0.02 and Input scale 0.001).
When I try to change Input scale to 0.002... BOOM... Nuclear explosion =) !!!!
Also to play Gradient it's very annoying...  I have to play with only the 15px, because 80% of the space is a gradient between black and red...
And look at the Curve graph... so flat for70% of the space.
I will wait to play with the last official release of PhoenixFD (^__^)

(http://www.francescolegrenzi.com/Temp/Corona/0248_VDB_02.jpg)
Title: Re: VDB - Shadow bug and emission question
Post by: martinsik on 2018-05-28, 08:01:20
PhoenixFD exports emission as temperature in Kelvins, so it recommended to set emission Mode to Blackbody, which automatically computes color from the temperature.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-28, 12:39:46
Ah, ok... but, with Blackbody I cannot "play" with any Channel color mapping... =)
EDIT: we can use the Emission Custom map, like a simple 3ds Max Gradient =)
Title: Re: VDB - Shadow bug and emission question
Post by: maru on 2018-05-28, 13:50:47
Some quick notes:
-The examples at the top basically show fire/explosion during daylight situation. Have you seen fire (e.g. campfire) during daylight? The fire is often invisible. :) So I would suggest switching all lights off, and experimenting with fire/explosions in the darkness, or with a single, dim light source
-Emission - like Martin said, setting its mode to blackbody helps a lot, and makes it more predictable
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-28, 14:01:07
Mara, and, if I want to reproduce something like this? =)

(https://i.ytimg.com/vi/UYTvNYuDRh0/maxresdefault.jpg)

Yes, it's more predictable, but we lose the possibility to use Channel color mapping.
To use Gradient Ramp isn't very complex, but it was better to play with the Channel color mapping ;-)
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-28, 14:19:38
The new Blackbody option in the CoronaVolumeGrid should fix this - you need to swap from the old Channel mapping mode to Blackbody (see screengrab, this scene used to require the super small values in the Channel Grid etc) and then use Temperature scale to manage the brightness of the Emission.
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-28, 14:20:55
Would be interested to see your test scene with that - though I note you do say you know of it, just that you miss the Channel Grid mapping (what would you use it for, though - curious as to why it might still be useful in these situations?)
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-28, 14:48:59
Hi Tom,
yes, I know, and Blackbody works nicely.

As for your question: for example to crate "magic" explosion/smoke  ;-)

(https://i.ytimg.com/vi/fhNpVbiN3qY/maxresdefault.jpg)

You can use, with Blackbody, a custom Gradient Ramp.
But I don't understand why we cannot use the nice built-it Channel color mapping when we are using Blackbody option =)
But... it's ok =)


(http://www.francescolegrenzi.com/Temp/Corona/0249_VDB_03.jpg)
Title: Re: VDB - Shadow bug and emission question
Post by: TomG on 2018-05-28, 14:54:05
TY for the intended use! Magic fire and smoke is nice :)
Title: Re: VDB - Shadow bug and emission question
Post by: maru on 2018-05-29, 11:14:49
I experimented with the volume grid a bit more and it seems that the channel color mapping is pretty predictable when adjusting absorption and scattering, but indeed hard to understand and tune when adjusting emission of objects exported from PhoenixFD.
It is much easier to grasp when adjusting emission of objects downloaded from OpenVDB. So (as it was already explained here) it seems that the scale (intensity?) of the temperature matters here and the solution to deal with PhoenixFD objects is to use the blackbody mode.

I think Francesco's argument is valid - it would be good to have some user friendly controls to easily adjust the gradient and intensity of the emission regardless of the temperature intensity. I do not understand why it's not working so, even though it is supposed to map the original temperature range to 0-1 range. Maybe controlling the color gradient for the blackbody mode would be a good workaround?
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-29, 15:51:46
Exacty... I had the same exact experience. =) Waiting for some new daily =)
Title: Re: VDB - Shadow bug and emission question
Post by: martinsik on 2018-05-29, 16:23:40
We are working on an update of VolumeGrid. The newest version will scale temperature exported from PhoenixFD internally, so it can be easily used in both channel mapping mode and blackbody mode. Once the new version is out, you will want to set your (input) scale, temperature scale to default values (1 for input scale/scale and 3600 for temperature scale) in your old scenes (instead of the extreme values used previously).
Note that this change might not get to the next daily build, but rather to the following one.
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-29, 16:32:58
It's a great news!!!
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-05-30, 22:01:17
I think you need to add a button inside the CoronaToolbar =)
Title: Re: VDB - Shadow bug and emission question
Post by: maru on 2018-06-06, 14:16:09
Hi Francesco, have you tried setting up emission in RC1? It's much much more intuitive now. :)
Title: Re: VDB - Shadow bug and emission question
Post by: cecofuli on 2018-06-06, 14:41:19
Now it seems more easy to play with the Emission Channel +Temperature_phx =)

(http://www.francescolegrenzi.com/Temp/Corona/0250_VDB_04.jpg)

(http://www.francescolegrenzi.com/Temp/Corona/0251_VDB_05.jpg)