首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ursina引擎lit_with_shadows_shader当添加到三维模型时纹理消失

Ursina引擎lit_with_shadows_shader当添加到三维模型时纹理消失
EN

Stack Overflow用户
提问于 2022-05-25 19:16:03
回答 4查看 177关注 0票数 0

这是我的代码:

代码语言:javascript
复制
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它工作,但当我添加它,以使用环境光,它不显示纹理,它是模型,但它是白色的,没有任何表面。

EN

回答 4

Stack Overflow用户

发布于 2022-05-30 15:16:49

为您的实体使用此代码:

代码语言:javascript
复制
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
)
票数 0
EN

Stack Overflow用户

发布于 2022-08-22 14:07:08

您需要定义您的纹理,否则着色器将无法渲染的东西是没有定义的。

代码语言:javascript
复制
ground = Entity(
    model = 'untitled.gltf',
    texture = "yourTextureName", # Put your texture here
    z = 20,
    y = -3,
    collider = 'box',
    shader = lit_with_shadows_shader
)

如果您没有纹理,您可以简单地添加颜色,如下所示:

代码语言:javascript
复制
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
)

您的最终代码应该是

代码语言:javascript
复制
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()
票数 0
EN

Stack Overflow用户

发布于 2022-08-23 13:00:18

您缺少了texture,下面是您的代码:

代码语言:javascript
复制
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()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72383066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档