Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparency #4

Open
JMidd91 opened this issue Sep 5, 2018 · 12 comments
Open

Transparency #4

JMidd91 opened this issue Sep 5, 2018 · 12 comments

Comments

@JMidd91
Copy link
Contributor

JMidd91 commented Sep 5, 2018

Hi,

after successfully implementing texturity into my project, for some reason I cant get my textures to display their alpha channel?

obviously ive seen the code

 Texturity.initGL('webgl',{alpha:true}); //optional parameters

and also digging deeper -

export function initGL(contextName = 'webgl', params = {}) {
    if (gl) return gl;
  
    params = Object.assign({
        alpha: false,
        antialias: false,
        depth: false
    }, params);

    element = document.createElement('canvas');
    gl = element.getContext(contextName, params);
    format = params.alpha ? gl.RGBA : gl.RGB; 

    shaderManager = new ShaderManager(gl);
    programs = shaderManager.createPrecompiledShaders();
    vertexBuffer = createBuffer();

    return gl;
}

when turning alpha to true with using

Texturity.initGL('webgl2', { alpha: true, antialias: false, depth: false } );

it doesnt seem to do anything for me?

been looking online and all i can really find is this and a few other sites that say similar things but having tried most of it, doesnt seem to help me at all unless I am doing it wrong?

many thanks

@Ni55aN
Copy link
Owner

Ni55aN commented Sep 5, 2018

What operations do not leave transparency?

I think this is due to existing shaders that write a value of 1 to the transparency buffer.

@JMidd91
Copy link
Contributor Author

JMidd91 commented Sep 5, 2018

not sure what you mean, this is my code that i have used along side your script -

Texturity.initGL('webgl2', { alpha: true, antialias: false, depth: false } );
var fastCanvas = new Texturity.Canvas(textureSize, textureSize);

var texture = Texturity.loadTexture(img);
var previewImg = fastCanvas.drawTexture(texture, 0, 0, nodeTextureSize, nodeTextureSize).toSrc();
node.imgDiv.style.background = 'url('+ previewImg +')'

@JMidd91
Copy link
Contributor Author

JMidd91 commented Sep 5, 2018

here is an example of what i mean (the right node I manually added the same png file as the node on the left)

image

@Ni55aN
Copy link
Owner

Ni55aN commented Sep 5, 2018

Ok, I got it. Seems like drawTexture() write to alpha channel value 1.0 independently to image. I'll correct it

@JMidd91
Copy link
Contributor Author

JMidd91 commented Sep 24, 2018

just wondering, did this get updated? forgot about this issue haha

@Ni55aN
Copy link
Owner

Ni55aN commented Sep 24, 2018

Yes, I have a busy month :)

@JMidd91
Copy link
Contributor Author

JMidd91 commented Sep 24, 2018

no worries, just wanted to show this thread wasnt inactive :) is it updated here? doesnt seem to be different for me? no rush though! isnt a show stopper bug for me, im just not competent enough to fix it myself haha

@Ni55aN
Copy link
Owner

Ni55aN commented Sep 24, 2018

I mean I forgot about this too. No updates

@Ni55aN
Copy link
Owner

Ni55aN commented Sep 24, 2018

You can try to replace 1.0 with a certain color value in the last parameter of vec4

@JMidd91
Copy link
Contributor Author

JMidd91 commented Sep 24, 2018

if you mean this line i did actually try that with no luck, unless i am miss understanding?

@Ni55aN
Copy link
Owner

Ni55aN commented Sep 24, 2018

No, inside the shaders folder

@JMidd91
Copy link
Contributor Author

JMidd91 commented Sep 24, 2018

ok so with your guidance i did a bit of digging / learning and found / changed this line

to the following -

gl_FragColor = vec4(texture2D(texture, texcoord).rgba);

if youre happy with this we can close this issue, i have created a pull request :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants