Render as main texture with code


My mesh is not ideal. But I do not need any smoothness on it or effects. But it renders with black artifacts. It goes away when I toggle in inspector Material > Textures > Albedo wrench icon “Render as main texture”, And I like that.

How can I apply this on mesh load to my material??

Hello can you repro in the playground?

I can but there is nothing to reproduce.

I will like to know what kind of code that button is adding or executing on the material cause. cant find it in the docs.

For me, it actually fixes my mesh look.

I will try to reproduce it but I just need to know what code this executes. Thats it.


oh sorry I misunderstood then, the code is here:

In a nutshell, we are creating a standardMaterial with that texture as emmisive:

Thank you very much :slight_smile:

Now I understand my problem.

My loaded mesh does have PBRMaterial and that makes it to have all shadows and those black spots.

Changing it to StandardMaterial and disabling lightning and setting emissiveTexture as my texture sorted me out :slight_smile:

var debugMaterial = new StandardMaterial('debugMaterial', scene);
debugMaterial.disableLighting = true;
debugMaterial.emissiveTexture = m.albedoTexture;

that is doing the trick for me thanks.

2 more questions if I can.

  1. Is emissiveTexture here not using more performance? I just will like to have mesh with texture and no shading nothing but I will also like to get the most performance out of it. Is there a setting that I need to set up to squeeze as much as possible performance-wise?

  2. Is StandardMaterial more performant efficient then PBRMaterial in this case?

  1. no on the contrary! Emissive is probably the fastest
  2. YES!