Hi Johan,

Doing a per vertex operation on the CPU that requires a round trip to
the graphics hardware is doomed to being very very slow indeed.

If you have complex lighting calculations then try a technique like
deferred lighting/shading - render the scene to a depth texture then
in a second pass use this depth texture to compute normals and
required lighting.  The advantage of this approach is that you one
compute the lighting for the pixels actually on screen, rather than
for every fragment.

Robert.

On Nov 27, 2007 12:54 PM, Johan Johnsson <[EMAIL PROTECTED]> wrote:
> I use below code to see if the vertex is occluded or not by objects
> infront of it. This is apart of the lighting check to see if the
> lightalgoritm needs to be runned on the pixel.
>
>
> case GLREADPIXELS:
>              {
>                  osg::Vec3   win;           // Space For Returned Projected
> Coords
>                  GLfloat     bufferZ = 0.0f;// Here We Will Store The Read
> Z From The Buffer
>
>
>                  osgViewer::Viewer::Cameras cameras;
>                  m_viewer->getCameras(cameras);
>
>                  osg::ref_ptr<osgUtil::SceneView> sv = new
> osgUtil::SceneView();
>
>                  for(osgViewer::Viewer::Cameras::iterator it =
> cameras.begin(); it != cameras.end(); ++it)
>                  {
>                      sv->setCamera(*it);
>                      sv->projectObjectIntoWindow(absolutePos, win);
>
>                      glReadPixels(win.x(), win.y(), 1, 1,
> GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_8_8_8_8_REV, &bufferZ);
>                      //std::cout << bufferZ << "\t" << win.x() << "\t" <<
> win.y() <<  "\t" << win.z() << std::endl;
>
>                      if(bufferZ < win.z())
>                      {
>                          return true;
>                      }
>                      else
>                      {
>                          return false;
>                      }
>                  }
>              }
>              break;
>
>          }
>
>
>
>
>
>
> On Tue, 27 Nov 2007 13:48:47 +0100, Robert Osfield
> <[EMAIL PROTECTED]> wrote:
>
> > Hi Johan,
> >
> > It would be worth stepping back a bit and explaining from a high level
> > what you are trying to do in terms of doing occlusion testing, as
> > there are many ways to do occlusion testing, one can't really answer
> > what would be the best technique without knowing more about the
> > problem you are wanting to solve.
> >
> > On Nov 27, 2007 12:27 PM, Johan Johnsson <[EMAIL PROTECTED]> wrote:
> >> Hi !
> >>
> >> i wonder over something in my occluding technique: does openGL have
> >> anything that is faster than
> >> glReadPixels(win.x(), win.y(), 1, 1, GL_DEPTH_COMPONENT,
> >> GL_UNSIGNED_INT_8_8_8_8_REV, &bufferZ); to get the depth from each
> >> pixel?,
> >> if not what i suggested to do ? Ive been thinking of making a shader out
> >> of it , but im not sure yet.
> >>
> >> --
> >> Mr. Johan Johnsson
> >> AutoSim AS, Strandveien 106, 9006 Tromsø
> >> Visit us at http://www.autosim.no
> >> _______________________________________________
> >> osg-users mailing list
> >> [email protected]
> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >>
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
> --
>
> Mr. Johan Johnsson
> AutoSim AS, Strandveien 106, 9006 Tromsø
> Visit us at http://www.autosim.no
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to