MilchRatchet / Luminary

CUDA based Pathtracing Offline and Realtime Renderer
MIT License
30 stars 1 forks source link

Per Material IoR #92

Closed SamuelTallet closed 10 months ago

SamuelTallet commented 10 months ago

Hello,

It would be great if Luminary could read and use a refractive index defined in a .mtl file for a material, for example:

newmtl window_glass
Ni 1.52
MilchRatchet commented 10 months ago

Good idea, I will try that out soon as it should be quite simple. As with the ocean and the toy though, the direct lighting will just ignore the refraction as I don't support caustics.

MilchRatchet commented 10 months ago

So this is now implemented as of 18cc1e336262386a6d89b621e6b124a37a970ad0. There are some things to note. Outside and inside are determined by the face normal, i.e., the face normal always points outside. Currently, the outside is always assumed to have a refractive index of 1, though I plan to account for ocean and toy refractive index if we are inside those. Also fully transparent objects will still be invisible even if their refractive index is not 1, this is mostly a performance thing and with my data driven design it would be a bit of a hassle to get rid of it, besides that, fully transparent objects are not all that realistic anyway.

It is also important to note that the material properties will be taken into account so by default refractions will be rough. Though I am thinking of making some changes to the parser so that it also supports non texture based material properties, i.e., you can just plug a number into the roughness and it simply takes that. The changes in the above mentioned commit makes this trivial to implement. I am just not sure yet how the global material override should interact with that.

Snap-2023-10-26-20-35-49

SamuelTallet commented 10 months ago

I am thinking of making some changes to the parser so that it also supports non texture based material properties, i.e., you can just plug a number into the roughness and it simply takes that.

🙂👍 Typically, renderers first look to see if there is a roughness texture and if there is, then the roughness property becomes a multiplier for each pixel of that texture. If there is no roughness texture, then the roughness is applied evenly to the surface…

I am just not sure yet how the global material override should interact with that.

The global material setting could be a fallback instead of an override. I think the material settings defined in the .mtl file should take priority over those defined in the .lum file.

In any case, thank you for what you have already accomplished 🙏