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;
|
mod attachement;
|
||||||
use self::attachement::Attachement;
|
use self::attachement::Attachement;
|
||||||
|
|
||||||
const VERTEX_SOURCE: &str =
|
static VERT_SRC: &'static str = include_str!("shaders/base.vert");
|
||||||
"#version 450 core
|
static FRAG_SRC: &'static str = include_str!("shaders/base.frag");
|
||||||
|
|
||||||
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);
|
|
||||||
}";
|
|
||||||
|
|
||||||
//--Pipeline implementation-------------------------------------------------------------------------
|
//--Pipeline implementation-------------------------------------------------------------------------
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -93,13 +68,13 @@ where
|
|||||||
debug!("Compiling shaders...");
|
debug!("Compiling shaders...");
|
||||||
let mut compiler = shaderc::Compiler::new().ok_or("shaderc not found")?;
|
let mut compiler = shaderc::Compiler::new().ok_or("shaderc not found")?;
|
||||||
let vertex_compile_artifact = compiler
|
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",
|
"main",
|
||||||
None)
|
None)
|
||||||
.map_err(|err| {error!("{}", err);
|
.map_err(|err| {error!("{}", err);
|
||||||
"Could not compile vertex shader"})?;
|
"Could not compile vertex shader"})?;
|
||||||
let fragment_compile_artifact = compiler
|
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",
|
"main",
|
||||||
None)
|
None)
|
||||||
.map_err(|err| {error!("{}", err);
|
.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