Any help with lighting?

Started by sergicion, November 25, 2012, 11:35:31

Previous topic - Next topic

sergicion

Hello! I'm newbie, and I'm not English, so maybe you can't understand me at all.

My question is this: what can I do to enable a sunlight? I'm trying to do something like this (with shadows too):

Fool Running

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

sergicion

Quote from: Fool Running on November 26, 2012, 14:34:26
Google is your friend. ;D
I search it but I don't get any result for global light...

OverBlob

Yeah CubeWorld will be a nice game!
There is nothing such as a "sun light enabling" in OpenGL, however you can make the sun lighting effect with lighting shaders. Have you ever heard about ADS Lighting? ADS stands for Ambient light, Diffuse light and Specular light of an object, which compose the three classic main caracteristics of a light source.
If you are not familiar with shader programming, I invite you to learn how it works: you can see basic implementation on the LWJGL wiki and you can learn how to make ADS shaders with OpenGL SuperBible (I use the 5th edition, and chapter 6 deals with lighting :)).

sergicion

Quote from: OverBlob on November 27, 2012, 18:30:06
Yeah CubeWorld will be a nice game!
There is nothing such as a "sun light enabling" in OpenGL, however you can make the sun lighting effect with lighting shaders. Have you ever heard about ADS Lighting? ADS stands for Ambient light, Diffuse light and Specular light of an object, which compose the three classic main caracteristics of a light source.
If you are not familiar with shader programming, I invite you to learn how it works: you can see basic implementation on the LWJGL wiki and you can learn how to make ADS shaders with OpenGL SuperBible (I use the 5th edition, and chapter 6 deals with lighting :)).
I'm Spanish and I don't know what is specular, diffuse and ambient. Are they colors?

paandar

I think you have a long road to travel...

I suggest you to start reading NEHE tutorials, they are an axcellent source of info, here is the link to lighting stuff:

http://nehe.gamedev.net/tutorial/texture_filters,_lighting_&_keyboard_control/15002/

Good luck ;)

OverBlob

Quote from: sergicion on December 04, 2012, 17:37:32
I'm Spanish and I don't know what is specular, diffuse and ambient. Are they colors?

Indeed, specular, diffuse and ambient represent the "colors" of an object but are linked to its lighting:
-Ambient is the base color of the object, that is to say: its color when it is not lit.
-Diffuse is roughly speeking the color of the light which enlighten the object, its resulting color at this point will be the sum of ambient and diffuse colors.
-Specular represents the color of the shiny reflection of the light source on the object.

All this components are added in the ADS light shader to light the object.

note: I'm french and I didn't know anything about lighting few month ago, that required me consequent work to make it through :P

As an advice, try to find good tutorials suites to learn basics of openGL programming and shaders, there is really A LOT to learn, but it is sooo exciting  :D.

NEHE tutorials seems to be very good references. However I heard that thoose tutorials are becoming quiet obsolete as they don't deal with openGL core profile (<- you can google that if you're not familiar yet).
Personnaly I learn openGL with the last edition of the openGL super bible, and there is very useful information about all that!  :)

I also found this link on the NEHE site that could be good to try:
http://www.opengl-tutorial.org/

sergicion

Oh, lots of thanks. Any tutorial that explains the sunlight? This is my last request, please.

OverBlob

(hope that you understood that "sunlight" source is exactly like any other light sources excepted the fact that it is more more faraway from your scene, and can be handeled by ADS lighting model (or Phong lighting model))

Well, I found this tutorial on the net: http://www.falloutsoftware.com/tutorials/gl/gl8.htm

Seems that it explains ADS lighting without using shaders, ie: with the old OpenGL specification, and propose kind of "light enabling".
I admit that I don't really know (and want to know) how it works as I began to learn OpenGL with the 3.1 specification. But if you're not enough comfortable with shader programming it could be rather straighforward for you...

(note: GL_Lighting and the associated functions in this tutorial are deprecated in OpenGL 3.0 version and have been removed from core OpenGL 3.1 and above. So it is recommended that you not use thoose functionalities in your programs(quote from: http://www.opengl.org/wiki/How_lighting_works))

Otherwise learn how to make shaders, how to extract normals of your surfaces, then have a look to this: http://www.matrix44.net/cms/notes/opengl-3d-graphics/the-ads-lighting-model  ;D)

Good luck!  :)