[solved] Problem with decal normals

Hi there, I have some trouble with DecalGeometry…
Here is the exemple which I modified to show my problem :
[update 27.06.19] - I changed materials to MeshNormalMaterial to better show the normal issue.

When I parent some decals in an object, which I thereafter rotate, the decals show weird shadows… I assume this is a problem of normal, but I’m not sure.

See the shadows of the stars on the following pictures ? It doesn’t follow the model’s normal.

I think there’s a confusion about how decals work. Each decal is separate geometry, and this new geometry is basically a cube cut-out of the original geometry, then a texture is painted on it. So, in your case, the head has a complex normal map, that map is ignored and only the head geometry is used. The reason for weird shadows is, probably, due to number of overlaps, because each of these spats is basically a separate mesh and if it is allowed to occlude - it will create these types of artifacts.

Hi Usnul, thanks for your answer.
I don’t know if if the shadow problem occurs because of overlapping meshes, because if I cancel the rotation of the mesh, I can overlap as much as I want without this issue occurring at any time :

Do you know how I can add decals to my non-static object, while keeping the lighting consistent ?

Normals when I adds the decals to a static object :

Normals when I rotate the object once, when I add it to the scene before to add the decals as its children :

Normals when I add the decals to the mesh while it’s rotating (my goal) :

those normals don’t look right (on the second to last image), normals along the back of the head pointing down.

It does look like something strange is going on. Maybe try to visualize normals on the decal geometry also. Also, perhaps try using “normal” material rendering for both as a toggle option, might help you get a better idea.

1 Like

I changed the materials as you suggested to make the problem more obvious, I updated the example of my first message.

I’ve been struggling so far without finding anything, it seems to come from how vertices normals are copied to the decal geometry inside DecalGeometry.
@Mugen87 I saw in the example code that you contributed to it, do you have any idea what could be my issue ?

Can you please verify if the vertex normals helper looks correct if you manually compute the vertex normals of the decal mesh like so:

var m = new THREE.Mesh( new DecalGeometry( mesh, position, orientation, size ), material );

The shading will not look correct, it’s just a test to verify if the normals have the right orientation.

1 Like

Hi Mugen, thanks for your quick answer,
the normals look correct with


I don’t really get it though, what does it mean ?

Let’s try something different. Remove the invocation of computeVertexNormals() and add an additional line in DecalGeometry after:

normal.transformDirection( mesh.matrixWorld );

I suspect DecalGeometry misses to transform the normal vector into world space.


It works ! My hero !
Thank you so much, I was turning mad :smiley:

1 Like

Will be fixed with R107 :+1: