1

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

teevik
  • 112
  • 1
  • 7
  • I think this should work. Are you sure the filepaths are correct? What output do you receive if you add `println!("{}", VERTEX_SHADER)`? – frankenapps Apr 18 '21 at 18:01
  • @frankenapps I'm pretty sure the filepaths are ok, there's no compilation errors from the `include_str!` macros When printing with ``` println!("Vertex Shader:"); println!("{}", VERTEX_SHADER); println!("Fragment Shader:"); println!("{}", FRAGMENT_SHADER); ``` it shows this: https://i.imgur.com/2DCBNVF.png – teevik Apr 18 '21 at 18:39
  • I've just tested your code and it works for me, it draws a nice green square. I would suggest to start a new project and copy the files one by one. – rodrigo Apr 19 '21 at 07:53

0 Answers0