KhronosGroup / OpenCOLLADA

652 stars 251 forks source link

Effect opacity messed up when previous effect has transparent texture #651

Open scurest opened 3 years ago

scurest commented 3 years ago

Suppose I have two effects in the library_effects. The first has a \ with a texture and a \ of 0.4, and the second has neither \ nor \.

Example library_effects ```xml my_image surface 0.8 0.8 0.8 1 1 1 1 1 0.4 0 0.32 0.8 1 ```

Then when I look at the second effect:

ie. it's reporting stale value from the first effect! If the first effect is modified so its \ is a color instead, the second effect will show the correct values.


This is caused by an early return in calculateOpacity

https://github.com/KhronosGroup/OpenCOLLADA/blob/6031fa956e1da4bbdd910af3a8f9e924ef0fca7a/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryEffectsLoader.cpp#L299-L301

The early return skips the rest of the function, including the code that resets values for the next effect

https://github.com/KhronosGroup/OpenCOLLADA/blob/6031fa956e1da4bbdd910af3a8f9e924ef0fca7a/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryEffectsLoader.cpp#L382-L385

so the next effect gets the stale values.