adding a solid shader
parent
fb45873c81
commit
c676907f65
@ -0,0 +1,19 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
// I don't know what these inputs actually are, but the shader doesn't compile
|
||||||
|
// if we don't actually consume them. It doesn't seem to matter what type I use
|
||||||
|
// to describe each field, so I just picked vec2.
|
||||||
|
//
|
||||||
|
// I think these are probably declared in the derived AsBindGroup trait that
|
||||||
|
// binds data between the Rust application and the shader?
|
||||||
|
layout(location = 0) in vec2 _;
|
||||||
|
layout(location = 1) in vec2 _;
|
||||||
|
layout(location = 2) in vec2 _;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 o_Target;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
o_Target = vec4(1.0, 0.0, 1.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// vim: set ft=glsl:
|
@ -0,0 +1,3 @@
|
|||||||
|
mod solid;
|
||||||
|
|
||||||
|
pub use solid::SolidMaterial;
|
@ -0,0 +1,34 @@
|
|||||||
|
use bevy::{
|
||||||
|
pbr::{Material, MaterialPipeline, MaterialPipelineKey},
|
||||||
|
reflect::TypeUuid,
|
||||||
|
render::{
|
||||||
|
mesh::MeshVertexBufferLayout,
|
||||||
|
render_resource::{
|
||||||
|
AsBindGroup, RenderPipelineDescriptor, ShaderRef, SpecializedMeshPipelineError,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(AsBindGroup, Clone, TypeUuid)]
|
||||||
|
#[uuid = "6dd176cf-c8c2-4cc5-8163-0df87c53139a"]
|
||||||
|
pub struct SolidMaterial {}
|
||||||
|
|
||||||
|
impl Material for SolidMaterial {
|
||||||
|
fn fragment_shader() -> ShaderRef {
|
||||||
|
"shaders/solid.frag".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn specialize(
|
||||||
|
_: &MaterialPipeline<Self>,
|
||||||
|
descriptor: &mut RenderPipelineDescriptor,
|
||||||
|
_: &MeshVertexBufferLayout,
|
||||||
|
_: MaterialPipelineKey<Self>,
|
||||||
|
) -> Result<(), SpecializedMeshPipelineError> {
|
||||||
|
let mut frag = descriptor
|
||||||
|
.fragment
|
||||||
|
.as_mut()
|
||||||
|
.expect("should have a fragment entry point here");
|
||||||
|
frag.entry_point = "main".into();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue