Mario Veraart (rioj7++at++fel.tno.nl)
Wed, 21 Jan 1998 21:41:53 +0100 (MET)
I have a problem with the rendering of transparent objects.
It gives the impression that the BACK_TO_FRONT sorting does not work
for the Transparent bin of a pfChannel. Or it could be that the
geometry isn't put into the transparent bin and is sorted based on the
geostate.
The effect I see is that depending on the position of the viewer with
respect of the transparent objects you sometimes doesn't see the
objects that are behind the nearest object. I use BLENDING for
transparency, because multisampling for a close objects look bad.
I have made a very small program that shows what I mean.
I have appended the code lines below that can be added to the demo
program /usr/share/Performer/src/pguide/libpf/C++/complex.C .
Run it without any arguments.
Depending on the viewer you can't see the green and blue cube if the
red one is the nearest. And you can see the red and the green one if
the blue cube is the nearest. At least that is what I see.
I force the bin to put the geometry in to the transparent one and
according to the manual page the default sorting mode of this bin is
BACK_TO_FRONT. Setting the required mode for the bin makes no
difference.
I use Performer 2.0 on a Max Impact.
Any clues to what might solve this artefact would be great.
Mario
-----------The src to add to complex.C
// CHANGE constant at line 359 from 1000 to about 3
// INSERT before the Usage function
#include <Performer/pf/pfNode.h>
#include <Performer/pf/pfPipe.h>
#include <Performer/pf/pfChannel.h>
#include <Performer/pf/pfGeode.h>
#include <Performer/pf/pfSCS.h>
#include <Performer/pr/pfLight.h>
#include <Performer/pr/pfGeoSet.h>
#include <Performer/pr/pfGeoState.h>
#include <Performer/pr/pfMaterial.h>
pfNode* newCube(pfVec3& cubePos, pfVec4& cubeColor, float cubeSize)
{
pfGeoSet* cube = pfdNewCube(pfGetSharedArena());
pfGeoState* geostate = new pfGeoState();
geostate->setAttr (PFSTATE_FRONTMTL, new pfMaterial());
geostate->setMode (PFSTATE_TRANSPARENCY, PFTR_BLEND_ALPHA);
geostate->setMode (PFSTATE_ALPHAFUNC, PFAF_NOTEQUAL);
geostate->setVal (PFSTATE_ALPHAREF, 0.0f);
cube->setGState(geostate);
pfVec4* sharedColor = new pfVec4();
sharedColor->copy(cubeColor);
cube->setAttr(PFGS_COLOR4, PFGS_OVERALL, sharedColor, NULL);
cube->setDrawBin(PFSORT_TRANSP_BIN);
pfMatrix matrix;
matrix.makeScale(cubeSize, cubeSize, cubeSize);
matrix.postTrans(matrix, cubePos[PF_X], cubePos[PF_Y], cubePos[PF_Z]);
pfSCS* scs = new pfSCS(matrix);
pfGeode* geode = new pfGeode();
geode->addGSet(cube);
scs->addChild(geode);
scs->flatten(0);
scs->removeChild(geode);
pfDelete(scs);
return (geode);
}
// INSERT just before the simulation loop
// position some cubes in the terrain
pfVec3 cubePos;
pfVec4 cubeColor;
float cubeSize;
cubePos.set(0, 10, 0);
cubeColor.set(1, 0, 0, 0.5);
cubeSize = 4;
scene->addChild(newCube(cubePos, cubeColor, cubeSize));
cubePos.set(0, 20, 0);
cubeColor.set(0, 1, 0, 0.5);
cubeSize = 4;
scene->addChild(newCube(cubePos, cubeColor, cubeSize));
cubePos.set(0, 30, 0);
cubeColor.set(0, 0, 1, 0.5);
cubeSize = 4;
scene->addChild(newCube(cubePos, cubeColor, cubeSize));
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:36 PDT