Giter Site home page Giter Site logo

`skshaderc` for MacOS about stereokit HOT 9 OPEN

mrstruijk avatar mrstruijk commented on May 28, 2024
`skshaderc` for MacOS

from stereokit.

Comments (9)

maluoi avatar maluoi commented on May 28, 2024 1

I unfortunately don't ship a skshaderc build that works on Mac yet! If you remove any .hlsl files from the project (like floor.hlsl), you can get past this. But if you need to add custom shaders, you'll need to build those on Windows or Linux at the moment.

This is on my radar though, I've just been hoping to build this with something like Hermit so I don't have to ship a permutation of binaries. So, slightly more involved than just making a mac friendly build.

from stereokit.

maluoi avatar maluoi commented on May 28, 2024 1

StereoKit does ship with a number of shaders that are "built-in", pre-compiled on Github Actions and packaged into the StereoKit library as binary data :) You can see a list of those over in this folder. This usually covers the majority of common cases, so you'll only need custom shaders if you need custom rendering or special effects!

You can access the builtin shaders via like Shader.PBR, or Shader.Unlit, but more often I end up just copying or using the default Materials that use those Shaders, like a Material.PBR.Copy() or Material.Unlit.Copy()

But for example, when loading a GLTF, StereoKit will match up the model's materials to an appropriate built-in shader that StereoKit always has. Generally that's the PBR one, but there's a few others GLTFs will sometimes use!

from stereokit.

mrstruijk avatar mrstruijk commented on May 28, 2024 1

@maluoi This is excellent! Thank you so much for taking the time to explain it al so clearly!

from stereokit.

mrstruijk avatar mrstruijk commented on May 28, 2024

Ah that's good to know, thanks! I couldn't find this in the documentation. So are there any shaders in the project currently that will compile on Mac for Android?

Thanks for the awesome work on this project. I saw a live demo done on the GlobalXR conference and I was so inspired!

from stereokit.

maluoi avatar maluoi commented on May 28, 2024

The shaders can compile, it's more that I just don't build or ship the mac flavored shader compiler binary for it! The simulator won't run on mac yet, I don't have a mac myself, and haven't met a lot of mac XR developers, so it's been a lower priority for me! Apple finally announcing their Vision Pro has made it a bit more common lately, which is why I'm much more interested in it now. But there's still a good pile of work to make that a good experience.

In theory, you could compile the shaders on Windows or Linux, and just grab the compiled .sks files, load those directly. It would work fine, it would just be a lot less fun to iterate on!

from stereokit.

mrstruijk avatar mrstruijk commented on May 28, 2024

Thanks for the explanation! However, I'm not fully understanding it yet. So if I want to build to the Quest, and skip the dotnet run section, we're still having the issue of the shaders having to compile for the Mac? Or is it because the compilation is done on the Mac, that skshaderc is unhappy with me?

Aside from this, would you know anything the guy in this tutorial might have done differently? He's happily compiling from your repo directly to the Quest from his Mac. He doesn't seem to take any other additional steps to make it work. He uses the XPlat template from a couple of years ago, but for me that results in the same issue as I have with a current commit.

from stereokit.

rayperkins avatar rayperkins commented on May 28, 2024

@mrstruijk, my work colleague had the same build issue pop up, it turns out we had a .hlsl file in the project. Since this wasn't used and so just removing the .hlsl file mean the StereoKit build.targets won't attempt to execute the shader compile at build time. The build issue you see is because shader compilation is done on the build machine.
As for the tutorial, if you're mac is a newer ARM64 then that may make a difference if the tutorial used x86.

We've been happily building and debugging a StereoKit app on a Quest 2 from an ARM64 Mac, just without any custom shader hlsl files.

However, if you are using the custom shader then you'd be best to do the work around Nick's mentioned (aka, compile the shader on windows/linux, maybe even a linux docker image would work).

from stereokit.

maluoi avatar maluoi commented on May 28, 2024

Thanks for the explanation! However, I'm not fully understanding it yet. So if I want to build to the Quest, and skip the dotnet run section, we're still having the issue of the shaders having to compile for the Mac? Or is it because the compilation is done on the Mac, that skshaderc is unhappy with me?

StereoKit's NuGet comes with a tool for compiling .hlsl files into more platform appropriate shader data. Currently this comes in the form of skshaderc.exe, a Windows x64 binary, and skshaderc a Linux x64 binary. When a .hlsl file is detected in the C# project, it'll attempt to compile it using one of these two binaries, and on Mac, that'll fail.

I'm not currently sure why that previous demo would have worked, it's been a while and a lot has changed since then! If x64 Macs can run a Linux x64 executable (plausible for CLI stuff? I have no idea though), that could account for it. It's also possible that automatic shader compilation may have been working a bit differently back then 😅

But yeah, as rayperkins mentioned, removing .hlsl files from your project will get you past this for now. You would need to compile them manually on a different OS, and copy the resulting .sks files, you can load those directly instead.

from stereokit.

mrstruijk avatar mrstruijk commented on May 28, 2024

You guys are the best, thank you @rayperkins and @maluoi! I'm slowly starting to understand what is happening, and that Is very satisfying. This is why I love these open source communities so much!

Ok final thing for me to wrap my head around: I remove the .hlsl from the project then it should work, fine. But some shader is used, right? This may be because I've been "raised" in Unity, but you gotta have some shader I presume? What is the cube using? Or the hands? And how about if I import any model, and wouldn't need to use any specific shader, is it still going to render?

from stereokit.

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.