Giter Site home page Giter Site logo

Array of Structs about fshade HOT 3 CLOSED

krauthaufen avatar krauthaufen commented on June 15, 2024
Array of Structs

from fshade.

Comments (3)

krauthaufen avatar krauthaufen commented on June 15, 2024 1

Is there a way to import only those functions which are actually defined for FShade? (for example, step is not defined, but is in Aardvar.Base.Fun).

Sadly not atm. but this would certainly make sense. maybe a new namespace FShade.Base re-exporting all the available functions could help there.

How would I go about adding a function? Either one which is built-in, or one which I include from a glsl library. I would like to add the step function, which I assume is not in their because Aardvark has a step function with a different meaning and type signature.

Adding an intrinsic function can be done via the GLSLIntrinsic attribute like:

[<GLSLIntrnsic("mix({0}, {1}, {2})")>]
let mix (a : float) (b : float) (t : float) : float = onlyInShaderCode "mix"

Hope that helps.

from fshade.

krauthaufen avatar krauthaufen commented on June 15, 2024

Hey, yes that should be possible, as long as you use array literals (instead of lists) if memory serves.
In that case the Arr wrapping should be unnecessary, since FShade will turn the array into a constant.

Another option would be to create an Arr using Unchecked.defaultof<_> as initial value and then set the elements via mutation.

from fshade.

makeartandgames avatar makeartandgames commented on June 15, 2024

I would like to contribute to the documentation and with an example, but I have been struggling due to #17 and some obscure runtime exceptions. For example, if I attempt to initialize an Arr like Arr([1.0, 2.0]) but forget to annotate with a type, I get a runtime exception about INatural being invalid. I am trying to track these as I go.

But I can initialize arrays, and I found IntrinsicFunctions.fs which helps with #17. I'm not sure I get what's going on though. These seem to be overriding the functions in Aardvark.Base.Fun. But....

  1. Is there a way to import only those functions which are actually defined for FShade? (for example, step is not defined, but is in Aardvar.Base.Fun).

  2. How would I go about adding a function? Either one which is built-in, or one which I include from a glsl library. I would like to add the step function, which I assume is not in their because Aardvark has a step function with a different meaning and type signature.

from fshade.

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.