Sign in to follow this  

Billboards but not particles

This topic is 4692 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

I am currently developing a space sim and require the use of billboards for nebula, sunflares and galaxies....I currently have a billboarding system set up that unfortunately is based on the view of the camera and not its position...What I need is something similar to glPointParameterfARB point sprite extention that will allow me to have points of any size or regular billboarding that is not affected by the view of the camera. I need the billboards to face the camera yes but I do not want them to move when I face a different direction unless I move from the current position...Im not sure what type of billboarding this will be but if anyone would be gracious enough to provide some links to tutorials with code examples it would be much appreciated...Im not the strongest with math so its no use speaking greek to me ;)

Share this post


Link to post
Share on other sites
im having a hard time understanding what u want, if its this

if ( camera moving)
{
calc for billboard new vertices positions
}

the problem is when u start moving the camera again the vertices are gonna 'jump' to the new billboarded positions which will look bad

Share this post


Link to post
Share on other sites
I'm assuming you mean that currently it is set up to just align the billboard so that it is parallel to the viewing plane, and what you want is a real billboard that directly faces the camera position?

Click here

Share this post


Link to post
Share on other sites
Quote:
Original post by keyofrassilon
I mean facing based on position not camera orientation...


Okay, check out that link in my last post. (Sorry, I know it looks like a signature :P)

Share this post


Link to post
Share on other sites
Ahh I did after I posted that reply....I must have looked at that tutorial several times before and always concluded it was doing the same thing as what I had...except it doesnt pull from the current modelview matrix....

I got it to do what I wanted using the spherical code in that tut...Originally I intended to capture the surrounding space into buffers and render them as a skybox for the planet's surface...The old billboarding method I used moved around too much to take seamless shots of the surrounding space...The new code fixed just that...Thanks!

If anyone is interested this is what I did to snapshot the surrounding space into buffers...Its ugly but it works...


void Engine::captureTerrainBox() {
float view = 90.0f;
float clip_min = 0.1f;
float clip_max = bounds * 10;

glFinish(); //make sure everything has been sent
glutSwapBuffers(); //swap the front and back buffers to display the image

screenX = TERRAIN_BACK;
screenY = TERRAIN_BACK;
captureSkybox = true;

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ALIGNMENT, 1);

glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(view, (GLfloat)screenX / (GLfloat) screenY, clip_min, clip_max);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
facing = 0;
facing2 = 180;

camera.updateCamera();
sys.drawSolarSystem();

glFinish(); //make sure everything has been sent

glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(view, (GLfloat)screenX / (GLfloat) screenY, clip_min, clip_max);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
facing = 360;
facing2 = 180;

camera.updateCamera();
sys.drawSolarSystem();

glFinish(); //make sure everything has been sent

glReadBuffer(GL_BACK);
glReadPixels(0,0,screenX,screenY,GL_RGB,GL_UNSIGNED_BYTE,terrain_back[0]);

glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(view, (GLfloat)screenX / (GLfloat) screenY, clip_min, clip_max);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
facing = 270;
facing2 = 180;

camera.updateCamera();
sys.drawSolarSystem();
glFinish(); //make sure everything has been sent

glReadBuffer(GL_BACK);
glReadPixels(0,0,screenX,screenY,GL_RGB,GL_UNSIGNED_BYTE,terrain_back[1]);

glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(view, (GLfloat)screenX / (GLfloat) screenY, clip_min, clip_max);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
facing = 180;
facing2 = 180;

camera.updateCamera();
sys.drawSolarSystem();
glFinish(); //make sure everything has been sent

glReadBuffer(GL_BACK);
glReadPixels(0,0,screenX,screenY,GL_RGB,GL_UNSIGNED_BYTE,terrain_back[2]);

glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(view, (GLfloat)screenX / (GLfloat) screenY, clip_min, clip_max);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
facing = 90;
facing2 = 180;

camera.updateCamera();
sys.drawSolarSystem();
glFinish(); //make sure everything has been sent

glReadBuffer(GL_BACK);
glReadPixels(0,0,screenX,screenY,GL_RGB,GL_UNSIGNED_BYTE,terrain_back[3]);

glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(view, (GLfloat)screenX / (GLfloat) screenY, clip_min, clip_max);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
facing = 360;
facing2 = 269.999999;

camera.updateCamera();
sys.drawSolarSystem();
glFinish(); //make sure everything has been sent

glReadBuffer(GL_BACK);
glReadPixels(0,0,screenX,screenY,GL_RGB,GL_UNSIGNED_BYTE,terrain_back[4]);

glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(view, (GLfloat)screenX / (GLfloat) screenY, clip_min, clip_max);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
facing = 360;
facing2 = 90.000001;

camera.updateCamera();
sys.drawSolarSystem();
glFinish(); //make sure everything has been sent

glReadBuffer(GL_BACK);
glReadPixels(0,0,screenX,screenY,GL_RGB,GL_UNSIGNED_BYTE,terrain_back[5]);

glDeleteTextures(1,&terrain_backID[0]);
glDeleteTextures(1,&terrain_backID[1]);
glDeleteTextures(1,&terrain_backID[2]);
glDeleteTextures(1,&terrain_backID[3]);
glDeleteTextures(1,&terrain_backID[4]);
glDeleteTextures(1,&terrain_backID[5]);

glGenTextures(1, &terrain_backID[0]);
glBindTexture(GL_TEXTURE_2D, terrain_backID[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenX,
screenY, 0, GL_RGB, GL_UNSIGNED_BYTE,
terrain_back[0]);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glGenTextures(1, &terrain_backID[1]);
glBindTexture(GL_TEXTURE_2D, terrain_backID[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenX,
screenY, 0, GL_RGB, GL_UNSIGNED_BYTE,
terrain_back[1]);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glGenTextures(1, &terrain_backID[2]);
glBindTexture(GL_TEXTURE_2D, terrain_backID[2]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenX,
screenY, 0, GL_RGB, GL_UNSIGNED_BYTE,
terrain_back[2]);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glGenTextures(1, &terrain_backID[3]);
glBindTexture(GL_TEXTURE_2D, terrain_backID[3]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenX,
screenY, 0, GL_RGB, GL_UNSIGNED_BYTE,
terrain_back[3]);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glGenTextures(1, &terrain_backID[4]);
glBindTexture(GL_TEXTURE_2D, terrain_backID[4]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenX,
screenY, 0, GL_RGB, GL_UNSIGNED_BYTE,
terrain_back[4]);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glGenTextures(1, &terrain_backID[5]);
glBindTexture(GL_TEXTURE_2D, terrain_backID[5]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenX,
screenY, 0, GL_RGB, GL_UNSIGNED_BYTE,
terrain_back[5]);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

screenX = SCREEN_X;
screenY = SCREEN_Y;
captureSkybox = false;

glReadBuffer(GL_FRONT);
glViewport(0, 0, (GLsizei)screenX, (GLsizei)screenY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(PERSPECTIVE, (GLfloat)screenX / (GLfloat) screenY, 10.0f, bounds);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
glClearColor(0.0, 0.0, 0.0, 0.0);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, white_mat);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);

glFinish(); //make sure everything has been sent
glutSwapBuffers(); //swap the front and back buffers to display the image
}





What I really need is a way to render GL directly into a buffer bypassing the default back color buffer which could allow me to create any size image...Right now Im limited to the maximum Y size of the screen...Anything less than 1024 x 1024 for this sort of texture is very pixelated...

Share this post


Link to post
Share on other sites

This topic is 4692 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this