Revised instancing example

This commit is contained in:
saschawillems 2017-01-08 11:13:21 +01:00
parent 93bdd86917
commit 094ed4bccf
13 changed files with 289 additions and 236 deletions

View file

@ -7,28 +7,20 @@ layout (binding = 1) uniform sampler2DArray samplerArray;
layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec3 inEyePos;
layout (location = 3) in vec3 inLightVec;
layout (location = 4) in vec3 inUV;
layout (location = 2) in vec3 inUV;
layout (location = 3) in vec3 inViewVec;
layout (location = 4) in vec3 inLightVec;
layout (location = 0) out vec4 outFragColor;
void main()
{
vec4 color = texture(samplerArray, inUV) * vec4(inColor, 1.0);
vec3 N = normalize(inNormal);
vec3 L = normalize(vec3(1.0));
vec3 Eye = normalize(-inEyePos);
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
vec4 IAmbient = vec4(vec3(0.1), 1.0);
vec4 IDiffuse = vec4(1.0) * max(dot(inNormal, inLightVec), 0.0);
float specular = 0.75;
vec4 ISpecular = vec4(0.5, 0.5, 0.5, 1.0) * pow(max(dot(Reflected, Eye), 0.0), 32.0) * specular;
outFragColor = vec4((IAmbient + IDiffuse) * color + ISpecular);
vec3 L = normalize(inLightVec);
vec3 V = normalize(inViewVec);
vec3 R = reflect(-L, N);
vec3 diffuse = max(dot(N, L), 0.0) * inColor;
vec3 specular = (dot(N,L) > 0.0) ? pow(max(dot(R, V), 0.0), 16.0) * vec3(0.75) * color.r : vec3(0.0);
outFragColor = vec4(diffuse * color.rgb + specular, 1.0);
}