Colour-Scale: Different in Fixed-Function and Autoshader

[edit]
As has been correctly pointed out to me below, this turns out to be less an interval issue than a colour-scale issue.

The core remains much the same–it’s just that it happens regardless of whether the colour is scaled via an interval, or simply via a call to “setColorScale”.

It also looks like “setColor” may exhibit the same behaviour.


[/edit]

So, I’m experimenting with the use of alpha-scaling, and in particular a LerpColorScaleInterval, to make an image less transparent.

Specifically, I want to have an image that incorporates shades of alpha, and then use an alpha-scale greater than 1 to bring some of those shades up to a value of 1–thus allowing me to subsequently have some parts–but not all–fade away over time.

Now, the game for which I’m doing this currently employs with the fixed-function pipeline: it’s almost entirely 2D, and has only limited special effects, so shaders aren’t really called for.

As such, I was thinking to run this effect, too, with the fixed-function pipeline.

Only to find that it doesn’t work: it looks like alpha-scales greater than 1 are clamped to 1. (Or effectively so.)

However, with the auto-shader activated, it does work! A test-image can be made less transparent via an alpha-scale greater than 1.

For now, I’ll probably go forward with the effect that I have in mind–and only that effect–running under the auto-shader. It just feels messy to do so; I’d rather it were fixed-function like the rest of the game. (Or switch everything over to the audo-shader–but that seems superfluous for this project.)

Still, I wanted to report this discrepancy there, and perhaps discuss it.

I’m sure that LerpColorScale has nothing to do with the problem.

from direct.showbase.ShowBase import ShowBase

from panda3d.core import ColorScaleAttrib, NodePath, Vec4
from direct.interval.LerpInterval import LerpColorScaleInterval


class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        self.test = NodePath("test")

        interval = LerpColorScaleInterval(
            self.test,
            duration = 1,
            colorScale = Vec4(1, 1, 1, 1.5),
            startColorScale = Vec4(1, 1, 1, 0.0)
        )

        interval.start()

        base.accept("enter", self.print_p)

    def print_p(self):
        print(self.test.get_color_scale())

app = MyApp()
app.run()

It’s just that the alpha channel is mixed in the shader as a regular value that needs to be multiplied. and the shader does it.

I’m wondering why set the multiplier using the ColorScale parameter if you can directly manipulate the final parameter.

from direct.showbase.ShowBase import ShowBase

from panda3d.core import NodePath, Vec4
from direct.interval.LerpInterval import LerpColorInterval


class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        self.test = loader.load_model("models/smiley")
        self.test.set_transparency(True)
        self.test.reparent_to(self.render)

        interval = LerpColorInterval(
            self.test,
            duration = 5,
            color = Vec4(1, 1, 1, 1.5),
            startColor = Vec4(1, 1, 1, 0.0)
        ).start()

        base.accept("enter", self.print_p)

    def print_p(self):
        print(self.test.get_color())

app = MyApp()
app.run()

You are correct, in fairness.

So it might be more accurate to say that colour-scale is different in fixed-function and autoshader usage.

Oh, just as a matter of habit, I suppose.

Testing quickly, it doesn’t make any real difference in this matter: it still seems to require the auto-shader (or a custom shader, of course) in order to apply an alpha scale greater than 1.

[edit]
It has occurred to me, in light of the above, to update the thread-title and the first post to better reflect the real issue.