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

    able-printer-41379

    05/27/2023, 8:26 PM
    like openfl_TextureCoordv / openfl_TextureSize etc..
  • a

    able-printer-41379

    05/27/2023, 8:26 PM
    i dont see anything that sets them in DisplayObject
  • h

    hallowed-ocean-84954

    05/27/2023, 8:36 PM
    they are set in the vertex shader
  • a

    able-printer-41379

    05/27/2023, 8:43 PM
    i know that they're made in the vertex shader, but more specifically where does
    shader.data.openfl_TextureCoordv.value = [...]
    happen
  • h

    hallowed-ocean-84954

    05/27/2023, 9:27 PM
    As far as know varying's are are set by one shader stage to pass to another shader stage. I don't think the host program ever sees them.
  • e

    enough-lawyer-1858

    05/27/2023, 10:11 PM
    I noticed there's a
    setPixels()
    function in
    BitmapData
    and I got curious how should the
    ByteArray
    behave so that the pixel transformation is set correctly?
  • e

    enough-lawyer-1858

    05/27/2023, 10:11 PM
    like
  • e

    enough-lawyer-1858

    05/27/2023, 10:13 PM
    if I had a 10x2
    BitmapData
    , and I wanted the pixels to turn red at positions
    (0,0)
    and
    (5, 1)
    how could I do that?
  • h

    hallowed-ocean-84954

    05/27/2023, 10:42 PM
    Looks like its row major layout.
  • e

    enough-lawyer-1858

    05/27/2023, 10:54 PM
    Oh, so like the pixels are as is to put it in a way?
  • h

    hallowed-ocean-84954

    05/27/2023, 10:56 PM
    row major would be all the pixels for the first row, then all the pixels for the next row and so on.
  • e

    enough-lawyer-1858

    05/27/2023, 10:57 PM
    like, from some lil pseudocode, this would be perfect?
    Copy code
    haxe
    var bitmapData = new BitmapData(10, 2, 0);
    var byteArray = new ByteArray(bitmapData.width * bitmapData.height);
    // and then do some loop that sets the colors to transparent and then calculate the position depending on which pixel is it, like if (5, 1), then position = 10
  • e

    enough-lawyer-1858

    05/27/2023, 10:58 PM
    something like that right?
  • h

    hallowed-ocean-84954

    05/27/2023, 10:59 PM
    yeah but the critical bit is how you loop over the rows and columns
  • h

    hallowed-ocean-84954

    05/27/2023, 11:00 PM
    Copy code
    for i 0...btimaptData.height {
         for j 0...bitmapData.width {
             set byte value for the pixel 
         }
      }
  • e

    enough-lawyer-1858

    05/27/2023, 11:00 PM
    Hm
  • h

    hallowed-ocean-84954

    05/27/2023, 11:00 PM
    the location in the array would be i*width + j
  • e

    enough-lawyer-1858

    05/27/2023, 11:01 PM
    wait, why i * width + j?
  • e

    enough-lawyer-1858

    05/27/2023, 11:01 PM
    oh
  • e

    enough-lawyer-1858

    05/27/2023, 11:01 PM
    I got it lmao
  • e

    enough-lawyer-1858

    05/27/2023, 11:02 PM
    but yeah, Thx! pretty helpful to play around
  • a

    able-printer-41379

    05/28/2023, 5:17 PM
    how can i grab the openfl_TextureCoord outside of a shader?
  • a

    able-printer-41379

    05/28/2023, 5:17 PM
    is there a property for it
  • h

    hallowed-ocean-84954

    05/28/2023, 5:32 PM
    Not that I know of - You might be able to get hold of the input attribute data from the ShaderParameters but then you should just be able to figure it out from the position and w/h of the sprite.
  • a

    able-printer-41379

    05/28/2023, 6:55 PM
    i tried __textureCoord.value but its always null
  • h

    hallowed-ocean-84954

    05/28/2023, 6:58 PM
    I have to ask, why do you need to read the value from Haxe though ? At best it just give you the sprite position which you should already know
  • a

    able-printer-41379

    05/28/2023, 7:46 PM
    so textureCoord is just sprite.x & sprite.y?
  • a

    able-printer-41379

    05/28/2023, 7:47 PM
    it got me confused since its a float that is smaller than 1
  • h

    hallowed-ocean-84954

    05/28/2023, 7:48 PM
    oh I'm sorry - I was thinking pos. No, texturecoord is a value between 0.0 and 1.0.
  • h

    hallowed-ocean-84954

    05/28/2023, 7:49 PM
    And that's true regardless of the sprite texture in use.
1...5354555657Latest