Diffuse alpha and glow?

This issue has come up as we work on the character builder portion of our game. We have models (created in Max) and have set them up with 4 texture stages:
Diffuse, normal, gloss, and most recently, glow.

At the moment, we have the 4 stages in separate PNG files. This works fine, our models look like how we want and all is groovy. (btw - gloss and glow are in the alpha layer of their files)

I know you can combine the gloss and glow into the other 2 as alpha layers, and perhaps that will be the solution to our problem.

We recently made it so the diffuse texture can be alpha’d. We use this to allow easy and flexible changes o the models look by changing the of some parts. It looks and works great.

The issue seems to be that when we alpha-enable the diffuse, we no longer can get the glow working .

Is there a set way to do this (alpha-enabled diffuse plus normal, glow, gloss options)?
Can post pics/files if it helps.

Thx

Heres what the texture stages look like in a typical model:

<Texture> Tex4 {
  "skins/standard/male_multi_bump.png"
  <Scalar> format { rgb }
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { normal }
}
<Texture> Tex3 {
  "skins/standard/male_multi_glow.png"
  <Scalar> format { alpha }
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { glow }
}
<Texture> Tex2 {
  "skins/standard/male_multi_refl.png"
  <Scalar> format { alpha }
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { gloss }
}
<Texture> Tex1 {
  "skins/standard/male_multi.png"
  <Scalar> format { rgba }
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { modulate }
}

If I change “modulate” stage to “rgb” rather than “rgba” the “glow” stage works correctly.
But if “modulate” is “rgba”, the “glow” stage does not seem to be picked up by the “bloom” filter.

Anyone have an idea on this? Thx.

I’m not sure what exactly you mean. Can you describe what the error message is (if any), what the result looks like, what you want it to look like, and what “alpha’d” and “alpha-enabling the diffuse” means?

Hi - no error msg - there just is no glow at all when diffuse texture has alpha enabled. When it is not enabled - glow works again.

This is as Tommyman (the artist on the project) describes above.

Will try to get pics showing the problem posted . Thx!

Here’s a “diffuse” or “modulate” texture, basic colours, plus an alpha layer (shown in the smaller black and white preview) to define what appears and doesn’t in some parts:


It’s having this alpha channel used by the “modulate” texture stage which prevents the “glow” texture stage from being processed by the “bloom” filter.
In the model (see text in second post) the “modulate” texture stage is set to “rgba” so it uses the alpha layer to hide or unhide parts defined in the texture’s alpha-layer.

The “glow” has it’s own texture, with it’s own alpha layer that defines what does, or does not glow.
In the model the “glow” texture stage is set to “alpha”.

Same for “gloss”. Separate texture with the texture stage in the model set to “alpha”.

“Normal” mapping also has its own texture, the texture stage of which in the model is just “RGB”.

AS to what it looks like, and what we want it to look like:


Sorry, only just noticed in dimmer lights it seems the Glow texture IS doing something.
The figure on the left is a model without an alpha layer in its diffuse/modulate texture, and the model is set to “rgb” on the "modulate texture stage.
The figure on the right has an alpha layer in its “diffuse/modulate” texture, and the model is set to “rgba” on it’s “modulate” texture stage.
What seems to be happening is the Bloom filter is not picking up the alpha information from the right hand model and processing it the way it is the left hand one.
But actually (and rather embarrassingly for me since I didn’t see it till this morning) the glow seems to be working, its just so weedy that in a strong light you dont see it active.
Sorry to have got the nature of the problem wrong.
It looks like it’s perhaps bloom related, not necessarily glow related

Updated nature of the problem.
It seems I was mistaken, in that the glow texture is doing something, but it’s not being processed by the bloom filter in models with an alpha layer in the diffuse/modulate texture stage.
See pic above.

Any thoughts from anyone?
The goal is to have the model look like the figure on the left, but with alpha enabled on the diffuse texture (like the figure on the right is)

OK after a sleepless day / night of playing with shaders and CommonFilters.py, we found this in the Docs:
panda3d.org/reference/devel/ … Attrib.php

ABO_glow: copy the glow map into the alpha channel of the primary frame buffer. If there is no glow map, set it to zero. Caveat: it is not possible to write glow or depth values to the framebuffer alpha channel at the same time as using alpha blending or alpha testing. Any attempt to use transparency, blending, or alpha testing will cause this flag to be overridden.

Can somebody who knows, please confirm if this is the problem/limitation we’re seeing?

If so, are there workarounds?
I’m playing with the advanced sample for glow filter. Would a mod to the glowshader there be a way (and I ask that as someone who knows zero CG)

There’s a normal_gloss envtype (as of the latest Panda version) - would a normal_glow envtype be a solution (if there is one? and if there isn’t can I request it now ? :slight_smile: )

Thx for any advice!

Still looking at this.

Would a normal_glow be the answer, or are we missing the mark completely on this?

Basically the bloom filter is using the alpha layer from Tex1 (modulate) to setup glow and we’d like it to use Tex3 (glow)

Sill wondering if there’s a way to do this.
Even if it’s “request a future Panda feature”.

Thx!

I still don’t know what exactly you mean by “enabling the alpha”.

You can use ABOGlow to make sure that Panda writes the glow map into the alpha channel of the frame buffer, so that you can use that for bloom (you can send the blend value to (0, 0, 0, 1) to make it just use the alpha channel of the frame buffer), if that’s what you intend.

You can use normal_glow to combine a normal map and glow map into the same texture. This will be more efficient, as you’ll be passing less textures to the GPU, but it will not change the way it is written to the framebuffer.

In this context “enabling the alpha” simply means that the “diffuse” texture has an alpha channel used to mask out certain parts of the model, and that the model itself has the “modulate” texture stage(ie the stage that uses the “diffuse” texture) set to “rgba”, there by “enabling” the use of the alpha channel in the diffuse texture.
The alpha channel is present, it is used, it is on.

I really don’t know how else to put it, as it’s not a complex concept, just one phrased in terminology I picked up in a different online community which doesn’t seem understood here.(It may be being used wrongly).

You could have a texture with an alpha channel, but if the model is set to “rgb” on that texture stage, the alpha channel is not going to do anything, it is not “enabled” in the model. If the texture stage is set to “rgba” then the alpha channel is used, is “enabled”.
In the way we’ve used the term “enabled”:
format { rgba } = “enabled”
format { rgb } = “not enabled”

And, because I’m sloppy with terms, I’ll often say a texture with an alpha channel is itself “alpha-enabled”. If it has no alpha-channel it’s not capable of anything alpha-related, if it has an alpha-channel that “enables” the texture.
Like I said it’s a bit sloppy, and I hope I’ve managed to clear it up rather than obscure things further.

And the trouble with that is what we have already said.
That:

  1. We have an alpha channel in the diffuse/modulate texture stage that is used for “alpha testing”. The modulate texture stage in the model is set to:
    format { rgba }

  2. From the manual:
    “Caveat: it is not possible to write glow or depth values to the framebuffer alpha channel at the same time as using alpha blending or alpha testing. Any attempt to use transparency, blending, or alpha testing will cause this flag to be overridden.”

  3. Because of 2, the glow values used by the Bloom filter do not seem to work correctly, unless I set the model’s “modulate” texture stage to “rgb” instead of “rgba”.

Thanks, I already tried it, and it didn’t seem to work any better than them being 2 separate textures.
As you say, the glow stuff gets written to the buffer the same way either way.

What i don’t understand is why it’s OK to use the alpha channel in the “glow” texture stage, and the alpha channel in the “gloss” texture stage, and these don’t “override” the ABOGlow flag in the frame buffer. But using the alpha channel in the “diffuse” channel does “override” ABOGlow.
Perhaps nobody ever wanted to use 4 texture stages on a model with an alpha channel on the “diffuse” stage before.

What I’ve been trying to do is to not use the built in Bloom filter, but instead to write a custom shader which only uses the alpha channel information in the Glow texture (tex_2), but being inept, have no idea how to do this.
I can read from tex_2 OK, OR I can read the alpha channel of what seem to be tex_0 (it’s not explicitly stated, but I assume “src_alpha” reads from tex_0).
But can’t figure out how to get the shader to read from the alpha channel of tex_2.
As I said, I am inept at this.

With ABO_glow set, only the glow texture will be written to the alpha framebuffer.

The “glow” and “gloss” modes don’t write to the alpha channel of the framebuffer at all.

If you want to create your own Bloom filter, then what you can also do is set ABO_aux_glow. This adds another render target to the framebuffer (alongside the colour, depth and stencil information, you could have multiple other targets), which you can access from a postprocessing shader.

Thanks, I’ll try what you suggest.

For what it’s worth to anyone else, I’ve found a fix, using M-dual alpha mode.
By manually editing the modulate texture stage in the model to be like so:

<Texture> Tex1 {
  "skins/standard/male_multi.png"
  <Scalar> format { rgba }
  <Scalar> alpha { dual }
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { modulate }
}

The " alpha { dual }" part is the fix.