Disney Material Update

Discussion related to the LuxCore functionality, implementations and API.
chuchur
Posts: 26
Joined: Tue Sep 15, 2020 8:44 am

Disney Material Update

Post by chuchur » Mon Aug 02, 2021 1:37 pm

Hi All,

I try to implement some new features for Disney Material.

In the first line, it is Specular Transmission. @Dade pointed me on https://schuttejoe.github.io/post/disneybsdf/ page, where almost all of the code has been done.

I have just a few questions about the implementation in Lux:

1. For the specular transmission calculation, we need a relative refraction index. Should it be defined as texture or derived from exterior/interior volumes?

I assume second, since we have this one for glass material, but looks like it's deprecated.

https://github.com/LuxCoreRender/LuxCor ... s.cpp#L203

Code: Select all

	if (props.IsDefined(propName + ".ioroutside")) {
			SLG_LOG("WARNING: deprecated property " + propName + ".ioroutside");
			exteriorIor = GetTexture(props.Get(Property(propName + ".ioroutside")(1.f)));
		} else if (props.IsDefined(propName + ".exteriorior"))
			exteriorIor = GetTexture(props.Get(Property(propName + ".exteriorior")(1.f)));
What would be a good way to define the relative refraction index?

2. Should we derive the color information for transmission from baseColor and ignore volumetric properties?

3. What should I be aware of in turning Disney Material from Opaque into Transmissive? Is just adding transmission even enough?

And maybe one more question about subsurface scattering in DisneyMaterial. Is it currently a fake without using any information of internal volume, depth, and curvature? Should we replace it in the future?

I'll keep posting my progress in this thread. Hope to have things done soon :)

User avatar
Dade
Developer
Posts: 5553
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Disney Material Update

Post by Dade » Mon Aug 02, 2021 2:18 pm

chuchur wrote:
Mon Aug 02, 2021 1:37 pm
1. For the specular transmission calculation, we need a relative refraction index. Should it be defined as texture or derived from exterior/interior volumes?

I assume second, since we have this one for glass material, but looks like it's deprecated.

https://github.com/LuxCoreRender/LuxCor ... s.cpp#L203

Code: Select all

	if (props.IsDefined(propName + ".ioroutside")) {
			SLG_LOG("WARNING: deprecated property " + propName + ".ioroutside");
			exteriorIor = GetTexture(props.Get(Property(propName + ".ioroutside")(1.f)));
		} else if (props.IsDefined(propName + ".exteriorior"))
			exteriorIor = GetTexture(props.Get(Property(propName + ".exteriorior")(1.f)));
What would be a good way to define the relative refraction index?
You can just copy the glass material code: https://github.com/LuxCoreRender/LuxCor ... s.cpp#L199

The ExtractExteriorIors()/ExtractInteriorIors() will take care of everything.
chuchur wrote:
Mon Aug 02, 2021 1:37 pm
2. Should we derive the color information for transmission from baseColor and ignore volumetric properties?
A material defines the behavior of an object surface while the volume defines the inside. They are 2 different things. You need only to worry of what happens on the surface (i.e. refraction due to different internal/external IORs and surface transmission color). As far as I remember, the Disney uses baseColor for surface transmission color.
chuchur wrote:
Mon Aug 02, 2021 1:37 pm
3. What should I be aware of in turning Disney Material from Opaque into Transmissive? Is just adding transmission even enough?
What do you mean exactly ? Do you wonder if the Disney material GetEventTypes() should be always return "GLOSSY | REFLECT|TRANSMIT" or return the "TRANSMIT" part only if it can really transmit ?
Support LuxCoreRender project with salts and bounties

chuchur
Posts: 26
Joined: Tue Sep 15, 2020 8:44 am

Re: Disney Material Update

Post by chuchur » Mon Aug 02, 2021 2:56 pm

What do you mean exactly ? Do you wonder if the Disney material GetEventTypes() should be always return "GLOSSY | REFLECT|TRANSMIT" or return the "TRANSMIT" part only if it can really transmit ?
Yes, and also if the material should take care of internal volume/attenuation/scattering. But you have answered it already :)

User avatar
Dade
Developer
Posts: 5553
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Disney Material Update

Post by Dade » Mon Aug 02, 2021 3:02 pm

chuchur wrote:
Mon Aug 02, 2021 2:56 pm
What do you mean exactly ? Do you wonder if the Disney material GetEventTypes() should be always return "GLOSSY | REFLECT|TRANSMIT" or return the "TRANSMIT" part only if it can really transmit ?
Yes
It is a complex argument: up to now all GetEventTypes() materials are static so it should return "GLOSSY | REFLECT|TRANSMIT" (not matter of the parameters) however there may be some bad interaction with some of the caches and other code because the material is declared "TRANSMIT" ... and it doesn't. I'm afraid we have to try and check what works best.
Support LuxCoreRender project with salts and bounties

chuchur
Posts: 26
Joined: Tue Sep 15, 2020 8:44 am

Re: Disney Material Update

Post by chuchur » Fri Aug 06, 2021 2:52 pm

Hi Dade, maybe one question more:

I've found that Spectrum is defined as

Code: Select all

typedef RGBColor Spectrum;
in https://github.com/LuxCoreRender/LuxCor ... lor.h#L494

Does it mean that we do make calculations in RGB color space?

User avatar
Dade
Developer
Posts: 5553
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Disney Material Update

Post by Dade » Fri Aug 06, 2021 3:11 pm

chuchur wrote:
Fri Aug 06, 2021 2:52 pm
Does it mean that we do make calculations in RGB color space?
Yes, since the very beginning.
Support LuxCoreRender project with salts and bounties

chuchur
Posts: 26
Joined: Tue Sep 15, 2020 8:44 am

Re: Disney Material Update

Post by chuchur » Tue Aug 10, 2021 3:56 pm

Hi,

I've done the pure transmittance part for Disney material I hope (see the red ball :)). Now I want to combine it with the rest.

I have a couple of questions related to the original paper (https://schuttejoe.github.io/post/disneybsdf/)

In LuxRender code I see:

1. For the Glass we decide if we reflect or passThrough in this way

Code: Select all

	if (passThroughEvent < threshold) 
2. For Disney in the current implementation we have

Code: Select all

	if (passThroughEvent <= ratioGlossy)
		*localSampledDir = DisneyMetallicSample(anisotropicGloss, roughness, wo, u0, u1);
	else if (passThroughEvent > ratioGlossy && passThroughEvent <= ratioGlossy + ratioClearcoat)
		*localSampledDir = DisneyClearcoatSample(clearcoatGloss, wo, u0, u1);
	else if (passThroughEvent > ratioGlossy + ratioClearcoat && passThroughEvent <= ratioGlossy + ratioClearcoat + ratioDiffuse)
		*localSampledDir = DisneyDiffuseSample(wo, u0, u1);
	else
		return Spectrum(); 
But in SampleDisneySpecTransmission code from the blog article https://schuttejoe.github.io/post/disneybsdf/:

Code: Select all

    
    if(sampler->UniformFloat() <= F) {
        wi = Normalize(Reflect(wm, wo));

        sample.flags = SurfaceEventFlags::eScatterEvent;
        sample.reflectance = G1v * surface.baseColor;

        float jacobian = (4 * AbsDot(wo, wm));
        pdf = F / jacobian;
    }
    else {
        if(thin) {
            // -- When the surface is thin so it refracts into and then out of the surface during this shading event.
            // -- So the ray is just reflected then flipped and we use the sqrt of the surface color.
            wi = Reflect(wm, wo);
            wi.y = -wi.y;
            sample.reflectance = G1v * Sqrt(surface.baseColor);

            // -- Since this is a thin surface we are not ending up inside of a volume so we treat this as a scatter event.
            sample.flags = SurfaceEventFlags::eScatterEvent;
        }
        else {
            if(Transmit(wm, wo, relativeIOR, wi)) {
                sample.flags = SurfaceEventFlags::eTransmissionEvent;
                sample.medium.phaseFunction = dotVH > 0.0f ? MediumPhaseFunction::eIsotropic : MediumPhaseFunction::eVacuum;
                sample.medium.extinction = CalculateExtinction(surface.transmittanceColor, surface.scatterDistance);
            }
            else {
                sample.flags = SurfaceEventFlags::eScatterEvent;
                wi = Reflect(wm, wo);
            }

            sample.reflectance = G1v * surface.baseColor;
        }

        wi = Normalize(wi);
        
        float dotLH = Absf(Dot(wi, wm));
        float jacobian = dotLH / (Square(dotLH + surface.relativeIOR * dotVH));
        pdf = (1.0f - F) / jacobian;
    }
    
I don't understand why he has a second if for transmit clause?

Code: Select all

 if (Transmit(wm, wo, relativeIOR, wi)) 
What "false" means in this case? I can't find the code for "Transmit" in the blog.

Thank you for your help! I hope I'm coming close to the end :)

Update: Sorry for my last question, I've noticed I haven't check the whole implementation of Selas. There is the whole source there (https://github.com/schuttejoe/Selas), so I can go further.
Attachments
RedSpecTransmittance.png
Last edited by chuchur on Wed Aug 11, 2021 8:37 am, edited 2 times in total.

User avatar
Sharlybg
Donor
Posts: 2942
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: Disney Material Update

Post by Sharlybg » Tue Aug 10, 2021 5:07 pm

Thank you for your help! I hope I'm coming close to the end :)
Congratulation :) this look promising.
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA

User avatar
FarbigeWelt
Donor
Posts: 1034
Joined: Sun Jul 01, 2018 12:07 pm
Location: Switzerland
Contact:

Re: Disney Material Update

Post by FarbigeWelt » Fri Aug 13, 2021 1:08 pm

chuchur wrote:
Tue Aug 10, 2021 3:56 pm
Hi,

I've done the pure transmittance part for Disney material I hope (see the red ball :)). Now I want to combine it with the rest.

Update: Sorry for my last question, I've noticed I haven't check the whole implementation of Selas. There is the whole source there (https://github.com/schuttejoe/Selas), so I can go further.
he

👍🏻👍🏻👍🏻🙌🏻🙌🏻🙌🏻🦾
:D
Congratulations, I think you made great work with fast advancing progresses! Please, go on and even beyond common expectations ... :lol:

Does anybody know somebody who tried improving stochastic path finding with the help of algorithms used for sales men's route
optimising regarding biological models like for example the slime mold Physarum polycephalum is famous for finding food in a maze almost miraculously?

Tsuda, Soichiro, Zauner, Klaus-Peter and Gunji, Yukio-Pegio (2007) Robot control with biological cells. Biosystems, 87, 215-223.
https://eprints.soton.ac.uk/263582/
Light and Word designing Creator - www.farbigewelt.ch - aka quantenkristall || #luxcorerender
Windows 10 Pro 64 || 2x16 Cores, AMD Ryzen 3950X @3.5GHz, 64 GB RAM, DDR4 @3.2 GHz
2x openCL, AMD Radeon RX 5700 XT, 8 GB VRAM || Gfp = SFFT Gflops

chuchur
Posts: 26
Joined: Tue Sep 15, 2020 8:44 am

Re: Disney Material Update

Post by chuchur » Wed Aug 18, 2021 1:36 pm

Hi Dade,

I just wonder what kind of event types i could use for Disney in GetEventTypes and Sample/Evaluate methods?

For Glass material we have SPECULAR | REFLECT| TRANSMIT and for Disney without transmission we have GLOSSY|REFLECT.

Should it be for Disney with transmission GLOSSY|SPECULAR|REFLECT| TRANSMIT in GetEventTypes ?

And in Sample/Evaluate GLOSSY|REFLECT for reflected path and SPECULAR|TRANSMIT for refracted path?

Post Reply