Merge branch '8-move-shader-codes-to-separate-files' into 'dev'
Resolve "Move shader codes to separate files" See merge request Steins7/iv!5
This commit is contained in:
commit
b8dd1890f7
@ -15,33 +15,8 @@ use super::{
|
||||
mod attachement;
|
||||
use self::attachement::Attachement;
|
||||
|
||||
const VERTEX_SOURCE: &str =
|
||||
"#version 450 core
|
||||
|
||||
layout (location = 0) in vec2 position;
|
||||
layout (location = 1) in vec3 color;
|
||||
|
||||
layout (location = 0) out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
layout (location = 1) out vec3 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
frag_color = color;
|
||||
}";
|
||||
|
||||
const FRAGMENT_SOURCE: &str =
|
||||
"#version 450 core
|
||||
|
||||
layout (location = 0) out vec4 frag_color;
|
||||
layout (location = 1) in vec3 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(color, 1);
|
||||
}";
|
||||
static VERT_SRC: &'static str = include_str!("shaders/base.vert");
|
||||
static FRAG_SRC: &'static str = include_str!("shaders/base.frag");
|
||||
|
||||
//--Pipeline implementation-------------------------------------------------------------------------
|
||||
#[derive(Debug)]
|
||||
@ -93,13 +68,13 @@ where
|
||||
debug!("Compiling shaders...");
|
||||
let mut compiler = shaderc::Compiler::new().ok_or("shaderc not found")?;
|
||||
let vertex_compile_artifact = compiler
|
||||
.compile_into_spirv(VERTEX_SOURCE, shaderc::ShaderKind::Vertex, "vertex.vert",
|
||||
.compile_into_spirv(VERT_SRC, shaderc::ShaderKind::Vertex, "vertex.vert",
|
||||
"main",
|
||||
None)
|
||||
.map_err(|err| {error!("{}", err);
|
||||
"Could not compile vertex shader"})?;
|
||||
let fragment_compile_artifact = compiler
|
||||
.compile_into_spirv(FRAGMENT_SOURCE, shaderc::ShaderKind::Fragment, "fragement.frag",
|
||||
.compile_into_spirv(FRAG_SRC, shaderc::ShaderKind::Fragment, "fragement.frag",
|
||||
"main",
|
||||
None)
|
||||
.map_err(|err| {error!("{}", err);
|
||||
|
||||
10
src/renderer/shaders/base.frag
Normal file
10
src/renderer/shaders/base.frag
Normal file
@ -0,0 +1,10 @@
|
||||
#version 450
|
||||
|
||||
layout (location = 0) out vec4 frag_color;
|
||||
layout (location = 1) in vec3 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4(color, 1);
|
||||
}
|
||||
|
||||
16
src/renderer/shaders/base.vert
Normal file
16
src/renderer/shaders/base.vert
Normal file
@ -0,0 +1,16 @@
|
||||
#version 450
|
||||
|
||||
layout (location = 0) in vec2 position;
|
||||
layout (location = 1) in vec3 color;
|
||||
|
||||
layout (location = 0) out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
layout (location = 1) out vec3 frag_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
frag_color = color;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user