Newer
Older
* Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#ifdef dGeoTexture
uniform vec2 uGeoTexDim;
attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;
#ifdef dGeoTexture
uniform sampler2D tNormal;
#else
attribute vec3 aNormal;
#endif
#include assign_group
#include assign_color_varying
#include assign_marker_varying
#include assign_position
#ifdef dGeoTexture
vec3 normal = readFromTexture(tNormal, aGroup, uGeoTexDim).xyz;
#else
vec3 normal = aNormal;
#endif
mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));
vec3 transformedNormal = normalize(normalMatrix * normalize(normal));
#if defined(dFlipSided) && !defined(dDoubleSided) // TODO checking dDoubleSided should not be required, ASR
transformedNormal = -transformedNormal;
#endif
vNormal = transformedNormal;