1
0
mirror of synced 2025-01-19 01:14:08 +01:00

Fix spacing

This commit is contained in:
KillzXGaming 2019-03-23 19:56:44 -04:00
parent 777fd47a01
commit 8610f33a1e
2 changed files with 114 additions and 114 deletions

Binary file not shown.

View File

@ -121,15 +121,15 @@ uniform int UseRoughnessMap;
int isTransparent; int isTransparent;
struct VertexAttributes { struct VertexAttributes {
vec3 objectPosition; vec3 objectPosition;
vec2 texCoord; vec2 texCoord;
vec2 texCoord2; vec2 texCoord2;
vec2 texCoord3; vec2 texCoord3;
vec4 vertexColor; vec4 vertexColor;
vec3 normal; vec3 normal;
vec3 viewNormal; vec3 viewNormal;
vec3 tangent; vec3 tangent;
vec3 bitangent; vec3 bitangent;
}; };
out vec4 fragColor; out vec4 fragColor;
@ -157,99 +157,99 @@ vec3 CalcBumpedNormal(vec3 normal, sampler2D normalMap, VertexAttributes vert, f
vec3 FresnelSchlick(float cosTheta, vec3 F0) vec3 FresnelSchlick(float cosTheta, vec3 F0)
{ {
return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0); return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0);
} }
vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness) vec3 FresnelSchlickRoughness(float cosTheta, vec3 F0, float roughness)
{ {
return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(1.0 - cosTheta, 5.0); return F0 + (max(vec3(1.0 - roughness), F0) - F0) * pow(1.0 - cosTheta, 5.0);
} }
float DistributionGGX(vec3 N, vec3 H, float roughness) float DistributionGGX(vec3 N, vec3 H, float roughness)
{ {
float a = roughness*roughness; float a = roughness*roughness;
float a2 = a*a; float a2 = a*a;
float NdotH = max(dot(N, H), 0.0); float NdotH = max(dot(N, H), 0.0);
float NdotH2 = NdotH*NdotH; float NdotH2 = NdotH*NdotH;
float num = a2; float num = a2;
float denom = (NdotH2 * (a2 - 1.0) + 1.0); float denom = (NdotH2 * (a2 - 1.0) + 1.0);
denom = PI * denom * denom; denom = PI * denom * denom;
return num / denom; return num / denom;
} }
float GeometrySchlickGGX(float NdotV, float roughness) float GeometrySchlickGGX(float NdotV, float roughness)
{ {
float r = (roughness + 1.0); float r = (roughness + 1.0);
float k = (r*r) / 8.0; float k = (r*r) / 8.0;
float num = NdotV; float num = NdotV;
float denom = NdotV * (1.0 - k) + k; float denom = NdotV * (1.0 - k) + k;
return num / denom; return num / denom;
} }
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
{ {
float NdotV = max(dot(N, V), 0.0); float NdotV = max(dot(N, V), 0.0);
float NdotL = max(dot(N, L), 0.0); float NdotL = max(dot(N, L), 0.0);
float ggx2 = GeometrySchlickGGX(NdotV, roughness); float ggx2 = GeometrySchlickGGX(NdotV, roughness);
float ggx1 = GeometrySchlickGGX(NdotL, roughness); float ggx1 = GeometrySchlickGGX(NdotL, roughness);
return ggx1 * ggx2; return ggx1 * ggx2;
} }
vec3 saturation(vec3 rgb, float adjustment) vec3 saturation(vec3 rgb, float adjustment)
{ {
const vec3 W = vec3(0.2125, 0.7154, 0.0721); const vec3 W = vec3(0.2125, 0.7154, 0.0721);
vec3 intensity = vec3(dot(rgb, W)); vec3 intensity = vec3(dot(rgb, W));
return mix(intensity, rgb, adjustment); return mix(intensity, rgb, adjustment);
} }
void main() void main()
{ {
fragColor = vec4(1); fragColor = vec4(1);
// Create a struct for passing all the vertex attributes to other functions. // Create a struct for passing all the vertex attributes to other functions.
VertexAttributes vert; VertexAttributes vert;
vert.objectPosition = objectPosition; vert.objectPosition = objectPosition;
vert.texCoord = f_texcoord0; vert.texCoord = f_texcoord0;
vert.texCoord2 = f_texcoord1; vert.texCoord2 = f_texcoord1;
vert.texCoord3 = f_texcoord2; vert.texCoord3 = f_texcoord2;
vert.vertexColor = vertexColor; vert.vertexColor = vertexColor;
vert.normal = normal; vert.normal = normal;
vert.tangent = tangent; vert.tangent = tangent;
vert.bitangent = bitangent; vert.bitangent = bitangent;
vec3 lightColor = vec3(10); vec3 lightColor = vec3(10);
// Wireframe color. // Wireframe color.
if (colorOverride == 1) if (colorOverride == 1)
{ {
fragColor = vec4(1); fragColor = vec4(1);
return; return;
} }
vec3 albedo = vec3(1); vec3 albedo = vec3(1);
if (HasDiffuse == 1) if (HasDiffuse == 1)
albedo = pow(texture(DiffuseMap , f_texcoord0).rgb, vec3(gamma)); albedo = pow(texture(DiffuseMap , f_texcoord0).rgb, vec3(gamma));
float metallic = 0; float metallic = 0;
if (HasMetalnessMap == 1) if (HasMetalnessMap == 1)
metallic = texture(MetalnessMap, f_texcoord0).r; metallic = texture(MetalnessMap, f_texcoord0).r;
float roughness = 0.5; float roughness = 0.5;
if (HasRoughnessMap == 1) if (HasRoughnessMap == 1)
roughness = texture(RoughnessMap, f_texcoord0).r; roughness = texture(RoughnessMap, f_texcoord0).r;
float ao = 1; float ao = 1;
if (HasShadowMap == 1 && bake_shadow_type == 0 || UseAOMap == 1) if (HasShadowMap == 1 && bake_shadow_type == 0 || UseAOMap == 1)
ao = texture(BakeShadowMap, f_texcoord1).r; ao = texture(BakeShadowMap, f_texcoord1).r;
float shadow = 1; float shadow = 1;
if (HasShadowMap == 1 && bake_shadow_type == 1) if (HasShadowMap == 1 && bake_shadow_type == 1)
shadow = texture(BakeShadowMap, f_texcoord1).g; shadow = texture(BakeShadowMap, f_texcoord1).g;
float cavity = 1; float cavity = 1;
@ -259,17 +259,17 @@ void main()
vec3 lightMapColor = vec3(1); vec3 lightMapColor = vec3(1);
float lightMapIntensity = 0; float lightMapIntensity = 0;
if (HasLightMap == 1) if (HasLightMap == 1)
{ {
lightMapColor = texture(BakeLightMap, f_texcoord1).rgb; lightMapColor = texture(BakeLightMap, f_texcoord1).rgb;
lightMapIntensity = texture(BakeLightMap, f_texcoord1).a; lightMapIntensity = texture(BakeLightMap, f_texcoord1).a;
} }
float specIntensity = 1; float specIntensity = 1;
if (HasMRA == 1) //Kirby Star Allies PBR map if (HasMRA == 1) //Kirby Star Allies PBR map
{ {
//Note KSA has no way to tell if one gets unused or not because shaders :( //Note KSA has no way to tell if one gets unused or not because shaders :(
//Usually it's just metalness with roughness and works fine //Usually it's just metalness with roughness and works fine
metallic = texture(MRA, f_texcoord0).r; metallic = texture(MRA, f_texcoord0).r;
roughness = texture(MRA, f_texcoord0).g; roughness = texture(MRA, f_texcoord0).g;
@ -277,84 +277,84 @@ void main()
ao = texture(MRA, f_texcoord0).a; ao = texture(MRA, f_texcoord0).a;
} }
// Calculate shading vectors. // Calculate shading vectors.
vec3 I = vec3(0,0,-1) * mat3(mtxMdl * mtxCam); vec3 I = vec3(0,0,-1) * mat3(mtxMdl * mtxCam);
vec3 N = normal; vec3 N = normal;
if (HasNormalMap == 1 && useNormalMap == 1) if (HasNormalMap == 1 && useNormalMap == 1)
N = CalcBumpedNormal(normal, NormalMap, vert, 0); N = CalcBumpedNormal(normal, NormalMap, vert, 0);
vec3 V = normalize(I); // view vec3 V = normalize(I); // view
vec3 L = normalize(specLightDirection); // Light vec3 L = normalize(specLightDirection); // Light
vec3 H = normalize(specLightDirection + I); // half angle vec3 H = normalize(specLightDirection + I); // half angle
vec3 R = reflect(I, N); // reflection vec3 R = reflect(I, N); // reflection
vec3 f0 = mix(vec3(0.04), albedo, metallic); // dialectric vec3 f0 = mix(vec3(0.04), albedo, metallic); // dialectric
vec3 kS = FresnelSchlickRoughness(max(dot(N, V), 0.0), f0, roughness); vec3 kS = FresnelSchlickRoughness(max(dot(N, V), 0.0), f0, roughness);
vec3 kD = 1.0 - kS; vec3 kD = 1.0 - kS;
kD *= 1.0 - metallic; kD *= 1.0 - metallic;
BakedData ShadowBake = ShadowMapBaked(BakeShadowMap,BakeLightMap, f_texcoord1, f_texcoord2, int(bake_shadow_type),int(bake_light_type), int(bake_calc_type), N ); BakedData ShadowBake = ShadowMapBaked(BakeShadowMap,BakeLightMap, f_texcoord1, f_texcoord2, int(bake_shadow_type),int(bake_light_type), int(bake_calc_type), N );
vec3 LightingDiffuse = vec3(0); vec3 LightingDiffuse = vec3(0);
if (HasLightMap == 1) if (HasLightMap == 1)
{ {
vec3 LightIntensity = vec3(0.1); vec3 LightIntensity = vec3(0.1);
LightingDiffuse += ShadowBake.indirectLighting.rgb * LightIntensity; LightingDiffuse += ShadowBake.indirectLighting.rgb * LightIntensity;
} }
// Diffuse pass // Diffuse pass
vec3 diffuseIblColor = texture(irradianceMap, N).rgb; vec3 diffuseIblColor = texture(irradianceMap, N).rgb;
vec3 diffuseTerm = diffuseIblColor * albedo; vec3 diffuseTerm = diffuseIblColor * albedo;
diffuseTerm *= kD; diffuseTerm *= kD;
diffuseTerm *= cavity; diffuseTerm *= cavity;
diffuseTerm *= ao; diffuseTerm *= ao;
diffuseTerm *= shadow; diffuseTerm *= shadow;
diffuseTerm += LightingDiffuse; diffuseTerm += LightingDiffuse;
// Adjust for metalness. // Adjust for metalness.
// diffuseTerm *= clamp(1 - metallic, 0, 1); // diffuseTerm *= clamp(1 - metallic, 0, 1);
// diffuseTerm *= vec3(1) - kS.xxx; // diffuseTerm *= vec3(1) - kS.xxx;
// Specular pass. // Specular pass.
int maxSpecularLod = 8; int maxSpecularLod = 8;
vec3 specularIblColor = textureLod(specularIbl, R, roughness * maxSpecularLod).rgb; vec3 specularIblColor = textureLod(specularIbl, R, roughness * maxSpecularLod).rgb;
vec2 envBRDF = texture(brdfLUT, vec2(max(dot(N, V), 0.0), roughness)).rg; vec2 envBRDF = texture(brdfLUT, vec2(max(dot(N, V), 0.0), roughness)).rg;
vec3 brdfTerm = (kS * envBRDF.x + envBRDF.y); vec3 brdfTerm = (kS * envBRDF.x + envBRDF.y);
vec3 specularTerm = specularIblColor * brdfTerm * specIntensity * 0.7f; vec3 specularTerm = specularIblColor * brdfTerm * specIntensity * 0.7f;
// Add render passes. // Add render passes.
fragColor.rgb = vec3(0); fragColor.rgb = vec3(0);
fragColor.rgb += diffuseTerm; fragColor.rgb += diffuseTerm;
fragColor.rgb += specularTerm; fragColor.rgb += specularTerm;
// Global brightness adjustment. // Global brightness adjustment.
fragColor.rgb *= 2.5; fragColor.rgb *= 2.5;
fragColor *= min(pickingColor, vec4(1)); fragColor *= min(pickingColor, vec4(1));
fragColor.rgb *= min(boneWeightsColored, vec3(1)); fragColor.rgb *= min(boneWeightsColored, vec3(1));
// Convert back to sRGB. // Convert back to sRGB.
fragColor.rgb = pow(fragColor.rgb, vec3(1 / gamma)); fragColor.rgb = pow(fragColor.rgb, vec3(1 / gamma));
// Alpha calculations. // Alpha calculations.
float alpha = texture(DiffuseMap, f_texcoord0).a; float alpha = texture(DiffuseMap, f_texcoord0).a;
fragColor.a = alpha; fragColor.a = alpha;
// Toggles rendering of individual color channels for all render modes. // Toggles rendering of individual color channels for all render modes.
fragColor.rgb *= vec3(renderR, renderG, renderB); fragColor.rgb *= vec3(renderR, renderG, renderB);
if (renderR == 1 && renderG == 0 && renderB == 0) if (renderR == 1 && renderG == 0 && renderB == 0)
fragColor.rgb = fragColor.rrr; fragColor.rgb = fragColor.rrr;
else if (renderG == 1 && renderR == 0 && renderB == 0) else if (renderG == 1 && renderR == 0 && renderB == 0)
fragColor.rgb = fragColor.ggg; fragColor.rgb = fragColor.ggg;
else if (renderB == 1 && renderR == 0 && renderG == 0) else if (renderB == 1 && renderR == 0 && renderG == 0)
fragColor.rgb = fragColor.bbb; fragColor.rgb = fragColor.bbb;
} }