From 2b409afc2d0e2cf149d68dd60b65e73ac3427214 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 1 Aug 2017 19:01:20 -0700 Subject: [PATCH] [MetaballsKit] Add a metal file to the framework --- Metaballs.xcodeproj/project.pbxproj | 4 ++++ MetaballsKit/SamplingKernel.metal | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 MetaballsKit/SamplingKernel.metal diff --git a/Metaballs.xcodeproj/project.pbxproj b/Metaballs.xcodeproj/project.pbxproj index e08f7c8..08b37fa 100644 --- a/Metaballs.xcodeproj/project.pbxproj +++ b/Metaballs.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ C0BBE3AA1F2E91D900E68524 /* Shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = C0BBE3A91F2E91D900E68524 /* Shaders.metal */; }; C0BBE3AC1F2E941200E68524 /* Renderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0BBE3AB1F2E941200E68524 /* Renderer.swift */; }; C0BBE3AD1F30CD7E00E68524 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0BBE3A71F2E893A00E68524 /* MetalKit.framework */; }; + C0BBE3AF1F314C8200E68524 /* SamplingKernel.metal in Sources */ = {isa = PBXBuildFile; fileRef = C0BBE3AE1F314C8200E68524 /* SamplingKernel.metal */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -60,6 +61,7 @@ C0BBE3A71F2E893A00E68524 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; C0BBE3A91F2E91D900E68524 /* Shaders.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = Shaders.metal; sourceTree = ""; }; C0BBE3AB1F2E941200E68524 /* Renderer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Renderer.swift; sourceTree = ""; }; + C0BBE3AE1F314C8200E68524 /* SamplingKernel.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = SamplingKernel.metal; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -150,6 +152,7 @@ C0BBE38E1F2E81B600E68524 /* MetaballsKit.h */, C0BBE38F1F2E81B600E68524 /* Info.plist */, C0BBE3A31F2E81C700E68524 /* Metaballs.swift */, + C0BBE3AE1F314C8200E68524 /* SamplingKernel.metal */, ); path = MetaballsKit; sourceTree = ""; @@ -369,6 +372,7 @@ buildActionMask = 2147483647; files = ( C0BBE3A41F2E81C700E68524 /* Metaballs.swift in Sources */, + C0BBE3AF1F314C8200E68524 /* SamplingKernel.metal in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MetaballsKit/SamplingKernel.metal b/MetaballsKit/SamplingKernel.metal new file mode 100644 index 0000000..90a2de8 --- /dev/null +++ b/MetaballsKit/SamplingKernel.metal @@ -0,0 +1,24 @@ +// +// SamplingKernel.metal +// Metaballs +// +// Created by Eryn Wells on 8/1/17. +// Copyright © 2017 Eryn Wells. All rights reserved. +// + +#include +using namespace metal; + +typedef struct { + float radius; + float2 position; + float2 velocity; +} Ball; + +kernel void +sampleFieldKernel(const device Ball* metaballs [[buffer(0)]], + texture2d [[texture(1)]], + uint2 gid [[thread_position_in_grid]]) +{ + // TODO: Compute a sample for this pixel given the field data, and write it to the out texture. +}