setting NORMALMAP removes shading on model

Is this the proper way to set a textures normal map in the fragment shader?

NORMALMAP = texture(grassNORM, UV / grassScale).rgb * vec3(2.0, 2.0, 1.0) - vec3(1.0, 1.0, 0.0);

When I use set NORMALMAP it goes from being shaded to being unshaded;

Without Normal Map set;

With Normal Map set;

I can't seem to figure this one out...


  • TwistedTwiglegTwistedTwigleg Posts: 5,251Admin

    Maybe your normal map is flipped? I know that DirectX uses a flipped green channel for the Y axis, so that could be what is happening here.

    One thing that may also help is to render the normal map to the ALBEDO so you can visually see what the output of the normal map looks like. That might help with figuring out why the shading is disappearing.

  • Lethal Raptor GamesLethal Raptor Games Posts: 26Member

    It could be flipped.. I inverted the green channel in GIMP but it made no difference. I'm not even sure if that's the proper way to flip the y axis?

    The normal map looks like this plugged into the ALBEDO.

    When using a SpatialMaterial on a cube and applying only the normal map it seems to look okay.

    I'm using the ShaderMaterial resource on my terrain, is this the correct way to use my own shader? Or should I be using the SpatialMaterial and somehow overriding the shader somewhere?

  • Lethal Raptor GamesLethal Raptor Games Posts: 26Member
    edited July 2021

    Hmm, setting NORMALMAP_DEPTH to 0.0 brought all the shading back - but no normal applied. I guess that what a depth of zero means. Could this be an issue with ShaderMaterials processing the NORMAL_MAP?

    Something worth noting might be the fact I'm generating all vertex normals and uv cords in the vertex shader.

  • MegalomaniakMegalomaniak Posts: 4,430Admin
    edited July 2021

    Ah, sounds like you might have to re-normalize the map.

    There is a normalize() function in the shader language:

    You can try using that.

  • Lethal Raptor GamesLethal Raptor Games Posts: 26Member

    Thanks for your reply, however that made no difference. :/

  • Lethal Raptor GamesLethal Raptor Games Posts: 26Member

    If I calculate the normals in the vertex shader, do I need to also calculate the BINORMAL and TANGENT? Could that be the issue?

  • MegalomaniakMegalomaniak Posts: 4,430Admin


  • Lethal Raptor GamesLethal Raptor Games Posts: 26Member

    Yeah that was it, thanks guys. I don't know how I had forgotten about those.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file