Initial commit: Final state of the master project

This commit is contained in:
2017-09-16 09:41:37 +02:00
commit 696180d43b
832 changed files with 169717 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
#version 330 core
#define $colorType$
in vec3 pos;
in vec3 normal;
#if defined(TEXTURE_COLORS) || defined(TEXTURE_AND_VERTEX_COLORS)
in vec2 uv;
#endif
#if defined(VERTEX_COLORS) || defined(TEXTURE_AND_VERTEX_COLORS)
in vec3 vertColor;
#endif
uniform sampler2D textureSampler;
uniform sampler2D lastDepthMap;
uniform float reflectivity;
uniform bool firstPass;
uniform float depthMargin;
uniform vec3 cameraDir;
layout (location = 0) out vec3 color;
//layout (location = 1) out float depthOut;
layout (location = 1) out float angleOut;
layout (location = 2) out vec3 normalOut;
layout (location = 3) out float reflectivityOut;
void main() {
#if defined(TEXTURE_COLORS)
vec4 fullColor = texture(textureSampler, uv);
#endif
#if defined(VERTEX_COLORS)
vec4 fullColor = vec4(vertColor, 1.0f);
#endif
#if defined(TEXTURE_AND_VERTEX_COLORS)
vec4 fullColor = texture(textureSampler, uv) * vec4(vertColor, 1.0f);
#endif
#ifdef NO_COLORS
vec4 fullColor = vec4(1.0f);
#endif
//Discard transparent fragments
if (fullColor.a < 0.5) {
discard;
}
else
{
float lastDepth = texelFetch(lastDepthMap, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0).r;
if (!firstPass && (lastDepth - gl_FragCoord.z) >= -depthMargin)
{
discard;
}
color = fullColor.rgb;
//vec3 lightDirection = normalize(vec3(0.25, -0.6, -1));
//color *= 0.3 + 0.7 * max(dot(-lightDirection, normalize(normal)), 0);
// Scale the normal between 0 and 1
normalOut = 0.5 + (normal * 0.5);
// Calculate the angle of the normal of this position with the camera
//angleOut = 1.;
if (normal == vec3(0))
angleOut = 1;
else
angleOut = abs(dot(cameraDir, normalize(normal)));
}
reflectivityOut = reflectivity;
}