Canvas/Image Manipulator problem

This forum is currently in read-only mode.
From the Asset Store
Elevate your games with our AI Chatbot Integration! Seamlessly connect your Construct 3 projects with GPT-4 for dynamic,
  • Slightly related to my previous issue...

    I have a Sprite from which I need to sample four color values from four different locations and paste them into an Array in the same cycle. To do that, I create a very small "capture" Canvas and loop through all the locations, moving the small canvas, pasting the Sprite onto it, copying the Canvas into an Image Manipulator and finally getting the Array value using Get R/G/B form the manipulator...

    The problem is, Image Manipulator only seems to catch the last color value. All the other steps execute properly, except for this particular one... Does anyone have any idea why this is happening? And is there a workaround?

    Here's a .cap that shows the problem:

    sendspace.com/file/b636gt

    Thanks in advance.

  • Transferring from the graphics card's VRAM to RAM needs 1 tick. So you have to delay the copying to the image manipulator by 1 tick each.

    Here's your changed cap: ImgManip_Canvas.cap

    You could also work with functions and call them delayed. I decided not to use them, because you can only delay a function in milliseconds, but you never know exactly how long a tick lasts. To avoid future issues with a function call coming too early or too late, I made it tickbased.

    EDIT: Wrong file linked. Corrected.

  • Thanks for the sample file.

    I was affraid it was the GPU-CPU data transfer...

    Unfortunately, I can't delay the color data collection by a tick, as the number of points to be sampled varies and the sampled data is used to construct just a portion of the final rendered frame.

    To give a bit more info, the colors are sampled from a depth pass of a scene and determine if a "light locator" (just a uniformly colored Sprite) is occluded by other objects - if the sample indicates it's not - draw a lens flare, if it is - do nothing and iterate to the next locator.

    Since I've posted, I came up with a more crude way of getting this "occlusion" data - the Capture Canvas still gets a part of the depth pass at the Light Locator coordinates, the lens flare is always drawn, but then the Capture Canvas gets stretched to fit the entire screen and is multiplied over the flare - non-occluded Capture Canvasses will be white, giving no change, while occluded ones will be black - blacking out the flare.

    It's an extra set of drawing and pasting instrucions, but so far performance doesn't suffer. I just waste 2MB of VRAM for the fullscreen flare Canvas.

    Thanks for your help.

  • Here is a way to check to see if a sprite is occluded by using only collisions.

    http://dl.dropbox.com/u/5426011/examples12/lensflare.cap

    • The flare has a point collision and is used to check every pixel of the det sprite to see if it's visible using ZIndex and collision.
    • The Sprite events can be replaced by a family to handle more objects.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you for the example file - yes, I know of point/per-pixel overlap tests.

    What I failed to mention is that I'm detecting occlusion in an environment comprising of 3dObjects and Sprites with displacement - overlap tests won't work on these, due to the collision masks not being accurate/updated...

    The Image Manipulator color picking was supposed to allow me to skip the flare drawing routine in case of occlusion, instead of drawing it and masking it over...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)