TextureStages: "setSavedResult" altering output?

I’ve hit an odd-seeming issue: on a particular object that uses multiple texture stages, calling “setSavedResult” (so that I can use the result of that stage after the next stage) seems to result in the output of that stage being different to the output when “setSavedResult” is not called. This is… unexpected. o_0

Relevant-seeming excerpts:

# In my initialisation method:

            skyStageMask = TextureStage("sky mask")
            skyStageMask.setSort(5)
            skyStageMask.setColor(Vec4(0.01, 0.02, 0.1, 1))
            skyStageMask.setCombineRgb(TextureStage.CMInterpolate,
                                TextureStage.CSPrimaryColor, TextureStage.COSrcColor,
                                TextureStage.CSConstant, TextureStage.COSrcColor,
                                TextureStage.CSTexture, TextureStage.COSrcColor)
            skyStageMask.setSavedResult(True)                                #### <-- Call to setSavedResult
            
            skyStageStarAddition = TextureStage("sky star addition")
            skyStageStarAddition.setSort(10)
            # I'm temporarily using CMReplace here to better highlight the effect
            skyStageStarAddition.setCombineRgb(TextureStage.CMReplace,
                                TextureStage.CSPrevious, TextureStage.COSrcColor)

            mask = loader.loadTexture("sky_mask.png")
            stars = loader.loadTexture("sky_stars.png")
            
            self.sky.setTexture(skyStageMask, mask)
            self.sky.setTexture(skyStageStarAddition, stars)

# Elsewhere, updated via a task:

        ## <calculate a value (a Vec4, specifically) for "skyColour"

        # Set the sky's colour
        self.sky.setColor(skyColour)

When the above call to “setSavedResult” is commented out, I get something like this:

When the call is left in, I get something like this:

Note that the gradient has disappeared.

I’m doing this on Ubuntu 13.10, using a home-built copy of Panda from the CVS repository (1.9, I believe).

Does anyone know what might be going wrong (whether mistake on my part, issue with my graphics card or drivers, bug in TextureStage or otherwise)? Otherwise, has anyone seen something like this?

bump, and a new TextureStage-related issue

I’ve hit a new unexpected result: I have a MeshDrawer being used to draw multiple simple objects using MeshDrawer’s “tri” method. Importantly, I intend for each object to fade in and out individually.

At first I was simply applying colour to the objects (via the colour parameter taken by “tri”), with the alpha channel of the colour producing the fade; this worked as expected.

Now, however, I want to apply a texture to my objects as well, and more specifially I want each object to combine two textures, with the degree to which each shows varying by object. To this end I added two texture stages to my MeshDrawer’s NodePath, with the second using the “interpolate” combine mode, using “CSPrimaryColor” as the interpolation source, the idea being to use the vertex colour to fade between the two textures.

For the most part this works as expected, with one problem: the previously-implemented alpha-fading no longer works.

Having experimented somewhat, I’ve found that if I apply a single texture to the object using the default texture stage then the fading continues to work as expected. As soon as I introduce a new texture stage, however, the fading ceases to work. I’ve also found that the RGB elements of the vertex colours (as supplied to “tri”) do seem to work: setting the colour to pure green adds a green tint to the texture.

Does anyone know what might be going wrong here? :confused:

I think that at this point, you might want to start looking into GLSL. It may be possible to come up with some magic to get the FFP to do this, but this will become increasingly difficult as the complexity of your effects increases.

Ah, you may be right; I’ve put off learning shaders, but it might be coming up to time to sit down and start in on them.

(In all fairness, I’m not sure that they work properly on this machine–for example, the shadow-mapping examples that come with Panda don’t work properly, although the shadows that Wezu uses in Avolition seem to work.)

Thank you for the reply. :slight_smile: