Indentation style changed to Allman
Using Artistic Style (http://astyle.sourceforge.net/) Options: --style=allman --indent=tab --keep-one-line-blocks --align-pointer=type --align-reference=name
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
uniform vec4 Color;
|
||||
|
||||
in VertexData {
|
||||
in VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
@@ -11,7 +12,8 @@ in VertexData {
|
||||
|
||||
out vec4 FragmentColor;
|
||||
|
||||
void main() {
|
||||
void main()
|
||||
{
|
||||
//FragmentColor = vec4(1.0 - gl_Color.r, 1.0 - gl_Color.g, 1.0 - gl_Color.b, 0.0);
|
||||
FragmentColor = Color;
|
||||
}
|
||||
+20
-16
@@ -2,7 +2,7 @@
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
|
||||
|
||||
layout(binding=0) uniform sampler2D texture0;
|
||||
layout(binding=1) uniform sampler2D shadowMap;
|
||||
|
||||
@@ -16,7 +16,8 @@ uniform float linearAttenuation[maxNumberOfLights];
|
||||
uniform float quadraticAttenuation[maxNumberOfLights];
|
||||
uniform float spotExponent[maxNumberOfLights];
|
||||
|
||||
in VertexData {
|
||||
in VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
@@ -24,10 +25,11 @@ in VertexData {
|
||||
} Input;
|
||||
|
||||
vec3 scene_ambient = vec3(0.5, 0.5, 0.5);
|
||||
|
||||
|
||||
out vec4 fragmentColor;
|
||||
|
||||
void main() {
|
||||
void main()
|
||||
{
|
||||
|
||||
// Texture
|
||||
vec4 texel = texture2D(texture0, Input.TextureCoord);
|
||||
@@ -50,10 +52,12 @@ void main() {
|
||||
//float bias = 0.001 * tan(acos(cosTheta)); // cosTheta is dot( n,l ), clamped between 0 and 1
|
||||
//bias = clamp(bias, 0.0, 0.01);
|
||||
float visibility = 1.0;
|
||||
if (Input.ShadowCoord.x >= 0.0 && Input.ShadowCoord.x <= 1.0 && Input.ShadowCoord.y >= 0.0 && Input.ShadowCoord.y <= 1.0) {
|
||||
if (Input.ShadowCoord.x >= 0.0 && Input.ShadowCoord.x <= 1.0 && Input.ShadowCoord.y >= 0.0 && Input.ShadowCoord.y <= 1.0)
|
||||
{
|
||||
float bias = 0.00005;
|
||||
vec4 shadowMapValue = texture(shadowMap, Input.ShadowCoord.xy);
|
||||
if (shadowMapValue.z < clamp(Input.ShadowCoord.z - bias, 0, 1)) {
|
||||
if (shadowMapValue.z < clamp(Input.ShadowCoord.z - bias, 0, 1))
|
||||
{
|
||||
visibility = 0.3;
|
||||
}
|
||||
}
|
||||
@@ -68,40 +72,40 @@ void main() {
|
||||
//vec3 lightPosition = vec3(0, 0, 2);
|
||||
vec3 Ls = specular[i]; // Specular light
|
||||
vec3 Ld = diffuse[i]; // Diffuse light
|
||||
|
||||
|
||||
vec3 lightPosView = vec3(view * vec4(position[i], 1.0));
|
||||
vec3 surfacePosition = vec3(model * vec4(Input.Position, 1.0));
|
||||
vec3 surfacePosView = vec3(view * vec4(surfacePosition, 1.0));
|
||||
vec3 surfaceToLight = normalize(lightPosView - surfacePosView);
|
||||
mat3 normalMatrix = transpose(inverse(mat3(view * model)));
|
||||
vec3 surfaceNormal = normalize(normalMatrix * Input.Normal);
|
||||
|
||||
|
||||
float dist = length(position[i] - surfacePosition);
|
||||
|
||||
attenuation = 1.0 / (constantAttenuation[i]
|
||||
+ linearAttenuation[i] * dist
|
||||
+ quadraticAttenuation[i] * pow(dist, 2.0));
|
||||
+ linearAttenuation[i] * dist
|
||||
+ quadraticAttenuation[i] * pow(dist, 2.0));
|
||||
//attenuation = attenuation * pow(clampedCosine, spotExponent[i]);
|
||||
|
||||
|
||||
// Diffuse light
|
||||
float dotProd = dot(surfaceToLight, surfaceNormal);
|
||||
dotProd = max(dotProd, 0.0);
|
||||
|
||||
|
||||
Id = Ld * Kd * abs(dotProd) * attenuation;
|
||||
|
||||
|
||||
// Specular light
|
||||
vec3 reflection = reflect(-surfaceToLight, surfaceNormal);
|
||||
float dotSpecular = dot(reflection, normalize(-surfacePosView));
|
||||
dotSpecular = max(dotSpecular, 0.0);
|
||||
float specularFactor = pow(dotSpecular, 30.0); // Specular factor
|
||||
|
||||
|
||||
Is = attenuation * Ls * Ks * specularFactor;
|
||||
|
||||
totalLighting = totalLighting + Id + Is;
|
||||
}
|
||||
|
||||
fragmentColor = vec4(totalLighting, 1.0) * texel;
|
||||
|
||||
fragmentColor = vec4(totalLighting, 1.0) * texel;
|
||||
|
||||
|
||||
//fragmentColor = vec4(Id, 1.0) * texel;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ uniform mat4 MVP;
|
||||
|
||||
out vec4 FragmentColor;
|
||||
|
||||
void main() {
|
||||
void main()
|
||||
{
|
||||
FragmentColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
@@ -5,13 +5,15 @@ uniform mat4 MVP;
|
||||
layout(triangles) in;
|
||||
layout(line_strip, max_vertices = 6) out;
|
||||
|
||||
in VertexData {
|
||||
in VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
} Input[3];
|
||||
|
||||
out VertexData {
|
||||
out VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
|
||||
@@ -4,6 +4,7 @@ uniform mat4 MVP;
|
||||
|
||||
layout(location = 0) out float FragmentDepth;
|
||||
|
||||
void main() {
|
||||
void main()
|
||||
{
|
||||
FragmentDepth = gl_FragCoord.z;
|
||||
}
|
||||
@@ -6,7 +6,8 @@ layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TextureCoord;
|
||||
|
||||
out VertexData {
|
||||
out VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
uniform samplerCube CubemapTexture;
|
||||
|
||||
in VertexData {
|
||||
in VertexData
|
||||
{
|
||||
vec3 TextureCoord;
|
||||
} Input;
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ uniform mat4 MVP;
|
||||
|
||||
layout(location = 0) in vec3 Position;
|
||||
|
||||
out VertexData {
|
||||
out VertexData
|
||||
{
|
||||
vec3 TextureCoord;
|
||||
} Output;
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec2 TextureCoord;
|
||||
|
||||
out VertexData {
|
||||
out VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
layout(binding = 0) uniform sampler2D DepthTexture;
|
||||
|
||||
in VertexData {
|
||||
in VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
@@ -11,12 +12,13 @@ out vec4 FragmentColor;
|
||||
|
||||
float LinearizeDepth(float z)
|
||||
{
|
||||
float n = 0.1; // camera z near
|
||||
float f = 800.0; // camera z far
|
||||
return (2.0 * n) / (f + n - z * (f - n));
|
||||
float n = 0.1; // camera z near
|
||||
float f = 800.0; // camera z far
|
||||
return (2.0 * n) / (f + n - z * (f - n));
|
||||
}
|
||||
|
||||
void main() {
|
||||
void main()
|
||||
{
|
||||
float z = texture(DepthTexture, Input.TextureCoord).x;
|
||||
vec4 color = vec4(z, z, z, 0);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 2) in vec2 TextureCoord;
|
||||
|
||||
out VertexData {
|
||||
out VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec2 TextureCoord;
|
||||
} Output;
|
||||
|
||||
Reference in New Issue
Block a user