Menu

#97 Custom Primitive Variables Not Working in ObjectBegin/End

open-accepted
nobody
None
5
2008-07-13
2008-07-12
Anonymous
No

Custom primitive variables of polygons specified inside an ObjectBegin/End block do not make it to the surface shader in Pixie 2.2.4. Here's an example with shader:

CustomColor.sl:

surface CustomColor(varying color CustomColor = color(1);)
{
Ci = CustomColor;
Oi = Os; Ci *= Oi;
}

Plane.rib:

ObjectBegin "Plane"
PointsGeneralPolygons
[ 1 1 ]
[ 3 3 ]
[ 0 1 2 2 3 0 ]
"vertex point P" [
0 0 0
1 0 0
1 1 0
0 1 0 ]
"vertex color CustomColor" [
1 0 0
0 1 0
0 0 1
1 1 0 ]
"vertex normal N" [ 0 0 -1 0 0 -1 0 0 -1 0 0 -1 ]
ObjectEnd

ShadingInterpolation "smooth"

FrameBegin 1
ShadingRate 1
Format 640 480 1
PixelSamples 4 4
Display "box.tif" "framebuffer" "rgb"
Projection "orthographic"

WorldBegin
Translate 0 0 5
Surface "CustomColor"
ObjectInstance "Plane"
WorldEnd
FrameEnd

The rendered image in Pixie results in a white quad, i.e. the default value of CustomColor was used in the shader. If, however, the PointsGeneralPolygons call is moved down into the world description, replacing the ObjectInstance call, everything works as expected and we get a nicely colored quad.

Discussion

  • Okan Arikan

    Okan Arikan - 2008-07-13
    • status: open --> open-accepted
     
  • Okan Arikan

    Okan Arikan - 2008-07-13

    Logged In: YES
    user_id=555300
    Originator: NO

    Yes, this is a limitation of Pixie. When a primitive is parsed, all variables that it references are matched to the currently assigned shader. The alternative is to delay this linking until it is absolutely necessary. I am thinking about a major overhaul to the way we do the shaders in Pixie. During these changes, I will also make the variable linking more flexible and this problem will be resolved. Unfortunately I can not give an exact timeline for the next version.

    Meanwhile, you can move the Surface "CustomColor" inside the objectbegin/end to get around the problem.

    Okan

     

Log in to post a comment.