Now bump mapping wors
This commit is contained in:
1 parent
7fc9a5e5d6
commit
73839b05d9
5 files changed
+148
-122
No files matched your search
@@ -5,25 +5,32 @@ uniform float FogEndDistance;
|
||||
|
||||
varying vec2 texCoord;
|
||||
varying vec3 vertexPos;
|
||||
varying vec3 normal;
|
||||
varying vec3 absoluteVertexPos;
|
||||
varying vec3 normal;
|
||||
varying vec3 tangent;
|
||||
varying vec3 bitangent;
|
||||
|
||||
void main()
|
||||
{
|
||||
//vec3 norm = normalize(normal)*0.5 + vec3(0.5, 0.5, 0.5);
|
||||
//gl_FragColor = vec4(norm, 1.0);
|
||||
|
||||
vec3 norm = normalize(normal);
|
||||
|
||||
vec3 norm1 = normalize(normal);
|
||||
vec3 norm2 = texture2D(NormalMap, texCoord).rgb * 2.0 - 1.0;
|
||||
|
||||
mat3 TBN = mat3(tangent, bitangent, norm1);
|
||||
|
||||
vec3 transformedNormal = normalize(TBN * norm2);
|
||||
|
||||
//gl_FragColor = vec4(transformedNormal*0.5+ vec3(0.5, 0.5, 0.5), 1.0);
|
||||
|
||||
vec3 lightPos = vec3(-2, 5, 0);
|
||||
|
||||
vec3 lightVec = absoluteVertexPos - lightPos;
|
||||
|
||||
float coef = max(dot(-normalize(lightVec),norm),0.2);
|
||||
float coef = max(dot(-normalize(lightVec),transformedNormal),0.2);
|
||||
|
||||
float coef2 = clamp((15.0 - length(lightVec))/10.0, 0.2, 1.0);
|
||||
|
||||
vec4 texColor = texture2D(NormalMap,texCoord).rgba;
|
||||
vec4 texColor = texture2D(Texture,texCoord).rgba;
|
||||
|
||||
gl_FragColor = vec4(texColor.rgb*coef2*coef, 1.0);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
attribute vec3 vPosition;
|
||||
attribute vec2 vTexCoord;
|
||||
attribute vec3 vNormal;
|
||||
attribute vec3 vTangent;
|
||||
attribute vec3 vBinormal;
|
||||
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat3 ModelRotateMatrix;
|
||||
@@ -10,7 +12,8 @@ varying vec2 texCoord;
|
||||
varying vec3 vertexPos;
|
||||
varying vec3 absoluteVertexPos;
|
||||
varying vec3 normal;
|
||||
|
||||
varying vec3 tangent;
|
||||
varying vec3 bitangent;
|
||||
void main()
|
||||
{
|
||||
vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0);
|
||||
@@ -21,6 +24,8 @@ void main()
|
||||
|
||||
texCoord = vTexCoord.st;
|
||||
|
||||
normal = vNormal;
|
||||
normal = normalize(vNormal);
|
||||
tangent = normalize(vTangent);
|
||||
bitangent = cross(normal, tangent);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user