Reset the shader to fix the minimap

This commit is contained in:
samuncle 2019-03-11 22:13:06 +01:00
parent 3cbac8e6ea
commit 674a449c10
2 changed files with 11 additions and 14 deletions

View File

@ -62,6 +62,11 @@ vec3 CalcViewPositionFromDepth(in vec2 TexCoord, in sampler2D DepthMap)
return ViewPosition.xyz / ViewPosition.w; return ViewPosition.xyz / ViewPosition.w;
} }
float rand(vec2 co)
{
return fract(sin(dot(co.xy,vec2(12.9898,78.233))) * 43758.5453);
}
vec3 RayCast(vec3 dir, inout vec3 hitCoord, out float dDepth, in sampler2D DepthMap, in vec3 fallback, float spread) vec3 RayCast(vec3 dir, inout vec3 hitCoord, out float dDepth, in sampler2D DepthMap, in vec3 fallback, float spread)
{ {
@ -82,8 +87,8 @@ vec3 RayCast(vec3 dir, inout vec3 hitCoord, out float dDepth, in sampler2D Depth
if ((projectedCoord.x > 0.0 && projectedCoord.x < 1.0) && (projectedCoord.y > 0.0 && projectedCoord.y < 1.0)) if ((projectedCoord.x > 0.0 && projectedCoord.x < 1.0) && (projectedCoord.y > 0.0 && projectedCoord.y < 1.0))
{ {
// Mix with fallback (black area should be dark anyway) // Mix with fallback (black area should be dark anyway)
vec3 finalColor = textureLod(albedo, projectedCoord.xy, 1.0).rgb; //vec3 finalColor = textureLod(albedo, projectedCoord.xy, 1.0).rgb;
finalColor = fastBlur(projectedCoord.xy, spread); vec3 finalColor = fastBlur(projectedCoord.xy, spread);
if ((finalColor.r + finalColor.g + finalColor.b) > 0.) if ((finalColor.r + finalColor.g + finalColor.b) > 0.)
{ {
vec2 inside = (gl_FragCoord.xy / u_screen) - 0.5; vec2 inside = (gl_FragCoord.xy / u_screen) - 0.5;
@ -106,13 +111,6 @@ vec3 RayCast(vec3 dir, inout vec3 hitCoord, out float dDepth, in sampler2D Depth
return fallback; return fallback;
} }
float rand(vec2 co)
{
return fract(sin(dot(co.xy,vec2(12.9898,78.233))) * 43758.5453);
}
float rand2(vec2 co) float rand2(vec2 co)
{ {
return fract(sin(dot(co.xy,vec2(45.454545,5631.4))) * 43758.5453); return fract(sin(dot(co.xy,vec2(45.454545,5631.4))) * 43758.5453);
@ -165,10 +163,8 @@ void main(void)
float dDepth; float dDepth;
float minRayStep = 100.0f; float minRayStep = 100.0f;
vec3 outColor = RayCast(reflected * max(minRayStep, -View_Pos.z), hitPos, dDepth, dtex, fallback, 0.001); vec3 outColor = RayCast(mix(reflected, reflected2, 1.0 - specval) * max(minRayStep, -View_Pos.z),
vec3 outColor2 = RayCast(reflected2 * max(minRayStep, -View_Pos.z), hitPos, dDepth, dtex, fallback, 0.001); hitPos, dDepth, dtex, fallback, mix(0.001, 0.01, 1.0 - specval));
outColor = mix(outColor, outColor2, 1.0 - specval);
Spec = vec4(outColor.rgb, 1.0); Spec = vec4(outColor.rgb, 1.0);

View File

@ -21,6 +21,7 @@ void main()
// Metallic map is stored in normal color framebuffer .w // Metallic map is stored in normal color framebuffer .w
// Emit map is stored in diffuse color framebuffer.w // Emit map is stored in diffuse color framebuffer.w
float metallicMapValue = texture(normal_color, tc).w; float metallicMapValue = texture(normal_color, tc).w;
float specMapValue = texture(normal_color, tc).z;
float emitMapValue = diffuseMatColor.w; float emitMapValue = diffuseMatColor.w;
float ao = texture(ssao_tex, tc).x; float ao = texture(ssao_tex, tc).x;
@ -28,7 +29,7 @@ void main()
vec3 SpecularComponent = texture(specular_map, tc).xyz; vec3 SpecularComponent = texture(specular_map, tc).xyz;
vec3 diffuse_color_for_mix = diffuseMatColor.xyz * 4.0; vec3 diffuse_color_for_mix = diffuseMatColor.xyz * 4.0;
vec3 metallicMatColor = mix(vec3(0.5), diffuse_color_for_mix, metallicMapValue); vec3 metallicMatColor = mix(vec3(specMapValue), diffuse_color_for_mix, metallicMapValue);
vec3 tmp = DiffuseComponent * mix(diffuseMatColor.xyz, vec3(0.0), metallicMapValue) + (metallicMatColor * SpecularComponent); vec3 tmp = DiffuseComponent * mix(diffuseMatColor.xyz, vec3(0.0), metallicMapValue) + (metallicMatColor * SpecularComponent);
vec3 emitCol = diffuseMatColor.xyz + (diffuseMatColor.xyz * diffuseMatColor.xyz * emitMapValue * emitMapValue * 10.0); vec3 emitCol = diffuseMatColor.xyz + (diffuseMatColor.xyz * diffuseMatColor.xyz * emitMapValue * emitMapValue * 10.0);