Setting per-vertex light?

Setting per-vertex light?

Post by Espen Ruud Schult » Sat, 28 Jun 2003 03:50:50



I'm gonna do my own lighting calculation for terrains.  Is it possible to
set light value for each vertex kinda the same way you set color?

, Espen

 
 
 

Setting per-vertex light?

Post by Poison6 » Sat, 28 Jun 2003 06:17:59


Quote:> I'm gonna do my own lighting calculation for terrains.  Is it possible to
> set light value for each vertex kinda the same way you set color?

> , Espen

    why not this ?

    float light_intensity = ...
    glColor3f(light_intensity,light_intensity,light_intensity);

--
   Poison64
   poison64(aT)poczta.onet.pl || poison64(aT)op.pl
   => http://www.poison64.prv.pl/
   => ICQ# 125215364 => GG# 4817051

 
 
 

Setting per-vertex light?

Post by Espen Ruud Schult » Sat, 28 Jun 2003 07:37:28



Quote:>> I'm gonna do my own lighting calculation for terrains.  Is it possible
>> to set light value for each vertex kinda the same way you set color?

>> , Espen

>     why not this ?

>     float light_intensity = ...
>     glColor3f(light_intensity,light_intensity,light_intensity);

The main reason is textures.  The second reason is that I want to be able to
use existing colors if there are any.  The third reason is that light is its
own thing, and I want to keep it like this.  I want to set color, and I want
to set light, without doing any color/light magic.

This seem like an easy subject, and I will be very suprised if OpenGL
doesn't have a function to set per-vertex light.  It really shouldn't be any
harder than setting the vertex color - glLight1f( GLfloat value );

I just want to utilize OpenGL's hardware calculations for light.  I set
color, I set light, I set texture - and out from the pipline comes the
correct pixel colors for my objects...

, Espen

 
 
 

Setting per-vertex light?

Post by Poison6 » Sat, 28 Jun 2003 15:43:08


Quote:> The main reason is textures.

    what about them ??

Quote:> The second reason is that I want to be able to
> use existing colors if there are any.  The third reason is that light is
its
> own thing, and I want to keep it like this.  I want to set color, and I
want
> to set light, without doing any color/light magic.

    r1*light_r,g1*light_g,b1*light_b

    magic ?
    i think this should do the trick

    AFAIK if you want to calculate lighting per-vertex yourself
    you cant use opengl lighting, but i'am not sure

--
   Poison64
   poison64(aT)poczta.onet.pl || poison64(aT)op.pl
   => http://www.poison64.prv.pl/
   => ICQ# 125215364 => GG# 4817051

 
 
 

Setting per-vertex light?

Post by Espen Ruud Schult » Sun, 29 Jun 2003 08:30:47



Quote:>> The main reason is textures.

>     what about them ??

>> The second reason is that I want to be able to
>> use existing colors if there are any.  The third reason is that light
>> is its own thing, and I want to keep it like this.  I want to set
>> color, and I want to set light, without doing any color/light magic.

>     r1*light_r,g1*light_g,b1*light_b

>     magic ?
>     i think this should do the trick

>     AFAIK if you want to calculate lighting per-vertex yourself
>     you cant use opengl lighting, but i'am not sure

Ok, so it won't be as stright forward as I want - hmm, I guess OpenGL have
the same designers as life...

Anyway, it seems like I have to do either textures or colors, I can't have
both and just enable one of them, becasue if I use textures, I have to use
grayscale color.  So it's easy when doing just color, but how about
textures?  I guess I have to mix grayscale colors with the texture to
"light" it.  Now how do I do that?

, Espen

 
 
 

Setting per-vertex light?

Post by Johan » Sun, 29 Jun 2003 13:22:12


Quote:> Ok, so it won't be as stright forward as I want - hmm, I guess OpenGL have
> the same designers as life...

> Anyway, it seems like I have to do either textures or colors, I can't have
> both and just enable one of them, becasue if I use textures, I have to use
> grayscale color.  So it's easy when doing just color, but how about
> textures?  I guess I have to mix grayscale colors with the texture to
> "light" it.  Now how do I do that?

> , Espen

What precisely are you planning to achieve?
If i understand you correctly you could achieve good results with the
multitexturing extension and combine (blend) a lightmap texture with another
to fake lighting.

Otherwise just use gl lighting, enable it, define normals and texture
coordinates and it should work.

MrDutchy.

 
 
 

Setting per-vertex light?

Post by Espen Ruud Schult » Sun, 29 Jun 2003 19:16:36




Quote:>> Ok, so it won't be as stright forward as I want - hmm, I guess OpenGL
>> have the same designers as life...

>> Anyway, it seems like I have to do either textures or colors, I can't
>> have both and just enable one of them, becasue if I use textures, I
>> have to use grayscale color.  So it's easy when doing just color, but
>> how about textures?  I guess I have to mix grayscale colors with the
>> texture to "light" it.  Now how do I do that?

>> , Espen

> What precisely are you planning to achieve?

I'm planning to achieve real looking lighting of a terrain mesh by using
slope lighting - with a real sun lighting it.

Quote:

> If i understand you correctly you could achieve good results with the
> multitexturing extension and combine (blend) a lightmap texture with
> another to fake lighting.

Nope.

Quote:

> Otherwise just use gl lighting, enable it, define normals and texture
> coordinates and it should work.

And nope.

I really just need to set how lit each vertex og my terrain mesh is using my
own calculations.  And I need to so with support for a color mesh, a single
texture mesh, and most important a multitextured mesh...

Thanx for the replies so far!

, Espen

 
 
 

Setting per-vertex light?

Post by Will » Mon, 30 Jun 2003 00:13:18


Quote:

>I really just need to set how lit each vertex og my terrain mesh is using my
>own calculations.  And I need to so with support for a color mesh, a single
>texture mesh, and most important a multitextured mesh...

>Thanx for the replies so far!

>, Espen

What's wrong with either setting vertex colors or using multitexturing and a
lightmap?  You say no, but you don't say what is wrong with these solutions
that make them unsuitable for you.

Also, you say you want to do the lighting yourself, and you want OpenGL also to
do the lighting for you at the same point....  I'm really confused about what
exactly you are trying to achieve.
------------------
Woooogy
I have to go back in time to pretend to be myself when I tell myself to tell
myself, because I don't remember having been told by myself to tell myself.  I
love temp*mechanics.

 
 
 

Setting per-vertex light?

Post by Espen Ruud Schult » Mon, 30 Jun 2003 01:37:45



Quote:>> I really just need to set how lit each vertex og my terrain mesh is
>> using my own calculations.  And I need to so with support for a color
>> mesh, a single texture mesh, and most important a multitextured mesh...

>> Thanx for the replies so far!

>> , Espen

> What's wrong with either setting vertex colors or using multitexturing
> and a lightmap?  You say no, but you don't say what is wrong with these
> solutions that make them unsuitable for you.

Do you not read what I write?  Why do you think I want to use slope lighting
for my terrain mesh?  People, please but a little fantasy into it.  I got
this sun that's moving 360 degree around my scene.  It also got different
horizontal angle as it moves + different lighting color, etc, etc...  Do you
need more to exclude lightmaps?

Quote:

> Also, you say you want to do the lighting yourself, and you want OpenGL
> also to do the lighting for you at the same point....  I'm really
> confused about what exactly you are trying to achieve.

OpenGL calculates how lit a vertex is, THEN it mix that light with color and
textures.  Now if I could just tell OpenGL how lit a vertex is, THEN it
could mix that light with color and textures.  But it seems like I have to
tell my own program how lit a vertex is, THEN let my own program mix that
with color and textures.  Do you see my point?  The more of the lighting
calculation the hardware GPU does, the better...

BTW, it seems like my previous post ended a little to soon, so I just ask my
final question here:

It seem like I have to do all lighting myself by setting a vertex's color.
How do I mix a vertex's color so I can lit my terrain mesh when textured?
More specific:  How do I mix vertex colors and texture?

, Espen

 
 
 

Setting per-vertex light?

Post by Will » Mon, 30 Jun 2003 02:53:44


Quote:>Do you not read what I write?  Why do you think I want to use slope lighting
>for my terrain mesh?  People, please but a little fantasy into it.  I got
>this sun that's moving 360 degree around my scene.  It also got different
>horizontal angle as it moves + different lighting color, etc, etc...  Do you
>need more to exclude lightmaps?

Ummm...  Yes.  You can use colored or dynamic light maps, so I don't see why
you are rejecting them out of hand.  You can do your lighting calculations
however you want, store them into a texture, and let the GPU do the blending
for you.

Quote:>OpenGL calculates how lit a vertex is, THEN it mix that light with color and
>textures.  Now if I could just tell OpenGL how lit a vertex is, THEN it
>could mix that light with color and textures.  But it seems like I have to
>tell my own program how lit a vertex is, THEN let my own program mix that
>with color and textures.  Do you see my point?  The more of the lighting
>calculation the hardware GPU does, the better...

As has already been said, just multiply the lighting at a vertex by the vertex
color.  Trying to send two vertex colors to the GPU and have it do the multiply
would be wasteful of bandwidth to the card, and not overwhelmingly useful.

OpenGL will the multiply the texture by the single combined vertex color for
you, and it should look great.

Quote:>It seem like I have to do all lighting myself by setting a vertex's color.
>How do I mix a vertex's color so I can lit my terrain mesh when textured?
>More specific:  How do I mix vertex colors and texture?

>, Espen

OpenGL will mix the vertex color with the texture.  It's a very common
technique.
------------------
Woooogy
I have to go back in time to pretend to be myself when I tell myself to tell
myself, because I don't remember having been told by myself to tell myself.  I
love temp*mechanics.
 
 
 

Setting per-vertex light?

Post by MP » Mon, 30 Jun 2003 11:01:13



>It seem like I have to do all lighting myself by setting a vertex's color.
>How do I mix a vertex's color so I can lit my terrain mesh when textured?
>More specific:  How do I mix vertex colors and texture?

Simple, just set your vertex colors, enable your texture, set the texture
environment mode to GL_MODULATE, and draw the scene. The texture will then
be modulated by the vertex colors.

MP

 
 
 

Setting per-vertex light?

Post by Espen Ruud Schult » Tue, 01 Jul 2003 02:23:03




>> It seem like I have to do all lighting myself by setting a vertex's
>> color. How do I mix a vertex's color so I can lit my terrain mesh when
>> textured? More specific:  How do I mix vertex colors and texture?

> Simple, just set your vertex colors, enable your texture, set the texture
> environment mode to GL_MODULATE, and draw the scene. The texture will
> then be modulated by the vertex colors.

Thanx dude!  Finally I managed to produce a stright question, and someone to
give me a stright answer...

, Espen

 
 
 

1. Per vertex or per pixel lighting?

I've been led to believe that in typical realtime 3D engines (i.e.
games), all lighting is calculated per-vertex and then interpolated
across polys with gourad shading. If this is so, how do you shine a
spotlight on the middle of a large wall made of a single poly? Would the
engine divide the wall into lots of smaller polys?

Thanx

--

http://www.silencegreys.com/extension/

2. VM_ACTIVATE

3. Specify texture coords per polygon and not per vertex of a model

4. News for Digital Producers: Dec 2nd

5. triangles with per face normals SLOWER than per vertex normals

6. Animating gradients and/or gradient ramps

7. Light glow vs Light per surface

8. 1000 Windows

9. Setting up polygon given a set of vertices

10. (Vertex lighting vs lightmaps) and outside lighting

11. Texture per Vertex

12. RiPointsPolygons and per vertex normals

13. how many flops per vertex