Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/MetalTexturedMesh/AAPLMathUtilities.m
- +++ b/MetalTexturedMesh/AAPLMathUtilities.m
- @@ -314,7 +314,7 @@ quaternion_float quaternion_slerp(quaternion_float q0, quaternion_float q1, floa
- return q0 * cosf(angleInc) + q2 * sinf(angleInc);
- }
- -vector_float3 AAPL_SIMD_OVERLOAD quaternion_rotate_vector(quaternion_float q, vector_float3 v) {
- +vector_float3 quaternion_rotate_vector(quaternion_float q, vector_float3 v) {
- vector_float3 qp = vector_make(q.x, q.y, q.z);
- float w = q.w;
- diff --git a/MetalTexturedMesh/Renderer.swift b/MetalTexturedMesh/Renderer.swift
- index 549a082..760d1e9 100644
- --- a/MetalTexturedMesh/Renderer.swift
- +++ b/MetalTexturedMesh/Renderer.swift
- @@ -40,7 +40,7 @@ class Renderer : NSObject, MTKViewDelegate
- // Clear to solid white
- view.clearColor = MTLClearColorMake(1, 1, 1, 1)
- // Use a BGRA 8-bit normalized texture for the drawable
- - view.colorPixelFormat = .bgra8Unorm
- + view.colorPixelFormat = .bgra8Unorm_srgb
- // Use a 32-bit depth buffer
- view.depthStencilPixelFormat = .depth32Float
- diff --git a/MetalTexturedMesh/Shaders.metal b/MetalTexturedMesh/Shaders.metal
- index 2308954..c5ee748 100644
- --- a/MetalTexturedMesh/Shaders.metal
- +++ b/MetalTexturedMesh/Shaders.metal
- @@ -50,15 +50,5 @@ fragment half4 fragment_lit_textured(VertexOut fragmentIn [[stage_in]],
- texture2d<float, access::sample> tex2d [[texture(0)]],
- sampler sampler2d [[sampler(0)]])
- {
- - // Sample the texture to get the surface color at this point
- - half3 surfaceColor = half3(tex2d.sample(sampler2d, fragmentIn.texCoords).rrr);
- - // Re-normalize the interpolated surface normal
- - half3 normal = normalize(half3(fragmentIn.normal));
- - // Compute the ambient color contribution
- - half3 color = ambientLightIntensity * surfaceColor;
- - // Calculate the diffuse factor as the dot product of the normal and light direction
- - float diffuseFactor = saturate(dot(normal, -lightDirection));
- - // Add in the diffuse contribution from the light
- - color += diffuseFactor * diffuseLightIntensity * surfaceColor;
- - return half4(color, 1);
- + return half4(0, 0.157, 0.202, 1);
- }
- diff --git a/MetalTexturedMesh/ViewController.swift b/MetalTexturedMesh/ViewController.swift
- index c286161..516d70a 100644
- --- a/MetalTexturedMesh/ViewController.swift
- +++ b/MetalTexturedMesh/ViewController.swift
- @@ -17,7 +17,8 @@ class ViewController: NSViewController {
- super.viewDidLoad()
- let metalView = self.view as! MTKView
- -
- + metalView.colorPixelFormat = .bgra8Unorm_srgb
- + NSLog("color pixel format is \(metalView.colorPixelFormat)");
- // We initialize our renderer object with the MTKView it will be drawing into
- renderer = Renderer(mtkView:metalView)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement