djeustice Posted November 6, 2017 Share Posted November 6, 2017 Hello. I have this Seat.gltf model in my scene that I exported it from 3ds Max. Anyways, how do I change the diffuse texture on it? The seat imports with a black texture (SeatBlack_baseColorTexture.png). I'd like to change it to this (SeatLime_baseColorTexture.png). My goal eventually is to let the user pick from a variety of seat colors. Any pointers in the right direction would be appreciated. Thanks. var mySeat = BABYLON.SceneLoader.Append("./models/", "Seat.gltf", scene, function (scene) { }, null, function (scene) { var LimeTexture = new BABYLON.PBRMaterial("", scene); LimeTexture.baseColorTexture = new BABYLON.Texture("models/SeatLime_baseColorTexture.png", scene); mySeat.material = LimeTexture; }); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 6, 2017 Share Posted November 6, 2017 Hello you can have a look at the PBR documentation here: http://doc.babylonjs.com/how_to/physically_based_rendering 3dsMax is exporting PBRMetallicRoughnessMaterial: http://doc.babylonjs.com/how_to/physically_based_rendering#pbrmetallicroughnessmaterial Quote Link to comment Share on other sites More sharing options...
mr_pinc Posted November 6, 2017 Share Posted November 6, 2017 Based off of your small example it appears your texutre swap is happening in the incorrect place. It's happening in the 'Error' callback of the load method. It should be in the first callback that you currently have blank. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
djeustice Posted November 7, 2017 Author Share Posted November 7, 2017 This seems to be working for changing just the diffuse texture. I'll take a look at exporting PBRMetallicRoughness from 3ds Max. Thank you kindly. var myKayak2; BABYLON.SceneLoader.ImportMesh("", "models/", "Kayak.gltf", scene, function (newMeshes) { myKayak2 = newMeshes[0]; var BWTexture = new BABYLON.StandardMaterial("BlueWave", scene); BWTexture.diffuseTexture = new BABYLON.Texture("models/BlueWave.png", scene); BWTexture.diffuseTexture.hasAlpha = false; BWTexture.backFaceCulling = false; myKayak2.material._subMaterials[2] = BWTexture; }); Quote Link to comment Share on other sites More sharing options...
efxlab Posted February 10, 2018 Share Posted February 10, 2018 (edited) hey @djeustice, what is ._subMaterials[2] ? I have not success to change texture from gltf scene. From a new material I got not UVs texture placement correct and change in live from DynamicTexture I have black texture. Here an exemple : Edited February 10, 2018 by efxlab example Quote Link to comment Share on other sites More sharing options...
Guest Posted February 12, 2018 Share Posted February 12, 2018 So @efxlab found a solution: The texture has to be loaded flipped:) efxlab 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.