naive normal direction
This commit is contained in:
parent
9a0df4e4ab
commit
4264f2dfa3
1 changed files with 8 additions and 1 deletions
|
@ -113,5 +113,12 @@ vec3 calculate_normal(vec4 terrain_position) {
|
||||||
vec3 p2 = (points[1] - terrain_position).xyz;
|
vec3 p2 = (points[1] - terrain_position).xyz;
|
||||||
|
|
||||||
// calculate normal
|
// calculate normal
|
||||||
return normalize(cross(p1, p2));
|
vec3 normal = normalize(cross(p1, p2));
|
||||||
|
|
||||||
|
// naively assume that a normal always has to look upwards
|
||||||
|
if (normal.y < 0.0) {
|
||||||
|
return -normal;
|
||||||
|
} else {
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue