MDL tint scaling: Difference between texture color and coded value?

It seems like base::file_texture.tint is doing some unexpected intensity scaling (?)

I have a very simplistic material which compares using a gradient from uvw coordinates vs a linear gradient from a texture file (see attachment - it is a gradient from black at the bottom to white at the top (linear in RGB space), with RGB=128|128|128 at half-point, and a small white border). This is the material:

mdl 1.6;

import ::df::*;
import ::state::*;
import ::math::*;
import ::base::*;
import ::tex::*;

export material gradient_test()
 = let{
    base::texture_return tex = base::file_texture(texture_2d("gradient-linear-black-white.png"));
    float3 uvw = state::texture_coordinate(0);
 } in
 material(
    thin_walled: true,
    surface: material_surface(
        scattering: 
            df::diffuse_reflection_bsdf(
                    roughness: 0,
                    tint: uvw.x < 0.5 ? color(uvw.y) : tex.tint        
            )
        )
    );

I would expect the left half and the right half to behave the same, but they do not.
The texture-based tint does not generate any returns for very dark shades (RGB < 20), and the scaling seems to be completely different in the left half.

I have double-checked the gradient image and the texture coordinates of the target (simple square facet). The difference can be reproduced regardless of image format (png/bmp, RGB or grayscale).

Am i missing something? Does base::texture_return make some internal scaling that is not documented? I am currently extremely confused and open for any suggestions/hints/guesses as to what is happening here.

Attachment: gradient Texture file:

if you want your image to be interpreted to be in linear space, you should tell this in the texture constructor. By default texture_2d(“gradient-linear-black-white.png”) will assume the image needs gamma correction if 8 bit. (equivalent to tex::gamma_default )

If you want to interpret an image as linear always, tell teh constructor tof texture_2d, ie
texture_2d(“gradient-linear-black-white.png”,tex::gamma_linear)

1 Like

Today i learned about gamma correction. Thank you so much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.