buildinginstructions.js icon indicating copy to clipboard operation
buildinginstructions.js copied to clipboard

TEXMAP images with alpha trasparency error

Open billthefish opened this issue 3 years ago • 5 comments

Parts the have TEXMAPs with alpha transparency do not render correctly in physical color mode. The geometry covered by the TEXMAP renders transparent.

To Reproduce

  • Create a model that contains only a reference to a part that contains a TEXMAP image with alpha transparency. I used: '1 0 0 0 0 1 0 0 0 1 0 0 0 1 2454aps5.dat. Note: Only the unofficial version of 2454aps5 uses a TEXMAP image
  • Load into the software with physical color rendering turned on

Screenshots Go to https://www.ldraw.org/cgi-bin/ptdetail.cgi?f=parts/2454aps5.dat to see the rendering in action. To turn on physical render mode, click the button with the "eye" icon.

billthefish avatar Aug 15 '22 20:08 billthefish

This is a known defect due to the physical materials using the standard materials from three.js. See end of LDRColorMaterials.js

if(!texmap) { color.m = m; }

The problem is that the color of a material blends together with the texture when using the standard materials. The "quick draw" materials I have made for instructions are completely controlled by builinstructions.js, which is why the issue does not appear there. Should we raise this as an issue with the three.js project?

LasseD avatar Aug 17 '22 11:08 LasseD

It's up to you to report or not since you're the technical expert and can explain what is happening better than I can.

billthefish avatar Aug 17 '22 14:08 billthefish

See also: https://stackoverflow.com/questions/68834918/how-can-i-remove-influence-of-setting-color-in-meshs-material-in-three-js

@Mugen87 is one of the core authors of three.js, and the color mixing is unfortunately intended without the option to turn it off. Adding a check for "inside a texture" as our custom LDraw shaders have, would result in a performance degradation in rendering, so I doubt we will see success in getting three.js core changed. However. We could branch our own version with this feature. The downside is then that the branch has to be maintained by us.

LasseD avatar Aug 29 '22 16:08 LasseD

"Rolling our own" Three.js is prolly a bad idea for a number of reasons. I'm willing to live with this quirk as long as you are since LDraw.org doesn't really use physical color rendering in any meaningful way.

billthefish avatar Aug 29 '22 16:08 billthefish

I'm still not happy with that. Let me see if I can "hack" the shader generator in any way.

LasseD avatar Aug 29 '22 17:08 LasseD