Skip to content

Commit 9436c64

Browse files
committed
New Logo, production db, add library shader to project
1 parent 2d2d0db commit 9436c64

25 files changed

+144
-21
lines changed

ShaderMania.entitlements

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>aps-environment</key>
6+
<string>development</string>
7+
<key>com.apple.developer.icloud-container-identifiers</key>
8+
<array>
9+
<string>iCloud.com.moenig.ShaderMania</string>
10+
</array>
11+
<key>com.apple.developer.icloud-services</key>
12+
<array>
13+
<string>CloudDocuments</string>
14+
<string>CloudKit</string>
15+
</array>
16+
<key>com.apple.developer.ubiquity-container-identifiers</key>
17+
<array>
18+
<string>iCloud.com.moenig.ShaderMania</string>
19+
</array>
20+
<key>com.apple.developer.icloud-container-environment</key>
21+
<string>Production</string>
22+
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
23+
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
24+
</dict>
25+
</plist>

ShaderMania.xcodeproj/project.pbxproj

+8
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
2B36F67925D4DE84001611BE /* OpenSans.json in Resources */ = {isa = PBXBuildFile; fileRef = 2B36F67525D4DE84001611BE /* OpenSans.json */; };
5555
2B3D4C7925A68ECA00D2F8EA /* Views.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B3D4C7825A68ECA00D2F8EA /* Views.swift */; };
5656
2B3D4C7A25A68ECA00D2F8EA /* Views.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B3D4C7825A68ECA00D2F8EA /* Views.swift */; };
57+
2B6B9C7625E0BC6000F266DF /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B6B9C7525E0BC6000F266DF /* CloudKit.framework */; };
5758
2B77B7BB25773978002D99C0 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B77B7BA25773978002D99C0 /* File.swift */; };
5859
2B77B7BC25773978002D99C0 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B77B7BA25773978002D99C0 /* File.swift */; };
5960
2B7C7EEC25DCB5D400727BC0 /* Library.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B7C7EEB25DCB5D400727BC0 /* Library.swift */; };
@@ -94,6 +95,8 @@
9495
2B36F67425D4DE84001611BE /* OpenSans.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = OpenSans.tiff; sourceTree = "<group>"; };
9596
2B36F67525D4DE84001611BE /* OpenSans.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = OpenSans.json; sourceTree = "<group>"; };
9697
2B3D4C7825A68ECA00D2F8EA /* Views.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Views.swift; sourceTree = "<group>"; };
98+
2B6B9C7225E0BC4E00F266DF /* ShaderMania.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShaderMania.entitlements; sourceTree = "<group>"; };
99+
2B6B9C7525E0BC6000F266DF /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/CloudKit.framework; sourceTree = DEVELOPER_DIR; };
97100
2B77B7BA25773978002D99C0 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
98101
2B7C7EEB25DCB5D400727BC0 /* Library.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Library.swift; sourceTree = "<group>"; };
99102
2B7C7EFB25DD0E0900727BC0 /* StoreManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreManager.swift; sourceTree = "<group>"; };
@@ -105,6 +108,7 @@
105108
isa = PBXFrameworksBuildPhase;
106109
buildActionMask = 2147483647;
107110
files = (
111+
2B6B9C7625E0BC6000F266DF /* CloudKit.framework in Frameworks */,
108112
);
109113
runOnlyForDeploymentPostprocessing = 0;
110114
};
@@ -123,6 +127,7 @@
123127
2B0EEA482565DF3900C84C6C = {
124128
isa = PBXGroup;
125129
children = (
130+
2B6B9C7225E0BC4E00F266DF /* ShaderMania.entitlements */,
126131
2B0EEA4D2565DF3900C84C6C /* Shared */,
127132
2B0EEA582565DF3A00C84C6C /* iOS */,
128133
2B0EEA5F2565DF3A00C84C6C /* macOS */,
@@ -201,6 +206,7 @@
201206
2B0EEAC1256619D000C84C6C /* Frameworks */ = {
202207
isa = PBXGroup;
203208
children = (
209+
2B6B9C7525E0BC6000F266DF /* CloudKit.framework */,
204210
2B7C7F0225DD0E6D00727BC0 /* StoreKit.framework */,
205211
2B0EEAC2256619D000C84C6C /* CloudKit.framework */,
206212
);
@@ -492,6 +498,7 @@
492498
buildSettings = {
493499
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
494500
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
501+
CODE_SIGN_ENTITLEMENTS = ShaderMania.entitlements;
495502
CODE_SIGN_STYLE = Automatic;
496503
DEVELOPMENT_TEAM = G6R6L3VH62;
497504
ENABLE_PREVIEWS = YES;
@@ -516,6 +523,7 @@
516523
buildSettings = {
517524
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
518525
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
526+
CODE_SIGN_ENTITLEMENTS = ShaderMania.entitlements;
519527
CODE_SIGN_STYLE = Automatic;
520528
DEVELOPMENT_TEAM = G6R6L3VH62;
521529
ENABLE_PREVIEWS = YES;

Shared/Assets.xcassets/AppIcon.appiconset/Contents.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,25 @@
7171
"size" : "40x40"
7272
},
7373
{
74-
"filename" : "Image 2-1.png",
74+
"filename" : "Space 2-2.png",
7575
"idiom" : "ipad",
7676
"scale" : "1x",
7777
"size" : "76x76"
7878
},
7979
{
80-
"filename" : "Image 2.png",
80+
"filename" : "Space 2-1.png",
8181
"idiom" : "ipad",
8282
"scale" : "2x",
8383
"size" : "76x76"
8484
},
8585
{
86-
"filename" : "Image 2-2.png",
86+
"filename" : "Space 2.png",
8787
"idiom" : "ipad",
8888
"scale" : "2x",
8989
"size" : "83.5x83.5"
9090
},
9191
{
92-
"filename" : "Image-1.png",
92+
"filename" : "Space.png",
9393
"idiom" : "ios-marketing",
9494
"scale" : "1x",
9595
"size" : "1024x1024"
@@ -130,19 +130,19 @@
130130
"size" : "256x256"
131131
},
132132
{
133-
"filename" : "RoundedIcon 2-1.png",
133+
"filename" : "Space_Rounded 2-1.png",
134134
"idiom" : "mac",
135135
"scale" : "2x",
136136
"size" : "256x256"
137137
},
138138
{
139-
"filename" : "RoundedIcon 2.png",
139+
"filename" : "Space_Rounded 2.png",
140140
"idiom" : "mac",
141141
"scale" : "1x",
142142
"size" : "512x512"
143143
},
144144
{
145-
"filename" : "RoundedIcon.png",
145+
"filename" : "Space_Rounded.png",
146146
"idiom" : "mac",
147147
"scale" : "2x",
148148
"size" : "512x512"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Loading

Shared/ContentView.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct ContentView: View {
1818
}
1919

2020
@State var editingState : EditingState = .Both
21-
@State var editingStateText : String = " Source & Nodes"
21+
@State var editingStateText : String = "Source & Nodes"
2222

2323
@Binding var document : ShaderManiaDocument
2424
@StateObject var storeManager : StoreManager
@@ -30,7 +30,7 @@ struct ContentView: View {
3030
@State private var userNickName : String = ""
3131
@State private var userDescription : String = ""
3232

33-
@State private var showLibrary : Bool = false
33+
@State private var showLibrary : Bool = true
3434

3535
@State private var showAssetNamePopover : Bool = false
3636
@State private var assetName : String = ""
@@ -100,7 +100,7 @@ struct ContentView: View {
100100
.zIndex(0)
101101
.animation(.default)
102102
.allowsHitTesting(true)
103-
.frame(maxHeight: editingState == .Both ? geometry.size.height / 2.3 : geometry.size.height)
103+
.frame(maxHeight: editingState == .Both ? geometry.size.height / 2.5 : geometry.size.height)
104104
}
105105
}
106106

Shared/Files/default/Shader

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11

22
void mainImage(thread Data &data)
33
{
4+
float2 uv = (data.fragCoord.xy-data.viewSize.xy*.5) / data.viewSize.y;
5+
6+
uv *= float2x2(.707, -.707, .707, .707);
7+
8+
float scale = ParamFloat<UI: "Slider", name: "Scale", min: 0.1, max: 30, default: 15>
9+
uv *= scale;
10+
11+
// ParamUrl<name: "Watch Tutorial", url: "www.youtube.com/watch?v=cQXAbndD5CQ">
412

5-
data.outColor = float4(data.uv, 0, 1);
13+
float2 gv = fract(uv)-.5;
14+
float2 id = floor(uv);
15+
16+
float m = 0.;
17+
float t;
18+
for(float y=-1.; y<=1.; y++) {
19+
for(float x=-1.; x<=1.; x++) {
20+
float2 offs = float2(x, y);
21+
22+
t = -data.time + length(id-offs)*.2;
23+
float r = mix(.4, 1.5, sin(t)*.5+.5);
24+
float c = smoothstep(r, r*.9, length(gv+offs));
25+
m = m*(1.-c) + c*(1.-m);
26+
}
27+
}
28+
29+
data.outColor = float4(float3(m), 1.0);
630
}

Shared/Files/help.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
/*
33
* ShaderMania 1.5
44
*
5-
* To learn more about shader development:
5+
* Nodes are shaders or images. The currently selected node is rendered in the preview. You can easily change
6+
* which shader is rendered by just selecting it. The selection state is saved with the project.
67
*
7-
* The Book Of Shaders https://thebookofshaders.com
8-
* The Art of Code YouTube Channel https://www.youtube.com/channel/UCcAlTqd9zID6aNX3TzwxJXg
8+
* You can add nodes from existing shaders from the Shader Library by clicking on the shader and selecting "Add to Project".
99
*
1010
*/
1111

@@ -29,19 +29,19 @@ typedef struct
2929
} Data;
3030

3131
// Variables with UI parameters, parameter data is stored and reset when the parameter name changes
32-
// Up to 10 parameters per node are supported
32+
// Up to 10 parameters per node / shader are supported
3333

3434
// Float slider parameter
35-
float size = ParamFloat<UI: "Slider", name: "Disk Size", min: 0, max: 1, default: 0.8>
35+
float size = ParamFloat<UI: "Slider", name: "Parameter Name", min: 0, max: 1, default: 0.8>
3636

3737
// Float3 color picker parameter
38-
float3 diskColor = ParamFloat3<UI: "Color", name: "Disk Color", default: #ffffff>
38+
float3 diskColor = ParamFloat3<UI: "Color", name: "Parameter Name", default: #ffffff>
3939

4040
// Url, ShaderMania will add https:// at the front automatically
4141
ParamUrl<name: "Watch Tutorial", url: "url without https://">
4242

4343
// Input slots (up to 4 are supported per node)
44-
texture2d<float> input = ParamInput<name: "Input">
44+
texture2d<float> input = ParamInput<name: "Input Slot Name">
4545

4646
// To read from input slots
4747
getLinearSample(texture2d<float>, float2 coord);

Shared/Library.swift

+46
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import Foundation
99
import CloudKit
10+
import CoreGraphics
1011

1112
class LibraryShader
1213
{
@@ -150,6 +151,14 @@ class Library
150151
predicate = NSPredicate(value: true)
151152
} else {
152153
predicate = NSPredicate(format: "self contains %@", searchFor)
154+
/*
155+
query(predicate, { (list) -> () in
156+
self.currentList = list
157+
158+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
159+
self.core.libraryChanged.send(self.currentList)
160+
}
161+
})*/
153162
}
154163

155164
getShaders(predicate, { (list) -> () in
@@ -176,6 +185,29 @@ class Library
176185
})
177186
}
178187

188+
func query(_ predicate: NSPredicate,_ cb: @escaping (LibraryShaderList)->())
189+
{
190+
let query = CKQuery(recordType: "Shaders", predicate: predicate)
191+
192+
let queryOperation = CKQueryOperation(query: query)
193+
queryOperation.desiredKeys = ["recordName", "description", ""]
194+
//queryOperation.queuePriority = .veryHigh
195+
196+
queryOperation.recordFetchedBlock = { (record: CKRecord!) -> Void in
197+
print("got something")
198+
if let shaderRecord = record {
199+
//this is where you are appending to your array
200+
//self.moviesArray.append(moviesRecord)
201+
print(shaderRecord.recordID.recordName)
202+
}
203+
}
204+
205+
queryOperation.queryCompletionBlock = { cursor, error in
206+
}
207+
208+
publicDatabase.add(queryOperation)
209+
}
210+
179211
func getShaders(_ predicate: NSPredicate,_ cb: @escaping (LibraryShaderList)->())
180212
{
181213
let list = LibraryShaderList()
@@ -239,4 +271,18 @@ class Library
239271
cb(list)
240272
}
241273
}
274+
275+
/// Adds the library to the curent project
276+
func addShaderToProject(_ shader: LibraryShader)
277+
{
278+
if let folder = shader.folder {
279+
for asset in folder.assets {
280+
if asset.type == .Shader || asset.type == .Image {
281+
core.assetFolder.assets.append(asset)
282+
}
283+
}
284+
}
285+
core.nodesWidget.update()
286+
core.contentChanged.send()
287+
}
242288
}

Shared/NodesWidget.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ public class NodesWidget : ObservableObject
285285
for (index, nodeUUID) in asset.slots {
286286
if nodeUUID == node.id {
287287
asset.slots[index] = nil
288-
print("connection deleted")
289288
}
290289
}
291290
}
@@ -343,6 +342,7 @@ public class NodesWidget : ObservableObject
343342
//canConnect = false
344343
asset.slots[t] = nil
345344
// Disconnect instead of not allowing to connect when slot is already taken
345+
core.contentChanged.send()
346346
}
347347

348348
if canConnect {
@@ -409,6 +409,8 @@ public class NodesWidget : ObservableObject
409409
} else {
410410
connectingNode!.slots[connectingTerminalId!] = currentNode!.id
411411
}
412+
413+
core.contentChanged.send()
412414
}
413415

414416
action = .None

Shared/Project.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,19 @@ class Project
126126
checkTextures(collected: collected, preview: preview, device: device)
127127

128128
for asset in collected {
129-
130129
if asset.type == .Shader {
131130
drawShader(asset, preview, device)
132131
}
133132
}
134133

134+
if preview {
135+
for asset in assetFolder.assets {
136+
if asset.previewTexture != nil && collected.contains(asset) == false {
137+
clear(asset.previewTexture!, float4(0,0,0,0))
138+
}
139+
}
140+
}
141+
135142
if preview == false {
136143
lastSize = size
137144
}

Shared/Views.swift

+10-1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ struct ShaderList: View {
210210

211211
if let userRecord = authorOfShader.userRecord {
212212
Text((userRecord["nickName"] as! String))
213+
.padding(.top, 5)
213214
Text((userRecord["description"] as! String))
214215
.padding(.top, 4)
215216
}
@@ -278,12 +279,20 @@ struct ShaderList: View {
278279
.foregroundColor(Color.secondary)
279280
Spacer()
280281
}
282+
.padding(.top, 5)
281283
HStack {
282284
Text(detailedShader.description)
283285
Spacer()
284286
}
285287
.padding(.top, 2)
286-
288+
289+
Button(action: {
290+
document.core.library.addShaderToProject(detailedShader)
291+
})
292+
{
293+
Text("Add to Project")
294+
}
295+
.padding(.top, 5)
287296
}
288297

289298
} else {

macOS/macOS.entitlements

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
<true/>
2626
<key>com.apple.security.files.user-selected.read-write</key>
2727
<true/>
28+
<key>com.apple.developer.icloud-container-environment</key>
29+
<string>Production</string>
2830
<key>com.apple.security.network.client</key>
2931
<true/>
3032
</dict>

0 commit comments

Comments
 (0)