Sign in to follow this  
obiot

beta 8.0 & updated WebGL renderer

Recommended Posts

Hi all,

The 8.0 release cycle was supposed to mainly focus on the physic implementation (that we started) but we ended up revamping the WebGL renderer following increasing report of issues in terms of compatibility and/or performances since we did enable WebGL auto-detection since version 7.0

Now we have a much more "modern" implementation, better recycling/cleaning of WebGL texture across screen/stage change, a much more compatible implementation on platform like Linux, which should now allow to have the WebGL renderer working by default on most of the platforms.

Performances also have been drastically improved, with things like the fragment Shader that have been super simplified for texture rendering, coming from the previous code in the 7.0.x version :

// Uniforms

/**
 * 2D texture sampler array
 * Maximum number of textures is determined at compile-time
 * @ignore
 */
uniform sampler2D uSampler[{{= ctx.maxTextures }}];


// Varyings

/**
 * Fragment color
 * @ignore
 */
varying vec4 vColor;

/**
 * Fragment texture unit index
 * @ignore
 */
varying float vTexture;

/**
 * Fragment texture coordinates
 * @ignore
 */
varying vec2 vRegion;


void main(void) {
    // Convert texture unit index to integer
    int texture = int(vTexture);


    if (texture == 0) {
        gl_FragColor = texture2D(uSampler[0], vRegion) * vColor;
    }
{{ for (var i = 1; i < ctx.maxTextures - 1; i++) { }}
    else if (texture == {{= i }}) {
        gl_FragColor = texture2D(uSampler[{{= i }}], vRegion) * vColor;
    }
{{ } }}
    else {
        gl_FragColor = texture2D(uSampler[{{= ctx.maxTextures - 1 }}], vRegion) * vColor;
    }
}

 

to a much more simple version in 8.0 :

uniform sampler2D uSampler;
varying vec4 vColor;
varying vec2 vRegion;

void main(void) {
   gl_FragColor = texture2D(uSampler, vRegion) * vColor;
}

all this to say that before officially release this version (probably later this week) I would love some feedback, for those already using master or if anyone is willing to give it a try, to make sure there are no major regression compared to the 7.0 branch, or just to hear about the performance improvement you are noticing.

latest build is available here https://melonjs-builds.s3.amazonaws.com/index.html?prefix=artifacts/master/2616/build/

last thing, as I was mentioning that we started to also improve the physic implementation, as a consequence we now have a world global gravity settings that can then be lowered or amplified per physic object (instead of previously where each object gravity were managed separately), see here for the detailed changes : https://github.com/melonjs/melonJS/wiki/Upgrade-Guide#71x-to-800

In the 8.0 version if you need to adjust the global gravity value, you can just change or disable ut by setting me.game.world.gravity to 0 (it's a vector) and you should be back to the previous 7.x behaviour.

Looking forward to your feedback,

thanks !

Edited by obiot

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.