Reputation: 21
I can't figure out how to make Ursina procedural models look the same as mesh-based models.
from ursina import *
from ursina import shaders
app = Ursina()
L1 = DirectionalLight(color=color.white)
L1.setHpr((0, 0, 0))
e = Entity(model=Cube(), x=-2, color=color.green)
e = Entity(model='cube', x=2, color=color.red)
_ed = EditorCamera(rotation_speed = 200, panning_speed=200)
app.run()
Produces the following result:
Green and red cubes but green is black"
What am I missing? Why is the green cube not lit by the directional light?
I have tried using different shaders included in Ursina but it did not solve the problem.
Upvotes: 1
Views: 72
Reputation: 1
Are you confused by the black color of the face on the right cube? Your light source is a directional projector (lamp). You illuminated one straight face on the red cube, but the light does not reach the green cube and the cube is black. Check:
from ursina import *
app = Ursina()
light = AmbientLight()
light.rotation = Vec3(0, 0, 0) # Setup light
e = Entity(model=Cube(), x=-2, color=color.green)
e = Entity(model='cube', x=2, color=color.red)
app.run()
you don't need to flip the normals, you need to set the light
Upvotes: 0
Reputation: 21
Adding a call to generate_normals() seems to fix the problem:
e = Entity(model=Cube(), x=-2, color=color.green)
e.model.generate_normals()
Upvotes: 1