[Bf-committers] Question about lighting in shaded view.

Ton Roosendaal bf-committers@blender.org
Thu, 22 May 2003 12:45:04 +0200


Hi Jacek,

The confusion is that the routines you talk about are (were) only used  
in real-time mode for the old game engine. The current 'shaded'  
drawmode uses its own lamp and shading methods, as written in  
drawdisplist.c.

The drawmode 'opengl solid' uses 2 fake opengl lamps, always located  
fixed to the viewing position. This makes sure you always see  
something... otherwise you'll have to position lamps all the time.

Nevertheless, this system was designed in the old days, when 3d  
accelleration was expensive. With the current gfx power, it would be  
quite useful to implement a new 'solid' drawing mode, using pure  
OpenGL. The Blender display list methods need a BIG make over badly...  
there is too much old stuff from the past in it. But maybe this might  
be too far stretched for you? This is something thoroughly related to  
the 3d editor itself, so I'd prefer a few people to look at this first  
to come with a proposal... including finding solutions for how to  
display selection status for 'solid' or how to introduce useful  
wireframe colours.

Below you find a few remarks inserted:

> GL_LIGHTING is disabled, so answer for question "how Blender support  
> more than
> 8 lights?" is "it doesn't use OpenGL for lighting!".

Yes, well not for 'shaded' mode. It uses a function compatible to its  
own internal renderer.

> First argument of drawmeshshaded is Object, then two arrays.
>
> Arrays are used in glColor calls. Second array is used for second size  
> of
> faces.
>
> What really is in these arrays? Probably some precalculated color  
> values. But
> where exactly is that calculation? I assume that Blender loop in lamp  
> list and
> add (blend?) colors for each vertex. But where that operation is  
> located in
> source?

It is for double sided rendering. In Blender a light can shine at one  
side of a single face, it then displays it correctly by drawing  
front/back separately.

> PS. My goal is to fix lighting errors - sometime lights are not  
> updated until
> you move/rotate object. Try also to add/remove lamp in shaded mode -  
> nothing
> changes.

This is just opimized for slow cpu's. For more complex scenes, it might  
require over a second to recalculate light, making moving objects or a  
light not interactive anymore.

One of the requirements for a new Display List system could be that it  
can update in an adaptive way, to maintain interactive drawing speeds.

-Ton-

------------------------------------------------------------------------ 
--
Ton Roosendaal  Blender Foundation ton@blender.org