OpenGL2: Change normal/tangent vertex encoding.
This commit is contained in:
parent
7e808f92d6
commit
e488663e31
8 changed files with 108 additions and 56 deletions
|
@ -74,7 +74,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
|
|||
void main()
|
||||
{
|
||||
vec3 position = attr_Position;
|
||||
vec3 normal = attr_Normal * 2.0 - vec3(1.0);
|
||||
vec3 normal = attr_Normal;
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
|
|
|
@ -102,10 +102,9 @@ void main()
|
|||
#if defined(USE_VERTEX_ANIMATION)
|
||||
vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);
|
||||
vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp);
|
||||
normal = normalize(normal - vec3(0.5));
|
||||
#else
|
||||
vec3 position = attr_Position;
|
||||
vec3 normal = attr_Normal * 2.0 - vec3(1.0);
|
||||
vec3 normal = attr_Normal;
|
||||
#endif
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
|
|
|
@ -207,10 +207,9 @@ void main()
|
|||
#if defined(USE_VERTEX_ANIMATION)
|
||||
vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);
|
||||
vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp);
|
||||
normal = normalize(normal - vec3(0.5));
|
||||
#else
|
||||
vec3 position = attr_Position;
|
||||
vec3 normal = attr_Normal * 2.0 - vec3(1.0);
|
||||
vec3 normal = attr_Normal;
|
||||
#endif
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
|
|
|
@ -167,11 +167,6 @@ void main()
|
|||
#endif
|
||||
#endif
|
||||
|
||||
normal = normal * 2.0 - vec3(1.0);
|
||||
#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
tangent = tangent * 2.0 - vec3(1.0);
|
||||
#endif
|
||||
|
||||
#if defined(USE_TCGEN)
|
||||
vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);
|
||||
#else
|
||||
|
@ -195,13 +190,13 @@ void main()
|
|||
#endif
|
||||
|
||||
#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0);
|
||||
vec3 bitangent = cross(normal, tangent) * attr_Tangent.w;
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT_VECTOR)
|
||||
vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);
|
||||
#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
vec3 L = attr_LightDirection * 2.0 - vec3(1.0);
|
||||
vec3 L = attr_LightDirection;
|
||||
#if defined(USE_MODELMATRIX)
|
||||
L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
|
||||
#endif
|
||||
|
|
|
@ -11,5 +11,5 @@ void main()
|
|||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
|
||||
var_Position = attr_Position;
|
||||
var_Normal = attr_Normal * 2.0 - vec3(1.0);
|
||||
var_Normal = attr_Normal;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,6 @@ void main()
|
|||
{
|
||||
vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);
|
||||
vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp);
|
||||
normal = normalize(normal - vec3(0.5));
|
||||
|
||||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue