Skip to content
This repository has been archived by the owner on Feb 16, 2025. It is now read-only.

Commit

Permalink
v0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
heestand-xyz committed May 23, 2019
1 parent 3671fa3 commit e7ab73d
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.6.0</string>
<string>0.6.1</string>
<key>CFBundleVersion</key>
<string>777</string>
</dict>
Expand Down
Binary file modified Resources/Metal Libs/PixelKitShaders-macOS.metallib
Binary file not shown.
Binary file modified Resources/Metal Libs/PixelKitShaders.metallib
Binary file not shown.
6 changes: 6 additions & 0 deletions Resources/PixelKit-Raw.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@
3A48929822941972002A0E66 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A4891BF22941972002A0E66 /* Types.swift */; };
3A48929922941972002A0E66 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A4891BF22941972002A0E66 /* Types.swift */; };
3A48929A229419DB002A0E66 /* AirPlayPIX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A48915422941972002A0E66 /* AirPlayPIX.swift */; };
3A6A1D8E2296BCD4001BB134 /* LumaLevelsPIX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A6A1D8B2296BCD4001BB134 /* LumaLevelsPIX.swift */; };
3A6A1D8F2296BCD4001BB134 /* LumaLevelsPIX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A6A1D8B2296BCD4001BB134 /* LumaLevelsPIX.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -380,6 +382,7 @@
3A4891BD22941972002A0E66 /* Render.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Render.swift; sourceTree = "<group>"; };
3A4891BE22941972002A0E66 /* Texture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Texture.swift; sourceTree = "<group>"; };
3A4891BF22941972002A0E66 /* Types.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = "<group>"; };
3A6A1D8B2296BCD4001BB134 /* LumaLevelsPIX.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LumaLevelsPIX.swift; sourceTree = "<group>"; };
3A8AC3482277282C00A142AA /* PixelKit.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PixelKit.entitlements; sourceTree = "<group>"; };
3AF28BCC219312900079FC7A /* PixelKit_macOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PixelKit_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
744A9DAA22932D9200A01CA1 /* Syphon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Syphon.framework; sourceTree = "<group>"; };
Expand Down Expand Up @@ -646,6 +649,7 @@
3A48919922941972002A0E66 /* Merger */ = {
isa = PBXGroup;
children = (
3A6A1D8B2296BCD4001BB134 /* LumaLevelsPIX.swift */,
3A48919A22941972002A0E66 /* LumaBlurPIX.swift */,
3A48919B22941972002A0E66 /* Metal */,
3A48919D22941972002A0E66 /* LookupPIX.swift */,
Expand Down Expand Up @@ -940,6 +944,7 @@
3A4891CF22941972002A0E66 /* Operators.swift in Sources */,
3A48923722941972002A0E66 /* FeedbackPIX.swift in Sources */,
3A48928B22941972002A0E66 /* LiveColor.swift in Sources */,
3A6A1D8F2296BCD4001BB134 /* LumaLevelsPIX.swift in Sources */,
3A48928D22941972002A0E66 /* LiveValue.swift in Sources */,
3A48923D22941972002A0E66 /* HueSatPIX.swift in Sources */,
3A48927122941972002A0E66 /* MIDI.swift in Sources */,
Expand Down Expand Up @@ -1108,6 +1113,7 @@
3A48927622941972002A0E66 /* PIXProtocols.swift in Sources */,
3A4891EE22941972002A0E66 /* PIXGenerator.swift in Sources */,
3A4891EA22941972002A0E66 /* NoisePIX.swift in Sources */,
3A6A1D8E2296BCD4001BB134 /* LumaLevelsPIX.swift in Sources */,
3A4891C222941972002A0E66 /* PixelKit.swift in Sources */,
3A48923E22941972002A0E66 /* KaleidoscopePIX.swift in Sources */,
3A4891E822941972002A0E66 /* PIXContent.swift in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions Resources/PixelKitShaders.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
3A6A1D912296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal in Sources */ = {isa = PBXBuildFile; fileRef = 3A6A1D902296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal */; };
3A6A1D922296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal in Sources */ = {isa = PBXBuildFile; fileRef = 3A6A1D902296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal */; };
3A7C229C2285B4660096F53C /* EffectSingleRangePIX.metal in Sources */ = {isa = PBXBuildFile; fileRef = 3A7C22672285B4640096F53C /* EffectSingleRangePIX.metal */; };
3A7C229D2285B4660096F53C /* EffectSingleRangePIX.metal in Sources */ = {isa = PBXBuildFile; fileRef = 3A7C22672285B4640096F53C /* EffectSingleRangePIX.metal */; };
3A7C229E2285B4660096F53C /* error.metal in Sources */ = {isa = PBXBuildFile; fileRef = 3A7C22682285B4640096F53C /* error.metal */; };
Expand Down Expand Up @@ -116,6 +118,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
3A6A1D902296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = EffectMergerLumaLevelsPIX.metal; sourceTree = "<group>"; };
3A7C22672285B4640096F53C /* EffectSingleRangePIX.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = EffectSingleRangePIX.metal; sourceTree = "<group>"; };
3A7C22682285B4640096F53C /* error.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = error.metal; sourceTree = "<group>"; };
3A7C22692285B4640096F53C /* noise.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = noise.metal; sourceTree = "<group>"; };
Expand Down Expand Up @@ -194,6 +197,7 @@
3A7C22852285B4640096F53C /* EffectMergerDisplacePIX.metal */,
3A7C22962285B4650096F53C /* EffectMergerLookupPIX.metal */,
3A7C226D2285B4640096F53C /* EffectMergerLumaBlurPIX.metal */,
3A6A1D902296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal */,
3A7C22872285B4650096F53C /* EffectMergerRemapPIX.metal */,
3A7C227E2285B4640096F53C /* EffectMergerReorderPIX.metal */,
3A7C226E2285B4640096F53C /* EffectMergerTimeMachinePIX.metal */,
Expand Down Expand Up @@ -353,6 +357,7 @@
3A7C22D02285B4660096F53C /* EffectSingleHueSatPIX.metal in Sources */,
3A7C22FC2285B4660096F53C /* EffectMergerBlendPIX.metal in Sources */,
3A7C22E22285B4660096F53C /* hsv.metal in Sources */,
3A6A1D912296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal in Sources */,
3A7C22EC2285B4660096F53C /* EffectMergerCrossPIX.metal in Sources */,
3A7C22D42285B4660096F53C /* EffectSingleCropPIX.metal in Sources */,
3A7C229C2285B4660096F53C /* EffectSingleRangePIX.metal in Sources */,
Expand Down Expand Up @@ -413,6 +418,7 @@
3A7C22D12285B4660096F53C /* EffectSingleHueSatPIX.metal in Sources */,
3A7C22FD2285B4660096F53C /* EffectMergerBlendPIX.metal in Sources */,
3A7C22E32285B4660096F53C /* hsv.metal in Sources */,
3A6A1D922296BDF6001BB134 /* EffectMergerLumaLevelsPIX.metal in Sources */,
3A7C22ED2285B4660096F53C /* EffectMergerCrossPIX.metal in Sources */,
3A7C22D52285B4660096F53C /* EffectSingleCropPIX.metal in Sources */,
3A7C229D2285B4660096F53C /* EffectSingleRangePIX.metal in Sources */,
Expand Down
64 changes: 64 additions & 0 deletions Shaders/EffectMergerLumaLevelsPIX.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// EffectMergerLumaLevelsPIX.metal
// PixelKit Shaders
//
// Created by Hexagons on 2017-11-26.
// Copyright © 2017 Hexagons. All rights reserved.
//

#include <metal_stdlib>
using namespace metal;

#import "random_header.metal"

struct VertexOut{
float4 position [[position]];
float2 texCoord;
};

struct Uniforms {
float brightness;
float darkness;
float contrast;
float gamma;
float opacity;
};

fragment float4 effectMergerLumaLevelsPIX(VertexOut out [[stage_in]],
texture2d<float> inTexA [[ texture(0) ]],
texture2d<float> inTexB [[ texture(1) ]],
const device Uniforms& in [[ buffer(0) ]],
sampler s [[ sampler(0) ]]) {

float pi = 3.14159265359;
int max_res = 16384 - 1;

float u = out.texCoord[0];
float v = out.texCoord[1];
float2 uv = float2(u, v);

float4 c = inTexA.sample(s, uv);

float4 cb = inTexB.sample(s, uv);
float lum = (cb.r + cb.g + cb.b) / 3;

float opacity = (1.0 - (1.0 - in.opacity) * lum);
float a = c.a * opacity;

c *= 1 / (1.0 - in.darkness * lum);
c -= 1.0 / (1.0 - in.darkness * lum) - 1;

c *= 1.0 - (1.0 - in.brightness) * lum;

c -= 0.5;
c *= 1.0 + in.contrast * lum;
c += 0.5;

c = pow(c, 1 / max(0.001, 1.0 - (1.0 - in.gamma) * lum));

c *= opacity;

return float4(c.r, c.g, c.b, a);
}


2 changes: 2 additions & 0 deletions Source/PIX/PIXs/Content/Resource/VideoPIX.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public class VideoPIX: PIXResource {
_playing = false
}

#if os(iOS)
public func thumbnail(fraction: CGFloat, at size: CGSize, placement: PixelKit.ImagePlacement = .fill) -> UIImage? {
guard let player = helper.player else {
pixelKit.log(pix: self, .warning, .resource, "Can't make thumbnail. Video not loaded.")
Expand Down Expand Up @@ -186,6 +187,7 @@ public class VideoPIX: PIXResource {
let uiImage = UIImage(cgImage: cgImage)
return PixelKit.resize(uiImage, to: size, placement: placement)
}
#endif

}

Expand Down
61 changes: 61 additions & 0 deletions Source/PIX/PIXs/Effects/Merger/LumaLevelsPIX.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// LumaLevelsPIX.swift
// PixelKit
//
// Created by Hexagons on 2018-08-09.
// Open Source - MIT License
//

import CoreGraphics

public class LumaLevelsPIX: PIXMergerEffect, PIXAuto {

override open var shader: String { return "effectMergerLumaLevelsPIX" }

// MARK: - Public Properties

public var brightness: LiveFloat = 1.0
public var darkness: LiveFloat = 0.0
public var contrast: LiveFloat = 0.0
public var gamma: LiveFloat = 1.0
public var opacity: LiveFloat = 1.0

// MARK: - Property Helpers

override public var liveValues: [LiveValue] {
return [brightness, darkness, contrast, gamma, opacity]
}

}

public extension PIXOut {

func _lumaLevels(with pix: PIX & PIXOut, brightness: LiveFloat = 1.0, darkness: LiveFloat = 0.0, contrast: LiveFloat = 0.0, gamma: LiveFloat = 1.0, opacity: LiveFloat = 1.0) -> LumaLevelsPIX {
let lumaLevelsPix = LumaLevelsPIX()
lumaLevelsPix.name = ":lumaLevels:"
lumaLevelsPix.inPixA = self as? PIX & PIXOut
lumaLevelsPix.inPixB = pix
lumaLevelsPix.brightness = brightness
lumaLevelsPix.darkness = darkness
lumaLevelsPix.contrast = contrast
lumaLevelsPix.gamma = gamma
lumaLevelsPix.opacity = opacity
return lumaLevelsPix
}

func _vignetting(radius: LiveFloat = 0.5, inset: LiveFloat = 0.25, gamma: LiveFloat = 0.5) -> LumaLevelsPIX {
let pix = self as! PIX & PIXOut
let rectangle = RectanglePIX(res: pix.resolution ?? ._1024)
rectangle.bgColor = .white
rectangle.color = .black
rectangle.name = "vignetting:rectangle"
rectangle.size = LiveSize(w: (pix.resolution?.aspect ?? 1.0) - inset, h: 1.0 - inset)
let lumaLevelsPix = LumaLevelsPIX()
lumaLevelsPix.name = "vignetting:lumaLevels"
lumaLevelsPix.inPixA = pix
lumaLevelsPix.inPixB = rectangle._blur(radius)
lumaLevelsPix.gamma = gamma
return lumaLevelsPix
}

}
2 changes: 2 additions & 0 deletions Source/PixelKit Extensions/Texture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ extension PixelKit {
case fit
}

#if os(iOS)
public static func resize(_ image: UIImage, to size: CGSize, placement: ImagePlacement = .fill) -> UIImage {

let frame: CGRect
Expand Down Expand Up @@ -140,6 +141,7 @@ extension PixelKit {

return resized_image!
}
#endif

func makeTexture(from pixelBuffer: CVPixelBuffer, with commandBuffer: MTLCommandBuffer, force8bit: Bool = false) throws -> MTLTexture {
// let width = CVPixelBufferGetWidth(pixelBuffer)
Expand Down

0 comments on commit e7ab73d

Please sign in to comment.