Skip to content

Commit c20cdd7

Browse files
committed
update readme
1 parent 4fd35c0 commit c20cdd7

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

Examples/ExampleMacOS/ExampleMacOS/Logic/Functions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MyRender: EMMetalRenderFunction {
2828
override var vertImpl: String {
2929
"rd.size = 10;"
3030
"rd.position = vertexInput.input0;"
31-
"rd.color = float4(1, 0.6, 0.8, 1);"
31+
"rd.color = vertexInput.input1;"
3232
}
3333

3434
@ShaderStringBuilder

Examples/ExampleMacOS/ExampleMacOS/Logic/MyRenderer.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import EasyMetalShader
1010
class MyRenderer: ShaderRenderer {
1111

1212
var particles: [VertexInput] = {
13-
var ps: [simd_float4] = []
13+
var inputs: [VertexInput] = []
1414
for _ in 0...1000 {
15-
ps.append(.init(Float.random(in: -1...1), Float.random(in: -1...1), 0, 1))
16-
}
17-
return ps.map {
18-
var vertexInput = VertexInput()
19-
vertexInput.input0 = $0
20-
return vertexInput
15+
var input = VertexInput()
16+
input.input0 = .init(Float.random(in: -1...1), Float.random(in: -1...1), 0, 1)
17+
input.input1 = .init(Float.random(in: 0.3...1), 0.3, 0.3, 1)
18+
inputs.append(input)
2119
}
20+
return inputs
2221
}()
2322

2423
let compute = MyCompute()

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class MyRender: EMMetalRenderFunction {
227227
override var vertImpl: String {
228228
"rd.size = 10;"
229229
"rd.position = vertexInput.input0;"
230-
"rd.color = float4(1, 0.6, 0.8, 1);"
230+
"rd.color = vertexInput.input1;"
231231
}
232232

233233
@ShaderStringBuilder
@@ -242,15 +242,14 @@ class MyRender: EMMetalRenderFunction {
242242
class MyRenderer: ShaderRenderer {
243243

244244
var particles: [VertexInput] = {
245-
var ps: [simd_float4] = []
245+
var inputs: [VertexInput] = []
246246
for _ in 0...1000 {
247-
ps.append(.init(Float.random(in: -1...1), Float.random(in: -1...1), 0, 1))
248-
}
249-
return ps.map {
250-
var vertexInput = VertexInput()
251-
vertexInput.input0 = $0
252-
return vertexInput
247+
var input = VertexInput()
248+
input.input0 = .init(Float.random(in: -1...1), Float.random(in: -1...1), 0, 1)
249+
input.input1 = .init(Float.random(in: 0.3...1), 0.3, 0.3, 1)
250+
inputs.append(input)
253251
}
252+
return inputs
254253
}()
255254

256255
let compute = MyCompute()

0 commit comments

Comments
 (0)