Advertisement

Disco Lights?

Started by November 09, 2000 01:45 AM
7 comments, last by cyanide 24 years ago
hi d00ds, can u please suggest as to how can i create small disco lights spots, like the effects created by the dance balls in the disco station? cyanide. Greetz from the "CYANIDE" http://www.sanchit.8m.com/
[size="1"]----#!/usr/bin/perlprint length "The answer to life,universe and everything";
How about this.. You need an algorithm to create spheres out of triangles.. and what''ll you''ll do is create the sphere with some of the triangles NOT DRAWN or transparent (either way) then put your light source inside the sphere that has all these ''holes'' in it.. Now if you rotate the the sphere about it''s center you should have somewhat of a disco ball effect (depending on the type of light you use also.. This method should be fairly quick as you are only using one light source a few triangles. smaller the sphere the smaller the holes for the light. though I have never implemented this ....give it a shot! In theory it works
Advertisement
hi JizzRoy,
that was an excellent idea indeed!
but now one more problem, when i alpha blend those small spheres in the background and use the fog effect, the triangle outlines are visible (quite sharp), wasting all the effort?
How can i remove those lines, so that these triangle sides hide in the fog..

cyanide.

Greetz from the "CYANIDE"
http://www.sanchit.8m.com/
[size="1"]----#!/usr/bin/perlprint length "The answer to life,universe and everything";
hi,
i even used values like 0.8 for the alpha and messed with all the different options but still there are lines. how can i get rid of them?

cyanide.

Greetz from the "CYANIDE"
http://www.sanchit.8m.com/
[size="1"]----#!/usr/bin/perlprint length "The answer to life,universe and everything";
To suggest a totally different approach... if I''m correctly guessing what effect you''re looking for, it would seem to make more sense to cast a bunch of rays (just some vector collision-detection, which you''d BETTER have if you''re writing a real game... or you''re probably walking throguh walls :-) ) and then draw some overlays (spherical things, probably) of little light dots where they hit. It seems to me that this would save a lot of clipping computations that would otherwise have to be done with the dynamic lightsource, and obviously those sharp edges wouldn''t be a problem...

That, or you''re talking about something totally different.

--Tr][aD--
--Tr][aD--
Hey cyanide, here is what is troubling! When you blend you use the blend function and when fog comes, it brings in it''s own blending function and takes the magic out of the sprites. I had looked for a solution for this, couldn''t find one, don''t want to find one now coz I have a better idea. Blend using alpha testing instead of blending functions and you should be cool.

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);

If this doesn''t help , let me know. I have played with this a lot and now on my terrains trees and fog cohabitate without screwing each other up!!

Neo
Advertisement
hi neogl,
your idea seems quite logical but dunno whats with this fog.
ok, i''m pasting a few lines of the code (borland delphi), please tell me if i''m doing something wrong.

glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);
glBindTexture(GL_TEXTURE_2D, texture[12] + (tex_count mod 12));
glBegin(GL_TRIANGLE_STRIP);
glColor4f (1, 1, 1, 0.8);
...

thanks,
cyanide.


Greetz from the "CYANIDE"
http://www.sanchit.8m.com/
[size="1"]----#!/usr/bin/perlprint length "The answer to life,universe and everything";
hi neogl,
please also verify that if this fog code is also correct.

//Borland Delphi.

glEnable(GL_FOG); // Enables GL_FOG
glFogi (GL_FOG_MODE, GL_LINEAR); // Fog Mode
glFogfv (GL_FOG_COLOR, @fogColor); // Set Fog Color
glFogf (GL_FOG_DENSITY, 0.55); // How Dense
glHint (GL_FOG_HINT, GL_NICEST); // Fog Hint Value
glFogf (GL_FOG_START, 1.0); // Fog Start
glFogf (GL_FOG_END, 5.0); // Fog End Depth

glEnable(GL_DEPTH_TEST);
glDepthFunc (GL_LESS);
...

still can''t get it to work. please help me!

thanks,
cyanide.
[size="1"]----#!/usr/bin/perlprint length "The answer to life,universe and everything";

cyanide, don''t enable the blend function if you don;t have to. The fog will take care of it''s own blending. This is how I draw my sprites (or overlays or masks, whatever you like to call it).

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);
Sprite::Draw();
glDisable(GL_ALPHA_TEST);

I make sure that the parts I don;t want to draw has an alpha value of 0.0 (anything less than 0.5) and the parts I want drawn has an alpha value of 1.0 (anything more than 0.5 coz I am using .5 as my threshold here). You can do this by manually running through the TGA (or any image) data that you loaded and clamping the alpha values depending on the RGB values. (if R ==0 && G== 0 && B==0) alpha = 0; (transparent). if your image data is correct, whatever yuo are doing is right, just take out the two lines of blending and you should be good.
Your fog function abd parameters seems reasonable, I will just cut-n-paste mine anyway..

void CEnvironment::SwitchFog(GLint fog_switch)
{
if(fog_switch == ON)
{
glFogi(GL_FOG_MODE, mFogFilter); glFogfv(GL_FOG_COLOR, mFogColor); glFogf(GL_FOG_DENSITY, mFogDensity); glHint(GL_FOG_HINT, GL_FASTEST); glFogf(GL_FOG_START, mFogStartDepth); glFogf(GL_FOG_END, mFogEndDepth); glEnable(GL_FOG);
}
else glDisable(GL_FOG);
}

Hope this helps, if it doesn''t mail me your code. We will crack it , it''s only OpenGL....:-)
Good Luck
Neo

This topic is closed to new replies.

Advertisement