KhronosGroup / KhronosGroup/OpenCOLLADA

Effect opacity messed up when previous effect has transparent texture

Open Beginner friendly
#651 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
678
Forks
260
PR merge metrics
No merged PRs in 30d

Description

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

Example library_effects
  <library_effects>
    <effect id="White-effect">
      <profile_COMMON>
        <newparam sid="surface">
          <surface type="2D">
            <init_from>my_image</init_from>
          </surface>
        </newparam>
        <newparam sid="sampler">
          <sampler2D>
            <source>surface</source>
          </sampler2D>
        </newparam>
        <technique sid="common">
          <lambert>
            <diffuse>
              <color sid="diffuse">0.8 0.8 0.8 1</color>
            </diffuse>
            <transparent>
              <color>1 1 1 1</color>
              <texture texture="sampler" texcoord="UVMap"/>
            </transparent>
            <transparency>
              <float sid="transparency">0.4</float>
            </transparency>
          </lambert>
        </technique>
      </profile_COMMON>
    </effect>
    <effect id="Blue-effect">
      <profile_COMMON>
        <technique sid="common">
          <lambert>
            <diffuse>
              <color sid="diffuse">0 0.32 0.8 1</color>
            </diffuse>
          </lambert>
        </technique>
      </profile_COMMON>
    </effect>
  </library_effects>

Then when I look at the second effect:

  • getOpaqueMode will be ALPHA_ONE
  • getOpacity will be 0.4 0.4 0.4 0.4
  • getTransparent will be none (this is correct)
  • getTransparency will be 0.4

ie. it's reporting stale value from the first effect! If the first effect is modified so its <transparent> 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryEffectsLoader.cpp, especially calculateOpacity around lines 299-301 and 382-385. Reproduce the two-effect library_effects example from the issue, then verify that an effect without transparent or transparency no longer inherits opacity values from the preceding effect. Done means getOpaqueMode, getOpacity, getTransparent, and getTransparency report the second effect's own values.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.