Hello there,
I’ve created a simple PBRMetallicRoughness shader using the Node Material tool where I can customize the color of my models, with diffuse, normal and a color map texture reads and I can preview there just fine there and when I load that inside my game as well. However, I need to feed custom textures on them (for different kind of models I have, obviously) and I followed this tutorial
to assign the textures but whenever I do that the tiling bugs out.
Here’s a code snipped
async LoadCustomMaterial () : Promise {
this._nodeMaterial = await BABYLON.NodeMaterial.ParseFromFileAsync(‘MyModelColorSwap’, this._assetManager.getPath(‘shaders/’) + ‘MyModelColorSwap.json’, this._scene!);
}
Later on I do
LoadTextures () : void {
this._albedo = new BABYLON.Texture(this._assetManager.getPath(‘textureMaps/’) + ‘My_Albedo.png’, this._scene);
this._colorMask = new BABYLON.Texture(this._assetManager.getPath(‘textureMaps/’) + ‘My_ColorMap.png’, this._scene);
this._normal = new BABYLON.Texture(this._assetManager.getPath(‘textureMaps/’) + ‘My_Normal.png’, this._scene);
}
and then
const diffuseBlock = this._nodeMaterial!.getBlockByName('DiffuseMap');
const colorMapBlock = this._nodeMaterial!.getBlockByName('ColorMap');
const normalBlock = this._nodeMaterial!.getBlockByName('NormalMap');
const txtDiffBlock = diffuseBlock as TextureBlock;
const txtColorMapBlock = colorMapBlock as TextureBlock;
const txtNormalBlock = normalBlock as TextureBlock;
txtDiffBlock.texture = this._albedo;
txtColorMapBlock.texture = this._colorMask;
txtNormalBlock.texture = this._normal;
I print all the values and everything seem ready.
I also tried matching every single parameter that I have inside Node Material (Texture Node) via code to see if that was the issue, but with no luck.
Ex:
txtDiffBlock.texture.wrapU = 1;
txtDiffBlock.texture.wrapV = 1;
txtDiffBlock.texture.uAng = 0;
txtDiffBlock.texture.vAng = 0;
txtDiffBlock.texture.wAng = 0;
txtDiffBlock.texture.uOffset = 0;
txtDiffBlock.texture.vOffset = 0;
txtDiffBlock.texture.uScale = 1;
txtDiffBlock.texture.vScale = 1;
etc.
I also tried BABYLON.NodeMaterial.IgnoreTexturesAtLoadTime = true;
Any ideas on what’s going on in my case?
Cheers!