Revert "Revert "Merge pull request #75 from teamfisk/NormalSpecularMapping""

This reverts commit b56824786c.
This commit is contained in:
2016-02-03 16:30:00 +01:00
parent b56824786c
commit bd2da7bc9f
29 changed files with 2029 additions and 145 deletions
@@ -3,6 +3,7 @@
layout (binding = 0) uniform sampler2D SceneTexture;
layout (binding = 1) uniform sampler2D BloomTexture;
uniform float Exposure;
uniform float Gamma;
in VertexData{
vec2 TextureCoordinate;
@@ -12,7 +13,6 @@ out vec4 fragmentColor;
void main()
{
const float gamma = 2.2;
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
hdrColor += bloomColor;
@@ -21,7 +21,7 @@ void main()
vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
//gamme correction
result = pow(result, vec3(1.0 / gamma));
result = pow(result, vec3(1.0 / Gamma));
fragmentColor = vec4(result, 1.0);
//fragmentColor = hdrColor;
+23 -5
View File
@@ -17,15 +17,21 @@ uniform bool ExponentialAccelaration;
in VertexData{
vec3 Position;
vec3 Normal;
vec3 Tangent;
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 ExplosionColor;
float ExplosionPercentageElapsed;
}Input[];
out VertexData{
vec3 Position;
vec3 Normal;
vec3 Tangent;
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 ExplosionColor;
float ExplosionPercentageElapsed;
}Output;
layout(triangles) in;
@@ -114,12 +120,17 @@ void main()
{
// calculate the max distance (s) the triangle will move
float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
float te = (length(triangleCenter2ExplosionRadius) / s);
Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s);
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = te;
}
else
{
Output.ExplosionColor = EndColor * timePercetage;
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = timePercetage;
}
// for every vertex on the triangle...
@@ -132,6 +143,8 @@ void main()
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
Output.Tangent = Input[i].Tangent;
Output.BiTangent = Input[i].BiTangent;
// convert to model space for the gravity to always be in -y
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
@@ -154,11 +167,14 @@ void main()
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{
Output.ExplosionColor = vec4(0.0);
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = 0.0;
}
else
{
Output.ExplosionColor = EndColor * timePercetage;
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = timePercetage;
}
// for every vertex on the triangle...
@@ -168,7 +184,9 @@ void main()
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
Output.Tangent = Input[i].Tangent;
Output.BiTangent = Input[i].BiTangent;
// no change in position, pass through vertex
gl_Position = gl_in[i].gl_Position;
EmitVertex();
+8 -7
View File
@@ -7,13 +7,13 @@ uniform vec4 Color;
uniform vec4 DiffuseColor;
uniform vec2 ScreenDimensions;
uniform vec4 FillColor;
uniform vec4 AmbientColor;
uniform float FillPercentage;
layout (binding = 0) uniform sampler2D DiffuseTexture;
layout (binding = 1) uniform sampler2D NormalMapTexture;
layout (binding = 2) uniform sampler2D SpecularMapTexture;
layout (binding = 3) uniform sampler2D GlowMapTexture;
#define TILE_SIZE 16
struct LightSource {
@@ -55,13 +55,12 @@ in VertexData{
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 ExplosionColor;
float ExplosionPercentageElapsed;
}Input;
out vec4 sceneColor;
out vec4 bloomColor;
vec4 scene_ambient = vec4(0.3,0.3,0.3,1);
struct LightResult {
vec4 Diffuse;
vec4 Specular;
@@ -120,6 +119,7 @@ void main()
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate);
vec4 position = V * M * vec4(Input.Position, 1.0);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-position);
@@ -128,7 +128,7 @@ void main()
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
LightResult totalLighting;
totalLighting.Diffuse = scene_ambient;
totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0);
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
int start = int(LightGrids.Data[currentTile].Start);
@@ -150,8 +150,9 @@ void main()
totalLighting.Specular += light_result.Specular;
}
vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
@@ -160,7 +161,7 @@ void main()
color_result += FillColor;
}
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
color_result += glowTexel;
color_result += glowTexel*3;
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
+3 -1
View File
@@ -20,6 +20,7 @@ out VertexData{
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 ExplosionColor;
float ExplosionPercentageElapsed;
}Output;
void main()
@@ -41,5 +42,6 @@ void main()
Output.Normal = vec3(M * vec4(Normal, 0.0));
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
Output.BiTangent = vec3(M * vec4(BiTangent, 0.0));
Output.ExplosionColor = vec4(0.0);
Output.ExplosionColor = vec4(1.0);
Output.ExplosionPercentageElapsed = 0.0;
}