mapping but it's normal
This commit is contained in:
@@ -7,6 +7,12 @@ uniform mat3 u_normalMatrix;
|
||||
varying vec3 v_normal;
|
||||
#endif // normalFlag
|
||||
|
||||
#if defined(tangentFlag) && defined(binormalFlag)
|
||||
attribute vec3 a_tangent;
|
||||
attribute vec3 a_binormal;
|
||||
varying mat3 v_tbn;
|
||||
#endif // tangentFlag && bitangentFlag
|
||||
|
||||
#ifdef colorFlag
|
||||
varying vec4 v_color;
|
||||
attribute vec4 a_color;
|
||||
@@ -27,17 +33,22 @@ attribute vec2 a_texCoord0;
|
||||
#ifdef diffuseTextureFlag
|
||||
uniform vec4 u_diffuseUVTransform;
|
||||
varying vec2 v_diffuseUV;
|
||||
#endif
|
||||
#endif // diffuseTextureFlag
|
||||
|
||||
#ifdef normalTextureFlag
|
||||
uniform vec4 u_normalUVTransform;
|
||||
varying vec2 v_normalUV;
|
||||
#endif // normalTextureFlag
|
||||
|
||||
#ifdef emissiveTextureFlag
|
||||
uniform vec4 u_emissiveUVTransform;
|
||||
varying vec2 v_emissiveUV;
|
||||
#endif
|
||||
#endif // emissiveTextureFlag
|
||||
|
||||
#ifdef specularTextureFlag
|
||||
uniform vec4 u_specularUVTransform;
|
||||
varying vec2 v_specularUV;
|
||||
#endif
|
||||
#endif // specularTextureFlag
|
||||
|
||||
uniform mat4 u_worldTrans;
|
||||
|
||||
@@ -74,9 +85,15 @@ varying vec4 v_worldPosition;
|
||||
void main()
|
||||
{
|
||||
#ifdef normalFlag
|
||||
//vec3 normal = u_normalMatrix * a_normal;
|
||||
//vec3 normal = (transpose(inverse(u_normalMatrix)) * a_normal);
|
||||
vec3 normal = normalize(u_normalMatrix * a_normal);
|
||||
v_normal = normal;
|
||||
|
||||
#if defined(tangentFlag) && defined(binormalFlag)
|
||||
vec3 tangent = normalize(u_normalMatrix * a_tangent);
|
||||
vec3 bitangent = normalize(u_normalMatrix * a_binormal);
|
||||
v_tbn = mat3(tangent, bitangent, normal);
|
||||
#endif // tangentFlag && bitangentFlag
|
||||
#endif // normalFlag
|
||||
|
||||
#ifdef colorFlag
|
||||
@@ -87,6 +104,10 @@ void main()
|
||||
v_diffuseUV = u_diffuseUVTransform.xy + a_texCoord0 * u_diffuseUVTransform.zw;
|
||||
#endif // diffuseTextureFlag
|
||||
|
||||
#ifdef normalTextureFlag
|
||||
v_normalUV = u_normalUVTransform.xy + a_texCoord0 * u_normalUVTransform.zw;
|
||||
#endif // normalTextureFlag
|
||||
|
||||
#ifdef emissiveTextureFlag
|
||||
v_emissiveUV = u_emissiveUVTransform.xy + a_texCoord0 * u_emissiveUVTransform.zw;
|
||||
#endif // emissiveTextureFlag
|
||||
|
||||
Reference in New Issue
Block a user