Have jReality programming problems or questions? Post them here.
-
STRESS
- Posts: 141
- Joined: Mon 19. Jan 2009, 12:10
Post
by STRESS » Wed 27. May 2009, 10:50
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.
-
gunn
- Posts: 323
- Joined: Thu 14. Dec 2006, 09:56
- Location: TU Berlin
-
Contact:
Post
by gunn » Thu 28. May 2009, 11:37
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.
jReality core developer
-
gunn
- Posts: 323
- Joined: Thu 14. Dec 2006, 09:56
- Location: TU Berlin
-
Contact:
Post
by gunn » Thu 28. May 2009, 12:21
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.
jReality core developer
-
STRESS
- Posts: 141
- Joined: Mon 19. Jan 2009, 12:10
Post
by STRESS » Fri 29. May 2009, 10:48
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.
-
gunn
- Posts: 323
- Joined: Thu 14. Dec 2006, 09:56
- Location: TU Berlin
-
Contact:
Post
by gunn » Fri 29. May 2009, 14:29
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.
jReality core developer
-
STRESS
- Posts: 141
- Joined: Mon 19. Jan 2009, 12:10
Post
by STRESS » Fri 29. May 2009, 17:55
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!
-
steffen
- Posts: 186
- Joined: Fri 16. Jun 2006, 13:30
- Location: TU Berlin
-
Contact:
Post
by steffen » Sun 31. May 2009, 17:06
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... ;-)