Page 1 of 2

Disney Material Update

Posted: Mon Aug 02, 2021 1:37 pm
by chuchur
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 :)

Re: Disney Material Update

Posted: Mon Aug 02, 2021 2:18 pm
by Dade
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 ?

Re: Disney Material Update

Posted: Mon Aug 02, 2021 2:56 pm
by chuchur
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 :)

Re: Disney Material Update

Posted: Mon Aug 02, 2021 3:02 pm
by Dade
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.

Re: Disney Material Update

Posted: Fri Aug 06, 2021 2:52 pm
by chuchur
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?

Re: Disney Material Update

Posted: Fri Aug 06, 2021 3:11 pm
by Dade
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.

Re: Disney Material Update

Posted: Tue Aug 10, 2021 3:56 pm
by chuchur
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.

Re: Disney Material Update

Posted: Tue Aug 10, 2021 5:07 pm
by Sharlybg
Thank you for your help! I hope I'm coming close to the end :)
Congratulation :) this look promising.

Re: Disney Material Update

Posted: Fri Aug 13, 2021 1:08 pm
by FarbigeWelt
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/

Re: Disney Material Update

Posted: Wed Aug 18, 2021 1:36 pm
by chuchur
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?