davimusprime Posted June 9, 2017 Share Posted June 9, 2017 I'm working on a batting helmet customizer. The user chooses a style and then colors/finishes for the sections of the style. With all of the style and color options available I decided it would be best to let babylon color the model instead of loading a bunch of textures whenever a color/style was changed. So, my idea was to take the original model in the scene, make it the "base" color then clone it, change its color to the secondary color and apply the opacityTexture to crop out the style where I want it. let original = this.scene.getMeshByName(name); let clone = original.clone(name + 'clone',original.parent); clone.material = original.material.clone(original.material.name+'clone'); (<BABYLON.StandardMaterial>clone.material).diffuseColor = BABYLON.Color3.Green(); let task = loader.addTextureTask('opacity','assets/textures/opacity.png'); task.onSuccess = (t) => { console.log(t); (<BABYLON.StandardMaterial>clone.material).opacityTexture = t.texture; clone.position.y = 0.003; }; At first, this didn't appear to do anything, but if I offset the clone just a tiny bit there was actually some transparency stuff happening. Sadly, it wasn't transparent where it was supposed to be and it seemed to only be able to go transparent along vectors. We used this approach using three js (and alphaMap instead of opacityTexture) with better results but the application is just too cumbersome on machines and babylon seems, at least in theory, to have better performance. helmets.custom.rawlings.com Any tips, suggestions, or other routes I should take? Thanks, David Quote Link to comment Share on other sites More sharing options...
davimusprime Posted June 9, 2017 Author Share Posted June 9, 2017 Oh, and here's the opacity texture. going for a fade from one color to the other. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 10, 2017 Share Posted June 10, 2017 Hey So the opacity texture considers that you provide a transparent texture by default. If you prefer using RGB to provide the opacity, then just set material.opacityTexture.getAlphaFromRGB = true Quote Link to comment Share on other sites More sharing options...
davimusprime Posted June 12, 2017 Author Share Posted June 12, 2017 On 6/10/2017 at 0:42 PM, Deltakosh said: Hey So the opacity texture considers that you provide a transparent texture by default. If you prefer using RGB to provide the opacity, then just set material.opacityTexture.getAlphaFromRGB = true hoooooooly crap! thank you thank you thank you! 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.