# GLSL HARD Problem: Dynamically calculated normals in shader work on wrong axis

**URL:** <https://discourse.threejs.org/t/glsl-hard-problem-dynamically-calculated-normals-in-shader-work-on-wrong-axis/16560>\
**Category:** Questions\
**Tags:** glsl\
**Created:** [June 25, 2020, 11:57pm UTC](https://discourse.threejs.org/t/glsl-hard-problem-dynamically-calculated-normals-in-shader-work-on-wrong-axis/16560 "2020-06-25T23:57:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rockclimber](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/rockclimber/32/1043_2.png) [@rockclimber](https://discourse.threejs.org/u/rockclimber)\
**Post date:** [June 25, 2020, 11:57pm UTC](https://discourse.threejs.org/t/glsl-hard-problem-dynamically-calculated-normals-in-shader-work-on-wrong-axis/16560/1 "2020-06-25T23:57:27Z")

</div>

![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/5/5e1c4a1ab8914d7052cdb533b481ecb73daa9b8a.jpeg)  
I’m trying to get this cool LOD terrain system to work but normals don’t want to behave correctly. I extracted this system from a browser game called Trigger Rally. It took me ages to get this to work. It was written in CoffeeScript and for a very old version of Three.js. Finally it works, the shadows work but the normals are a massive pain.

Light is circling over the terrain and a ball drops a shadow to help understand where the light is coming from.

Here’s a version with detailed normals, independent from vertex shader. They behave like if the light was travelling on another axis

> **[HELP normals - CodeSandbox](https://codesandbox.io/s/help-normals-qwlfn?file=%2FrenderTerrain.js)**
>
> fork it and use as a template for your questions or experiments.

Here’s the version with uncommented piece of code that makes the normals work but they only have vertex shader resolution. Very angular:

> **[HELP normals uncomment - CodeSandbox](https://codesandbox.io/s/help-normals-uncomment-6myhq?file=%2FrenderTerrain.js)**
>
> fork it and use as a template for your questions or experiments.

The relevant shader code in in renderTerrain.js line 530

It’s worth mentioning that the original game is working in Z up world and I managed to get this shader to work in Y up world. Except of the normals.
