https://linen.dev logo
Join Discord
Powered by
# openfl
  • f

    future-iron-61487

    03/23/2023, 4:44 AM
    google just injects shit because they think they're king of the world
  • d

    damp-artist-60225

    03/23/2023, 6:33 PM
    Yeah it seems they want people to use their embeded button, I didn't even think there was another option, the documentation was a bit confusing to me
  • a

    ambitious-knife-25690

    03/23/2023, 6:45 PM
    maybe, but, they're also operating on a huge scale. If they make some kind of api change, having the ability to not break everything for every service seems useful
  • f

    future-iron-61487

    03/24/2023, 12:42 AM
    That absolutely makes sense, but they used it to change the behaviour of your website (effectively adding a popup) which I think is inexcusable
  • h

    hallowed-ocean-84954

    03/24/2023, 4:44 AM
    Can someone explain why
    Copy code
    final fs_string = '#pragma header
       
            uniform float uWidth;
            uniform float uHeight;
            uniform float uPixelWidth;
            uniform float uPixelHeight;
    
            void main() {
                vec2 st = openfl_TextureCoordv.xy;  // Note, already normalized
    
                float x = floor(floor(openfl_TextureCoordv.x * uWidth / uPixelWidth) * uPixelWidth) / uWidth;
                float y = floor(floor(openfl_TextureCoordv.y * uHeight / uPixelHeight) * uPixelHeight) / uHeight;
                
                // Output the color
                // gl_FragColor = flixel_texture2D(bitmap, vec2(x, y));    
                gl_FragColor = vec4(grayscale(bitmap, vec2(x, y)), 1.0);
            }
        ';
        @:glFragmentSource(fs_string)
    throws
    Copy code
    haxe\std/haxe/macro/ExprTools.hx:286: characters 12-17 : Uncaught exception Unsupported expression: {pos: #pos(parasol/shaders/GrayscalePixelationShader.hx:65: characters 24-33), expr: EConst(CIdent(fs_string))}
    .../openfl/9,1,0/src/openfl/utils/_internal/ShaderMacro.hx:37: characters 26-51 : Called from here
    when just including the literal string it builds ok ?
  • h

    hallowed-ocean-84954

    03/24/2023, 4:45 AM
    the reason I ask is that I am trying to load shader source from a file and throw it at the metadata and it's not working
  • a

    able-action-74275

    03/24/2023, 8:18 AM
    @hallowed-ocean-84954 does it work if you use var instead of final?
  • h

    hallowed-ocean-84954

    03/24/2023, 1:10 PM
    @able-action-74275 no it doesn't - tried both and tried static and non-static.
  • h

    hallowed-ocean-84954

    03/24/2023, 1:12 PM
    I was mulling it over last night and I don't really understand the error message - I believe it's a type mismatch in essence but I don't see quite how. I had a look at the ShaderMacro code and I think it's trying to read the metadata parameter and I'm guessing that whatever phase of compilation constructs that is not constructing the right type.
  • a

    able-action-74275

    03/24/2023, 1:13 PM
    yeah I think I had a similar problem when I did somethign like this
  • a

    able-action-74275

    03/24/2023, 1:14 PM
    ended up changing
    glFragmentSource
    at run time in my shader constructor before calling
    super()
  • h

    hallowed-ocean-84954

    03/24/2023, 1:15 PM
    ah .... I tried something like that but that created the additional problem that now the macro processing was not creating the member variables for the uniforms
  • h

    hallowed-ocean-84954

    03/24/2023, 1:15 PM
    so that broke the rest of the shader comp.
  • a

    able-action-74275

    03/24/2023, 1:16 PM
    yeah it's a bit tricky
  • h

    hallowed-ocean-84954

    03/24/2023, 1:16 PM
    I'm a bit baffled because I thought a string was a string was a string but clearly it's not that simple
  • a

    able-action-74275

    03/24/2023, 1:18 PM
    what I ended up doing was having the
    glFragmentSource
    set up ready for macro to be able to replace the
    #pragma header
    and then doing a find and replace in constructor to inject the extra source
  • a

    able-action-74275

    03/24/2023, 1:18 PM
    I replace
    //!voidmainImage
    with the injected source
  • a

    able-action-74275

    03/24/2023, 1:19 PM
    maybe it's wonky but it works
  • a

    able-action-74275

    03/24/2023, 1:19 PM
    that way the macro can do it's thing
  • h

    hallowed-ocean-84954

    03/24/2023, 1:20 PM
    ah ... and that doesn't change the uniforms so the macro works .... hmmmm
  • h

    hallowed-ocean-84954

    03/24/2023, 1:22 PM
    My aim is to be able to stop using cut and paste and define a library of functions and use macros to assemble the functions into a program. But the main program would have to define the uniforms. So something like what you did would probably work
  • a

    able-action-74275

    03/24/2023, 1:23 PM
    an alternative is changing the macro and adding your own inject points, which might be possible with source shadowing?
  • a

    able-action-74275

    03/24/2023, 1:25 PM
    all goes down in
    src/openfl/utils/_internal/ShaderMacro.hx
  • h

    hallowed-ocean-84954

    03/24/2023, 1:25 PM
    I'm not a fan of source shadowing for the long term, fine for testing I guess and you're ok so long as you don't update the lib and have to keep up to date. And I would like to put this into parasol in a way people could just use the functions too - and shipping a shadow seems more problematic still
  • a

    able-action-74275

    03/24/2023, 1:26 PM
    yeah
  • h

    hallowed-ocean-84954

    03/24/2023, 1:26 PM
    I think I'll try to learn more about how metadata processing works - maybe there is a way to trick the system
  • h

    hallowed-ocean-84954

    03/24/2023, 1:26 PM
    I fear that's buried in the compiler somewhere though - which I've never looked at
  • h

    hallowed-ocean-84954

    03/24/2023, 1:28 PM
    but many thanx for kicking ideas around - and thanx for the shadertoy example - may end up doing something similar
  • a

    able-action-74275

    03/24/2023, 1:30 PM
    no worries, hope it helps! sometimes quick and dirty is the best we have 😅
  • a

    able-action-74275

    03/24/2023, 1:30 PM
    I would be interested in a cleaner solution though
1...474849...57Latest