Hello all! I’m working on the Solar System and I wanted to achieve sunlight effect.(I’m new to panda3d) So I put a PointLight in the Sun.
I used this code(seen in the manual):
plight = PointLight('plight')
plight.setColor((0.2, 0.2, 0.2, 1))
plnp = render.attachNewNode(plight)
plnp.setPos(10, 20, 0)
As you can see, the effect isn’t what I expected. Can somebody please help me to make sunlight?
You’ve set your sun’s colour to (0.2, 0.2, 0.2, 1)–which amounts to a very dim grey. That might be the reason that your light isn’t as expected!
To clarify, the values in each colour-channel for a light (i.e. red, green, blue, and alpha) run from 0 to 1, I believe, with 1 being “full intensity”.
I understand. I’ve deleted that line, now i can see things normally, but the shadows are on the opposite sides of the planets. And I can’t see the background. Any ideas why?
Your 3D planet collisions might possibly cause this. Is your light exactly centered in the middle of the sun?
Hmm… Is it possible that your planets are “inside out”? That is, that their surface-normals point inwards rather than outwards? That could produce a result such a this, I do think.
(Just in case, let me note that even if the models weren’t created that way, scaling them by a negative value can have the same effect, if I’m not much mistaken.)
Right now, it is centered in the exact middle of the sun.
Well, I don’t think that my planets are “inside out”. But in case i’m wrong, how can I check this?
And I have never tried to scale these planets by a negative value.
How did you create your planets?
If you used a modelling program (such as Blender or Maya), you should be able to check there. There should be an option somewhere about to show normals: if they’re pointing outwards from the surface, then you should be fine; of they’re pointing inwards, then there’s a problem.
I used Blender, I’ll check it.
They are pointing outwards.
Hmm… It’s likely not that, then!
One thought: I mentioned scaling, and you said that you weren’t scaling these models by negative values. Are you scaling anything by a negative value?
Otherwise, have you applied a “CullFaceAttrib” somewhere, perhaps?
If “no” to both, then I don’t know offhand what might be causing this issue. What happens if you load something like the default panda-model into your scene? (Scaling it up if called for.) Is it likewise incorrectly lit?
What happens if you move the light outside the sun? I personally suspect that the sun’s geometry is creating the shadows on the wrong side of the planets.
No to both, and I’ll try the panda model soon.
The effect is the same. Even for the sun. There are shadows, but on the wrong side.
I guess it’s your model then, if the stock 3D models work then I guess you could texture your spheres in Panda instead.
When I load the model, it has shadows on the right side. So I guess the problem is with the spheres, right?
There is no texture installed on these models in blender. I load textures in Panda3d.
Hmmm, so is your blender model just simply a sphere?