Ah, okay, I will try that calculation later tonight, thanks
Edit: okay back, a little late, though I tried your idea but I only got a quarter light, plus after looking more closely it is swizzling from a vec3 from a vec4 so I assume it is a matrix of some kind .
after a day of trying the closest I got was half light.
:removed to conserve bandwidth
plus if you notice, in the original picture, compared to this, the original had a sort of inverse specular to it which darked some areas to make it look greasy or wet, something I dont see here.
Here is my updated shader pair for you guys to see where I am at, maybe you can find where I went wrong, I will continue tomorrow though, the vertex shader.
# version 150 // vertex shader
uniform mat4 p3d_ModelViewMatrix;
uniform mat4 p3d_ModelViewProjectionMatrix;
in vec2 p3d_MultiTexCoord0;
in vec3 p3d_Normal;
in vec3 p3d_Binormal;
in vec3 p3d_Tangent;
in vec4 p3d_Vertex;
out vec2 vUv;
out vec4 vEye;
out mat3 tbnMatrix;
void main() {
vUv = p3d_MultiTexCoord0;
vEye = vec4(p3d_Vertex.x, p3d_Vertex.y, p3d_Vertex.z, 0);
vec4 tan = normalize(p3d_ModelViewMatrix * vec4(p3d_Tangent, 0));
vec4 bi = normalize(p3d_ModelViewMatrix * vec4(p3d_Binormal, 0));
vec3 nrm = normalize(vec3(p3d_ModelViewMatrix * vec4(p3d_Normal, 0)));
tbnMatrix = mat3(normalize(tan.xyz), normalize(bi.xyz), nrm);
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
}
and the fragment shader.
# version 150 // fragment shader
uniform sampler2D p3d_Texture0;
uniform sampler2D p3d_Texture1;
in vec2 vUv;
in vec4 vEye;
in mat3 tbnMatrix;
out vec4 p3d_FragColor;
void main (){
// Material (Global)
vec4 bright = vec4(1, 1, 1, 1);
vec4 sheen = vec4(0.64, 0.64, 0.64, 1);
vec4 scale = vec4(1.0, 1.0, 1.0, 1.0); // colorscale
vec4 reflect = vec4(0.5, 0.5, 0.5, 1);
// Directional Light (Global)
vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
vec3 forward = vEye.xyz;
vec4 ambient = vec4(0.5, 0.5, 0.5, 0.5) * bright;
vec4 diffuse = vec4(0, 0, 0, 0) * sheen;
float specular = 32.0;
// Translate tangent-space normal in map to view-space.
vec3 glaze = normalize(texture(p3d_Texture1, vUv).xyz * 2.0 - 1.0);
vec3 glossMap = normalize(tbnMatrix * glaze);
vec4 gloss = vec4(0, 0, 0, 0) + (color * pow(clamp(dot(glossMap, normalize(forward - vec3(0, 1, 0))), 0, 1.0), specular));
// Begin view-space light summation
vec4 shadow = diffuse + (color + clamp(dot(glossMap, forward), 0.0, 1.0));
vec4 summation = clamp(reflect + (ambient * bright) + (shadow * sheen), 0.0, 1.0);
summation.a = sheen.w;
vec4 result = (summation * scale).rbga * texture(p3d_Texture0, vUv).rgba;
// End view-space light calculations
vec3 texel = result.rgb + gloss.rgb;
p3d_FragColor = vec4(texel, 1.0);
}
once again thanks for your help
Edit: well it turns out you were right, after another day of tweaking I found out it was a light direction that was needed, it was just I was using the model matrix wrong, so here where I am so far, I am getting close.
:removed to conserve bandwidth
oh and the updated shader, vertex
# version 150 // vertex shader
uniform mat4 p3d_ModelViewMatrix;
uniform mat4 p3d_ModelViewProjectionMatrix;
in vec2 p3d_MultiTexCoord0;
in vec3 p3d_Normal;
in vec3 p3d_Binormal;
in vec3 p3d_Tangent;
in vec4 p3d_Vertex;
out vec2 vUv;
out vec4 vEye;
out mat3 tbnMatrix;
void main() {
vUv = p3d_MultiTexCoord0;
//vEye = vec4(p3d_Vertex.x, p3d_Vertex.y, p3d_Vertex.z, 0);
//vEye = vec4(normalize(vec3(0, 0, 1) + 1), 0);
vec3 view = -normalize((p3d_ModelViewMatrix * p3d_Vertex).xyz);
vEye = vec4(view, 1.0);
vec4 tan = normalize(p3d_ModelViewMatrix * vec4(p3d_Tangent, 0));
vec4 bi = normalize(p3d_ModelViewMatrix * vec4(p3d_Binormal, 0));
vec3 nrm = normalize(vec3(p3d_ModelViewMatrix * vec4(p3d_Normal, 0)));
tbnMatrix = mat3(normalize(tan.xyz), normalize(bi.xyz), nrm);
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
}
and the fragment
# version 150 // fragment shader
uniform sampler2D p3d_Texture0;
uniform sampler2D p3d_Texture1;
in vec2 vUv;
in vec4 vEye;
in mat3 tbnMatrix;
out vec4 p3d_FragColor;
void main (){
// Material (Global)
vec4 bright = vec4(0.5, 0.5, 0.5, 0.5);
vec4 sheen = vec4(0.64, 0.64, 0.64, 1);
vec4 scale = vec4(1.0, 1.0, 1.0, 1.0); // colorscale
vec4 reflect = vec4(0, 0, 0, 1);
// Directional Light (Global)
vec4 color = vec4(0.33, 0.33, 0.33, 0.33);
vec3 forward = vec3(0, 0, -1);
vec4 ambient = vec4(0, 0, 0, 0) + bright;
vec4 diffuse = vec4(0, 0, 0, 0) + sheen;
float specular = 6.0;
// Translate tangent-space normal in map to view-space.
vec3 glaze = normalize(texture(p3d_Texture1, vUv).xyz * 2.0 - 1.0);
vec3 glossMap = normalize(tbnMatrix * glaze);
vec4 gloss = vec4(0, 0, 0, 0) + (color * pow(clamp(dot(glossMap, normalize(vEye.xyz + vec3(0, 1, 0))), 0.0, 1.0), specular));
// Begin view-space light summation
vec4 shadow = diffuse + (color * clamp(dot(glossMap, normalize(vEye.xyz + forward)), 0.0, 1.0));
vec4 summation = clamp(reflect + (ambient * bright) + (shadow * sheen), 0.0, 1.0);
summation.a = sheen.w;
vec4 result = (summation * scale).rbga * texture(p3d_Texture0, vUv).rgba;
// End view-space light calculations
vec3 texel = mix(result.rgb, gloss.rgb, 0.45) * 1.9;
p3d_FragColor = vec4(texel, 1.0);
}