Light parameter only taking effect on second run

Light parameter only taking effect on second run

Post by LilSpik » Sun, 29 Jun 2003 01:02:59



Hi,

I have been having problems with my light source, I dont want it to be
directional, and I am using the included code every time I draw a frame.

But the first draw of the screen, the light appears to be directional, with
everything being far brighter than it should, then everything sorts itself
out on the second redraw. Why is this? What am I doing wrong? Any pointers
or help is appreciated. Thanks!     - LilSpike

...

  LightSetting[0] := 1;
  LightSetting[1] := 1;
  LightSetting[2] := 1;
  LightSetting[3] := 1;

  LightPosition[0] := 0;
  LightPosition[1] := 0;
  LightPosition[2] := 100.0;
  LightPosition[3] := 1;





...

 
 
 

Light parameter only taking effect on second run

Post by Mikko 'memon' Monone » Sun, 29 Jun 2003 03:54:08


The values are stored when you submit the light position, so change that
to the last.

--memon


                            uow3W                 uow3w~/6Jo'3p15u1'mmm

 
 
 

Light parameter only taking effect on second run

Post by LilSpik » Sun, 29 Jun 2003 06:02:34


Thanks for your reply, but I have tried this but this does not fix the
problem, it sometime takes till the third redraw before it sets properly.
Are there any other things I can check or do, as this seems a bit weird.
Thanks again     - LilSpike
 
 
 

Light parameter only taking effect on second run

Post by Espen Ruud Schult » Sun, 29 Jun 2003 08:38:40



> Hi,

> I have been having problems with my light source, I dont want it to be
> directional, and I am using the included code every time I draw a frame.

> But the first draw of the screen, the light appears to be directional,
> with everything being far brighter than it should, then everything sorts
> itself out on the second redraw. Why is this? What am I doing wrong? Any
> pointers or help is appreciated. Thanks!     - LilSpike

> ...

>   LightSetting[0] := 1;
>   LightSetting[1] := 1;
>   LightSetting[2] := 1;
>   LightSetting[3] := 1;

>   LightPosition[0] := 0;
>   LightPosition[1] := 0;
>   LightPosition[2] := 100.0;
>   LightPosition[3] := 1;






Try to set all light attributes but position in it's own function that you
only call at initialization and when or if they change.  Then only set the
light position at each frame.  You will also gain some speed by doing this.
Remember that all lights will keep its attributes and values until they are
changed...

, Espen

 
 
 

Light parameter only taking effect on second run

Post by LilSpik » Sun, 29 Jun 2003 10:11:53


Thanks, this works faster :) but I am still wondering about why the first
(or second) call setting the position of the light does not notice that I am
specifying a non directional light, so it flashes bright when for the first
frame (as it does if I use the same parameters with a directional light)
then switches to how it should be on a subsequent frame. Not a big problem,
though I would like to fix it if I can.   - LilSpike
 
 
 

Light parameter only taking effect on second run

Post by Andrew F. Vespe » Sun, 29 Jun 2003 10:43:19



> Thanks, this works faster :) but I am still wondering about why the first
> (or second) call setting the position of the light does not notice that I am
> specifying a non directional light, so it flashes bright when for the first
> frame (as it does if I use the same parameters with a directional light)
> then switches to how it should be on a subsequent frame. Not a big problem,
> though I would like to fix it if I can.   - LilSpike

My guess is that you have a bug in your program somewhere and that
you aren't really setting the position of the light for the first
frame. Possibly you don't have a current OpenGL context at that time?
Possibly the transformation pipeline isn't set up correctly?
Possibly you are rendering the frame before setting the light
parameters?


> The values are stored when you submit the light position, so change that
> to the last.

Well, the attributes of a *vertex* need to be set before the
vertex position, but the same is not true for lights.

--
Andy V (OpenGL Alpha Geek)
"In order to make progress, one must leave the door to the unknown ajar."
Richard P. Feynman, quoted by Jagdish Mehra in _The Beat of a Different Drum_.

OpenGL Technical FAQ: http://www.opengl.org/developers/faqs/technical.html

 
 
 

Light parameter only taking effect on second run

Post by Mikko 'memon' Monone » Sun, 29 Jun 2003 20:55:25




>> The values are stored when you submit the light position, so change that
>> to the last.

> Well, the attributes of a *vertex* need to be set before the
> vertex position, but the same is not true for lights.

Hmm... that must be true. I remember reading it from somewhere, but I've
mistaken it.

--memon


                            uow3W                 uow3w~/6Jo'3p15u1'mmm

 
 
 

1. Running out of ram with Lighting effects

PS 4 won't let me use lighting effects more than a couple of times before
I get the message "Can't perform the operation because you don't have
enough RAM" (or something to that effect) I have allocated around 20 meg
for PhotoShop (Mac) which is plenty I would think, and the problem occurs
with images as small as 300 x 300 pixels. Has anyone experienced the same
problem?

2. New image

3. help!! D3DVECTOR no overloaded function takes 3 parameters

4. Semi-Transparent Drop Shadow (non Win2000)

5. Adding a second light to light.c sample from the Red Book

6. Switching from Truespace

7. About the function glTexImage1D parameter ( the second : -) ):

8. pics

9. feedback needed...takes 1 second

10. Lighting Running Lights on Star Ship

11. 'using' combined with running parameter

12. Run a program: Second Try

13. Lighting and Light Glow Effect Question