[SOLVED] Scripted material looks washed out compared to copied reference material

I am attempting to copy the brown material seen in the screenshot onto a scripted material that I can adjust at runtime. The pink material is that copy, so obviously it looks very different and washed out. im copying all the information seen below but the materials look very different. what propery could be causing this?

vineMat.diffuse.copy(this.deadVineMat.diffuse);
vineMat.emissive.copy(this.deadVineMat.emissive);
vineMat.specular.copy(this.deadVineMat.specular);

        vineMat.opacity = this.deadVineMat.opacity;
        vineMat.blendType = this.deadVineMat.blendType;
        vineMat.gloss = this.deadVineMat.gloss;

        vineMat.useMetalness = this.deadVineMat.useMetalness;
        vineMat.metalness = this.deadVineMat.metalness;
        vineMat.useLighting = this.deadVineMat.useLighting;
        vineMat.cull = this.deadVineMat.cull;
        vineMat.depthWrite = this.deadVineMat.depthWrite;
        vineMat.depthTest = this.deadVineMat.depthTest;

Hi @Aweber and welcome!

I don’t know if you already do, but I think you also need to update the material after applying the values.

vineMat.update();

Hey Albertos! I am updating the material but its still very weird looking.

No idea what could be the problem.

If you clone the brown material, why you need to set the values in the first place? They already should be good.

var vineMat = this.deadVineMat.clone();
var mesh = this.entity.render.meshInstances[0];
mesh.material = vineMat;
mesh.material.update();

I was not sure that it was copying over correctly so i ended up (redundantly) having both methods to be sure, but both produce the same result.

Are you able to create a sample project?

So I must have been copying the diffuse incorrectly or maybe translating it wrong? I was setting the colors to the incorrect values. I was using the 0-255 values and not the 0-1 values. Now its working correctly with the new values, (original value/255= correct value for scripting)

1 Like

Great you have solved the problem! The diffuse color is indeed using normalized values. Thanks for sharing your solution!