Skip to content

Commit

Permalink
Input Feed
Browse files Browse the repository at this point in the history
  • Loading branch information
heestand-xyz committed Jan 4, 2021
1 parent abd0e48 commit 2d78654
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Source/PIX/PIXs/Effects/Single/FeedbackPIX.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ public class FeedbackPIX: PIXSingleEffect {
// MARK: - Public Properties

var feedTexture: MTLTexture? {
guard let texture = feedPix?.texture else { return nil }
guard let texture = inputFeed?.texture else { return nil }
return try? Texture.copy(texture: texture, on: pixelKit.render.metalDevice, in: pixelKit.render.commandQueue)
}

public var feedActive: Bool = true { didSet { setNeedsRender() } }
public var feedPix: (PIX & NODEOut)? { didSet { if feedActive { setNeedsRender() } } }

@available(*, deprecated, renamed: "inputFeed")
public var feedPix: (PIX & NODEOut)? {
get { inputFeed }
set { inputFeed = newValue }
}
public var inputFeed: (PIX & NODEOut)? { didSet { if feedActive { setNeedsRender() } } }

public required init() {
super.init(name: "Feedback", typeName: "pix-effect-single-feedback")
pixelKit.render.listenToFramesUntil {
Expand All @@ -45,7 +50,7 @@ public class FeedbackPIX: PIXSingleEffect {
}

func tileFeedTexture(at tileIndex: TileIndex) -> MTLTexture? {
guard let tileFeedPix = feedPix as? PIX & NODETileable2D else {
guard let tileFeedPix = inputFeed as? PIX & NODETileable2D else {
pixelKit.logger.log(node: self, .error, .texture, "Feed Input PIX Not Tileable.")
return nil
}
Expand Down Expand Up @@ -110,7 +115,7 @@ public extension NODEOut {
crossPix.inputA = self as? PIX & NODEOut
crossPix.inputB = loop?(feedbackPix) ?? feedbackPix
crossPix.fraction = fraction
feedbackPix.feedPix = crossPix
feedbackPix.inputFeed = crossPix
return feedbackPix
}

Expand All @@ -119,7 +124,7 @@ public extension NODEOut {
// feedbackPix.name = "feed:feedback"
// let pix = self as! PIX & NODEOut
// feedbackPix.input = pix
// feedbackPix.feedPix = pix + (loop?(feedbackPix) ?? feedbackPix)
// feedbackPix.inputFeed = pix + (loop?(feedbackPix) ?? feedbackPix)
// return feedbackPix
// }

Expand Down

0 comments on commit 2d78654

Please sign in to comment.