You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS M3 Pro下Ursina Engine GLSL着色器版本兼容问题求助

Ursina在MacOS M3 Pro上光照失效及GLSL版本兼容问题解决

问题场景

在MacOS M3 Pro设备的虚拟环境中全新安装Ursina后,运行以下基础光照场景代码时,所有对象呈黑色,光照无法正常工作:

from ursina import *

class Pivot(Entity):
    def update(self):
        self.rotation_y += time.dt * 30

def show():
    app = Ursina(development_mode=True)
    EditorCamera()

    main_light = DirectionalLight()
    main_light.look_at(Vec3(-1, -1, -1))
    main_light.color = color.white

    cube = Entity(model='cube', scale=1)

    camera.parent = Pivot()
    camera.position = (0, 2, -20)
    camera.look_at(Vec3(0, 0, 0))

    app.run()

show()

控制台输出报错:

application successfully started
:display:gsg:glgsg(error): An error occurred while compiling GLSL vertex shader created-shader:
ERROR: created-shader:1: '' : version '130' is not supported
:display:gsg:glgsg(error): An error occurred while compiling GLSL fragment shader created-shader:
ERROR: created-shader:2: '' : version '140' is not supported

解决方法

方法1:启用OpenGL核心配置初始化Ursina

修改Ursina初始化代码,添加opengl_core_profile=True参数,强制使用兼容Mac的OpenGL核心配置:

app = Ursina(development_mode=True, opengl_core_profile=True)

方法2:指定兼容的OpenGL版本环境变量

在代码开头添加环境变量设置,指定Mac支持的OpenGL版本:

import os
os.environ['PANDASSL_OPENGL_VERSION'] = '3.2'

from ursina import *
# 后续代码保持不变

方法3:手动指定兼容着色器

给实体指定Ursina内置的兼容光照着色器,替换默认的自动生成着色器:

cube = Entity(model='cube', scale=1, shader=lit_with_shadows_shader)

若仅需测试对象是否正常显示,可先使用基础着色器:

cube = Entity(model='cube', scale=1, shader=basic_shader)

方法4:安装Ursina最新开发版

官方可能已修复M系列Mac的兼容问题,通过Git安装最新开发版本:

pip install git+https://github.com/pokepetter/ursina.git

内容的提问来源于stack exchange,提问作者AG-88301

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 05:12:11