Texture envtype

Can a single texture entry contain more than one envtype in *.EGG? For example DECAL and GLOW. Or i needed to make individual texture entries for each envtype?

You will need different textures for this. These envtypes map directly to TextureStage.setMode(), in which “glow” and “decal” are mutually exclusive.

David

There are a few combined modes though, such as MModulateGlow, MNormalHeight, etc, which contain some information in the RGB channels and some in the alpha channel.

You can use the second parameter to loader.loadTexture to load an image into the alpha channel, or use alpha-filename (I think). Like:

combined = loader.loadTexture("colormap.png", "glowmap.png")
stage = TextureStage("")
stage.setMode(TextureStage.MModulateGlow)
model.setTexture(stage, combined)

Thanks. I just try to implement Blender’s material parametres, so i think that I’ll have some more questions :slight_smile:

This is my material settings:
./tex/checker3.png has alpha channel

<Material> Material {
  <Scalar> diffr { 0.034 }
  <Scalar> diffg { 0.034 }
  <Scalar> diffb { 0.034 }
  <Scalar> diffa { 0.500 }
  <Scalar> specr { 0.500 }
  <Scalar> specg { 0.500 }
  <Scalar> specb { 0.500 }
  <Scalar> shininess { 12.5 }
  <Scalar> emitr { 0.000 }
  <Scalar> emitg { 0.000 }
  <Scalar> emitb { 0.000 }
}

<Texture> test {
  "./tex/checker3.png"
  <Scalar> combine-rgb { MODULATE }
  <Scalar> combine-alpha { ADD }
  <Scalar> combine-rgb-source0 { TEXTURE } 
  <Scalar> combine-rgb-source1 { PRIMARY-COLOR }
  <Scalar> combine-alpha-source0 { TEXTURE } 
  <Scalar> combine-alpha-source1 { PRIMARY-COLOR }  
  <Scalar> combine-alpha-operand0 { SRC-ALPHA }
  <Scalar> combine-alpha-operand1 { SRC-ALPHA }
}

When my combine-alpha is ADD - it seems, that alpha is missing, otherwise (MODULATE, SUBTRACT) it’s work as expected.

Since “add” means to add in alpha to whatever is already in the alpha channel in the framebuffer, you have to ensure that your framebuffer initially has alpha value 0.

David

How I can check it?

As I understand, the combine modes provide the same things as in Open GL. In this case, I don’t understand why the framebuffer affect ADD and why it does not affect the SUBTRACT. Or am I mistaken?
opengl.org/sdk/docs/man/xhtml/glTexEnv.xml

Likewise, GL_COMBINE_ALPHA accepts any of GL_REPLACE,
GL_MODULATE, GL_ADD, GL_ADD_SIGNED, GL_INTERPOLATE, or
GL_SUBTRACT.  The following table describes how alpha values are
combined:        
        
GL_COMBINE_ALPHA     |  Texture Function
--------------------------------------------------
GL_REPLACE           |   Arg0
                     |   
GL_MODULATE          |   Arg0 × Arg1
                     |       
GL_ADD               |   Arg0 + Arg1
                     |      
GL_ADD_SIGNED        |   Arg0 + Arg1 - 0.5
                     |       
GL_INTERPOLATE       |   Arg0 × Arg2 + Arg1 × (1 - Arg2)
                     |                   
GL_SUBTRACT          |   Arg0 - Arg1

Just set a clear color that has 0 in the fourth parameter, e.g. base.win.setClearColor((0, 0, 0, 0)). This is assuming you’re drawing your object in front of the background color, of course; if there is another object behind it, that object may contribute to the alpha value in the framebuffer.

Add and subtract are both affected by the framebuffer color, of course, but add only makes sense when the initial value is not 1, and subtract only makes sense when the initial value is not 0. I’m not sure what the default clear color is, but it’s likely to be 1.

David

I tried base.win.setClearColor((0, 0, 0, 0)) and nothing has changed. My test code:

# -*- coding: utf-8 -*-
from panda3d.core import *
import direct.directbase.DirectStart

base.win.setClearColor((0, 0, 0, 0))

env = loader.loadModel('environment')
env.reparentTo(render)
box = loader.loadModel('/home/ninth/exp_test/test')
box.reparentTo(render)
box.setScale(100)
render.setScale(0.05)


dlight = DirectionalLight('dlight')  
dlight.setColor(VBase4(0.8, 0.8, 0.8, 1))  
dlnp = render.attachNewNode(dlight)  
dlnp.setHpr(0, -60, 0)  
render.setLight(dlnp)

run() 

Result:

Edit:
Scene without ‘environment’ has the same result, and pview too

I think this is a bug. I tried to make the same things through PyOpenGl.

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE)
    glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_ADD)
    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE)
    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PRIMARY_COLOR)

As I expected:

Base color (1, 1, 1, 0.5)

Base color (1, 1, 1, 0.0)

EDIT: transparency of the base color works only if i do “setTransparency(True)”. Can i set it into *.EGG file?

Yeah, you can, with alpha.

It’s works only with - not with

I seem figured out.
should have entry, and alpha in should be < 1.0. In this case diffa { A } in the entry works as expected.

EDIT: the same applies to the entries.