Linear/point sampling runtime.

0 favourites
  • 5 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Any chance of getting linear/point sampling control per layout or as system action?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I also agree it would be nice, be it for only an option menu for some pixel based games if people do not enjoy pixels that much

  • I'd love to see it, but it doesn't seem feasible as a runtime toggle. To enable or disable linear sampling you need to reload the textures in question. So first off we'd need to have control over the loading of assets, which iirc can't be done while Canvas2D is still in the mix at least.

  • I figured it must be something that happens during the first loading/caching screen, on the other hand I would mind if this runtime action will preform a full browser reload to take effect, I just need something to check for it on the startup of C2, maybe save it to local storage and read it before loading the game, the other alternative is having 2 JS files, which is less ideal.

  • You can get a runtime point sampling/linear sampling toggle going if you don't mind editing layout.js a bit.

    How C2's rendering pipeline works is basically draw all scene objects onto a big texture and then display that texture on screen. Fullscreen scaling 'high quality' scales all objects up first, then renders them to the final output texture. 'Low quality' on the other hand renders all objects to the final texture at 1x1 scale and then scales that texture up to fill the screen afterwards. What this means is that if you disable linear sampling on the final texture then nothing gets filtered in 'low quality' mode because all the objects got rendered to it at 1x1, and texture filters only come into effect at non-1x1 scales.

    Simplest way to get it working (for webgl) is:

    Open layout.js and go down to the

    Layout.prototype.drawGL = function (glw)[/code:2z0irrse] line.
    
    Below that you'll see the 'if (render_to_texture)' if-statement where the final output texture gets created.
    
    Change both lines within, from:
    [code:2z0irrse]this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.linearSampling);
    [/code:2z0irrse]
    .. to:
    [code:2z0irrse]this.runtime.layout_tex = glw.createEmptyTexture(this.runtime.draw_width, this.runtime.draw_height, this.runtime.pointSampling);
    [/code:2z0irrse]
    And now you can turn linear sampling on and off by switching between 'high quality' and 'low quality' fullscreen scaling. 
    If you want it to work with shader effects as well it gets a bit more involved tho. PM me if you're interested and I'll explain more in detail.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)