Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

EDI

Parabolic Maddness

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

no, it''s not a fatal mental dissease ;-) i am working on drawing a directional ''light'' on a 2d surface, i have discoverd how to make a very perfect symetrical radial light sphere by using the distance formula to plot a circle inside a square and determine alpha values, but what i would really like to do is draw a parabolic light, e.g kinda like a floodlight, i was able to draw a parabola between 3 control points using the quadradic equasion, unfortunetly, filling it is another story, i first tried walking up each edge and filling horizontaly, but when the light was rotated to certain angles it would show ''holes'' between the fill lines, so i guess my question is does anyone know how to plot out a directional light?
  
      /\\
      /\ \
      / \ \        
      [dest]

forgive the horrible ascii art, but that is sort of a top view of what i need to draw,

any infromation is apreciated,
thanks in advance
:-)

  
Raymond Jacobs, Profesional Web Applications Developer, Weekend Game Developer, www.EtherealDarkness.com

Share this post


Link to post
Share on other sites
Advertisement
It *might* be easier to actually do a trace from each point back to the light and use spotlight formulae to work out the intensity. Depends what you want to use it for I guess.

Share this post


Link to post
Share on other sites
JuNC is on the right track here. Drawing a parabola really is a hack. It will almost certainly be easier to use the real equations instead, and it will look good from any angle.

Just treat your light as a 3D source projecting on your 2D world. The calculations to perform are very easy: for each point, just take a vector from the point on the 2D surface towards the lightsource, normalize it, and compute the dotproduct between this vector and the plane normal of your 2D surface. If your 2D surface is axis aligned (most likely), then this computation can be highly simplified, as two normal components will be zero.

/ Yann

Share this post


Link to post
Share on other sites
i have tried that,

the problem is when i draw the lines out from the vector,
they either leave holes or overlap, im using a common line algorythm,when the lines overlay the alpha builds up and causes an unatual patern to the light




i use something like this


for(t=0;t<45;t++)
{
//draw a line at angle t with length of 100
}

this leaves holes,

if i increase t by floating point increments it closes up the holes but they areas of the light are drawn twice
and the alpha build up makes the light look unnatural

Raymond Jacobs,
Profesional Web Applications Developer,
Weekend Game Developer,
www.EtherealDarkness.com

[edited by - EDI on October 18, 2002 9:06:34 AM]

[edited by - EDI on October 18, 2002 9:10:24 AM]

Share this post


Link to post
Share on other sites
I think you may have misinterpreted what they were saying. Instead of drawing it by doing lots of lines, cycle through and do it pixel by pixel, checking the exact intensity of the light as it affects that specific pixel and use that to draw that single pixel. Then move to the next one, lather, rinse and repeat.

There are no holes, because you do each pixel individually, and there is no overdraw.

Trying is the first step towards failure.

Share this post


Link to post
Share on other sites
i have also tried the method pixel for pixel,

the problem is that im using sine and cosine to determine the position of a pixel at a certain angle,

depending on the precision i use as the length increases the distance between pixels increases,
so twoards the source the overdraw is very great and twoards the end holes might apear

Raymond Jacobs,
Profesional Web Applications Developer,
Weekend Game Developer,
www.EtherealDarkness.com

Share this post


Link to post
Share on other sites
I don''t understand, why you''d need to use cos/sin to determine the pixels affected. The usual way to do that, is as follows:

*) project the light''s bounding area onto the plane, create an axis aligned bounding rectangle containing it.

*) scan through all points in this rectangle (simply two nested loops) and compute the light intensity at each pixel using the dotproduct.

The result will be a nice projected light cone, without any holes. Alternatively, instead of computing the bounding rectangle, you could simply loop through all the pixels on your surface. That''s quite a waste of performance, but it doesn''t really matter that muc if your lighting is done as a preprocess.

/ Yann

Share this post


Link to post
Share on other sites
i dont know what you mean by
"
*) project the light's bounding area onto the plane
"

here are my inputs,

the source coordinets x,y
the theta *direction* of the light
and the angle relative to the theta where it will depart from the light source
*apeture*
*think of a lighthouse, but looking straight down on top of it, that is what i want the light to look like*



"
create an axis aligned bounding rectangle containing it.
"
what do you mean by axis algined?
"
*) scan through all points in this rectangle (simply two nested loops) and compute the light intensity at each pixel using the dotproduct.
"

i know how to scan through a rectangle, but i havent
really used dotproduct, i know is is multiplication of scalars or somthing, right?

anyway, if there is a tutorial, of if anyone wants to offer some psuedo code, or even real code that will be helpful, since i havent ever doing anything with light theory

Raymond Jacobs,
Profesional Web Applications Developer,
Weekend Game Developer,
www.EtherealDarkness.com

[edited by - EDI on October 18, 2002 10:25:25 AM]

Share this post


Link to post
Share on other sites

Question: do you want a 100% 2D light cone ? In that case, just use your original radial light equation, and include an agle dependend cutoff value for the spot effect. This is a logical extension to your spherical light sphere. But it will look totally 2D.

Or do you want a pseudo-3D effect, eg. like when seing a lighthouse from above: the cone will touch the ground from a certain height, so the 2D cone will be somewhat distorted due to the perspective, which gives a ''3D feeling'' to the lightsource (neglecting the fact, that a lighthouse that actually projects it''s cone onto the ground would be malfunctioing in the real world )

In the later case, you''ll have to use real 3D computations onto the 2D surface, as described above. If that''s what you want, let me know, I could post some pseudo code (it''s pretty simple).

/ Yann

Share this post


Link to post
Share on other sites
what i want is basicly this,

take a cone, sit it on it's base

slice the cone in half verticly,

then lay the cone down on the flat side that was created from the slice

it's outline is roughly the shape of a pizza slice,

but because the cone is a 3d object light brightness will be greator on the top of the cone and falloff the edges,

, but basicly,


i want a pizza slice, wheerin the pixels that are plotted decrase in brightness the futher away they are , falloff.

i can acive the computation for the dimming, but i dont know how to plot the slice without holes forming or without drawing certain pixels more than once,

ive only managed to draw an entire circle, not a slice, using the rectangular method,

so i guess my need is, how do i draw a slice of a filled circle,wherein no pixels overlap in the fill



Raymond Jacobs,
Profesional Web Applications Developer,
Weekend Game Developer,
www.EtherealDarkness.com

[edited by - EDI on October 18, 2002 10:44:01 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!