diff --git a/src/rust/nehe/matrix.rs b/src/rust/nehe/matrix.rs index 610381c..967ebe4 100644 --- a/src/rust/nehe/matrix.rs +++ b/src/rust/nehe/matrix.rs @@ -132,9 +132,9 @@ impl Mtx self.0[11] = r[6] * tmp[3] + r[7] * tmp[7] + r[8] * tmp[11]; } - #[inline(always)] - #[must_use] - pub const fn as_ptr(&self) -> *const f32 { self.0.as_ptr() } + #[inline(always)] + #[must_use] + pub const fn as_ptr(&self) -> *const f32 { self.0.as_ptr() } } impl Default for Mtx diff --git a/src/shaders/lesson7.metal b/src/shaders/lesson7.metal index a680ad4..2b828ed 100644 --- a/src/shaders/lesson7.metal +++ b/src/shaders/lesson7.metal @@ -21,9 +21,9 @@ struct VertexUniform struct Light { - float4 ambient; - float4 diffuse; - float4 position; + float4 ambient; + float4 diffuse; + float4 position; }; struct Vertex2Fragment @@ -38,16 +38,16 @@ vertex Vertex2Fragment VertexMain( constant VertexUniform& u [[buffer(0)]], constant Light& light [[buffer(1)]]) { - const auto position = u.modelView * float4(in.position, 1.0); - const auto normal = metal::normalize(u.modelView * float4(in.normal, 0.0)).xyz; + const auto position = u.modelView * float4(in.position, 1.0); + const auto normal = metal::normalize(u.modelView * float4(in.normal, 0.0)).xyz; - const auto lightVec = light.position.xyz - position.xyz; - const auto lightDist2 = metal::length_squared(lightVec); - const auto dir = metal::rsqrt(lightDist2) * lightVec; - const auto lambert = metal::max(0.0, metal::dot(normal, dir)); + const auto lightVec = light.position.xyz - position.xyz; + const auto lightDist2 = metal::length_squared(lightVec); + const auto dir = metal::rsqrt(lightDist2) * lightVec; + const auto lambert = metal::max(0.0, metal::dot(normal, dir)); - const auto ambient = 0.04 + 0.2 * half3(light.ambient.rgb); - const auto diffuse = 0.8 * half3(light.diffuse.rgb); + const auto ambient = 0.04 + 0.2 * half3(light.ambient.rgb); + const auto diffuse = 0.8 * half3(light.diffuse.rgb); Vertex2Fragment out; out.position = u.projection * position; @@ -57,7 +57,7 @@ vertex Vertex2Fragment VertexMain( } fragment half4 FragmentMain( - Vertex2Fragment in [[stage_in]], + Vertex2Fragment in [[stage_in]], metal::texture2d texture [[texture(0)]], metal::sampler sampler [[sampler(0)]]) { diff --git a/src/shaders/lesson9.metal b/src/shaders/lesson9.metal index 6a2130f..dee120d 100644 --- a/src/shaders/lesson9.metal +++ b/src/shaders/lesson9.metal @@ -44,7 +44,7 @@ vertex Vertex2Fragment VertexMain( } fragment half4 FragmentMain( - Vertex2Fragment in [[stage_in]], + Vertex2Fragment in [[stage_in]], metal::texture2d texture [[texture(0)]], metal::sampler sampler [[sampler(0)]]) {