Closed powerslave closed 12 years ago
The idea sounds good to me. Not sure if @alteredq tried this already though.
We don't use alpha textures. It's one of the things from OBJ / MTL that is simply not implemented on our side.
It just gets passed on to JSON (in case somebody would want to handle it by their own) but there is no correspondent thing in standard materials, it'll just get ignored.
Ah, I thought the mapAlpha was like a flag that indicated that the diffuse texture had transparency. Closing this one then.
Yup, alpha map is grayscale image for handling transparency separately from the diffuse map. Kinda redundant as you can bake alpha directly into the diffuse map.
It can make sense in some scenarios, but so far there was no real need to implement this feature.
I still think it would be a good idea to add the flag.
I'd say one can assume that whenever a diffuse texture is used that contains alpha information, the texture should be rendered in a transparent way. Do you agree on that?
currently, convert_obj_three.py outputs
"illumination" : 4,
"mapAlpha" : "TEXTURE_WITH_TRANSPARENCY.png",
"mapDiffuse" : "TEXTURE_WITH_TRANSPARENCY.png",
"opticalDensity" : 1.0,
"specularCoef" : 20.0,
"transparency" : 1.0
will result in a material that does NOT render the texture transparent.
when adding the transparent flag
"illumination" : 4,
"mapAlpha" : "TEXTURE_WITH_TRANSPARENCY.png",
"mapDiffuse" : "TEXTURE_WITH_TRANSPARENCY.png",
"opticalDensity" : 1.0,
"specularCoef" : 20.0,
"transparency" : 1.0,
"transparent" : true
the texture is rendered WITH transparency.
I therefore still suggest to add the transparent flag to convert_obj_three.py, because
Note that, as alterdeq mentioned, the mapAlpha is completely out of the equation here. convert_obj_three.py adds the mapAlpha property whenever a texture with transparency information is found, however the property is ignored for rendering. The "transparent" property is necessary to tell mapDiffuse to be rendered transparent.
I was wondering why, when converting models with convert_obj_three.py, materials with mapAlpha don't have the transparent flag set. As far as I see it, mapAlpha textures are only rendered transparent when this flag is set. So why not add the transparent flag directly to the resulting model.js file whenever a mapAlpha is set, instead of setting it in the main script in the JSON callback?
I patched my convert_obj_three.py with
and for me it seems to do what I'd expect. The output .js simply has the transparent flag added.
Is this a good idea, or is there a reason why the transparent flag is not set "automatically"?