# Alpha value in MTL file format

## Recommended Posts

I want to use MTL files for my materials. Here, ambient, diffuse, specular colors are defined as RGB or XYZ (or custom spectrum values which I just ignore). In the MTL file format, the dissolve factor d is defined as:

d factor

Specifies the dissolve for the current material.

"factor" is the amount this material dissolves into the background. A
factor of 1.0 is fully opaque. This is the default when a new material
is created. A factor of 0.0 is fully dissolved (completely
transparent).

I assume that this is the "alpha" channel of all the RGB/XYZ values? Does one normally pass ambient, diffuse, specular colors as float3 with one separate float for the alpha channel to the shaders or does one use float4s (some redundancy)?

Edited by matt77hias

##### Share on other sites

One doesn't normally pass ambient, diffuse, and specular anymore.  That is an antiquated setup for replicating the fixed-function pipeline.
The good news is that you can do it however you see fit, since the only common way to do it is not to do it.

I would assume an alpha channel on specular and ambient would be multipliers of the alpha on diffuse, so if you have Diffuse.A = 0.5 and Specular.A = 0.5, final alpha = 0.25.  Of course you can do this math offline rather than in the shader and then you are still stuck with 2 floats you are not using.

vec3's are still aligned on 16-byte boundaries, so if you pass a vec3 for each of them you gain nothing.  I would pass vec4's and either use the alpha channels or not.  Tweak them in your 3D modeling software and see what results from it, then decide how to use them based off that.

L. Spiro

Edited by L. Spiro

##### Share on other sites
I would assume an alpha channel on specular and ambient would be multipliers of the alpha on diffuse, so if you have Diffuse.A = 0.5 and Specular.A = 0.5, final alpha = 0.25.  Of course you can do this math offline rather than in the shader and then you are still stuck with 2 floats you are not using.

So only the diffuse color should be extended with the dissolve as alpha channel, since these contributions will be added in the end?

float4 Ka = Ka_mtl 0

float4 Kd = Kd_mtl d

float4 Ks = Ks_mtl 0

My Ka, Kd and Ks are the multiplies for their associated textures map_Ka, map_Kd, map_Ks. (I have a ray tracing background so maybe I use a far too many (mip mapped) textures for each material, but FPS/MEM is still ok.) One doesn't normally pass ambient, diffuse, and specular anymore.

Edited by matt77hias

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account