added preview imange,
passed data to shader, need to process data in shader
This commit is contained in:
@@ -8,11 +8,13 @@ uniform mat3 n_matrix;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D secondTexture;
|
||||
uniform float materialShininess;
|
||||
uniform vec3 materialSpecularColor;
|
||||
|
||||
uniform bool b_transparent;
|
||||
uniform bool b_specular;
|
||||
uniform bool b_normalmap;
|
||||
uniform bool b_light;
|
||||
|
||||
uniform struct Light {
|
||||
@@ -35,7 +37,15 @@ void main()
|
||||
if(b_light)
|
||||
{
|
||||
// some values
|
||||
vec3 normalWorld = normalize(n_matrix * v_surfaceNormal);
|
||||
mat3 tbn = transpose(mat3(a_polyTan, a_polyBiTan, a_polyNorm));
|
||||
|
||||
vec3 finalNormal = normalize(n_matrix * v_surfaceNormal);
|
||||
|
||||
// if(b_normalmap)
|
||||
// {
|
||||
// finalNormal = texture2D(secondTexture, v_surfaceUV).rgb;
|
||||
// finalNormal = normalize(finalNormal * 2.0 -1.0)
|
||||
// }
|
||||
|
||||
vec4 surfaceColor = vec4(texture2D(texture, v_surfaceUV));
|
||||
surfaceColor.rgb = pow(surfaceColor.rgb, vec3(2.2));
|
||||
@@ -62,13 +72,13 @@ void main()
|
||||
vec3 ambient = light.ambientCoefficient * surfaceColor.rgb * light.intensities;
|
||||
|
||||
// diffuse
|
||||
float diffuseCoefficient = max(0.0, dot(normalWorld, surfaceToLight));
|
||||
float diffuseCoefficient = max(0.0, dot(finalNormal, surfaceToLight));
|
||||
vec3 diffuse = diffuseCoefficient * surfaceColor.rgb * light.intensities;
|
||||
|
||||
// specular
|
||||
float specularCoefficient = 0.0;
|
||||
if(diffuseCoefficient > 0.0)
|
||||
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalWorld))), materialShininess);
|
||||
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, finalNormal))), materialShininess);
|
||||
vec3 specColor;
|
||||
if(b_specular)
|
||||
specColor = vec3(surfaceColor.a);
|
||||
|
Reference in New Issue
Block a user