Shader crashes the game when including it through "include_str!" (bevy)

391 Views Asked by At

I copy-pasted the shader example from https://github.com/bevyengine/bevy/blob/main/examples/shader/shader_custom_material.rs which worked well. However, I want to put the shaders in their own files so I don't need to have them inline in the rust script.

I tried using include_str! to include the shader file as a string, which i thought would do the same as having the shader in a raw string literal, however now this error happens when running the game:

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

I'm using bevy 0.5, and all the code is at https://gist.github.com/teevik/e7f419231a529e777d20ace06cac80b7

0

There are 0 best solutions below