这是我的代码:
import numba as nb
from ursina import *
from ursina.shaders import lit_with_shadows_shader
app = Ursina()
ground = Entity(
model = 'untitled.gltf',
z = 20,
y = -3,
collider = 'box',
shader = lit_with_shadows_shader
)
pivot = Entity()
AmbientLight()
DirectionalLight(parent=pivot, y=2, z=3, shadows=True)
EditorCamera()
sky = Sky()
app.run()我试图显示一个3D模型,我从sketchfab和没有shader = lit_with_shadows_shader它工作,但当我添加它,以使用环境光,它不显示纹理,它是模型,但它是白色的,没有任何表面。
发布于 2022-05-30 15:16:49
为您的实体使用此代码:
ground = Entity(
model = 'untitled.gltf',
z = 20,
y = -3,
collider = 'box',
texture = 'texture.png', # or load_texture('texture.png') : load texture
shader = lit_with_shadows_shader
)发布于 2022-08-22 14:07:08
您需要定义您的纹理,否则着色器将无法渲染的东西是没有定义的。
ground = Entity(
model = 'untitled.gltf',
texture = "yourTextureName", # Put your texture here
z = 20,
y = -3,
collider = 'box',
shader = lit_with_shadows_shader
)如果您没有纹理,您可以简单地添加颜色,如下所示:
ground = Entity(
model = 'untitled.gltf',
color = color.rgba(40,90,12,0.5) #This will be half transparent, to disable it change the 0.5 value to 1 or 0
z = 20,
y = -3,
collider = 'box',
shader = lit_with_shadows_shader
)您的最终代码应该是
import numba as nb
from ursina import *
from ursina.shaders import lit_with_shadows_shader
app = Ursina()
ground = Entity(
model = 'untitled.gltf',
texture = 'textureFileName.png',
z = 20,
y = -3,
collider = 'box',
shader = lit_with_shadows_shader
)
pivot = Entity()
AmbientLight()
DirectionalLight(parent=pivot, y=2, z=3, shadows=True)
EditorCamera()
sky = Sky()
app.run()发布于 2022-08-23 13:00:18
您缺少了texture,下面是您的代码:
import numba as nb
from ursina import *
from ursina.shaders import lit_with_shadows_shader
app = Ursina()
ground = Entity(
model = 'untitled.gltf',
z = 20,
y = -3,
collider = 'box',
texture='white_cude',
shader = lit_with_shadows_shader
)
pivot = Entity()
AmbientLight()
DirectionalLight(parent=pivot, y=2, z=3, shadows=True)
EditorCamera()
sky = Sky()
app.run()https://stackoverflow.com/questions/72383066
复制相似问题