Hello.
i have one problem. I CAN'T MAKE MY DIRECTIONAL LIGHT BRIGHTER!!!
yeah thats it. i can figure out the rest, but i am using a directional light to give a nice avarage lighting, and I just can't figure out how to adjust the strength of the directional light. is there some trick to this? or am i just looking in the wrong location? it is also making my ground texture look really blue.
light.setLocation( new Vector3f( -100, -100, -100 ) );
light.setDirection(new Vector3f(0, -1, 0));
Doesn't really make sense to me, only a spot light has both location and direction.
Your problem is probably the material color, see MaterialState and adjust the ambient/diffuse/specular settings.
i have a fairly avarage lighting setup. one single directional lightpointing from the top down. but if its any help i'll post the code. what i am trying to say is, can i raise the strength of my light. just like if i where to put a more powerful light bulb into a lamp. i can't find anything that does this. and right now my entire game is very dim.
light.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) );
light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) );
light.setSpecular(new ColorRGBA(1.0f, 1.0f, 0.0f, 1.0f));
light.setLocation( new Vector3f( -100, -100, -100 ) );
light.setDirection(new Vector3f(0, -1, 0));
lightstate.setGlobalAmbient(new ColorRGBA(1,0.5f,0.5f, 1));
lightstate.setEnabled(true);
light.setEnabled(true);
lightstate.attach(light);
scene.setRenderState(lightstate);
scene.updateRenderState();
That will be a function of your material color/texture, the directional light's specular, diffuse, and ambient color, the direction of the light compared with the normals on your geometry, and the global ambient color on you LightState, and anything else I'm forgetting at the moment.
Posting the pertinent sections of code would help people help you better.
Cheers!
I noticed your diffuse color has 0.75f for the alpha component. Is that intentional? This may contribute to your problem a little bit.
Also, if this is truly your code, then you are using a PointLight not a DirectionalLight. Since you have set your location 100 units below the origin at (-100, -100, -100) and the direction is along the negative y-axis, that will mean anything above -100 on the y-axis will be very, very dark since the light isn't shining on it. Where is your geometry located in the world?
The other thing I notice is that your global ambient light will tend to give everything a reddish tint to it since the red component is twice either of the other two.
One last thought on the light, try turning attenuation off to make sure that's not causing issues. If that works, you may need to modify your attenuation function.
Other than that, you should look at your material states to make sure the colors are right.
That's all I got at the moment Let me know if that doesn't work.
that setLocation was a mistake in the code i sent. i began with a point light. then commented it out. i assure you i am using a directional light. it still seems odd to me to adjust light brightness by adjusting the material it reflects off of. there must be some other variable for brightness.
as for the global ambient. i kept getting a bluish tint on everything. so i tried to compensate for this by adding a reddish tint to everything. i guess i don't fully understand what each of these variables do.
my code is this without any alterations:
light.setDiffuse( new ColorRGBA( 0.75f, 0.75f, 0.75f, 0.75f ) );
light.setAmbient( new ColorRGBA( 0.5f, 0.5f, 0.5f, 1.0f ) );
light.setSpecular(new ColorRGBA(1.0f, 1.0f, 0.0f, 1.0f));
//light.setLocation( new Vector3f( -100, -100, -100 ) );
light.setDirection(new Vector3f(0, -1, 0));
//dl.setEnabled(true);
lightstate.setGlobalAmbient(new ColorRGBA(1,0.5f,0.5f, 1));
lightstate.setEnabled(true);
light.setEnabled(true);
lightstate.attach(light);
scene.setRenderState(lightstate);
scene.updateRenderState();
i also just tried to change the 0.75 alpha diffuse, and it didn't seems to change anything. it seems that everything i do makes no difference.
clwillingham said:
i have one problem. I CAN'T MAKE MY DIRECTIONAL LIGHT BRIGHTER!!!
i'd say you have two problems, the other being that your capslock button is stuck ;)
i know, CAPS LOCK IS CRUISE CONTROL FOR COOL! 8)
On to more serious matters:
set all your light colors to (1, 1, 1, 1);
Then you have the light as bright as possible and completely white
After that you can begin to play around with the MaterialState for your geometries.
Thats the way to get your light to maximum brightness, take it or leave it. :wink:
have a nice evening.
try doing a "light.setAttenuation(false)", shouldn't make a difference in this case, but you can double-check anyway
Also, try adding a box to your scene like the following:
Box b = new Box("TestBox", new Vector3f(-1,-1,-1), new Vector3f(1,1,1));
scene.attachChild(b);
scene.updateRenderState();
This should put a box at the origin, the top of the box facing the (0, 1, 0) should be bright white (since it's facing the light) while the other 5 sides should be darkish gray (due to the fact that they are not facing the light). If the box looks right, it's probably the materials in the rest of the scene, if not, then something else is going on preventing the light from reaching the objects in your scene.
Hope that helps!
Ok i just found the problem :D.
its quite simple. i was not using any material state. and i was using a quad for the ground. i learned that quads only have good lighting on one side. i don't know why but the other side was blueish. i did not have to add a box, because my game is already to a stage where it is supporting full blown levels. just no bad guys yet. thanks for all the help you have all provided. i hope to be able to finish this game some time, but i will not say anything about it in case it doesn't work (i have learned from other peoples doings that this is usually a good approach to game development).
Glad you solved the problem.
On a side note, by default all geometry is only lit on one side. This is because the normal vector (typically perpendicular to the surface in one direction) is a critical component in light calculations. If you want two sided lighting, I believe LightState.setTwoSidedLighting(true) will turn it on.
Enjoy writing your game! Hope to see it one day