Page 1 of 1

How do you deactivate texturing?

Posted: Wed 27. May 2009, 10:50
by STRESS
Hello I've got a problem, my scene looks like this

Code: Select all

   [root]
      |
      |
      ----> [child] - Appearance
                 |
                 |
                 ----> [child2] - Appearance
[] = SceneGraphComponent

The appearance on child creates some textures. But the appearance on child2 doesn't. However, I still get the same textures that have been created on the appearance for child when rendering the child2 node. Is there an easy way to manually deactivate texturing? I couldn't find any obvious CommonAttribute neither a method in PolygonShader. I could do it by setting a new GLSL shading program but that seems to be a hacky solution.

Oh yeah btw if the appearance on child uses a GLSL shader it also stays active on child2 unless I set "useGLSL" to false.

Re: How do you deactivate texturing?

Posted: Thu 28. May 2009, 11:37
by gunn
To turn off texturing in a child node,

Code: Select all

ap.setAppearance(CommonAttributes.POLYGON_SHADER+CommonAttributes.TEXTURE_2D, Appearance.INHERITED);
This will override the texture reference in the scene graph above this node.

To turn off other texture units, use the appropriate name instead of TEXTURE_2D.

Same goes for turning off any appearance attribute, for example, USE_GLSL.

Thanks for the question, it'll find it's way into the tutorial.

Re: How do you deactivate texturing?

Posted: Thu 28. May 2009, 12:21
by gunn
Hmmm. My previous post appears not to work as desired. (Just trying to write a tutorial showing this example and ran up against this fact). What does appear to work looks like:

Code: Select all

ap.setAppearance(CommonAttributes.POLYGON_SHADER+CommonAttributes.TEXTURE_2D, Appearance.DEFAULT);
It appears that setting an attribute to INHERITED just removes it from the attribute map of the Appearance. Since it wasn't defined in the child to begin with, that has no effect. Setting it to DEFAULT on the other hand seems to have the desired effect of hiding occurrences of the attribute that lie in the scene graph above the node when evaluating the effective appearance of a node.

Re: How do you deactivate texturing?

Posted: Fri 29. May 2009, 10:48
by STRESS
gunn wrote:Hmmm. My previous post appears not to work as desired. (Just trying to write a tutorial showing this example and ran up against this fact). What does appear to work looks like:

Code: Select all

ap.setAppearance(CommonAttributes.POLYGON_SHADER+CommonAttributes.TEXTURE_2D, Appearance.DEFAULT);
Assuming that you mean ap.setAttribute instead of ap.setAppearance.

Unforunately neither .INHERITED nor .DEFAULT seem to work for me.

Re: How do you deactivate texturing?

Posted: Fri 29. May 2009, 14:29
by gunn
Assuming that you mean ap.setAttribute instead of ap.setAppearance
Right.

In rereading your original post I realized that you seem to be using the textures within a GLSL shader, while my example uses DefaultPolygonShader. I don't think that should make any difference, however, since the textures are referenced using identical means.

What would be good is, if you could post example code which demontrates this problem. That would help me fix it. There's now a tutorial example de.jreality.tutorial.app.AppearanceInheritanceExample in the svn. One possibility would be if you could modify that so it demonstrates your problem.

Re: How do you deactivate texturing?

Posted: Fri 29. May 2009, 17:55
by STRESS
Upps sorry it is actually working. Thanks gunn. I had a typo in my code I found it when I verified it with your new example! Thanks a lot!

Re: How do you deactivate texturing?

Posted: Sun 31. May 2009, 17:06
by steffen
Right, Appearance.INHERITED means just removing the attribute from that appearance (then the attribute gets inherited...) Appearance.DEFAULT means that the default value (which is usually defined in the corresponding shader interface) is used. For textures, the default value should be no texture... ;-)