mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 19:15:19 +02:00
Unifying the lighting pass for scaterring and not
This commit is contained in:
parent
8f2bf2b423
commit
1eb4acf815
11 changed files with 137 additions and 178 deletions
|
@ -34,16 +34,15 @@
|
||||||
vec3 color = vec3(0.0);
|
vec3 color = vec3(0.0);
|
||||||
|
|
||||||
<@if isScattering@>
|
<@if isScattering@>
|
||||||
vec3 fresnel = vec3(0.028); // Default Di-electric fresnel value for skin
|
|
||||||
float metallic = 0.0;
|
|
||||||
<@else@>
|
<@else@>
|
||||||
|
color += emissive * isEmissiveEnabled();
|
||||||
|
<@endif@>
|
||||||
|
|
||||||
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
|
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
|
||||||
if (metallic > 0.5) {
|
if (metallic > 0.5) {
|
||||||
fresnel = albedo;
|
fresnel = albedo;
|
||||||
metallic = 1.0;
|
metallic = 1.0;
|
||||||
}
|
}
|
||||||
color += emissive * isEmissiveEnabled();
|
|
||||||
<@endif@>
|
|
||||||
|
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
|
||||||
|
|
||||||
<$declareDeferredCurvature()$>
|
<$declareDeferredCurvature()$>
|
||||||
|
|
||||||
vec3 evalAmbientSphereGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float roughness, float scattering, vec4 blurredCurvature, vec4 diffusedCurvature) {
|
vec3 evalAmbientSphereGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness, float scattering, vec4 blurredCurvature, vec4 diffusedCurvature) {
|
||||||
|
|
||||||
<$prepareGlobalLight(1)$>
|
<$prepareGlobalLight(1)$>
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
|
|
||||||
<$declareDeferredCurvature()$>
|
<$declareDeferredCurvature()$>
|
||||||
|
|
||||||
vec3 evalSkyboxGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float roughness, float scattering, vec4 blurredCurvature, vec4 diffusedCurvature) {
|
vec3 evalSkyboxGlobalColorScattering(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness, float scattering, vec4 blurredCurvature, vec4 diffusedCurvature) {
|
||||||
<$prepareGlobalLight(1)$>
|
<$prepareGlobalLight(1)$>
|
||||||
|
|
||||||
vec3 midNormal = normalize((blurredCurvature.xyz - 0.5f) * 2.0f);
|
vec3 midNormal = normalize((blurredCurvature.xyz - 0.5f) * 2.0f);
|
||||||
|
|
|
@ -25,46 +25,23 @@ void evalLightingDirectional(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
|
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
|
|
||||||
<@include SubsurfaceScattering.slh@>
|
|
||||||
<$declareSubsurfaceScatteringBRDF()$>
|
|
||||||
<$declareSkinSpecularLighting()$>
|
|
||||||
|
|
||||||
void evalLightingDirectionalScattering(out vec3 diffuse, out vec3 specular, Light light,
|
void evalLightingDirectionalScattering(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
vec3 eyeDir, vec3 normal, float roughness,
|
vec3 eyeDir, vec3 normal, float roughness,
|
||||||
float metallic, vec3 fresnel, vec3 albedo, float shadow,
|
float metallic, vec3 fresnel, vec3 albedo, float shadow,
|
||||||
float scattering, vec3 midNormal, vec3 lowNormal, float curvature) {
|
float scattering, vec3 midNormal, vec3 lowNormal, float curvature) {
|
||||||
|
|
||||||
vec3 fragLightDir = -normalize(getLightDirection(light));
|
vec3 fragLightDir = -normalize(getLightDirection(light));
|
||||||
vec3 brdf = evalSkinBRDF(fragLightDir, normal, midNormal, lowNormal, curvature);
|
|
||||||
float scatteringLevel = getScatteringLevel();
|
|
||||||
vec4 shading;
|
|
||||||
float standardDiffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
|
||||||
{ // Key Sun Lighting
|
|
||||||
// Diffuse Lighting
|
|
||||||
//float diffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
|
||||||
|
|
||||||
// Specular Lighting
|
evalFragShading(diffuse, specular,
|
||||||
vec3 halfDir = normalize(eyeDir + fragLightDir);
|
normal, fragLightDir, eyeDir,
|
||||||
|
metallic, fresnel, roughness,
|
||||||
|
scattering, vec4(midNormal, curvature), vec4(lowNormal, curvature));
|
||||||
|
|
||||||
float specular = skinSpecular(normal, fragLightDir, eyeDir, roughness, 1.0);
|
vec3 lightEnergy = shadow * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
vec3 fresnelColor = fresnelSchlick(fresnel, fragLightDir, halfDir);
|
diffuse *= albedo * lightEnergy;
|
||||||
float power = specularDistribution(roughness, normal, halfDir);
|
|
||||||
//vec3 specular = power * fresnelColor * standardDiffuse;
|
|
||||||
|
|
||||||
shading = vec4(vec3(specular), (1 - fresnelColor.x));
|
specular *= lightEnergy;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (scatteringLevel < 0.1) {
|
|
||||||
brdf = vec3(standardDiffuse);
|
|
||||||
}
|
|
||||||
brdf = mix(vec3(standardDiffuse), brdf, scatteringLevel * scattering);
|
|
||||||
|
|
||||||
|
|
||||||
diffuse = albedo * brdf.xyz * shadow * getLightColor(light) * getLightIntensity(light);
|
|
||||||
|
|
||||||
specular = shading.rgb * shadow * getLightColor(light) * getLightIntensity(light);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -46,10 +46,6 @@ void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
|
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
|
|
||||||
<@include SubsurfaceScattering.slh@>
|
|
||||||
<$declareSubsurfaceScatteringBRDF()$>
|
|
||||||
<$declareSkinSpecularLighting()$>
|
|
||||||
|
|
||||||
void evalLightingPointScattering(out vec3 diffuse, out vec3 specular, Light light,
|
void evalLightingPointScattering(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
vec3 fragLightVec, vec3 fragEyeDir, vec3 normal, float roughness,
|
vec3 fragLightVec, vec3 fragEyeDir, vec3 normal, float roughness,
|
||||||
float metallic, vec3 fresnel, vec3 albedo, float shadow,
|
float metallic, vec3 fresnel, vec3 albedo, float shadow,
|
||||||
|
@ -65,36 +61,14 @@ void evalLightingPointScattering(out vec3 diffuse, out vec3 specular, Light ligh
|
||||||
vec3 lightEnergy = radialAttenuation * shadow * getLightColor(light) * getLightIntensity(light);
|
vec3 lightEnergy = radialAttenuation * shadow * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
// Eval shading
|
// Eval shading
|
||||||
vec3 brdf = evalSkinBRDF(fragLightDir, normal, midNormal, lowNormal, curvature);
|
evalFragShading(diffuse, specular,
|
||||||
float scatteringLevel = getScatteringLevel();
|
normal, fragLightDir, fragEyeDir,
|
||||||
vec4 shading;
|
metallic, fresnel, roughness,
|
||||||
float standardDiffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
scattering, vec4(midNormal, curvature), vec4(lowNormal, curvature));
|
||||||
{ // Key Sun Lighting
|
|
||||||
// Diffuse Lighting
|
|
||||||
//float diffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
|
||||||
|
|
||||||
// Specular Lighting
|
diffuse *= albedo * lightEnergy;
|
||||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
|
||||||
|
|
||||||
float specular = skinSpecular(normal, fragLightDir, fragEyeDir, roughness, 1.0);
|
specular *= lightEnergy;
|
||||||
|
|
||||||
vec3 fresnelColor = fresnelSchlick(fresnel, fragLightDir, halfDir);
|
|
||||||
float power = specularDistribution(roughness, normal, halfDir);
|
|
||||||
//vec3 specular = power * fresnelColor * standardDiffuse;
|
|
||||||
|
|
||||||
shading = vec4(vec3(specular), (1 - fresnelColor.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (scatteringLevel < 0.1) {
|
|
||||||
brdf = vec3(standardDiffuse);
|
|
||||||
}
|
|
||||||
brdf = mix(vec3(standardDiffuse), brdf, scatteringLevel * scattering);
|
|
||||||
|
|
||||||
|
|
||||||
diffuse = albedo * brdf.xyz * lightEnergy;
|
|
||||||
|
|
||||||
specular = shading.rgb * lightEnergy;
|
|
||||||
|
|
||||||
if (getLightShowContour(light) > 0.0) {
|
if (getLightShowContour(light) > 0.0) {
|
||||||
// Show edge
|
// Show edge
|
||||||
|
|
|
@ -11,9 +11,6 @@
|
||||||
|
|
||||||
<@func declareLightingSpot(supportScattering)@>
|
<@func declareLightingSpot(supportScattering)@>
|
||||||
|
|
||||||
|
|
||||||
<@include DeferredLighting.slh@>
|
|
||||||
|
|
||||||
void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
vec4 fragLightDirLen, float cosSpotAngle, vec3 fragEyeDir, vec3 normal, float roughness,
|
vec4 fragLightDirLen, float cosSpotAngle, vec3 fragEyeDir, vec3 normal, float roughness,
|
||||||
float metallic, vec3 fresnel, vec3 albedo, float shadow) {
|
float metallic, vec3 fresnel, vec3 albedo, float shadow) {
|
||||||
|
@ -49,10 +46,6 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
|
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
|
|
||||||
<@include SubsurfaceScattering.slh@>
|
|
||||||
<$declareSubsurfaceScatteringBRDF()$>
|
|
||||||
<$declareSkinSpecularLighting()$>
|
|
||||||
|
|
||||||
void evalLightingSpotScattering(out vec3 diffuse, out vec3 specular, Light light,
|
void evalLightingSpotScattering(out vec3 diffuse, out vec3 specular, Light light,
|
||||||
vec4 fragLightDirLen, float cosSpotAngle, vec3 fragEyeDir, vec3 normal, float roughness,
|
vec4 fragLightDirLen, float cosSpotAngle, vec3 fragEyeDir, vec3 normal, float roughness,
|
||||||
float metallic, vec3 fresnel, vec3 albedo, float shadow,
|
float metallic, vec3 fresnel, vec3 albedo, float shadow,
|
||||||
|
@ -68,36 +61,14 @@ void evalLightingSpotScattering(out vec3 diffuse, out vec3 specular, Light light
|
||||||
vec3 lightEnergy = angularAttenuation * radialAttenuation * shadow * getLightColor(light) * getLightIntensity(light);
|
vec3 lightEnergy = angularAttenuation * radialAttenuation * shadow * getLightColor(light) * getLightIntensity(light);
|
||||||
|
|
||||||
// Eval shading
|
// Eval shading
|
||||||
vec3 brdf = evalSkinBRDF(fragLightDir, normal, midNormal, lowNormal, curvature);
|
evalFragShading(diffuse, specular,
|
||||||
float scatteringLevel = getScatteringLevel();
|
normal, fragLightDir, fragEyeDir,
|
||||||
vec4 shading;
|
metallic, fresnel, roughness,
|
||||||
float standardDiffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
scattering, vec4(midNormal, curvature), vec4(lowNormal, curvature));
|
||||||
{ // Key Sun Lighting
|
|
||||||
// Diffuse Lighting
|
|
||||||
//float diffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
|
||||||
|
|
||||||
// Specular Lighting
|
diffuse *= albedo * lightEnergy;
|
||||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
|
||||||
|
|
||||||
float specular = skinSpecular(normal, fragLightDir, fragEyeDir, roughness, 1.0);
|
specular *= lightEnergy;
|
||||||
|
|
||||||
vec3 fresnelColor = fresnelSchlick(fresnel, fragLightDir, halfDir);
|
|
||||||
float power = specularDistribution(roughness, normal, halfDir);
|
|
||||||
//vec3 specular = power * fresnelColor * standardDiffuse;
|
|
||||||
|
|
||||||
shading = vec4(vec3(specular), (1 - fresnelColor.x));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (scatteringLevel < 0.1) {
|
|
||||||
brdf = vec3(standardDiffuse);
|
|
||||||
}
|
|
||||||
brdf = mix(vec3(standardDiffuse), brdf, scatteringLevel * scattering);
|
|
||||||
|
|
||||||
|
|
||||||
diffuse = albedo * brdf.xyz * lightEnergy;
|
|
||||||
|
|
||||||
specular = shading.rgb * lightEnergy;
|
|
||||||
|
|
||||||
if (getLightShowContour(light) > 0.0) {
|
if (getLightShowContour(light) > 0.0) {
|
||||||
// Show edges
|
// Show edges
|
||||||
|
|
|
@ -66,14 +66,48 @@ float isShowContour() {
|
||||||
|
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
<@func declareBeckmannSpecular()@>
|
||||||
|
|
||||||
|
uniform sampler2D scatteringSpecularBeckmann;
|
||||||
|
|
||||||
|
float fetchSpecularBeckmann(float ndoth, float roughness) {
|
||||||
|
return pow(2.0 * texture(scatteringSpecularBeckmann, vec2(ndoth, roughness)).r, 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
float fresnelSchlickScalar(float fresnelColor, vec3 lightDir, vec3 halfDir) {
|
||||||
|
float base = 1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0);
|
||||||
|
float exponential = pow(base, 5.0);
|
||||||
|
return (exponential)+fresnelColor * (1.0 - exponential);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 skinSpecular(vec3 N, vec3 L, vec3 V, float roughness, float intensity) {
|
||||||
|
vec2 result = vec2(0.0, 1.0);
|
||||||
|
float ndotl = dot(N, L);
|
||||||
|
if (ndotl > 0.0) {
|
||||||
|
vec3 h = L + V;
|
||||||
|
vec3 H = normalize(h);
|
||||||
|
float ndoth = dot(N, H);
|
||||||
|
float PH = fetchSpecularBeckmann(ndoth, roughness);
|
||||||
|
float F = fresnelSchlickScalar(0.028, H, V);
|
||||||
|
float frSpec = max(PH * F / dot(h, h), 0.0);
|
||||||
|
result.x = ndotl * intensity * frSpec;
|
||||||
|
result.y -= F;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
<@endfunc@>
|
||||||
|
|
||||||
<@func declareEvalPBRShading()@>
|
<@func declareEvalPBRShading()@>
|
||||||
|
|
||||||
vec3 fresnelSchlick(vec3 fresnelColor, vec3 lightDir, vec3 halfDir) {
|
vec3 fresnelSchlickColor(vec3 fresnelColor, vec3 lightDir, vec3 halfDir) {
|
||||||
return fresnelColor + (1.0 - fresnelColor) * pow(1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5);
|
float base = 1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0);
|
||||||
|
float exponential = pow(base, 5.0);
|
||||||
|
return vec3(exponential) + fresnelColor * (1.0 - exponential);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float specularDistribution(float roughness, vec3 normal, vec3 halfDir) {
|
float specularDistribution(float roughness, vec3 normal, vec3 halfDir) {
|
||||||
float ndoth = clamp(dot(halfDir, normal), 0.0, 1.0);
|
float ndoth = clamp(dot(halfDir, normal), 0.0, 1.0);
|
||||||
float gloss2 = pow(0.001 + roughness, 4);
|
float gloss2 = pow(0.001 + roughness, 4);
|
||||||
|
@ -96,7 +130,7 @@ vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float m
|
||||||
|
|
||||||
// Specular Lighting
|
// Specular Lighting
|
||||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||||
vec3 fresnelColor = fresnelSchlick(fresnel, fragLightDir, halfDir);
|
vec3 fresnelColor = fresnelSchlickColor(fresnel, fragLightDir, halfDir);
|
||||||
float power = specularDistribution(roughness, fragNormal, halfDir);
|
float power = specularDistribution(roughness, fragNormal, halfDir);
|
||||||
vec3 specular = power * fresnelColor * diffuse;
|
vec3 specular = power * fresnelColor * diffuse;
|
||||||
|
|
||||||
|
@ -104,73 +138,42 @@ vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float m
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<$declareEvalPBRShading()$>
|
<$declareEvalPBRShading()$>
|
||||||
|
|
||||||
// Return xyz the specular/reflection component and w the diffuse component
|
// Return xyz the specular/reflection component and w the diffuse component
|
||||||
vec4 evalFragShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float metallic, vec3 specular, float roughness) {
|
vec4 evalFragShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float metallic, vec3 fresnel, float roughness) {
|
||||||
return evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, specular, roughness);
|
return evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, fresnel, roughness);
|
||||||
}
|
|
||||||
<!
|
|
||||||
uniform sampler2D scatteringSpecularBeckmann;
|
|
||||||
|
|
||||||
float fetchSpecularBeckmann(float ndoth, float roughness) {
|
|
||||||
return pow(2.0 * texture(scatteringSpecularBeckmann, vec2(ndoth, roughness)).r, 10.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float fresnelReflectance(vec3 H, vec3 V, float Fo) {
|
|
||||||
float base = 1.0 - dot(V, H);
|
|
||||||
float exponential = pow(base, 5.0);
|
|
||||||
return exponential + Fo * (1.0 - exponential);
|
|
||||||
}
|
|
||||||
|
|
||||||
float skinSpecular(vec3 N, vec3 L, vec3 V, float roughness, float intensity) {
|
<$declareBeckmannSpecular()$>
|
||||||
float result = 0.0;
|
<@include SubsurfaceScattering.slh@>
|
||||||
float ndotl = dot(N, L);
|
<$declareSubsurfaceScatteringBRDF()$>
|
||||||
if (ndotl > 0.0) {
|
|
||||||
vec3 h = L + V;
|
|
||||||
vec3 H = normalize(h);
|
|
||||||
float ndoth = dot(N, H);
|
|
||||||
float PH = fetchSpecularBeckmann(ndoth, roughness);
|
|
||||||
float F = fresnelReflectance(H, V, 0.028);
|
|
||||||
float frSpec = max(PH * F / dot(h, h), 0.0);
|
|
||||||
result = ndotl * intensity * frSpec;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
void evalFragShading(out vec3 diffuse, out vec3 specular,
|
||||||
}
|
vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir,
|
||||||
|
float metallic, vec3 fresnel, float roughness,
|
||||||
// Eval shading
|
float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature) {
|
||||||
vec3 brdf = evalSkinBRDF(fragLightDir, normal, midNormal, lowNormal, curvature);
|
if (scattering > 0.0) {
|
||||||
float scatteringLevel = getScatteringLevel();
|
vec3 brdf = evalSkinBRDF(fragLightDir, fragNormal, midNormalCurvature.xyz, lowNormalCurvature.xyz, lowNormalCurvature.w);
|
||||||
vec4 shading;
|
float NdotL = clamp(dot(fragNormal, fragLightDir), 0.0, 1.0);
|
||||||
float standardDiffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
diffuse = mix(vec3(NdotL), brdf, scattering);
|
||||||
{ // Key Sun Lighting
|
|
||||||
// Diffuse Lighting
|
|
||||||
//float diffuse = clamp(dot(normal, fragLightDir), 0.0, 1.0);
|
|
||||||
|
|
||||||
// Specular Lighting
|
// Specular Lighting
|
||||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||||
|
vec2 specularBrdf = skinSpecular(fragNormal, fragLightDir, fragEyeDir, roughness, 1.0);
|
||||||
|
|
||||||
float specular = skinSpecular(normal, fragLightDir, fragEyeDir, roughness, 1.0);
|
diffuse *= specularBrdf.y;
|
||||||
|
specular = vec3(specularBrdf.x);
|
||||||
|
|
||||||
vec3 fresnelColor = fresnelSchlick(fresnel, fragLightDir, halfDir);
|
} else {
|
||||||
float power = specularDistribution(roughness, normal, halfDir);
|
vec4 shading = evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, specular, roughness);
|
||||||
//vec3 specular = power * fresnelColor * standardDiffuse;
|
diffuse = vec3(shading.w);
|
||||||
|
specular = shading.xyz;
|
||||||
shading = vec4(vec3(specular), (1 - fresnelColor.x));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (scatteringLevel < 0.1) {
|
|
||||||
brdf = vec3(standardDiffuse);
|
|
||||||
}
|
|
||||||
brdf = mix(vec3(standardDiffuse), brdf, scatteringLevel * scattering);
|
|
||||||
|
|
||||||
|
|
||||||
diffuse = albedo * brdf.xyz * lightEnergy;
|
|
||||||
|
|
||||||
specular = shading.rgb * lightEnergy;
|
|
||||||
|
|
||||||
!>
|
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -140,6 +140,8 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
||||||
// Render transparent objects forward in LightingBuffer
|
// Render transparent objects forward in LightingBuffer
|
||||||
addJob<DrawDeferred>("DrawTransparentDeferred", transparents, shapePlumber);
|
addJob<DrawDeferred>("DrawTransparentDeferred", transparents, shapePlumber);
|
||||||
|
|
||||||
|
addJob<DebugSubsurfaceScattering>("DebugScattering", deferredLightingInputs);
|
||||||
|
|
||||||
|
|
||||||
// Lighting Buffer ready for tone mapping
|
// Lighting Buffer ready for tone mapping
|
||||||
addJob<ToneMappingDeferred>("ToneMapping");
|
addJob<ToneMappingDeferred>("ToneMapping");
|
||||||
|
@ -151,7 +153,6 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
||||||
|
|
||||||
// Debugging stages
|
// Debugging stages
|
||||||
{
|
{
|
||||||
addJob<DebugSubsurfaceScattering>("DebugScattering", deferredLightingInputs);
|
|
||||||
|
|
||||||
// Debugging Deferred buffer job
|
// Debugging Deferred buffer job
|
||||||
const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(diffusedCurvatureFramebuffer, curvatureFramebuffer));
|
const auto debugFramebuffers = render::Varying(DebugDeferredBuffer::Inputs(diffusedCurvatureFramebuffer, curvatureFramebuffer));
|
||||||
|
|
|
@ -39,7 +39,7 @@ void main(void) {
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
frag.specularVal.xyz);
|
frag.specularVal.xyz);
|
||||||
_fragColor = vec4(color, 1.0);
|
_fragColor = vec4(color, 1.0);
|
||||||
} else if (frag.mode == FRAG_MODE_SCATTERING) {
|
} else { //if (frag.mode == FRAG_MODE_SCATTERING) {
|
||||||
|
|
||||||
vec4 blurredCurvature = fetchCurvature(_texCoord0);
|
vec4 blurredCurvature = fetchCurvature(_texCoord0);
|
||||||
vec4 diffusedCurvature = fetchDiffusedCurvature(_texCoord0);
|
vec4 diffusedCurvature = fetchDiffusedCurvature(_texCoord0);
|
||||||
|
@ -51,12 +51,14 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
|
frag.emissive,
|
||||||
frag.roughness,
|
frag.roughness,
|
||||||
frag.scattering,
|
frag.scattering,
|
||||||
blurredCurvature,
|
blurredCurvature,
|
||||||
diffusedCurvature);
|
diffusedCurvature);
|
||||||
_fragColor = vec4(color, 1.0);
|
_fragColor = vec4(color, 1.0);
|
||||||
} else {
|
/* } else {
|
||||||
vec3 color = evalAmbientSphereGlobalColor(
|
vec3 color = evalAmbientSphereGlobalColor(
|
||||||
getViewInverse(),
|
getViewInverse(),
|
||||||
shadowAttenuation,
|
shadowAttenuation,
|
||||||
|
@ -67,6 +69,6 @@ void main(void) {
|
||||||
frag.metallic,
|
frag.metallic,
|
||||||
frag.emissive,
|
frag.emissive,
|
||||||
frag.roughness);
|
frag.roughness);
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ void main(void) {
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
frag.specularVal.xyz);
|
frag.specularVal.xyz);
|
||||||
_fragColor = vec4(color, 1.0);
|
_fragColor = vec4(color, 1.0);
|
||||||
} else if (frag.mode == FRAG_MODE_SCATTERING) {
|
} else {// if (frag.mode == FRAG_MODE_SCATTERING) {
|
||||||
|
|
||||||
vec4 blurredCurvature = fetchCurvature(_texCoord0);
|
vec4 blurredCurvature = fetchCurvature(_texCoord0);
|
||||||
vec4 diffusedCurvature = fetchDiffusedCurvature(_texCoord0);
|
vec4 diffusedCurvature = fetchDiffusedCurvature(_texCoord0);
|
||||||
|
@ -51,12 +51,14 @@ void main(void) {
|
||||||
frag.position.xyz,
|
frag.position.xyz,
|
||||||
frag.normal,
|
frag.normal,
|
||||||
frag.diffuse,
|
frag.diffuse,
|
||||||
|
frag.metallic,
|
||||||
|
frag.emissive,
|
||||||
frag.roughness,
|
frag.roughness,
|
||||||
frag.scattering,
|
frag.scattering,
|
||||||
blurredCurvature,
|
blurredCurvature,
|
||||||
diffusedCurvature);
|
diffusedCurvature);
|
||||||
_fragColor = vec4(color, 1.0);
|
_fragColor = vec4(color, 1.0);
|
||||||
} else {
|
/* } else {
|
||||||
vec3 color = evalSkyboxGlobalColor(
|
vec3 color = evalSkyboxGlobalColor(
|
||||||
getViewInverse(),
|
getViewInverse(),
|
||||||
shadowAttenuation,
|
shadowAttenuation,
|
||||||
|
@ -69,5 +71,6 @@ void main(void) {
|
||||||
frag.roughness);
|
frag.roughness);
|
||||||
|
|
||||||
_fragColor = vec4(color, frag.normalVal.a);
|
_fragColor = vec4(color, frag.normalVal.a);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ void main(void) {
|
||||||
vec3 diffuse;
|
vec3 diffuse;
|
||||||
vec3 specular;
|
vec3 specular;
|
||||||
|
|
||||||
if ((isScatteringEnabled() > 0.0) && (frag.mode == FRAG_MODE_SCATTERING)) {
|
if (frag.mode == FRAG_MODE_SCATTERING) {
|
||||||
vec4 blurredCurvature = fetchCurvature(texCoord);
|
vec4 blurredCurvature = fetchCurvature(texCoord);
|
||||||
vec4 diffusedCurvature = fetchDiffusedCurvature(texCoord);
|
vec4 diffusedCurvature = fetchDiffusedCurvature(texCoord);
|
||||||
vec3 midNormal = normalize((blurredCurvature.xyz - 0.5f) * 2.0f);
|
vec3 midNormal = normalize((blurredCurvature.xyz - 0.5f) * 2.0f);
|
||||||
|
@ -79,7 +79,7 @@ void main(void) {
|
||||||
evalLightingPointScattering(diffuse, specular, light,
|
evalLightingPointScattering(diffuse, specular, light,
|
||||||
fragLightVecLen2.xyz, fragEyeDir, frag.normal, frag.roughness,
|
fragLightVecLen2.xyz, fragEyeDir, frag.normal, frag.roughness,
|
||||||
frag.metallic, frag.specular, frag.diffuse, 1.0,
|
frag.metallic, frag.specular, frag.diffuse, 1.0,
|
||||||
frag.scattering, midNormal, lowNormal, lowCurvature);
|
frag.scattering * isScatteringEnabled(), midNormal, lowNormal, lowCurvature);
|
||||||
} else {
|
} else {
|
||||||
evalLightingPoint(diffuse, specular, light,
|
evalLightingPoint(diffuse, specular, light,
|
||||||
fragLightVecLen2.xyz, fragEyeDir, frag.normal, frag.roughness,
|
fragLightVecLen2.xyz, fragEyeDir, frag.normal, frag.roughness,
|
||||||
|
|
|
@ -70,7 +70,7 @@ void main(void) {
|
||||||
|
|
||||||
vec3 diffuse;
|
vec3 diffuse;
|
||||||
vec3 specular;
|
vec3 specular;
|
||||||
if ((isScatteringEnabled() > 0.0) && (frag.mode == FRAG_MODE_SCATTERING)) {
|
if (frag.mode == FRAG_MODE_SCATTERING) {
|
||||||
vec4 blurredCurvature = fetchCurvature(texCoord);
|
vec4 blurredCurvature = fetchCurvature(texCoord);
|
||||||
vec4 diffusedCurvature = fetchDiffusedCurvature(texCoord);
|
vec4 diffusedCurvature = fetchDiffusedCurvature(texCoord);
|
||||||
vec3 midNormal = normalize((blurredCurvature.xyz - 0.5f) * 2.0f);
|
vec3 midNormal = normalize((blurredCurvature.xyz - 0.5f) * 2.0f);
|
||||||
|
@ -80,7 +80,7 @@ void main(void) {
|
||||||
evalLightingSpotScattering(diffuse, specular, light,
|
evalLightingSpotScattering(diffuse, specular, light,
|
||||||
fragLightDirLen.xyzw, cosSpotAngle, fragEyeDir, frag.normal, frag.roughness,
|
fragLightDirLen.xyzw, cosSpotAngle, fragEyeDir, frag.normal, frag.roughness,
|
||||||
frag.metallic, frag.specular, frag.diffuse, 1.0,
|
frag.metallic, frag.specular, frag.diffuse, 1.0,
|
||||||
frag.scattering, midNormal, lowNormal, lowCurvature);
|
frag.scattering * isScatteringEnabled(), midNormal, lowNormal, lowCurvature);
|
||||||
} else {
|
} else {
|
||||||
evalLightingSpot(diffuse, specular, light,
|
evalLightingSpot(diffuse, specular, light,
|
||||||
fragLightDirLen.xyzw, cosSpotAngle, fragEyeDir, frag.normal, frag.roughness,
|
fragLightDirLen.xyzw, cosSpotAngle, fragEyeDir, frag.normal, frag.roughness,
|
||||||
|
|
|
@ -11,10 +11,11 @@ import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
import "configSlider"
|
import "configSlider"
|
||||||
|
|
||||||
Column {
|
Row {
|
||||||
spacing: 8
|
spacing: 8
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: deferredLighting
|
|
||||||
spacing: 10
|
spacing: 10
|
||||||
Repeater {
|
Repeater {
|
||||||
model: [
|
model: [
|
||||||
|
@ -22,9 +23,36 @@ Column {
|
||||||
"Shaded:LightingModel:enableShaded",
|
"Shaded:LightingModel:enableShaded",
|
||||||
"Emissive:LightingModel:enableEmissive",
|
"Emissive:LightingModel:enableEmissive",
|
||||||
"Lightmap:LightingModel:enableLightmap",
|
"Lightmap:LightingModel:enableLightmap",
|
||||||
|
]
|
||||||
|
CheckBox {
|
||||||
|
text: modelData.split(":")[0]
|
||||||
|
checked: Render.getConfig(modelData.split(":")[1])
|
||||||
|
onCheckedChanged: { Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] = checked }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Column {
|
||||||
|
spacing: 10
|
||||||
|
Repeater {
|
||||||
|
model: [
|
||||||
"Scattering:LightingModel:enableScattering",
|
"Scattering:LightingModel:enableScattering",
|
||||||
"Diffuse:LightingModel:enableDiffuse",
|
"Diffuse:LightingModel:enableDiffuse",
|
||||||
"Specular:LightingModel:enableSpecular",
|
"Specular:LightingModel:enableSpecular",
|
||||||
|
]
|
||||||
|
CheckBox {
|
||||||
|
text: modelData.split(":")[0]
|
||||||
|
checked: Render.getConfig(modelData.split(":")[1])
|
||||||
|
onCheckedChanged: { Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] = checked }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
spacing: 10
|
||||||
|
Repeater {
|
||||||
|
model: [
|
||||||
"Ambient:LightingModel:enableAmbientLight",
|
"Ambient:LightingModel:enableAmbientLight",
|
||||||
"Directional:LightingModel:enableDirectionalLight",
|
"Directional:LightingModel:enableDirectionalLight",
|
||||||
"Point:LightingModel:enablePointLight",
|
"Point:LightingModel:enablePointLight",
|
||||||
|
@ -37,4 +65,5 @@ Column {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue