lighting experiments with vertex color

Community Forums/Showcase/lighting experiments with vertex color

RemiD(Posted 2015) [#1]
I have done some tests to build (with code) structures which could be inhabited by humans, and i have colored the outside and the inside of each room by using vertex color.


and for those who have a fast enough connection :
rd-stuff.fr/lighting-experiments-with-vertex-color-640x480-10fps-HQ.gif

I like the render even if the structures look too identical for the moment, i need to add more stuff outside and inside each structure.

Not sure what i am going to do with this, my initial plan was to see if it was easier to build a village with code instead of with a modeling tool, and here i am...


AdamStrange(Posted 2015) [#2]
looking interesting.

I would suggest adding a sky or graded background to make the building "pop" more

currently I find the buildings too indistinct and dark


RGR(Posted 2015) [#3]
Hey, this is a concept - not a finished program. It shows what it shall show (especially the gif) and its a great idea to build on!

Why is it that someone always has to moan and give smart advice on things which have nothing to do with the subject.

Although this looks as a personal insult ... it is NOT ...

Sorry AdamStrange to use your post to make my remark ... go to any thread (Yues mars project, etc.) Someone always makes remarks which are not helpful at all. I.e. a bloke wants to help and gets the remark: "Your Lander looks like a Toy compared to Yues" ... I bet the helping demo was not intendet to make a better project than the original ... very motivationg to help again ...

It just doesn't feel good to read such things ...


Ploppy(Posted 2015) [#4]
I personally welcome critisism on my own projects as long as it is constructive. It helps me to see stuff that sometimes I unintentionally didn't see in the past. However, I do agree that some critisisms do go too far. Like you said, on Yue's thread some of the comments were not constructive at all and were just basic nitpicking. I think that what Yue has done so far is very very promising indeed. And some good gfx thrown in too.

@Remid - nice neony effect there. Be good to see more...


RemiD(Posted 2015) [#5]
@AdamStrange>>This is a "raw" test made in a few hours so yes it is too empty for the moment.
About the buildings and ground being too dark, this is because it is supposed to be at night.

@RGR>>I don't mind critics if they are fair, that's ok.


I thought that it was interesting to show how the looks of a scene can be improved only by using vertex color.

I have played Tenchu 1 recently and i have found the lighting nice (many lights in the scene without shadows). I think that they probably used per texel lighting (lightmap textures) but i wanted to show that a similar lighting can be achieved with vertex color if the meshes are subdivided (each 1.0 unit in this case)

Now the problem when you subdivide meshes is that there are more triangles (sometimes too many!) in the scene, so here are some ideas :
- currently each building (tower) is one mesh with one surface
what i want to try :
- divide each building into 2 separate meshes, one for the exterior, one for the interior.
when the camera is far enough from a building, only show the mesh of the exterior of the building and a kind of quad of the same color than the lighting inside the building so that the player thinks he can see inside even if he doesn't,
when the camera is near enough from a building, show the exterior and the interior of the building,
when the camera is inside the building, show only the interior of the building
- if the buildings are all oriented the same way, maybe separate each side of a building in one mesh (wallfront, wallback, wallleft, wallright, floor, ceiling), and depending on the orientation of the camera, show only the necessary meshes...

The idea is to have the minimum number of surfaces but also the minimum number of vertices and triangles per surface.


Steve Elliott(Posted 2015) [#6]
Yes, this seems to be the current (annoying) trend on this forum. Somebody throws an early work in progress picture, which somebody else pulls apart - even though it's just a proof off concept or very early prototype.

*However* I think Adam was fine with his comment...Just maybe peeps are getting sensitive because of all the negative feedback floating around here.


RemiD(Posted 2015) [#7]
Personally, if the critic is justified and reasonable, i think this is ok.


RGR(Posted 2015) [#8]
Ah you like fair critics? Ok here it is ...

There are no tables and chairs in these rooms. no pictures on the walls. It looks all so dull. No people in there. No TV as in every home. No-one is talking - I expect at least some little action.
And then: No cars in the streets - so the lights on the roads are missing - such a dead scene ... and you want to impress someone?

LOL

Honest - as Steve Elliot also said - its the trend which is annoying. Everyone wants to put his persanal views into things which are just fine as they are. And many things are due to language differences rather unmotivating even if they are not meant as that.

Of course do I also have peronal wished for every thing. But I do not have the right to moan over a thing which is meant as a demo and only wants to give good advice for further development.

Yeah ... without cars which blink when they change the line and that uninspired flying camera without turns and floats like in a Tomb Raider Trailer the complete scene above is completely dull ... erm ... too indistinct and dark ... and this is only fair critisism

;-)


RemiD(Posted 2015) [#9]
"Fair" was probably not the appropriate word...

I agree with you that each person has his own tastes and views about something and it is useless and not appreciated to push your tastes/views to somebody else but i also think that the "technical critics/suggestions" are useful and appreciated. (at least for me)

What i mean by "technical critics/suggestions" :
the weird things (possible errors) that you see as a programmer/3d modeler/uvmapper/texturer/rigger/skinner/animator that another person may not see (unwanted gaps between some triangles, weird normals, uv errors, bad skinning, unconvincing animation, collisions failures, inconsistency with shape style or color style in the world, weird lighting and shadows, luminosity too low too high, sound too low too high, unexpected actions turns moves animations with some controls, weird behavior of ai in some cases, weird program flow, bugs, incompatibilities issues, program stuck in some cases, etc...)

And all these things are not a matter of personal tastes !

edit:
So in this case, from your comments, i can improve a few "technical" things :
-maybe add more luminosity in the scene
-have a less jerky camera movement
-provide an animated gif/video with more fps (maybe 10fps ?)

And yes this demo is empty, it is wip, the intent was to demonstrate how it is possible to add nice lighting with vertex color only. Anyway i understand your message.


Rick Nasher(Posted 2015) [#10]
Ah.. missed this one. For what it's worth I think it's a pretty good demo of what's possible. Also read your post Light a scene with DirectX7 vertex lighting or with LightMesh vertex lighting.

I myself was looking into lighting for the past few days. Never did before(shame on me). I wrongfully thought that without any lights in a Blitz3d scene the whole thingy would appear dark as if night, thinking would be easy to emplement a day-night cycele. How wrong can you be? ;-)

This caused me to delve into the realm of lightmappers, illumination etc and came to the conclusion that one needs to set up the scene pretty dark from the start or use a lightmapper to implement lights and shades. Whish I'd known that from the start cos lots of lightmappers fail to load my mesh(complex building in 3ds/b3d).


RemiD(Posted 2015) [#11]

I wrongfully thought that without any lights in a Blitz3d scene the whole thingy would appear dark as if night


I also make mistakes and learn everyday, this is how we progress i suppose...


Do you understand the difference between vertex lighting and texel lighting ?

Vertex lighting affects the vertices of a surface, it can produce very nice shades if the surface is subdivided enough (so that the edge of a triangle is, for example, maximum 0.5unit). With this technique, it is very fast to light a surface (because there are not many vertices).

a DirectX light is vertex lighting
Lightmesh is vertex lighting
Coloring the vertices with vertexcolor is vertex lighting (for example i have created a function "LightSurface" similar to lightmesh but to light only a surface of a mesh, not all surfaces of a mesh)

Texel lighting affects the texels of a texture, it can also produce very nice shades and the surface does not need to be subdivided, but the "texels filling" (the process to define how many texels will be in the triangle depending on its width height in the world) must give enough texels in each triangle (so that there is, for example, one texel each 0.1unit), and the uvmapping must be clean so that no triangles overlap and are packed optimally. With this technique, it can be slow to light a surface (because there can be many texels).

"lightmapping" is texel lighting

These 2 techniques are ideal for static lighting and usually a directx light or lightmesh or entitycolor is used to light the turning moving entities (characters, vehicles, weapons, projectiles)

Note that these techniques can be used only for lighting (without shadows), or for lighting with shadows.

I hope this clarifies a bit how lighting can be done with Blitz3d...


Krischan(Posted 2015) [#12]
For static lighting I've made an experiment with DOT lights last year:

http://www.blitzbasic.com/Community/posts.php?topic=103075#1238557


Bobysait(Posted 2015) [#13]
Good starting point.

My 2 cents : (that's a <If I Were You> statement)
There is many approachs you could consider for coloring instead of using the "vertex-color-only" method.
Using a 1*1 pixel texture(*), you could paint your vertex in grey scale only and apply the diffuse color on the texture

the reason of this is the extension in later future :
- if you want a night/day cycle, you 'll have to update each vertex to modify its color (consume the cpu)
With a texture you'll have only one pixel to modify
- if you want to create a large city, you'll want to use copy (else, you'll drastically consume your ram and vram). With vertex color, you won't be able to get a copy with a different color
With a 1*1 texture applied on a brush, you can paintentity (and this apply to the entity, not the mesh, so a mesh and its copy can share vertex data without sharing the brush material) Then you have one 1*1 texture for each room

Of course if there is no need to extend the demo, then there is no need for extra stuff to manage lighting.

(*)In a different engine we could have use a brush only (without the need for a texture) but blitz3d does not compute vertex-color and brush-color it's one or the other but not both.


ps : IMHO, AdamStrange was right, and there is no need to consider his comment as "not helpfull/bad critics"
It's a demo to show the stuff ? So the black background does not help to show the volumes. That's relevant, and maybe some of you just forgot that all the monitors have not the same brightness.
On my laptop, the screen is just some small part colors with saturated colors and the rest is almost black. On the desktop computer, the monitor shows better the shapes.
So maybe just a background color to share the screenshot would actually be a good idea.

BTW, we are on a programming site, not on deviant-art. We are here to share and learn, not just to hear people say "Oh, you're sooooo amazing"
Maybe for some people here, it's just time to grow up a little bit and think about we won't progress if we don't accept the critics.

<<looking interesting.>>
That's true, and it's the smart part.

<<I would suggest adding a sky or graded background to make the building "pop" more
currently I find the buildings too indistinct and dark>>
It says what, it says why and it says how to fix it.
That's just a relevant and constructive comment, not just an opinion like "I like the look/I don't like" (and that, for sure, we don't care ^^).


RemiD(Posted 2015) [#14]
... (double post)


RemiD(Posted 2015) [#15]
I accept critics if they are not about your personal tastes (because we all have different tastes...)

I take note of your critic of the non lighted sides being too dark depending on your gpu/screen/configuration, but i have tested it on different computers that i have here and even with half the luminosity i still see the difference between the non lighted sides and the black background.

This is indeed a problem, because i want to convey a dark night with a weak luminosity (only the light from the sun reflected on the moon) (the ambientlight is 15,15,15 in this scene), but i also want the users to be able to see what is going on.


RemiD(Posted 2015) [#16]

if you want to create a large city, you'll want to use copy (else, you'll drastically consume your ram and vram).


about this, you may be interested by my post here :
http://www.blitzbasic.com/Community/posts.php?topic=104500


Bobysait(Posted 2015) [#17]
The problem related with the luminosity comes from many labtop. They have darker contrast and luminosity tilts when you're not exactly in front of the screen (you might need to flip the screen to actually see the dark areas brighter)

But here, what you're trying to do does not involve a dark color theme, you're looking for a dark ambiance. You can achieve this using some depth in the saturation and brighter color tones which will allow to get darker areas where it's actually darker. Else, everything will be a pain to work on because the base is probably too dark.
Don't know if I'm clear, but ... as I know you're french ;)

Plus la base est noire, moins t'auras de choix de contraste pour faire ressortir des éléments de décor (j'imagine que tu vas pas juste faire des cubes pour la ville, et t'auras besoin de jouer sur la saturation ET sur le contraste, sans quoi t'auras du très noir sur un poil moins noir, et au final tu verras pas grand chose)

Si tu remontes un peu la luminosité ambiante, t'auras d'avantages de contraste et tu peux ajouter le côté lugubre en jouant sur des teintes de gris cumulés à une couleur ambiante ce qui assombrira sans perdre de profondeur dans la 3D

par exemple

la scene est très claire en réalité, mais ça fait sombre et c'est très lisible.

ps : Je vais jeter un oeil à ton lien plus tard ;)


RemiD(Posted 2015) [#18]
Je vois ce que tu veux dire, mais un peu extrême ton exemple... Je vise plutot une ambiance similaire à tenchu 1 2 ou thief 1 2 3, assez sombre.

La démo ci dessus était juste pour illustrer qu'il est possible d'illuminer un extérieur (terrain) et des intérieurs (batiments), avec plein de couleurs différentes sans utiliser du texels lighting (lightmapping) et sans utiliser de lights directx 7, juste en colorant les vertices.

Je compte bien ajouter un ciel et des choses au lointain.



[OT]
Du coup tu as finis ton jeu ? Ou tu as changé de projet de jeu ?
(moi même j'en ai commencé plusieurs... Des fois j'arrête parce que ça me gonfle (créer des maps), ou parce que je n'ai plus d'intérêt/motivation pour le sujet, ou parce que je n'ai pas assez de temps et d'énergie (après le taf), donc je rame, mais je m'y remet de temps en temps...)
[/OT]


Krischan(Posted 2015) [#19]
Well, for procedural cities with lighting I found a nice tutorial some time ago, there is even a video, a screensaver application and the source (in C) available:

http://www.shamusyoung.com/twentysidedtale/?p=2940




Rick Nasher(Posted 2015) [#20]
Appears lighting is much more tricky than I initially thought. Thanks for the explanations RemiD.

I'm actually trying to light a building mesh in "free" roaming terrain, limited to like, say an industrial zone, so not a very large open world.

I want:
-shaded areas, like basements, elevators.
-a day night cycle.
-ability to light surfaces with flashlights, explosions, flickering TL's etc.
-no cut scenes.

Perhaps I'm pushing it as I'm rather inexperienced on the subject, but so far so good I'd say. But I noticed ambient light hardly seems to influence the building.

I initially thought that turning down the ambient light would make a whole scene dimmed and I could then just use spotlights, but apparently this is not how it works. From code examples such as the well-known(and excellent) cubed demo by by Rob Cummings, I now get that one needs to set up the scene pretty dark to begin with in the 3d modeler or use a light mapper to dim/apply the shading otherwise the colors of the textures will appear bright always. (Bummer: back to the drawing board)
Anyway many thanks again for explaining the lighting techniques.


RemiD(Posted 2015) [#21]
@Krischan>>Frankly, this procedural city looks nice but it is empty, the buildings are made with random shapes, without taking into account the possibility to go inside (there is no interior) or the purpose of the buildings/rooms, so it is not what i want to achieve. It may be useful for a plane game...


RemiD(Posted 2015) [#22]
@Rick>>I suggest to consider shadows as a separate step in the process of lighting, first you want to light each area (terrain, room) with one or several light and ambientlight (you can consider the ambientlight as the light which is reflected from the reached faces to others faces and which adds lighting to all faces even those which can't be reached directly by the light vector)
You can always add shadows later with another texture (lightmap) or with FastExtShadows or with SwiftShadowsSystem with DevilShadowsSystem.

For the lighting you can use directx 7 lights, or lightmesh, or custom vertex lighting, or custom texel lighting.
But the problem with directx7 lights is that the light will light all surfaces, all faces which are in the scene, so there will be some weird and unwanted blends of colors.
In this demo, the exteriors are only lighted with one omnilight + the ambientlight which corresponds to the moonlight and the ambientlight outside, and each interior is only lighted with one omnilight + the ambientlight which corresponds to the roomlight and the ambientlight inside the room.

For your wants, you can probably use an existing lightmapper (3DWorldStudio, Giles, YAL), or a custom texel lighting routine, or lightmesh, or a custom vertex lighting routine, for the static environments, and directx 7 lights or lightmesh or entitycolor for the turning moving things.
There is not a perfect answer, it depends on your understanding, capabilities, preferences...

For example, in Deus ex 1 or Thief 1 2, they seem to use a combination of premade lightmaps (texels lighting) for the static environments and directx 7 lights or a custom vertex lighting for the turning moving things.

For YAL :
http://www.blitzbasic.com/codearcs/codearcs.php?code=794
http://www.blitzbasic.com/codearcs/codearcs.php?code=525
http://www.blitzbasic.com/codearcs/codearcs.php?code=514
http://www.blitzbasic.com/codearcs/codearcs.php?code=502
http://www.blitzbasic.com/codearcs/codearcs.php?code=432

Also this effect can be added to the mix : http://www.blitzbasic.com/codearcs/codearcs.php?code=1000


AdamStrange(Posted 2015) [#23]
@RemiD
Whilst watching this thread and what you have been doing something sparked in my mind:
Currently I am dealing with lighting in the vertex shader, I hadn't considered using the vertex colours to recalculate lighting?

In a low-poly setting, this could be all offloaded to a vertex shader giving a (hopefully) biggish speed bump :)

It would also mean I could pump in some custom lighting system as well - hmm You've given me some good ideas :)

Oh, and while i'm at it - I have a reasonable solution for the dark look of the first image:
I'm on a mac.
When I worked on windows (in publishing) - I needed to have a very un-windows color setting for my monitors to keep graphic fidelity with onscreen and print. The mac doesn't have this issue - so it's monitor colour are naturally darker looking.
So you come from windows and the image looks great - I view on mac and say it looks dark. I think It's the OS settings not us? ;)


RemiD(Posted 2015) [#24]

 I have a reasonable solution for the dark look of the first image:I'm on a mac.When I worked on windows (in publishing) - I needed to have a very un-windows color setting for my monitors to keep graphic fidelity with onscreen and print. The mac doesn't have this issue - so it's monitor colour are naturally darker looking. So you come from windows and the image looks great - I view on mac and say it looks dark. I think It's the OS settings not us?


It may be because of the os settings but also because of hardware, some screens seem to produce a more clear or a more obscure image...
I don't see a solution except to give the possibility to the user to set the luminosity he wants...


RemiD(Posted 2015) [#25]

Using a 1*1 pixel texture(*), you could paint your vertex in grey scale only and apply the diffuse color on the texture
the reason of this is the extension in later future :
- if you want a night/day cycle, you 'll have to update each vertex to modify its color (consume the cpu)
With a texture you'll have only one pixel to modify


@Bobysait>>
I have just reread your post and seen this idea, this is smart and surely faster than having to browse all vertices and to modify the color of each vertex. Good idea, Thanks.