pbr: add "shaded" field to StandardMaterial
This commit is contained in:
parent
031a0c6d58
commit
6022ad2c4f
@ -6,6 +6,9 @@ pub struct StandardMaterial {
|
|||||||
pub albedo: Color,
|
pub albedo: Color,
|
||||||
#[shader_def]
|
#[shader_def]
|
||||||
pub albedo_texture: Option<Handle<Texture>>,
|
pub albedo_texture: Option<Handle<Texture>>,
|
||||||
|
#[render_resources(ignore)]
|
||||||
|
#[shader_def]
|
||||||
|
pub shaded: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for StandardMaterial {
|
impl Default for StandardMaterial {
|
||||||
@ -13,6 +16,7 @@ impl Default for StandardMaterial {
|
|||||||
StandardMaterial {
|
StandardMaterial {
|
||||||
albedo: Color::rgb(1.0, 1.0, 1.0),
|
albedo: Color::rgb(1.0, 1.0, 1.0),
|
||||||
albedo_texture: None,
|
albedo_texture: None,
|
||||||
|
shaded: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,12 +33,14 @@ layout(set = 3, binding = 1) uniform sampler StandardMaterial_albedo_texture_sam
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 albedo = Albedo;
|
vec4 output_color = Albedo;
|
||||||
# ifdef STANDARDMATERIAL_ALBEDO_TEXTURE
|
# ifdef STANDARDMATERIAL_ALBEDO_TEXTURE
|
||||||
albedo *= texture(
|
output_color *= texture(
|
||||||
sampler2D(StandardMaterial_albedo_texture, StandardMaterial_albedo_texture_sampler),
|
sampler2D(StandardMaterial_albedo_texture, StandardMaterial_albedo_texture_sampler),
|
||||||
v_Uv);
|
v_Uv);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef STANDARDMATERIAL_SHADED
|
||||||
vec3 normal = normalize(v_Normal);
|
vec3 normal = normalize(v_Normal);
|
||||||
vec3 ambient = vec3(0.05, 0.05, 0.05);
|
vec3 ambient = vec3(0.05, 0.05, 0.05);
|
||||||
// accumulate color
|
// accumulate color
|
||||||
@ -51,7 +53,9 @@ void main() {
|
|||||||
// add light contribution
|
// add light contribution
|
||||||
color += diffuse * light.color.xyz;
|
color += diffuse * light.color.xyz;
|
||||||
}
|
}
|
||||||
|
output_color.xyz *= color;
|
||||||
|
# endif
|
||||||
|
|
||||||
// multiply the light by material color
|
// multiply the light by material color
|
||||||
o_Target = vec4(color, 1.0) * albedo;
|
o_Target = output_color;
|
||||||
// o_Target = vec4(v_Normal, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user