Changing project sampling during runtime?

0 favourites
  • 7 posts
From the Asset Store
Antisuspend Plugin for Construct 3 prevents the runtime from getting suspended.
  • Ayy, similar to how there is a system action to "set pixel rounding", would it (hopefully) be a minor addition to add a "set filtering option" system action?

    I have a project that uses Linear sampling, but the sprites are pixel art. The project aims to be very customisable/moddable. I use linear sampling as it helps with making everything look smoother with rotations and 3DCamera and such. I messed around with point sampling but it looks too jagged and not good, doesn't look retro or cool, just looks distorted and eh.

    With an option to change filtering to point/linear at runtime, this would allow the player to do pixel art editing with drawing canvas. It would be acceptable to have the project change to Point sampling during this time, paste some stuff and make some changes to the drawing canvas, save it, then switch back to linear sampling when finished. This could also allow pallete swaps, as you could loop through each pixel on the drawing canvas to change a specific colour (whereas if you did this with linear sampling, then upon pasting a sprite, the colours in the drawing canvas are blurred between each other and it would not be easy to change 1 or 2 specific colours).

    Currently when linear sampling is on, I'm not sure it is possible to load clean pixel art into drawing canvas as you cannot "Load from url", and pasting a sprite will paste the linearly filtered sprite and not the original non-filtered pixel art.

    I originally wanted to use "set colour" to allow players to change the colours of parts of their character. However, effects only apply after the sprite has been linearly filtered, making the results of "Set colour" look unusual as it doesn't set the colour of the inbetween blended colours that appear from linear sampling, even if you mess with the tolerance parameter.

    If it's not minor, I'll pop it on the suggestions platform for sure.

    Thank you for your time!

  • in game running only we can change fullscreen scaling quality.

    Also i need other actions to set Pixel rounding,

    downscaling and sampling should be avaliable in event sheet

  • This isn't actually possible with WebGL 1, which still has some usage, and I suspect it would involve some fairly complicated updates to the renderer, so I doubt it's a simple change.

  • It seems possible in webgl 1 since the sampling is set per texture, but maybe the worry is how slow looping over all the textures and changing each one would be? Webgl 2 adds the sampler object which would let the filter change be done in one spot.

    Anyways, I can appreciate the issue of having to do it multiple ways depending on the webgl version, not to mention any renderer redesign to support such a feature.

  • Yeah, technically there's an API for it, but I'm pretty sure it would totally trash performance. I think some drivers even internally create an entirely new texture if you change the sampler option so it would cause a severe performance hit. The only good way to do it is with separate samplers, and further, currently all the rendering code works on the assumption the same sampling is used project-wide, because that's the only thing that's ever been supported so far.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I couldn't find anything about some drivers doing that, but I suppose drivers could do anything behind the scenes. Even if it was slow it's not something that would need to be done per frame, or in the case of what that initial post only some specific objects would need to be changed.

    Realistically all that would be needed is an option for a canvas to be drawn without filtering if wanted. The pixelate effect can be used to do the nearest filtering instead but it's not 100% perfect and isn't simple to do.

    Jase00

    You can utilize the pixelate effect to simulate nearest filtering of a scaled up canvas. If the canvas and sprite are unscaled the sprite will paste 1:1 perfect as long as you offset the canvas by (-0.5,-0.5).

    dropbox.com/s/88hlbstc1gjol2e/simulated_nearest_filtering.c3p

  • Thanks for the reply, Ashley. Definitely sounds more complex than I thought it might be.

    And R0J0, wowww this pixelate effect is a game changer!! Even ignoring drawing canvas for a moment, just throwing pixelate onto a sprite and setting pixel size to 1, and then using "set colour", works fine with linear filtering!! This opens so many doors for me!

    The only issue being when zoomed out far away with 3DCamera, the set colour struggles to apply (I guess the pixelate effect is struggling to apply too), and another issue with pixelate effect not applying at all on non-square images, but these are minor issues (and might be related to scaling which I need to wrap my head around a bit more). Beyond this, you could bake the colours/changes to a sprite by utilising drawing canvas to paste the clean pixelated sprite, make changes to the drawing canvas, load back into a sprite via Load URL, then there's no need to worry about the effects applying correctly anymore. Amazing!!

    I always thought the pixelatte effect was more for smaller little effects or screen transitions or something, but now I perceive it differently and see it as a tool to allow you to use linear filtering in your project, whilst still allowing you to choose individual objects that you would like to have point sampling applied to.

    Many thanks for unlocking many new ideas in my mind, and thanks for the example c3p. I hadn't explored the "using mouse to draw on canvas" aspect yet, so this helped a huge amount!!

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