Giter VIP home page Giter VIP logo

Comments (3)

heestand-xyz avatar heestand-xyz commented on May 23, 2024

So metalFileName is not used anymore,
metalBaseCode replaces this property.

Sorry this change was made in a patch update.

The update "hardcodes metal" (PixelKit 1.0.2 & RenderKit 0.4.0) is an update to eliminate bundle resources, as SwiftPM dose not support this yet. The MetalPIXs should conform to the updated NodeMetal protocol.

What versions of PixelKit and RenderKit are you using?
Are you using Pods or SwiftPM?

from pixelkit.

intonarumori avatar intonarumori commented on May 23, 2024

I was just trying the iOS example in the project.
Here are the steps:

  • Downloaded the zip from Github
  • Ran git submodule init to get the shaders
  • Ran pod install to get the dependencies
  • Build failed with errors

To fix the errors I made MetalPix, MetalEffectPix, MetalMergerEffectPIX, MetalMultiEffectPIX conform to NODEMetal by adding the following:
public var metalFileName: String = ""

I also added a convenience method to Render to be able to either load Metal code as string or from a file:


    public func embedMetalCode(uniforms: [MetalUniform], code: String, fileName: String) throws -> String {
        guard let bundle: Bundle = bundle else {
            throw MetalError.fileNotFound("No bundle provided. Can't look for file \"\(fileName).txt\"")
        }
        guard let metalFile = bundle.url(forResource: fileName, withExtension: "txt") else {
            throw MetalError.fileNotFound(fileName + ".txt")
        }
        do {
            let metalCode = try String(contentsOf: metalFile)
            return try embedMetalCode(uniforms: uniforms, code: code, metalBaseCode: metalCode)
        } catch {
            throw error
        }
    }

public func embedMetalCode(uniforms: [MetalUniform], code: String, metalBaseCode: String) throws -> String {
        do {
            var metalCode = metalBaseCode
            let uniformsCode = try dynamicUniforms(uniforms: uniforms)
            metalCode = try insert(uniformsCode, in: metalCode, at: "uniforms")
            let comment = "/// PixelKit Dynamic Shader Code"
            metalCode = try insert("\(comment)\n\n\n\(code)\n", in: metalCode, at: "code")
            #if DEBUG
            if logger.dynamicShaderCode {
                print("\nDYNAMIC SHADER CODE\n\n>>>>>>>>>>>>>>>>>\n\n\(metalCode)\n<<<<<<<<<<<<<<<<<\n")
            }
            #endif
            return metalCode
        } catch {
            throw error
        }
    }

With all of these the example did compile and I was able to test the different nodes, great project. If you experience the same with the example please consider fixing it, many thanks.

from pixelkit.

heestand-xyz avatar heestand-xyz commented on May 23, 2024

Nice fix,
I'm glad you got it working.

So I was able to reproduce the issue. It was caused by a missmatch of RenderKit and PixelKit versions.
I've switched over to swiftpm from pods for development and forgot to push the RenderKit pod.
New versions of RenderKit 0.4.2 and PixelKit 1.0.4 contains the fix.

Thanks,
/Anton

from pixelkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.