From e5678f291be553fb4aa2446fba9bd6dcfecb26c0 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 10 Nov 2018 21:46:32 -0500 Subject: [PATCH] Pass normals through to the fragment shader --- Terrain2/Shaders/Shaders.metal | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Terrain2/Shaders/Shaders.metal b/Terrain2/Shaders/Shaders.metal index e50422f..81b3a7c 100644 --- a/Terrain2/Shaders/Shaders.metal +++ b/Terrain2/Shaders/Shaders.metal @@ -19,13 +19,14 @@ using namespace metal; typedef struct { float3 position [[attribute(VertexAttributePosition)]]; + float3 normal [[attribute(VertexAttributeNormal)]]; float2 texCoord [[attribute(VertexAttributeTexcoord)]]; - uint2 gridCoord [[attribute(VertexAttributeGridCoord)]]; } Vertex; typedef struct { float4 position [[position]]; + float3 normal; float2 texCoord; } ColorInOut; @@ -42,6 +43,7 @@ vertex ColorInOut vertexShader(Vertex in [[stage_in]], // Replace the y coordinate with the height we read from the texture. float4 position(in.position.x, height.r, in.position.z, 1.0); out.position = uniforms.projectionMatrix * uniforms.modelViewMatrix * position; + out.normal = in.normal; out.texCoord = in.texCoord; return out;