Code Monkey home page Code Monkey logo

Comments (10)

almarklein avatar almarklein commented on June 5, 2024 1

... because it relies on a string format convention

Good point. It seems nice and simple, but it introduces new conventions to remember.

from pyshader.

Korijn avatar Korijn commented on June 5, 2024 1

I also like the 3-tuple, but the first component is just a limited set of choices (like the third component) so it is a little awkward that it's a string? How about:

    index: (INPUT, "VertexId", i32),
    outpos: (OUTPUT, "Position", vec4),
    outcolor: (OUTPUT, 0, vec3),

Just using constants or an enum? The options are then easy to discover with auto completing IDEs and REPLs, especially when scoped/namespaced properly

from pyshader.

almarklein avatar almarklein commented on June 5, 2024

Leaning towards the last option.

from pyshader.

almarklein avatar almarklein commented on June 5, 2024

I think this needs more time to sink in and refine. And I want to write a few more shaders (also a compute shader) before making a decision.

from pyshader.

Korijn avatar Korijn commented on June 5, 2024

Just adding a flavor for you to consider (haven't really got a clue about the internals at play here so please consider it just a brainfart)

@python2shader(inputs={"VertexId": i32}, outputs={"Position": vec4, "0": vec3})
def vertex_shader(inputs, outputs):
    positions = [vec2(+0.0, -0.5), vec2(+0.5, +0.5), vec2(-0.5, +0.7)]
    p = positions[inputs.VertexId]

    outputs.Position.xyzw = vec4(p, 0.0, 1.0)
    outputs.0.rgb = vec3(p, 0.5)

from pyshader.

almarklein avatar almarklein commented on June 5, 2024

I think I want the io definitions to be part of the function object, so putting it in the decorator might be a bit too far "up" :)

I put more examples above, basically flavors of using type annotations. I think I like the 2-tuple most; a normal type annotation tells "what the data is". We need to know "what the data is", and "where it comes from". We can fit the latter into a single string object relatively easily ...

from pyshader.

Korijn avatar Korijn commented on June 5, 2024

"Put definitions in the function signature - as object" looks most natural to me - the signature is very predictable Type(Key, DataType) :) love these new ideas!

I don't like this very much, because it relies on a string format convention rather than normal Python syntax:

    offset: ("input:SomeBuiltinIndex", i32),
    pos3dArray: ("buffer:0", Array(vec3)),
    avgArray: ("buffer:1", Array(f32)),

from pyshader.

almarklein avatar almarklein commented on June 5, 2024

Nice one, discoverability is indeed another plus for the "object-version", and using an enum brings that to the tuple-version. mmm ...

from pyshader.

Korijn avatar Korijn commented on June 5, 2024

Yeah or just predefined constants, like i32, vec4 etc are as well

from pyshader.

almarklein avatar almarklein commented on June 5, 2024

With #19 both the object-version and 3-tuple version are supported. We still need to decide on one (or e.g. a namedtuple) and refine it a bit.

from pyshader.

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.