Jump to content
  • Advertisement
Sign in to follow this  
cjtomekk

OpenGL OpenGL Quadrics and Shaders

This topic is 3985 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everynone, I want to speed up some quadrics processing. I use an effect with 200 gluSphere at most and the effect is a framerate killer. Is it possible to push the stuff to a shader? how should I do it?

Share this post


Link to post
Share on other sites
Advertisement
Could you please elaborate a bit more on this "connection" between quadratics, gluSphere and shaders? As you put it now, it simply doesn't make sense!

When you write 'effect' you mean the shading effect or the effect made from the spheres?

Share this post


Link to post
Share on other sites
Ok, so I simulate an explosion in space with gluSphere. A few fors and blended gluSphere with same center and different size are generated. Many spheres at a time. The spheres are semi transparent. I helped myself and made Lists for every step of "explosion". It fits in 200 lists. I want to put this in a shader to speed up rendering.

Edit: look at this: http://83.168.75.132/skool/exp_.avi

Share this post


Link to post
Share on other sites
It's important to understand what is causing the slow down.
It's unlikely that shaders are going to change anything. Shaders are for overriding the default vertex and fragment processing of the GL pipeline.

If you are using display lists, that should be fine. If you are drawing with blending this could be a possible reason. Maybe post your code here and someone can suggest something.

Share this post


Link to post
Share on other sites
I suppose its because blending or number of vertices.
Here's some code:
//make it globals or class privates
step=0.5f;
il=0;
i=0;
...
glDisable(GL_LIGHTING);
glColor3f(1.f,1.f,1.f);
glEnable(GL_BLEND);

glColor3f(0.5f/step,0.5f/step,0.5f/step);
gluSphere(sph,step*10,32,32);
if(step>=1){
glColor3f(0.5f/(step-1),0.5f/(step-1),0.5f/(step-1));
gluSphere(sph,(step-1)*10,32,32);
}

glColor3f(0.5f/step,0.5f/step,0.5f/step);
gluSphere(sph,5-step*10,32,32);

if(step>=1){
glColor3f(0.5f/(step-1),0.5f/(step-1),0.5f/(step-1));
gluSphere(sph,5-(step-1)*10,32,32);
}

if(il<50){
for(int k=0; k<il; k++){
glColor3f(0.015f+k*0.015f/il,0.015f+k*0.015f/il,0.015f+k*0.015f/il);
gluSphere(sph,il/25.f+k/5.f,16,16);
}
}else if(il<150){
for(int k=0; k<(150-il); k++){
glColor3f(0.015f+k*0.01f/(150-il),0.015f+k*0.01f/(150-il),0.015f+k*0.01f/(150-il));
gluSphere(sph,(150-il)/100.f+k/5.f,16,16);
}
}
il++;
step+=0.2f;
i++;
if(i==200) i=0;
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);

I know... chaos :-) but it was made upon experiments.

Just put the code in place where rendering is made.
Btw have You watched the clip?

Share this post


Link to post
Share on other sites
gluSphere is slow since it calculates the sphere. Try to use display lists. It might even better to stop using gluSphere and code it yourself and start using VBOs if you are up to it.

Share this post


Link to post
Share on other sites
For Spheres it's recommend to use a own mesh in a VBO. But it's also possible to transform a quadric mesh with a vertex shader into a sphere, torus or a bezier patch.
For rendering 200 Spheres it would be a good idea to use instancing, but unfortunately the needed extension is only supported by the GF8 based cards.

On my page are some tutorials about the shader related part:

Share this post


Link to post
Share on other sites
I would not worry about instancing.
If you move to VBOs and glDrawRangeElements, 1 call to glDrawRangeElements will render a sphere. 200 Spheres in a scene isn't too many glDrawRangeElements calls.

You can even make 1 display list with the sphere, and render as many times as you want. Just scale it, color it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!