request some new functions

Started by pitt, May 03, 2006, 10:57:38 AM

Previous topic - Next topic

pitt

Hi, Egon. I need your help to continue my project.

- Could you enable the rest of PixelFormat args please.

PixelFormat(int bpp, int alpha, int depth, int stencil, int samples, int num_aux_buffers, int accum_bpp, int accum_alpha, boolean stereo)

You might add more variables in Config Ex. Config.glStencilBpp


- just draw a specific face by objid,polyid retrieved from VisList

World.draw(FrameBuffer buffer,int objid,int polyid)


These should be enough to make real time shadow in my project.

Thank you very much.

EgonOlsen

Quote from: "pitt"
- just draw a specific face by objid,polyid retrieved from VisList

World.draw(FrameBuffer buffer,int objid,int polyid)
Wouldn't it be possible to simply use a different World/VisList instead?

pitt

I don't get it. :?  

Here is my brief code for realtime shadow.



while (true)
{

 GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

  World.renderScene(FrameBuffer);

   for (int i=0;i<VisList.getMaxSize();i++)
   {
     VisList.getData(i,data);
     if (IsShadowReceiver(data))
    {
         //render the face and the shadow
         glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
         glStencilFunc(GL_ALWAYS, 0x1, 0);
         glEnable(GL_DEPTH_TEST);
     
         //draw the face with stencil mask
            World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
           glDisable(GL_DEPTH_TEST);
   
         //projective shadow          
         glStencilFunc(GL_EQUAL, 1, 1);
         glEnable(GL_BLEND);
         list=shadowpolygon(data,lightpos);     //find the object that cast a shadow on this face
         for (int j=0;j<list.length;j++)
         {
          shadowmatrix(matrix,data,lightpos);  //create the matrix to project a shadow polygon on the face
          GL11.glPushMatrix();
          GL11.glMultMatrix(matrix);
          mydraw(list[j]);              //draw the projective shadow
          GL11.glPopMatrix();   
         }
         glDisable(GL_BLEND);

        //remove the stencil mask
        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
        World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
     } else  
    {
      //no shadow just render the face
      World.draw(FrameBuffer,Interact2D.getObjectID(data),Interact2D.getPolygonID(data));
     }
   }

   FrameBuffer.update();
   FrameBuffer.updateGLOnly();
   Thread.yield();
}

Any suggestion?

EgonOlsen

I'll look at it next week (not at home during the weekend).

pitt


EgonOlsen

Ok...it should be possible to add this. In fact, it's already there in the IRenderer-interface. You just can't use it because the actual renderer is not accessable by the API ATM. So the easiest way would be to make it accessable. But then, you would throw a lot of jPCT's optimizations out of the window by drawing each face separately. Would it be better to do something like draw(<VisList>, indexStart, indexEnd) instead to draw a batch of faces that are no shadow recievers in one call? If this possible for shadow recievers too? I.e. draw a batch of shadow revievers (by jPCT), draw a batch of shadows (on your own), draw the recievers again with  glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE)?

pitt


EgonOlsen

Ok, i've uploaded a modified version here: http://www.jpct.net/download/beta/jpctapi112_pre1.zip

You may now draw only parts of the visibility list as well as provide your own DisplayMode and/or PixelFormat for the GLRenderer (but i haven't tested this feature yet...) using Config.glAdditionalConfiguration.

I'm not sure if this is sufficient for you to add your shadow stuff. Just have a look.