Jump to content

Caustics In H9


Recommended Posts

Hi everybody.

I am trying to get some caustics with H9, but not usiong PBR using micropolygon or raytracing render engines only.

With H8 one can create a caustic photon map and use it in the GI SHOP attached to a light.

I have seen that all the photon map parameters are in the PBR tab. So it seems that the only way to use photon maps is through PBR, that's correct:?

If there is any option to get caustivs with micropoly or raytracing what is the workflow?

Thanks.

Link to comment
Share on other sites

Yes, you can still do caustic similarly to H8, things have just moved around a bit.

Set up a spotlight pointed at your object. Create a mantra output driver set to "Photon Map Generation". Go to the PBR Tab and remove the entry for the Global Photon Map, but leave the one for the Caustic map or set it to whatever you want. Add a Light Template object to your scene, and a VEX Global Illumination SHOP. Set the light shader for the Light Template object to the VEX_giLight you created, and in that shader set the Caustic Photon Map param to the caustic map created in the previous step. Then render with a separate Mantra driver set to either micropoly or raytrace.

See attached. Hope that helps.

post-2001-1197486108_thumb.png

caustics.hipnc

Link to comment
Share on other sites

Thats good to know - thanks John. I thought they'd axed the whole thing:) Any chance you can post a scene file for all?

Hi Jason,

There's a scene file attached to my post above.

Just re-downloaded it and tested, seems to work. It was made with 9.0.786, BTW.

Oh, and if you're talking about the VEX Photon Context above, I think you're right, it probably is deprecated, but that's just because a properly set up BRDF encapsulates everything the photon generation process needs to know about the probability of a photon being bounced, scattered, or absorbed. So if your BRDF is correct in your shader (and I'm assuming that's the case for the stock materials), then you get proper photon transmission for free, I believe. The scene above uses the stock Glass material, with "Do Fake Caustics" toggled off.

John

Edited by johner
Link to comment
Share on other sites

Oh I get it now - yes :) I was talking about the Photon Shader Context stuff. Opening your file explained it to me better and I see that you're using the "Photon Map Generation" mode, which is really using the nicely defined bsdf (F) in the shader, and then using that resultant photon map in the regular (non-PBR) rendering engine. Good stuff :)

Thanks for that,

Jason

Link to comment
Share on other sites

Oh I get it now - yes :) I was talking about the Photon Shader Context stuff. Opening your file explained it to me better and I see that you're using the "Photon Map Generation" mode, which is really using the nicely defined bsdf (F) in the shader, and then using that resultant photon map in the regular (non-PBR) rendering engine. Good stuff :)

Thanks for that,

Jason

Yup, I was happy to see the Photon Shader context go the way of the dodo, always seemed pretty wonky and error-prone to me. The BSDF is a much more generally useful way to do it.

For whatever it's worth, you can also still use a similar workflow to above to get multi-bounce GI using photon maps and regular Mantra micropoly rendering. Basically you need another output driver set to "View-Dependent Photon Map Generation" to generate the global photon map, then you add that to the VEX Global Illumination light.

I put the "jewel" from the above scene into a closed room with a light shining through the window. First is the PBR render, second is micropoly reusing the same global and caustic photon maps. Obviously I'd still need to do a bunch of tweaking to the photon settings, and for something like this I think you'd probably just go ahead and use PBR, but it's cool that it's possible nonetheless.

John

post-2001-1197571756_thumb.png

post-2001-1197571779_thumb.png

caustics_and_gi.hipnc

Link to comment
Share on other sites

That is cool, yeah. I RFE'd a bunch of caustics-related issues in the SESI forum the other day - most of them ease-of-use RFEs, but a couple to help make the sampling of the photons a little more tweakable.

Yup - my only fear is not being able to create/shape and, most importantly, visualize these BRDFs. I'm sure that a good shader-ball along with a visualizer for the distribution would be quite enabling in the world of BRDFs and PBR.

Looking around for a visualization for BRDFs, I saw these:

http://sbrdf.cs.unc.edu

http://people.csail.mit.edu/addy/research/brdf/index.html

http://people.csail.mit.edu/wojciech/

post-4-1197614762_thumb.jpg

post-4-1197614771_thumb.jpg

Link to comment
Share on other sites

Thanks johner for the explanation.

I have been trying this and have a look to your scene but when I try it in one of my scenes I get always the same error from mantra:

mantra: Aborting photon generation due to an extremely low photon storage ratio.  Try using a more accurate photon target.
Render Time: 9.21u 0.29s 5.48r
Memory:  16.24 MB of 16.36 MB arena size. VM Size: 30.18 MB
Photon Map /tmp/maps/caustic.pmap: Scaling irradiance
Photon Map /tmp/caustic.pmap: 0 photons stored

Have you get this error ?

Thanks

Link to comment
Share on other sites

Thanks johner for the explanation.

I have been trying this and have a look to your scene but when I try it in one of my scenes I get always the same error from mantra:

mantra: Aborting photon generation due to an extremely low photon storage ratio.  Try using a more accurate photon target.
Render Time: 9.21u 0.29s 5.48r
Memory:  16.24 MB of 16.36 MB arena size. VM Size: 30.18 MB
Photon Map /tmp/maps/caustic.pmap: Scaling irradiance
Photon Map /tmp/caustic.pmap: 0 photons stored

Have you get this error ?

Thanks

I think the cause of this error is the inability of the photon generation process to get enough caustic photons to be stored in the photon map. So, if the parameter is for 100,000 photons, it will give up at some point if it can't store that many.

A caustic is the result of light passing through either specular reflection or transmission, then hitting a diffuse surface. In the example file I posted, the glass has both specular reflections and transmission, which is why you see both white and red caustics. The floor is just a simple "Clay" shader, i.e. completely diffuse. And the light is shining right on the object, so it's easy for the photon process to generate enough photons in the map.

But if you change the "jewel" in the scene to a diffuse surface, for example assign the "Clay" material, there's no more specular bounces going on and not enough photons can be generated, and you get that same error that you've been seeing. Similarly, if you assign the "Glass" material to the floor, you'll get the same problem, in this case because there's no longer a diffuse surface for the photons to be stored on. Also, if the light is not aimed at the specular surface in such a way that the reflections / transmissions hit the diffuse surface.

So, I guess make sure that you're using a point light or spot light aimed at the surface, make sure that it's a surface with specular reflections and/or transmissions and that it it's BRDF is set up properly in the shader (or test by temporarily assigning a stock metal surface or the stock "Glass" shader with "Do Fake Caustics" off), and make sure the surface the caustics should appear on is at least partially diffuse.

Hope that helps.

Link to comment
Share on other sites

Thanks Johner for your extensive explanation.

Yes my problem is that I am not using a diffuse surface to store the photons that the reason because I don't get nothing.

My problem is that I want to get the caustics produces by a piece of cristal to itself or onto other cristals and then I think I can't use photons because it seems that them only works when you conbine a refreactive surface against a diffuse one.

Link to comment
Share on other sites

Thanks Johner for your extensive explanation.

Yes my problem is that I am not using a diffuse surface to store the photons that the reason because I don't get nothing.

My problem is that I want to get the caustics produces by a piece of cristal to itself or onto other cristals and then I think I can't use photons because it seems that them only works when you conbine a refreactive surface against a diffuse one.

Yes, unfortunately you're sort of fighting the physics of light transport there. Caustics really don't show up on purely specular surfaces. Two things might, however: 1) a reflection (through zero or more specular bounces) of the actual light source itself (i.e. you can see a reflection of the lightbulb), and 2) reflections of the caustics that are on other diffuse surfaces in the scene. To simulate the first you could put a sphere or something where your light source is and turn on it's "phantom" flag and make sure it doesn't cast shadows on the scene. But that's a pretty rare effect, I think. For the second, you probably just want to make sure the number of reflect/refract bounces is pretty high. In the default Glass shader that's on the Properties tab.

If you're looking to just cheat to get a particular effect, you could add some degree of diffuse lighting to a glass shader, making sure the Lambertian part of the BSDF is added in. It might make your glass kind of "filmy" or dirty looking. But you can also do something like create a Take where the diffuse intensity parameter on the glass is artificially high, then use that take in the Mantra driver that generates the photon map, which will allow photons to be stored on the glass surface. Then set the diffuse intensity pretty low for the real render pass. You can crank up the Global Tint in the VEX Global Illumination shader so that the caustics light is particularly strong, to compensate for the low diffuse parameter. So regular lights won't have much diffuse effect on the glass, but caustics will show up. Of course that would affect the diffuse surfaces too, so you could also do it with light masks or categories within the VEX shader if you wanted to get really fancy.

I haven't actually tried all this yet, but I think it will work.

Link to comment
Share on other sites

  • 2 weeks later...

Just for experimentation's sake, I shone a light up into a bent metal tube and a bent glass rod, fibreoptics-style.

There was a little more photon spillage than I expected - if you look on the opengl images you can see them hitting the ceiling. I assume a lot this is due to some kind of bias issues -something that didn't really improve as I increased the PBR Bias though.

Anyhow, they make for pretty pictures :)

Glass Rod:

post-4-1198994133_thumb.jpgpost-4-1198993609_thumb.jpg

Metal Tube:

post-4-1198994122_thumb.jpgpost-4-1198993619_thumb.jpg

Hip File (without my HDR environment though [for some ambient light] - just replace it):

fibreoptics.hipnc

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...