-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - Add PBR textures #1632
Changes from all commits
d9f3e7b
d7d3da9
589c4af
b82a10e
c8aeaf5
8f0d0f7
be39bed
c2e0ac2
71ea60c
ffee787
ed834fb
3983fc1
ba5f765
00b03a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ use crate::{ | |
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode, | ||
UniformProperty, VertexAttribute, VertexBufferLayout, VertexFormat, | ||
}, | ||
shader::{ShaderLayout, GL_INSTANCE_INDEX, GL_VERTEX_INDEX}, | ||
shader::{ShaderLayout, GL_FRONT_FACING, GL_INSTANCE_INDEX, GL_VERTEX_INDEX}, | ||
texture::{TextureSampleType, TextureViewDimension}, | ||
}; | ||
use bevy_core::AsBytes; | ||
|
@@ -33,6 +33,7 @@ impl ShaderLayout { | |
for input_variable in module.enumerate_input_variables(None).unwrap() { | ||
if input_variable.name == GL_VERTEX_INDEX | ||
|| input_variable.name == GL_INSTANCE_INDEX | ||
|| input_variable.name == GL_FRONT_FACING | ||
{ | ||
continue; | ||
} | ||
Comment on lines
33
to
39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might misunderstand the point of this condition, if so I'd love to learn. But wouldn't a more long-term solution be (snipped some diff --git a/crates/bevy_render/src/shader/shader_reflect.rs b/crates/bevy_render/src/shader/shader_reflect.rs
index 238da1ef..95761fed 100644
--- a/crates/bevy_render/src/shader/shader_reflect.rs
+++ b/crates/bevy_render/src/shader/shader_reflect.rs
@@ -31,8 +32,9 @@ impl ShaderLayout {
// obtain attribute descriptors from reflection
let mut vertex_attributes = Vec::new();
for input_variable in module.enumerate_input_variables(None).unwrap() {
- if input_variable.name == GL_VERTEX_INDEX
- || input_variable.name == GL_INSTANCE_INDEX
+ if input_variable
+ .decoration_flags
+ .contains(ReflectDecorationFlags::BUILT_IN)
{
continue;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oooh that does seem like a win / appears to do what we want it to. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
use bevy::prelude::*; | ||
use bevy::{pbr::AmbientLight, prelude::*}; | ||
|
||
fn main() { | ||
App::build() | ||
.insert_resource(AmbientLight { | ||
color: Color::WHITE, | ||
brightness: 1.0 / 5.0f32, | ||
}) | ||
.insert_resource(Msaa { samples: 4 }) | ||
.add_plugins(DefaultPlugins) | ||
.add_startup_system(setup.system()) | ||
.add_system(rotator_system.system()) | ||
.run(); | ||
} | ||
|
||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { | ||
commands.spawn_scene(asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0")); | ||
commands.spawn_bundle(LightBundle { | ||
transform: Transform::from_xyz(4.0, 5.0, 4.0), | ||
..Default::default() | ||
}); | ||
commands.spawn_bundle(PerspectiveCameraBundle { | ||
transform: Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), | ||
..Default::default() | ||
}); | ||
commands | ||
.spawn_bundle(LightBundle { | ||
transform: Transform::from_xyz(3.0, 5.0, 3.0), | ||
..Default::default() | ||
}) | ||
.insert(Rotates); | ||
} | ||
|
||
/// this component indicates what entities should rotate | ||
struct Rotates; | ||
|
||
fn rotator_system(time: Res<Time>, mut query: Query<&mut Transform, With<Rotates>>) { | ||
for mut transform in query.iter_mut() { | ||
*transform = Transform::from_rotation(Quat::from_rotation_y( | ||
(4.0 * std::f32::consts::PI / 20.0) * time.delta_seconds(), | ||
)) * *transform; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny comments here would make it easier for folks new to rendering to figure out exactly what's happening here.
See the
// tone_mapping
comment just below.