https://linen.dev logo
Join Discord
Powered by
# flixel
  • a

    able-printer-41379

    02/20/2023, 6:55 PM
    Copy code
    hx
    sprite.pixels.lock();
    for (x in 0...sprite.width+1){
      for (y in 0...sprite.height+1){
        sprite.pixels.setPixel32(x, y, new FlxColor(sprite.pixels.getPixel32(x, y)).getInverted());
      }
    }
    sprite.pixels.unlock();
  • w

    witty-island-52596

    02/20/2023, 6:57 PM
    https://mariusbancila.ro/blog/2009/11/13/using-colormatrix-for-creating-negative-image/
  • w

    witty-island-52596

    02/20/2023, 6:58 PM
    same math may apply to https://api.openfl.org/openfl/filters/ColorMatrixFilter.html
  • a

    able-printer-41379

    02/20/2023, 6:58 PM
    thanks
  • w

    witty-island-52596

    02/20/2023, 6:59 PM
    also what are you making where these effects need to be super performant but can't be a shader?
  • s

    shy-wire-69404

    02/20/2023, 6:59 PM
    Copy code
    glsl
    vec2 uv = openfl_TextureCoordv;
    vec4 color = texture2D(bitmap, uv);
    gl_FragColor = vec4(1.0 - color.rgb, 1.0)
  • s

    shy-wire-69404

    02/20/2023, 7:00 PM
    should work I think
  • w

    witty-island-52596

    02/20/2023, 7:00 PM
    I assumed this was some image processing tool
  • a

    able-printer-41379

    02/20/2023, 7:00 PM
    experimenting
  • a

    able-printer-41379

    02/20/2023, 7:00 PM
    with openfl
  • w

    witty-island-52596

    02/20/2023, 7:00 PM
    for?
  • a

    able-printer-41379

    02/20/2023, 7:01 PM
    nothing, just to learn more about it
  • h

    hallowed-holiday-15370

    02/20/2023, 7:01 PM
    to be fair, I only recently started messing with shaders at all and I still don't like using them very much... (and I was using my greyscale function to create an image that would be saved to disk)
  • s

    shy-wire-69404

    02/20/2023, 7:02 PM
    it's a learning curve
  • s

    shy-wire-69404

    02/20/2023, 7:02 PM
    but it opens up so much possibilities
  • a

    able-printer-41379

    02/20/2023, 7:02 PM
    i just moved from animations to colors since ive already experimented with animations (2 months ago i think) and made this with it https://github.com/Cherif107/OpenFL-Animate/
  • a

    able-printer-41379

    02/20/2023, 7:03 PM
    i honestly dont know what to do with it i just made it to learn more about openfl
  • w

    witty-island-52596

    02/20/2023, 7:09 PM
    I'm just saying pixel manipulation is something to avoid at all costs
  • w

    witty-island-52596

    02/20/2023, 7:10 PM
    like if there's a way to show something without it, use that, so maybe experiment with shaders if you're just bored, since they can do way more, way faster
  • w

    witty-island-52596

    02/20/2023, 7:13 PM
    especially if you're fine with resorting to to color matrix filter, which is just a poor mans shader
  • b

    busy-librarian-41101

    02/20/2023, 10:11 PM
    Hmm, speaking of avoiding pixel manipulation - any thoughts on passing a large set of values (say, a 200x200 grid of integers?) into a shader for drawing something like a minimap?
  • b

    busy-librarian-41101

    02/20/2023, 10:13 PM
    drawing something like this using setPixels32 is... fine? but a little ugly because it has to stay at low res to be performant. I haven't really successfully gotten around to passing arrays into a shader, and not sure if it would even be significantly more performant to just generate 40k perlin noise values -> pass it into the shader -> draw the map from there
  • s

    shy-wire-69404

    02/20/2023, 10:41 PM
    You sadly can't pass arrays to a shader currently. This is an openfl thing though, not flixel
  • s

    shy-wire-69404

    02/20/2023, 10:42 PM
    Best you can do is a mat4 with is 16 values and then again it's super annoying to work with in the shader because it's not an array
  • b

    busy-librarian-41101

    02/20/2023, 10:42 PM
    yeah, kinda what I thought 🙂
  • b

    busy-librarian-41101

    02/20/2023, 10:43 PM
    I suppose you can reduce the number of setPixel32 calls by 3x by writing values to a texture argb, then passing the texture to a shader
  • s

    shy-wire-69404

    02/20/2023, 10:43 PM
    There's an openfl pull request that should allow for some more features by letting you determine the glsl version, but no one reviewed it for quite some time
  • b

    busy-librarian-41101

    02/20/2023, 10:44 PM
    Could probably write to a texture - > pass the texture -> perform smoothing operations from within the shader to end up with a higher-res-appearing minimap
  • s

    shy-wire-69404

    02/20/2023, 10:45 PM
    You can also pass the camera buffer to the shader technically
  • s

    shy-wire-69404

    02/20/2023, 10:45 PM
    Yeah exactly
1...946194629463...9809Latest