rust - 当通过“include_str!”包含游戏时,着色器会导致游戏崩溃。(贝维)
问题描述
我从https://github.com/bevyengine/bevy/blob/main/examples/shader/shader_custom_material.rs复制粘贴了着色器示例,效果很好。但是,我想将着色器放在它们自己的文件中,因此我不需要将它们内联在 rust 脚本中。
我尝试使用include_str!
将着色器文件包含为字符串,我认为这与在原始字符串文字中包含着色器相同,但是现在运行游戏时会发生此错误:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
Compilation("glslang_shader_preprocess:\nInfo log:\nERROR: #version: ES shaders for SPIR-V require
version 310 or higher\nERROR: 0:1: '#' : preprocessor directive cannot be preceded by another token
\nERROR: 2 compilation errors. No code generated.\n\n\nDebug log:\n\n")',
C:\Users\teevik\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_render-
0.5.0\src\pipeline\pipeline_compiler.rs:161:22
我正在使用 bevy 0.5,所有代码都在https://gist.github.com/teevik/e7f419231a529e777d20ace06cac80b7
解决方案
推荐阅读
- django - 无法显示图像
- android - Android TelephonyManager requestCellInfoUpdate 在 API 29 上返回过时数据
- css - 将 CSS 组件添加到 Qt QML
- javascript - 如何修复接口和类型?
- c++ - Cpp中的方法(void)怎么了?
- r - 如果观察到警告,则在 for 循环 [R] 中跳过迭代
- java - 如何告诉杰克逊在反序列化时忽略某些字段
- shopify - 如何将自定义 html 块添加到页脚选项列表中?
- python - 删除从 API python 中提取的部分引用
- php - 如何在 Laravel 路由页面中使用会话数据(auth)