Jump to content

show Edge line between image and image like border


GBear
 Share

Recommended Posts

hi. i was using 2.2.9... and i updated to 3.0.8 yesterday..

and than i can see edge line with scaling or moving ..

 

 

basetexture has 1024*1024 size  and sprites draw sequentially like
    sprite1.position.set(0,0),  sprite2.position.set(1024, 0) 

 

 

what can i do for this?

thx..

 

 

post-10357-0-56133100-1448994242.png

Link to comment
Share on other sites

You dont have to make rounded coords, we can try solution based on filter I just came up with :)

function pixiAddTileFilter() {    var core = PIXI;    function TileFilter()    {        core.AbstractFilter.call(this,            // vertex shader            null,            // fragment shader            ['precision mediump float;',            'varying vec2 vTextureCoord;',            'uniform sampler2D uSampler;',            'uniform float alphaEdge;',            'void main(void)',            '{',            '   gl_FragColor = texture2D(uSampler, vTextureCoord);',            '	if (gl_FragColor.a > alphaEdge) gl_FragColor.a = 1.0;',            '}'].join("\n"),        // custom uniforms            {                alphaEdge:        { type: 'f', value: 0.25 }            });    }    TileFilter.prototype = Object.create(core.AbstractFilter.prototype);    TileFilter.prototype.constructor = TileFilter;    core.filters.TileFilter = TileFilter;}pixiAddTileFilter();

1) move your terrain in separate containter, which filterArea will contain current screen

container.filterArea = new PIXI.Container(0,0,renderer.width,renderer.height);

2) DO NOT MOVE THE CONTAINER. move terrain inside.

 

3) apply filter:

container.filters = [new PIXI.filters.TileFilter()];

I didnt try this solution yet, I just wrote it in notepad, I'll be happy if you create project for it to test :)

 

UPD. i tested this solution only in SVG, didnt test it in webgl yet

Link to comment
Share on other sites

I'm using antilias:true ...and same.. 
not using .. same..


and i don't use rounded coordinates for this.. 
sprite position always same.. and onlyposition  changed by parent container.

it look like reapet border like  bubamara tell me.... so i wanna set to CLAMP_TO_EDGE..

How can i control this?

thx..
 

Link to comment
Share on other sites

hi. i adjust forced..(not clear code);

i add texture.forceEdge..becuase Texture of 'powerOfTwo' set always gl.REPEAT);

 

and i can set outside...

 

i set to 'true' on  my 1024*1024 basetexture.

 

and then i can look normal screen 

        if(texture.forcedEdge){                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);        } else {            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);        }

THIS IS NORMAL SCREEN. 

post-10357-0-00092900-1449014095.png

WebGLRenderer.prototype.updateTexture = function (texture){    texture = texture.baseTexture || texture;    if (!texture.hasLoaded)    {        return;    }    var gl = this.gl;    if (!texture._glTextures[gl.id])    {        texture._glTextures[gl.id] = gl.createTexture();        texture.on('update', this.updateTexture, this);        texture.on('dispose', this.destroyTexture, this);    }    gl.bindTexture(gl.TEXTURE_2D, texture._glTextures[gl.id]);    gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha);    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source);    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST);    if (texture.mipmap && texture.isPowerOfTwo)    {        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST);        gl.generateMipmap(gl.TEXTURE_2D);    }    else    {        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST);    }    if (!texture.isPowerOfTwo)    {        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);    }    else    {                if(texture.forcedEdge){                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);        } else {            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);        }    }    return  texture._glTextures[gl.id];};
Link to comment
Share on other sites

Clamp will give you a more subtle seam, in this case you really won't see it (it's more subtle then the jpeg compression and DCT blocks I suspect) but I think overlapping such textures may be a better solution in the general case

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...