Why procedural models in Ursina are shaded differently

29 Views Asked by At

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"

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.

1

There are 1 best solutions below

0
Roman Rolinsky On

Adding a call to generate_normals() seems to fix the problem:

e = Entity(model=Cube(), x=-2, color=color.green)
e.model.generate_normals()