pbrt-v4 icon indicating copy to clipboard operation
pbrt-v4 copied to clipboard

Equivalent of Kt and Kr in dielectric material?

Open gugray opened this issue 1 year ago • 5 comments

I am trying to achieve the effect of colored glass in v4. Information I have found online (e.g. here) points me to the Kt property of the glass material in v3. "color Kt" [0.7 1 0.7 ]

v4's dielectric material does not have the Kt ad Kr properties which were available for glass in v3. If I try and start from a v3 file with glass, the --upgrade function converts "color Kt" [0.7 1 0.7 ] to "rgb Kt" [0.7 1 0.7 ]. The result, however, is rejected by v4 with the error ""Kr": unused parameter".

What is the right way to achieve colored glass in v4?

gugray avatar Aug 22 '24 14:08 gugray

In pbrt-v4 I believe the approach to take is to use a homogeneous Medium and set the appropriate absorption values.

red_glass

Left sphere is a diffuse transmission, right sphere is a default dielectric with a interior medium that absorbs everything but red.

shadeops avatar Aug 24 '24 20:08 shadeops

Thank you! May I trouble you to include an XML snippet for the two spheres?

gugray avatar Aug 24 '24 20:08 gugray

PixelFilter "gaussian" "float xradius" [ 2 ] "float yradius" [ 2 ]
Sampler "zsobol" "integer pixelsamples" [ 8192 ]
Integrator "volpath" "integer maxdepth" [ 5 ]
Accelerator "bvh"
Film "gbuffer"
    "string filename" [ "pbrt.exr" ]
    "integer xresolution" [ 1280 ]
    "integer yresolution" [ 720 ]


Transform [ 0.707106781186547462 -0.353553390593273731 -0.612372435695794581 0.0
            0 0.866025403784438597 -0.5 0.0
           -0.707106781186547573 -0.353553390593273897 -0.612372435695794359 0.0
            0.0 0.0 4.0 1.0 ]
Camera "perspective" "float fov" [ 45 ] "float screenwindow" [ -1 1 -0.5625 0.5625 ]

WorldBegin

    AttributeBegin
        Translate -2 3 0
        Rotate -50 0 0 1
        Rotate -90 0 1 0
        AreaLightSource "diffuse"
            "float scale" [ 200 ]
            "bool twosided" [ false ]
        AttributeBegin
            Rotate 180 1 0 0
            Shape "disk" "float radius" [ 0.25 ]
        AttributeEnd
    AttributeEnd

    Texture "/mat/checkerboard" "spectrum" "checkerboard"
        "rgb tex1" [ 0.75 0.75 0.75 ]
        "rgb tex2" [ 0.3 0.3 0.3 ]
        "float uscale" [ 300 ]
        "float vscale" [ 300 ]

    MakeNamedMaterial "/mat/ground"
        "string type"
        "diffuse" "texture reflectance" [ "/mat/checkerboard" ]

    MakeNamedMaterial "/mat/red_diffuse"
        "string type" "diffusetransmission"
        "rgb transmittance" [ 1 0 0 ]

    MakeNamedMaterial "/mat/glass" "string type" "dielectric"
        "rgb eta" [ 1.33 1.33 1.33 ]
        "float roughness" [ 0.001 ]


    AttributeBegin
        MakeNamedMedium "/mat/red_interior"
            "string type" "homogeneous"
            "float scale" [ 10 ]
            "rgb sigma_a" [ 0.01 1.0 1.0 ]
            "rgb sigma_s" [ 0.01 0.01 0.01 ]
    AttributeEnd

    AttributeBegin
        NamedMaterial "/mat/ground"
        AttributeBegin
            ReverseOrientation
            Shape "bilinearmesh"
                "normal N" [ 0 1 0 0 1 0 0 1 0 0 1 0 ]
                "point3 P" [ -50 0 -50 50 0 -50 -50 0 50 50 0 50 ]
                "integer indices" [ 0 1 2 3 ]
        AttributeEnd
    AttributeEnd

    AttributeBegin
        Translate -0.25 0.5 0.25
        Scale 0.2 0.2 0.2
        NamedMaterial "/mat/red_diffuse"
        AttributeBegin
            Shape "sphere"
        AttributeEnd
    AttributeEnd

    AttributeBegin
        Translate 0.25 0.5 -0.25
        Scale 0.2 0.2 0.2
        NamedMaterial "/mat/glass"
        MediumInterface "/mat/red_interior" ""
        AttributeBegin
            Shape "sphere"
        AttributeEnd
    AttributeEnd

I used the GPU (volume pathtracer), then ran it through imgtool's denoiser.

shadeops avatar Aug 24 '24 22:08 shadeops

If I try and start from a v3 file with glass, the --upgrade function converts "color Kt" [0.7 1 0.7 ] to "rgb Kt" [0.7 1 0.7 ]. The result, however, is rejected by v4 with the error ""Kr": unused parameter".

Can you confirm this? If I make a simple scene that contains

Material "glass" "color Kt" [0.5 0.5 0.5]

I get a warning from pbrt --upgrade, "Warning: s.pbrt:37:0: Parameter is being removed when converting to "dielectric" material: "rgb Kt" [ 0.5 0.5 0.5 ]", and indeed, the converted pbrt file just has

Material "dielectric"

(And thanks to @shadeops for that nice alternative.)

mmp avatar Jan 30 '25 15:01 mmp

The workaround from @shadeops works, but it doesn’t seem to produce exactly the same result.

Do I understand correctly that the homogeneous Medium simulates individual scattering events one by one, whereas Kt simply attenuates light exponentially along the path length — effectively accounting for an infinite number of scattering events?

pbrt-v4 (maybe it will converge eventually...):

Image

LuxCoreRender:

Image

Vutshi avatar Nov 04 '25 12:11 Vutshi