Shaders and Textures

Hey Everyone,

Excuse my inexperience with Shaders and Textures with this question. I love that glow effect from the Tron example in the examples section of panda3d. A few questions about it and shaders/textures in general:

  • I noticed that only part of the tron model was glowing, and that part came from that texture that only showed a light blue color. That texture was then applied to the model and made to glow. The rest of the model also had a texture on it (for example the face of the model), that did not have a corresponding texture file, so I’m assuming it was embedded in the model itself through the egg file?

What I would like to do is apply 2 textures to a model in runtime (not embedded in an egg file), one texture to “glow” with the camera shader, one to “not glow”, Could anyone provide an example of how to do this?

Thanks,

C

there is already some explanation about it :
discourse.panda3d.org/viewtopic.php?t=1142

Ah I see, so it was in that texture the whole time.

Please excuse my newbiness,

C

Quick question,

With my own experimentation with gimp I was able to setup a texture with an Alpha Channel that when applied to a model would control the glow shader. However one thing I noticed is that if I set the Model Transparency to True then panda would assume the Alpha Channel was for Transparency and it would make that area transparent instead of showing the texture without a glow effect.

What I’m wondering is can you setup a texture that does both. Allows a model to be transparent (which for me is important as many of my models are simply planes to allow for 2D graphics) so that the textures for these planes will not be “Squares”, but also allow me to somehow only allow for some parts of the texture to be affected by the glow shader.

Thanks,

C

Yes, but you’d have to change the model. It was created with one RGBA texture map, with glow value in the alpha channel. To do what you want, you’d need a model with two maps - an RGBA map containing color and transparency, and another Alpha-map containing only the glow value. Right now, creating models with fancy maps is not very convenient. It’s a question of hand-editing the egg files. We’re working on exporters that can handle that, but it’s a time-consuming process.

I see, so for instance in my game I ideally would have one egg model for these 2D objects (a plane), and normally I would assign textures to the model on loadup of the object (ie I would not point to the specific texture in the egg file).

Are you saying that in order to have a 2D object that can have glow effects on part of the texture, and be transparent I would have to have an egg file for each 2D object where I specify both the objects main texture file and its “glow map” texture file? Or could that be done on load up some how?

I don’t mind doing whatever to the model if its just one model and its a simple plane that gets used by many 2D objects, however I agree it would be cumbersome to have an egg model for every 2D object.

How would you edit an egg model to ask for 2 maps as an example to explore? ie if I attached the following standard plane egg model that I grabbed from the samples:

xof 0302txt 0064
Frame groundPlane_transform {
}

Frame pPlane1 {
  Mesh mesh1 {
    4;
    -0.500000; -0.500000; 0.000000;,
    -0.500000; 0.500000; 0.000000;,
    0.500000; 0.500000; 0.000000;,
    0.500000; -0.500000; 0.000000;;
    1;
    4; 
    0, 1, 2, 3;;
    MeshNormals norms1 {
      1;
      0.000000; 0.000000; 1.000000;;
      1;
      4; 
      0, 0, 0, 0;;
    }
    MeshVertexColors colors1 {
      4;
      0; 
      1.000000; 1.000000; 1.000000; 1.000000;;,
      1; 
      1.000000; 1.000000; 1.000000; 1.000000;;,
      2; 
      1.000000; 1.000000; 1.000000; 1.000000;;,
      3; 
      1.000000; 1.000000; 1.000000; 1.000000;;;
    }
    MeshTextureCoords uvs1 {
      4;
      0.000000; 1.000000;,
      0.000000; 0.000000;,
      1.000000; 0.000000;,
      1.000000; 1.000000;;
    }
  }
}

Thanks,

C

Well, if your models are just textured quads, there are several ways to approach it. I think the two most reasonable are:

  • Option 1: have a separate egg file for each sprite. The egg file specifies all the textures: the color map, the transparency map, and the glow map.

  • Option 2: no egg files at all. Create quads using the CardMaker class, and then apply textures manually by calling loadTexture and setTexture.

ColShag, what’s your modeling package ?
If you’re using Maya, you could use multitexture to export multiple textures on 1 object.
discourse.panda3d.org/viewtopic.php?t=2554