Ariel Yust Posted December 15, 2013 Share Posted December 15, 2013 I have this image: you can notice it has a gradient alpha inside, made in PS I want it to look like this in my project: I made this example using PS I'm using HasAlpha=true; and getting this instead: it's like it can't read the gradient alpha and translates it to solid color, as you can see in the bottom he draws some artifacts.weird stuff, am I doing something wrong ? is there a solution ? will there be any solution ? note: this is a *mirror* object, because I have max 8 of it I don't create a normal mirror using the mirror texture. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 15, 2013 Share Posted December 15, 2013 Hello, if you want one bit alpha (meaning alpha test), you have to use diffuseTexture property of StandardMaterialIn your case, bcause you want alpha blending, you have to set your texture into StandardMaterial.opacityTexture Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 15, 2013 Author Share Posted December 15, 2013 Hey can you give an example ? tried the above and it didn't work ? var Materials=[];Materials.push(loadTexture("gfx/GraphSquare.png", true, true)); function loadTexture(fileName, backFaceCulling, hasAlpha) { var m = new BABYLON.StandardMaterial(fileName, scene); var texture = new BABYLON.Texture(fileName, scene); texture.anisotropicFilteringLevel = 0; m.opacityTexture = texture; // <-- Crashes here //m.diffuseTexture = texture; m.backFaceCulling = backFaceCulling; //m.diffuseTexture.hasAlpha = hasAlpha; return m; }when you mean set mt Texture into opacityTexture do you mean creating black and white gradient and loading it as another texture into opacityTexture ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 15, 2013 Share Posted December 15, 2013 Yes I meant exactly that:) You should keep the diffuseTexture also for getting colors What error do you get ? Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 16, 2013 Author Share Posted December 16, 2013 Materials.push(loadTexture("gfx/CategoryMirror.png", true, true, "gfx/CategoryMirrorOpacity.png")); function loadTexture(fileName, backFaceCulling, hasAlpha, opacityPath) { var m = new BABYLON.StandardMaterial(fileName, scene); var texture = new BABYLON.Texture(fileName, scene); texture.anisotropicFilteringLevel = 0; if (opacityMaterial != null) { m.opacityTexture = new BABYLON.Texture(opacityPath, scene); } m.diffuseTexture = texture; m.backFaceCulling = backFaceCulling; m.diffuseTexture.hasAlpha = hasAlpha; return m; }As you can see both files have the same sizewhat I see is just the CategoryMirror.png withou alpha at all... the edges that need to be transparent are in cyan color WIERD.... Am I doing this right ? Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 16, 2013 Author Share Posted December 16, 2013 Here is the solution It seems that when you use hasAlpha with opacity texture then hasAlpha wouldn't do anythingso in the Opacity I need to add the gradient as black color COOL stuff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 16, 2013 Share Posted December 16, 2013 So it works? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 16, 2013 Share Posted December 16, 2013 And BTW yes, if you use OpacityTexture you cannot set useAlpha to true because there are opposite (useAlpha means alpha testing and opacitytexture implies alpha blending) Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 18, 2013 Author Share Posted December 18, 2013 So it works? Yes id does, Thank you! And BTW yes, if you use OpacityTexture you cannot set useAlpha to true because there are opposite (useAlpha means alpha testing and opacitytexture implies alpha blending) Thanks for telling me that now I figured it out by my self, actually the opacity looks better then HasAlpha, so I guess I'll be using it for awhile (I know it cost resources) anyway thanks and I'm back to programming *click click click* GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 22, 2013 Author Share Posted December 22, 2013 Found a new interesting problem, might be a juicy bug here are two files, one is the OpacityTexture of the other... I'm using css style "background-image:" tag with z-index lower then canvas for the background image,so the rest of the babylon.js project has transparent background to it... I'v noticed that if an object with a material that have OpacityTexture moves on that canvas, and behind it there's nothing (aka no visible object), then it becomes half transparent or something~! then when it moves above an object that doesn't have OpacityTexture it appears normal~! now I thought it might be something to do with lighting but I double checked at it doesn't ~! I'v created OpacityTexture to all of my objects, and now they are all appear cyan/blue half transparent.but when I disable OpacityTexture to the most far object from the camera then, the rest are still in transparent mode until they move or stand still above that most far object which in this case is using the image below (category.png). Hope I explained the issue correctly got any way to fix that ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 22, 2013 Share Posted December 22, 2013 Could you show us a demo of the bug? Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 23, 2013 Author Share Posted December 23, 2013 Here you go, Upper half shows an example when there is an object in background without TextureOpacity, and the colorfulicons move in front of it, you can clearly see that they are transparent in the places where they do not touch him, aka the transparent canvas background. Lower half shows an example where even the objects in the background have their own TextureOpacity, everyone gets to be transparent...var Materials = [];Materials.push(loadTexture("gfx/Card001.png", true, false, "gfx/CardOpacity.png"));function loadTexture(fileName, backFaceCulling, hasAlpha, opacityPath) { var m = new BABYLON.StandardMaterial(fileName, scene); var texture = new BABYLON.Texture(fileName, scene); //texture.anisotropicFilteringLevel = 0; if (opacityPath != null) { m.opacityTexture = new BABYLON.Texture(opacityPath, scene); } m.diffuseTexture = texture; m.backFaceCulling = backFaceCulling; m.diffuseTexture.hasAlpha = hasAlpha; return m; }That's the light I'm using, btw light.excludedMeshes Doesn't seem to work, it crashes when I push Meshes inside...I don't need lighting on my objects because it's a 3D UI and a Prototype var light = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene); light.diffuse = new BABYLON.Color3(1, 1, 1); light.specular = new BABYLON.Color3(0.4, 0.4, 0.4); light.groundColor = new BABYLON.Color3(1, 1, 1); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 24, 2013 Share Posted December 24, 2013 What error do you get when trying to use the excludedMeshes? BTW, I'm afraid that the transparency behavior is "normal": the canvas supports transparency blending with its background and when you wrote a transparent object into it, it will use the alpha value for its own alpha blending This only fix I can propose is to use nothing under the canvas or use a fullscreen quad to remove alpha values Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 25, 2013 Author Share Posted December 25, 2013 I can't move the quad to be in front of the screen all the time, when I update it in the animation loopit takes like several mil seconds for the quad to update it's position and angle... there must be another way for this to work...the HasAlpha crops the images and leaves pixelated edges, which look ugly!so using opacity texture is something small you could do to make the edges smoother and nice like in Photoshop Not using this feature to make gfx look normal, it ruins the whole purpose, I mean this feature is a must...if the canvas is transparent then it should use the background colors for the transparency, not the same canvas's colorsbut the object behind it in the screen, if something like that can't be supported then is there a way to create a static background image to stretch to the screen size ? as if an image is in the background ? I give you an example - what will happen if I want to show lets say a 3D item spin in a menu and I put it in a new canvas in front of my main canvas... the opacity textures will make it look transparent and weird, so it means we will have to use only HasAlpha... anyway my point is I need a solution... do you have any ? Thanks for the help! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 25, 2013 Share Posted December 25, 2013 Hummm... I will find one I just need a sample project where the problem is obvious as a test scene Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted December 31, 2013 Author Share Posted December 31, 2013 Sorry that I can't share my project, but it's easy to create a test scene I'm using planes and the function that I'v included in here for setting materials =] I'm at work now, but later I'll create you a test scene - But just for you Delta Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 31, 2013 Share Posted December 31, 2013 So kind of you I hate when potential bugs remain Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted February 17, 2014 Author Share Posted February 17, 2014 Hey... Sorry for taking so long, I had life troubles... in any case here I uploaded the example as promised, I hope you understand the problem =] btw: I'm using the latest babylon.js version 1.9.0 don't forget to add it and change *.txt to *.js The problem is that the Blue image looks cyan because I'm using Opacity map to smooth the texture's edgesit receives it's original color when it's behind the Red image, which has no Opacity Map. You will see why this is wrong I made it animate for ya =] Thanks & Good Luckmain.htmlmainTutos.txtscene_tuto.txthands.txt Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 17, 2014 Share Posted February 17, 2014 I've just check in a new version of babylon 1.9. It should fix your problem:) Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted February 18, 2014 Author Share Posted February 18, 2014 Delta, there is an Uncaught SyntaxError: Unexpected Token }in line 1in the latest version 1.9.0 of Babylonjs in the minified version https://raw2.github.com/BabylonJS/Babylon.js/master/babylon.1.9.0.js I think it might be this function:cylinder.setIndices(indices);return cylinder;}; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 19, 2014 Share Posted February 19, 2014 It should work, this is the version I use on www.babylonjs.com Perhaps some issue with the download ? Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted February 20, 2014 Author Share Posted February 20, 2014 I'm testing it on the project I shared here... and I'm copy pasting the RAW of Babylon.js from this link https://raw2.github.com/BabylonJS/Babylon.js/master/babylon.1.9.0.js also, I included you a screenshot of the errors I'm getting... Quote Link to comment Share on other sites More sharing options...
Temechon Posted February 20, 2014 Share Posted February 20, 2014 Hello Ariel, I retrieved your project and I don't have any errors with the latest minified babylonjs, as you can see here : https://dl.dropboxusercontent.com/u/17799537/test/main.html It should be an error in your babylon file stored locally. Can you please try again with the last version of babylon ? Here is the version I used in this test folder : https://dl.dropboxusercontent.com/u/17799537/test/babylon.1.9.0.js Please try to "Save as" instead of copy-pasting. Ariel Yust 1 Quote Link to comment Share on other sites More sharing options...
Ariel Yust Posted February 25, 2014 Author Share Posted February 25, 2014 Okay great I copy paste it now and it works...I guess it was something with my browser showing me the code wrong I don't know... In any case Thanks Delta the fix you made works for me =] GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.