mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 23:02:32 +02:00
Cleaning up the lighting with the simpler approach where emissive and lightmap is displayed on forward
This commit is contained in:
parent
ed67fe4051
commit
2fbdb22493
29 changed files with 272 additions and 358 deletions
|
@ -59,7 +59,7 @@ enum Slot {
|
|||
static const std::string DEFAULT_ALBEDO_SHADER {
|
||||
"vec4 getFragmentColor() {"
|
||||
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||
" return vec4(pow(frag.diffuse, vec3(1.0 / 2.2)), 1.0);"
|
||||
" return vec4(pow(frag.albedo, vec3(1.0 / 2.2)), 1.0);"
|
||||
" }"
|
||||
};
|
||||
|
||||
|
@ -93,7 +93,7 @@ static const std::string DEFAULT_OCCLUSION_SHADER{
|
|||
static const std::string DEFAULT_EMISSIVE_SHADER{
|
||||
"vec4 getFragmentColor() {"
|
||||
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||
" return (frag.mode == FRAG_MODE_SHADED ? vec4(pow(frag.emissive, vec3(1.0 / 2.2)), 1.0) : vec4(vec3(0.0), 1.0));"
|
||||
" return (frag.mode == FRAG_MODE_SHADED ? vec4(pow(texture(specularMap, uv).rgb, vec3(1.0 / 2.2)), 1.0) : vec4(vec3(0.0), 1.0));"
|
||||
" }"
|
||||
};
|
||||
|
||||
|
@ -107,7 +107,7 @@ static const std::string DEFAULT_UNLIT_SHADER{
|
|||
static const std::string DEFAULT_LIGHTMAP_SHADER{
|
||||
"vec4 getFragmentColor() {"
|
||||
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||
" return (frag.mode == FRAG_MODE_LIGHTMAPPED ? vec4(pow(frag.emissive, vec3(1.0 / 2.2)), 1.0) : vec4(vec3(0.0), 1.0));"
|
||||
" return (frag.mode == FRAG_MODE_LIGHTMAPPED ? vec4(pow(texture(specularMap, uv).rgb, vec3(1.0 / 2.2)), 1.0) : vec4(vec3(0.0), 1.0));"
|
||||
" }"
|
||||
};
|
||||
|
||||
|
|
|
@ -36,11 +36,10 @@ struct DeferredFragment {
|
|||
vec4 position;
|
||||
vec3 normal;
|
||||
float metallic;
|
||||
vec3 diffuse;
|
||||
vec3 albedo;
|
||||
float obscurance;
|
||||
vec3 specular;
|
||||
vec3 fresnel;
|
||||
float roughness;
|
||||
// vec3 emissive;
|
||||
int mode;
|
||||
float scattering;
|
||||
float depthVal;
|
||||
|
@ -63,7 +62,7 @@ DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
|
|||
frag.roughness = normalVal.a;
|
||||
|
||||
// Diffuse color and unpack the mode and the metallicness
|
||||
frag.diffuse = diffuseVal.xyz;
|
||||
frag.albedo = diffuseVal.xyz;
|
||||
frag.scattering = 0.0;
|
||||
unpackModeMetallic(diffuseVal.w, frag.mode, frag.metallic);
|
||||
|
||||
|
@ -73,14 +72,13 @@ DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
|
|||
|
||||
if (frag.mode == FRAG_MODE_SCATTERING) {
|
||||
frag.scattering = specularVal.x;
|
||||
//frag.emissive = vec3(0.0);
|
||||
}
|
||||
|
||||
if (frag.metallic <= 0.5) {
|
||||
frag.metallic = 0.0;
|
||||
frag.specular = vec3(0.03); // Default Di-electric fresnel value
|
||||
frag.fresnel = vec3(0.03); // Default Di-electric fresnel value
|
||||
} else {
|
||||
frag.specular = vec3(diffuseVal.xyz);
|
||||
frag.fresnel = vec3(diffuseVal.xyz);
|
||||
frag.metallic = 1.0;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float r
|
|||
_fragColor0 = vec4(albedo, packLightmappedMetallic(metallic));
|
||||
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
|
||||
_fragColor2 = vec4(lightmap, 1.0);
|
||||
|
||||
_fragColor3 = vec4(albedo * lightmap, 1.0);
|
||||
}
|
||||
|
||||
|
@ -63,8 +62,7 @@ void packDeferredFragmentUnlit(vec3 normal, float alpha, vec3 color) {
|
|||
}
|
||||
_fragColor0 = vec4(color, packUnlit());
|
||||
_fragColor1 = vec4(packNormal(normal), 1.0);
|
||||
//_fragColor2 = vec4(vec3(0.0), 1.0); // If unlit, do not worry about the emissive color target
|
||||
|
||||
_fragColor2 = vec4(vec3(0.0), 1.0);
|
||||
_fragColor3 = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,23 +31,12 @@
|
|||
Light light = getLight();
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
<@if isScattering@>
|
||||
<@else@>
|
||||
// color += emissive * isEmissiveEnabled();
|
||||
<@endif@>
|
||||
//color += emissive * isEmissiveEnabled();
|
||||
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
|
||||
if (metallic > 0.5) {
|
||||
fresnel = albedo;
|
||||
metallic = 1.0;
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
||||
|
||||
<@func declareEvalAmbientGlobalColor()@>
|
||||
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, float roughness) {
|
||||
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness) {
|
||||
<$prepareGlobalLight()$>
|
||||
color += albedo * getLightColor(light) * obscurance * getLightAmbientIntensity(light);
|
||||
return color;
|
||||
|
@ -56,21 +45,20 @@ vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obsc
|
|||
|
||||
<@func declareEvalAmbientSphereGlobalColor(supportScattering)@>
|
||||
|
||||
<$declareLightingAmbient(1, 0, 0, supportScattering)$>
|
||||
<$declareLightingDirectional(supportScattering)$>
|
||||
<$declareLightingAmbient(1, _SCRIBE_NULL, _SCRIBE_NULL, $supportScattering$)$>
|
||||
<$declareLightingDirectional($supportScattering$)$>
|
||||
|
||||
<@if supportScattering@>
|
||||
<$declareDeferredCurvature()$>
|
||||
<@endif@>
|
||||
|
||||
vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
|
||||
vec3 albedo, float metallic, float roughness
|
||||
vec3 albedo, vec3 fresnel, float metallic, float roughness
|
||||
<@if supportScattering@>
|
||||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||
<@endif@>
|
||||
) {
|
||||
<@endif@> ) {
|
||||
|
||||
<$prepareGlobalLight(supportScattering)$>
|
||||
<$prepareGlobalLight($supportScattering$)$>
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
|
@ -78,10 +66,9 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
|
|||
evalLightingAmbient(ambientDiffuse, ambientSpecular, light, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
);
|
||||
color += ambientDiffuse * isDiffuseEnabled() * isAmbientEnabled();
|
||||
color += ambientSpecular * isSpecularEnabled() * isAmbientEnabled();
|
||||
<@endif@> );
|
||||
color += ambientDiffuse;
|
||||
color += ambientSpecular;
|
||||
|
||||
|
||||
// Directional
|
||||
|
@ -90,10 +77,9 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
|
|||
evalLightingDirectional(directionalDiffuse, directionalSpecular, light, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
);
|
||||
color += directionalDiffuse * isDiffuseEnabled() * isDirectionalEnabled();
|
||||
color += directionalSpecular * isSpecularEnabled() * isDirectionalEnabled();
|
||||
<@endif@> );
|
||||
color += directionalDiffuse;
|
||||
color += directionalSpecular;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@ -103,31 +89,31 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
|
|||
|
||||
<@func declareEvalSkyboxGlobalColor(supportScattering)@>
|
||||
|
||||
<$declareLightingAmbient(0, 1, 0, supportScattering)$>
|
||||
<$declareLightingDirectional(supportScattering)$>
|
||||
<$declareLightingAmbient(_SCRIBE_NULL, 1, _SCRIBE_NULL, $supportScattering$)$>
|
||||
<$declareLightingDirectional($supportScattering$)$>
|
||||
|
||||
<@if supportScattering@>
|
||||
<$declareDeferredCurvature()$>
|
||||
<@endif@>
|
||||
|
||||
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
|
||||
vec3 albedo, float metallic, float roughness
|
||||
vec3 albedo, vec3 fresnel, float metallic, float roughness
|
||||
<@if supportScattering@>
|
||||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||
<@endif@>
|
||||
) {
|
||||
<$prepareGlobalLight(supportScattering)$>
|
||||
<$prepareGlobalLight($supportScattering$)$>
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, light, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
);
|
||||
color += ambientDiffuse * isDiffuseEnabled() * isAmbientEnabled();
|
||||
color += ambientSpecular * isSpecularEnabled() * isAmbientEnabled();
|
||||
color += ambientDiffuse;
|
||||
color += ambientSpecular;
|
||||
|
||||
|
||||
// Directional
|
||||
|
@ -138,8 +124,8 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
);
|
||||
color += directionalDiffuse * isDiffuseEnabled() * isDirectionalEnabled();
|
||||
color += directionalSpecular * isSpecularEnabled() * isDirectionalEnabled();
|
||||
color += directionalDiffuse;
|
||||
color += directionalSpecular;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@ -178,7 +164,7 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur
|
|||
<$declareLightingAmbient(1, 1, 1)$>
|
||||
<$declareLightingDirectional()$>
|
||||
|
||||
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness, float opacity) {
|
||||
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) {
|
||||
<$prepareGlobalLight()$>
|
||||
|
||||
color += emissive * isEmissiveEnabled();
|
||||
|
@ -187,16 +173,16 @@ vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, fl
|
|||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, light, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, obscurance);
|
||||
color += ambientDiffuse * isDiffuseEnabled() * isAmbientEnabled();
|
||||
color += ambientSpecular * isSpecularEnabled() * isAmbientEnabled() / opacity;
|
||||
color += ambientDiffuse;
|
||||
color += ambientSpecular / opacity;
|
||||
|
||||
|
||||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, light, fragEyeDir, fragNormal, roughness, metallic, fresnel, albedo, shadowAttenuation);
|
||||
color += directionalDiffuse * isDiffuseEnabled() * isDirectionalEnabled();
|
||||
color += directionalSpecular * isSpecularEnabled() * isDirectionalEnabled() / opacity;
|
||||
color += directionalDiffuse;
|
||||
color += directionalSpecular / opacity;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -7,76 +7,4 @@
|
|||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
!>
|
||||
<!
|
||||
<@if not DEFERRED_LIGHTING_SLH@>
|
||||
<@def DEFERRED_LIGHTING_SLH@>
|
||||
|
||||
|
||||
<@func declareEvalPBRShading()@>
|
||||
|
||||
vec3 fresnelSchlick(vec3 fresnelColor, vec3 lightDir, vec3 halfDir) {
|
||||
return fresnelColor + (1.0 - fresnelColor) * pow(1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5);
|
||||
}
|
||||
|
||||
float specularDistribution(float roughness, vec3 normal, vec3 halfDir) {
|
||||
float ndoth = clamp(dot(halfDir, normal), 0.0, 1.0);
|
||||
float gloss2 = pow(0.001 + roughness, 4);
|
||||
float denom = (ndoth * ndoth*(gloss2 - 1) + 1);
|
||||
float power = gloss2 / (3.14159 * denom * denom);
|
||||
return power;
|
||||
}
|
||||
/* //NOTE: ANother implementation for specularDistribution
|
||||
float specularDistribution(float roughness, vec3 normal, vec3 halfDir) {
|
||||
float gloss = exp2(10 * (1.0 - roughness) + 1);
|
||||
float power = pow(clamp(dot(halfDir, normal), 0.0, 1.0), gloss);
|
||||
power *= (gloss * 0.125 + 0.25);
|
||||
return power;
|
||||
}
|
||||
*/
|
||||
|
||||
// Frag Shading returns the diffuse amount as W and the specular rgb as xyz
|
||||
vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float metallic, vec3 fresnel, float roughness) {
|
||||
// Diffuse Lighting
|
||||
float diffuse = clamp(dot(fragNormal, fragLightDir), 0.0, 1.0);
|
||||
|
||||
// Specular Lighting
|
||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||
vec3 fresnelColor = fresnelSchlick(fresnel, fragLightDir,halfDir);
|
||||
float power = specularDistribution(roughness, fragNormal, halfDir);
|
||||
vec3 specular = power * fresnelColor * diffuse;
|
||||
|
||||
return vec4(specular, (1.0 - metallic) * diffuse * (1 - fresnelColor.x));
|
||||
}
|
||||
<@endfunc@>
|
||||
|
||||
<@func declareEvalBlinnRShading()@>
|
||||
|
||||
vec4 evalBlinnShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 specular, float roughness) {
|
||||
// Diffuse Lighting
|
||||
float diffuseDot = dot(fragNormal, fragLightDir);
|
||||
float facingLight = step(0.0, diffuseDot);
|
||||
float diffuse = diffuseDot * facingLight;
|
||||
|
||||
// Specular Lighting depends on the half vector and the roughness
|
||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||
|
||||
float gloss = (1.0 - roughness) * 128.0;
|
||||
glos *= gloss;
|
||||
float specularPower = pow(facingLight * max(0.0, dot(halfDir, fragNormal)), gloss);
|
||||
vec3 reflect = specularPower * specular * diffuse;
|
||||
|
||||
return vec4(reflect, diffuse);
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
||||
<$declareEvalPBRShading()$>
|
||||
|
||||
// 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) {
|
||||
return evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, specular, roughness);
|
||||
}
|
||||
|
||||
<@endif@>
|
||||
!>
|
|
@ -57,9 +57,9 @@ vec3 evalAmbientSpecularIrradiance(Light light, vec3 fragEyeDir, vec3 fragNormal
|
|||
}
|
||||
<@endfunc@>
|
||||
|
||||
<@func declareLightingAmbient(supportAmbientSphere1, supportAmbientMap1, supportIfAmbientMapElseAmbientSphere1, supportScattering)@>
|
||||
<@func declareLightingAmbient(supportAmbientSphere, supportAmbientMap, supportIfAmbientMapElseAmbientSphere, supportScattering)@>
|
||||
|
||||
<$declareEvalAmbientSpecularIrradiance(supportAmbientSphere1, supportAmbientMap1, supportIfAmbientMapElseAmbientSphere1)$>
|
||||
<$declareEvalAmbientSpecularIrradiance($supportAmbientSphere$, $supportAmbientMap$, $supportIfAmbientMapElseAmbientSphere$)$>
|
||||
|
||||
<@if supportScattering@>
|
||||
float curvatureAO(in float k) {
|
||||
|
@ -74,38 +74,38 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, Light light, vec3
|
|||
<@endif@>
|
||||
) {
|
||||
|
||||
<@if supportScattering@>
|
||||
|
||||
// Diffuse from ambient
|
||||
diffuse = (1 - metallic) * evalSphericalLight(getLightAmbientSphere(light), normal).xyz;
|
||||
|
||||
// Specular highlight from ambient
|
||||
specular = evalAmbientSpecularIrradiance(light, eyeDir, normal, roughness, fresnel) * obscurance * getLightAmbientIntensity(light);
|
||||
|
||||
|
||||
<@if supportScattering@>
|
||||
float ambientOcclusion = curvatureAO(lowNormalCurvature.w * 20.0f) * 0.5f;
|
||||
float ambientOcclusionHF = curvatureAO(midNormalCurvature.w * 8.0f) * 0.5f;
|
||||
ambientOcclusion = min(ambientOcclusion, ambientOcclusionHF);
|
||||
|
||||
/* if (showCurvature()) {
|
||||
diffuse = vec3(ambientOcclusion);
|
||||
specular = vec3(0.0);
|
||||
return;
|
||||
}*/
|
||||
obscurance = min(obscurance, ambientOcclusion);
|
||||
|
||||
if (scattering * isScatteringEnabled() > 0.0) {
|
||||
|
||||
// Diffuse from ambient
|
||||
diffuse = ambientOcclusion * albedo * evalSphericalLight(getLightAmbientSphere(light), lowNormalCurvature.xyz).xyz *getLightAmbientIntensity(light);
|
||||
// Diffuse from ambient
|
||||
diffuse = evalSphericalLight(getLightAmbientSphere(light), lowNormalCurvature.xyz).xyz;
|
||||
|
||||
// Specular highlight from ambient
|
||||
// vec3 specularLighting = evalGlobalSpecularIrradiance(light, fragEyeDir, fragNormal, roughness, fresnel);
|
||||
// color += specularLighting;
|
||||
|
||||
|
||||
// Specular highlight from ambient
|
||||
// specular = evalAmbientSpecularIrradiance(light, eyeDir, normal, roughness, fresnel) * obscurance * getLightAmbientIntensity(light);
|
||||
specular = vec3(0.0);
|
||||
|
||||
<@else@>
|
||||
// Diffuse from ambient
|
||||
diffuse = (1 - metallic) * albedo * evalSphericalLight(getLightAmbientSphere(light), normal).xyz * obscurance * getLightAmbientIntensity(light);
|
||||
|
||||
// Specular highlight from ambient
|
||||
specular = evalAmbientSpecularIrradiance(light, eyeDir, normal, roughness, fresnel) * obscurance * getLightAmbientIntensity(light);
|
||||
specular = vec3(0.0);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
float lightEnergy = obscurance * getLightAmbientIntensity(light);
|
||||
|
||||
if (isAlbedoEnabled() > 0.0) {
|
||||
diffuse *= albedo;
|
||||
}
|
||||
|
||||
diffuse *= lightEnergy * isDiffuseEnabled() * isAmbientEnabled();
|
||||
specular *= lightEnergy * isSpecularEnabled() * isAmbientEnabled();
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
|
|
@ -18,18 +18,18 @@ void evalLightingDirectional(out vec3 diffuse, out vec3 specular, Light light,
|
|||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||
<@endif@>
|
||||
) {
|
||||
|
||||
evalFragShading(diffuse, specular, normal, -getLightDirection(light), eyeDir, metallic, fresnel, roughness
|
||||
|
||||
// Attenuation
|
||||
vec3 lightEnergy = shadow * getLightColor(light) * getLightIntensity(light);
|
||||
|
||||
evalFragShading(diffuse, specular, normal, -getLightDirection(light), eyeDir, metallic, fresnel, roughness, albedo
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
);
|
||||
|
||||
vec3 lightEnergy = shadow * getLightColor(light) * getLightIntensity(light);
|
||||
|
||||
diffuse *= albedo * lightEnergy;
|
||||
|
||||
specular *= lightEnergy;
|
||||
diffuse *= lightEnergy * isDiffuseEnabled() * isDirectionalEnabled();
|
||||
specular *= lightEnergy * isSpecularEnabled() * isDirectionalEnabled();
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
|
|
@ -23,21 +23,19 @@ void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
|
|||
float fragLightDistance = length(fragLightVec);
|
||||
vec3 fragLightDir = fragLightVec / fragLightDistance;
|
||||
|
||||
// Eval attenuation
|
||||
// Eval attenuation
|
||||
float radialAttenuation = evalLightAttenuation(light, fragLightDistance);
|
||||
|
||||
vec3 lightEnergy = radialAttenuation * shadow * getLightColor(light) * getLightIntensity(light);
|
||||
|
||||
// Eval shading
|
||||
evalFragShading(diffuse, specular, normal, fragLightDir, fragEyeDir, metallic, fresnel, roughness
|
||||
evalFragShading(diffuse, specular, normal, fragLightDir, fragEyeDir, metallic, fresnel, roughness, albedo
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
);
|
||||
|
||||
diffuse *= albedo * lightEnergy;
|
||||
|
||||
specular *= lightEnergy;
|
||||
diffuse *= lightEnergy * isDiffuseEnabled() * isPointEnabled();
|
||||
specular *= lightEnergy * isSpecularEnabled() * isPointEnabled();
|
||||
|
||||
if (getLightShowContour(light) > 0.0) {
|
||||
// Show edge
|
||||
|
|
|
@ -29,15 +29,14 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
|||
vec3 lightEnergy = angularAttenuation * radialAttenuation * shadow * getLightColor(light) * getLightIntensity(light);
|
||||
|
||||
// Eval shading
|
||||
evalFragShading(diffuse, specular, normal, fragLightDir, fragEyeDir, metallic, fresnel, roughness
|
||||
evalFragShading(diffuse, specular, normal, fragLightDir, fragEyeDir, metallic, fresnel, roughness, albedo
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
);
|
||||
|
||||
diffuse *= albedo * lightEnergy;
|
||||
|
||||
specular *= lightEnergy;
|
||||
diffuse *= lightEnergy * isDiffuseEnabled() * isSpotEnabled();
|
||||
specular *= lightEnergy * isSpecularEnabled() * isSpotEnabled();
|
||||
|
||||
if (getLightShowContour(light) > 0.0) {
|
||||
// Show edges
|
||||
|
|
|
@ -75,6 +75,14 @@ void LightingModel::setSpecular(bool enable) {
|
|||
bool LightingModel::isSpecularEnabled() const {
|
||||
return (bool)_parametersBuffer.get<Parameters>().enableSpecular;
|
||||
}
|
||||
void LightingModel::setAlbedo(bool enable) {
|
||||
if (enable != isAlbedoEnabled()) {
|
||||
_parametersBuffer.edit<Parameters>().enableAlbedo = (float)enable;
|
||||
}
|
||||
}
|
||||
bool LightingModel::isAlbedoEnabled() const {
|
||||
return (bool)_parametersBuffer.get<Parameters>().enableAlbedo;
|
||||
}
|
||||
|
||||
void LightingModel::setAmbientLight(bool enable) {
|
||||
if (enable != isAmbientLightEnabled()) {
|
||||
|
@ -129,6 +137,7 @@ void MakeLightingModel::configure(const Config& config) {
|
|||
_lightingModel->setScattering(config.enableScattering);
|
||||
_lightingModel->setDiffuse(config.enableDiffuse);
|
||||
_lightingModel->setSpecular(config.enableSpecular);
|
||||
_lightingModel->setAlbedo(config.enableAlbedo);
|
||||
_lightingModel->setAmbientLight(config.enableAmbientLight);
|
||||
_lightingModel->setDirectionalLight(config.enableDirectionalLight);
|
||||
_lightingModel->setPointLight(config.enablePointLight);
|
||||
|
|
|
@ -37,12 +37,14 @@ public:
|
|||
|
||||
void setScattering(bool enable);
|
||||
bool isScatteringEnabled() const;
|
||||
|
||||
void setDiffuse(bool enable);
|
||||
bool isDiffuseEnabled() const;
|
||||
void setSpecular(bool enable);
|
||||
bool isSpecularEnabled() const;
|
||||
|
||||
void setAlbedo(bool enable);
|
||||
bool isAlbedoEnabled() const;
|
||||
|
||||
void setAmbientLight(bool enable);
|
||||
bool isAmbientLightEnabled() const;
|
||||
void setDirectionalLight(bool enable);
|
||||
|
@ -72,7 +74,7 @@ protected:
|
|||
float enableScattering{ 1.0f };
|
||||
float enableDiffuse{ 1.0f };
|
||||
float enableSpecular{ 1.0f };
|
||||
float spare;
|
||||
float enableAlbedo{ 1.0f };
|
||||
|
||||
float enableAmbientLight{ 1.0f };
|
||||
float enableDirectionalLight{ 1.0f };
|
||||
|
@ -103,6 +105,7 @@ class MakeLightingModelConfig : public render::Job::Config {
|
|||
Q_PROPERTY(bool enableScattering MEMBER enableScattering NOTIFY dirty)
|
||||
Q_PROPERTY(bool enableDiffuse MEMBER enableDiffuse NOTIFY dirty)
|
||||
Q_PROPERTY(bool enableSpecular MEMBER enableSpecular NOTIFY dirty)
|
||||
Q_PROPERTY(bool enableAlbedo MEMBER enableAlbedo NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(bool enableAmbientLight MEMBER enableAmbientLight NOTIFY dirty)
|
||||
Q_PROPERTY(bool enableDirectionalLight MEMBER enableDirectionalLight NOTIFY dirty)
|
||||
|
@ -122,6 +125,7 @@ public:
|
|||
bool enableScattering{ true };
|
||||
bool enableDiffuse{ true };
|
||||
bool enableSpecular{ true };
|
||||
bool enableAlbedo{ true };
|
||||
|
||||
bool enableAmbientLight{ true };
|
||||
bool enableDirectionalLight{ true };
|
||||
|
|
|
@ -12,10 +12,13 @@
|
|||
<@def LIGHTING_MODEL_SLH@>
|
||||
|
||||
<@func declareLightingModel()@>
|
||||
<@endfunc@>
|
||||
|
||||
<@func declareLightingModelMaster()@>
|
||||
|
||||
struct LightingModel {
|
||||
vec4 _UnlitShadedEmissiveLightmap;
|
||||
vec4 _ScatteringDiffuseSpecular;
|
||||
vec4 _ScatteringDiffuseSpecularAlbedo;
|
||||
vec4 _AmbientDirectionalPointSpot;
|
||||
vec4 _ShowContour;
|
||||
};
|
||||
|
@ -38,13 +41,16 @@ float isLightmapEnabled() {
|
|||
}
|
||||
|
||||
float isScatteringEnabled() {
|
||||
return lightingModel._ScatteringDiffuseSpecular.x;
|
||||
return lightingModel._ScatteringDiffuseSpecularAlbedo.x;
|
||||
}
|
||||
float isDiffuseEnabled() {
|
||||
return lightingModel._ScatteringDiffuseSpecular.y;
|
||||
return lightingModel._ScatteringDiffuseSpecularAlbedo.y;
|
||||
}
|
||||
float isSpecularEnabled() {
|
||||
return lightingModel._ScatteringDiffuseSpecular.z;
|
||||
return lightingModel._ScatteringDiffuseSpecularAlbedo.z;
|
||||
}
|
||||
float isAlbedoEnabled() {
|
||||
return lightingModel._ScatteringDiffuseSpecularAlbedo.w;
|
||||
}
|
||||
|
||||
float isAmbientEnabled() {
|
||||
|
@ -65,6 +71,7 @@ float isShowContour() {
|
|||
}
|
||||
|
||||
<@endfunc@>
|
||||
<$declareLightingModelMaster()$>
|
||||
|
||||
<@func declareBeckmannSpecular()@>
|
||||
|
||||
|
@ -149,9 +156,12 @@ vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float m
|
|||
|
||||
void evalFragShading(out vec3 diffuse, out vec3 specular,
|
||||
vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir,
|
||||
float metallic, vec3 fresnel, float roughness) {
|
||||
float metallic, vec3 fresnel, float roughness, vec3 albedo) {
|
||||
vec4 shading = evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, fresnel, roughness);
|
||||
diffuse = vec3(shading.w);
|
||||
if (isAlbedoEnabled() > 0.0) {
|
||||
diffuse *= albedo;
|
||||
}
|
||||
specular = shading.xyz;
|
||||
}
|
||||
|
||||
|
@ -159,11 +169,12 @@ void evalFragShading(out vec3 diffuse, out vec3 specular,
|
|||
<@include SubsurfaceScattering.slh@>
|
||||
<$declareSubsurfaceScatteringBRDF()$>
|
||||
|
||||
|
||||
void evalFragShading(out vec3 diffuse, out vec3 specular,
|
||||
vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir,
|
||||
float metallic, vec3 fresnel, float roughness,
|
||||
float metallic, vec3 fresnel, float roughness, vec3 albedo,
|
||||
float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature) {
|
||||
if (scattering > 0.0) {
|
||||
if (scattering * isScatteringEnabled() > 0.0) {
|
||||
vec3 brdf = evalSkinBRDF(fragLightDir, fragNormal, midNormalCurvature.xyz, lowNormalCurvature.xyz, lowNormalCurvature.w);
|
||||
float NdotL = clamp(dot(fragNormal, fragLightDir), 0.0, 1.0);
|
||||
diffuse = mix(vec3(NdotL), brdf, scattering);
|
||||
|
@ -174,12 +185,14 @@ void evalFragShading(out vec3 diffuse, out vec3 specular,
|
|||
|
||||
diffuse *= specularBrdf.y;
|
||||
specular = vec3(specularBrdf.x);
|
||||
|
||||
} else {
|
||||
vec4 shading = evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, specular, roughness);
|
||||
vec4 shading = evalPBRShading(fragNormal, fragLightDir, fragEyeDir, metallic, fresnel, roughness);
|
||||
diffuse = vec3(shading.w);
|
||||
specular = shading.xyz;
|
||||
}
|
||||
if (isAlbedoEnabled() > 0.0) {
|
||||
diffuse *= albedo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -102,12 +102,18 @@ void ToneMappingEffect::init() {
|
|||
}
|
||||
|
||||
void ToneMappingEffect::setExposure(float exposure) {
|
||||
_parametersBuffer.edit<Parameters>()._exposure = exposure;
|
||||
_parametersBuffer.edit<Parameters>()._twoPowExposure = pow(2.0, exposure);
|
||||
auto& params = _parametersBuffer.get<Parameters>();
|
||||
if (params._exposure != exposure) {
|
||||
_parametersBuffer.edit<Parameters>()._exposure = exposure;
|
||||
_parametersBuffer.edit<Parameters>()._twoPowExposure = pow(2.0, exposure);
|
||||
}
|
||||
}
|
||||
|
||||
void ToneMappingEffect::setToneCurve(ToneCurve curve) {
|
||||
_parametersBuffer.edit<Parameters>()._toneCurve = curve;
|
||||
auto& params = _parametersBuffer.get<Parameters>();
|
||||
if (params._toneCurve != curve) {
|
||||
_parametersBuffer.edit<Parameters>()._toneCurve = curve;
|
||||
}
|
||||
}
|
||||
|
||||
void ToneMappingEffect::render(RenderArgs* args) {
|
||||
|
@ -149,13 +155,8 @@ void ToneMappingEffect::render(RenderArgs* args) {
|
|||
|
||||
|
||||
void ToneMappingDeferred::configure(const Config& config) {
|
||||
if (config.exposure >= 0.0f) {
|
||||
_toneMappingEffect.setExposure(config.exposure);
|
||||
}
|
||||
|
||||
if (config.curve >= 0) {
|
||||
_toneMappingEffect.setToneCurve((ToneMappingEffect::ToneCurve)config.curve);
|
||||
}
|
||||
_toneMappingEffect.setExposure(config.exposure);
|
||||
_toneMappingEffect.setToneCurve((ToneMappingEffect::ToneCurve)config.curve);
|
||||
}
|
||||
|
||||
void ToneMappingDeferred::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
|
||||
|
|
|
@ -71,7 +71,7 @@ class ToneMappingConfig : public render::Job::Config {
|
|||
public:
|
||||
ToneMappingConfig() : render::Job::Config(true) {}
|
||||
|
||||
void setExposure(float newExposure) { exposure = std::max(0.0f, newExposure); emit dirty(); }
|
||||
void setExposure(float newExposure) { exposure = newExposure; emit dirty(); }
|
||||
void setCurve(int newCurve) { curve = std::max((int)ToneMappingEffect::None, std::min((int)ToneMappingEffect::Filmic, newCurve)); emit dirty(); }
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
|
||||
<@include DeferredBufferRead.slh@>
|
||||
<@include DeferredGlobalLight.slh@>
|
||||
|
||||
|
@ -30,17 +32,8 @@ void main(void) {
|
|||
float shadowAttenuation = 1.0;
|
||||
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
// _fragColor = vec4(frag.diffuse, 1.0);
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
/* vec3 color = evalLightmappedColor(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
frag.obscurance,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);*/
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature;
|
||||
|
@ -55,9 +48,9 @@ void main(void) {
|
|||
frag.obscurance,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.albedo,
|
||||
frag.fresnel,
|
||||
frag.metallic,
|
||||
// frag.emissive,
|
||||
frag.roughness,
|
||||
frag.scattering,
|
||||
midNormalCurvature,
|
||||
|
|
|
@ -30,17 +30,8 @@ void main(void) {
|
|||
float shadowAttenuation = evalShadowAttenuation(worldPos);
|
||||
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
// _fragColor = vec4(frag.diffuse, 1.0);
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
/* vec3 color = evalLightmappedColor(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
frag.obscurance,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);*/
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature;
|
||||
|
@ -54,9 +45,9 @@ void main(void) {
|
|||
frag.obscurance,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.albedo,
|
||||
frag.fresnel,
|
||||
frag.metallic,
|
||||
// frag.emissive,
|
||||
frag.roughness,
|
||||
frag.scattering,
|
||||
midNormalCurvature,
|
||||
|
|
|
@ -27,19 +27,9 @@ void main(void) {
|
|||
|
||||
float shadowAttenuation = 1.0;
|
||||
|
||||
// Light mapped or not ?
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
// _fragColor = vec4(frag.diffuse, 1.0);
|
||||
discard;
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
/* vec3 color = evalLightmappedColor(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
frag.obscurance,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);*/
|
||||
discard;
|
||||
} else {
|
||||
vec3 color = evalAmbientGlobalColor(
|
||||
|
@ -48,9 +38,9 @@ void main(void) {
|
|||
frag.obscurance,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.albedo,
|
||||
frag.fresnel,
|
||||
frag.metallic,
|
||||
// frag.emissive,
|
||||
frag.roughness);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
|
|
@ -29,19 +29,9 @@ void main(void) {
|
|||
vec4 worldPos = getViewInverse() * vec4(frag.position.xyz, 1.0);
|
||||
float shadowAttenuation = evalShadowAttenuation(worldPos);
|
||||
|
||||
// Light mapped or not ?
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
// _fragColor = vec4(frag.diffuse, 1.0);
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
/* vec3 color = evalLightmappedColor(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
frag.obscurance,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);*/
|
||||
discard;
|
||||
} else {
|
||||
vec3 color = evalAmbientGlobalColor(
|
||||
|
@ -50,9 +40,9 @@ void main(void) {
|
|||
frag.obscurance,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.albedo,
|
||||
frag.fresnel,
|
||||
frag.metallic,
|
||||
// frag.emissive,
|
||||
frag.roughness);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
|
|
@ -29,17 +29,8 @@ void main(void) {
|
|||
|
||||
// Light mapped or not ?
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
// _fragColor = vec4(frag.diffuse, 1.0);
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
/* vec3 color = evalLightmappedColor(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
frag.obscurance,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);*/
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature;
|
||||
|
@ -53,13 +44,14 @@ void main(void) {
|
|||
frag.obscurance,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.albedo,
|
||||
frag.fresnel,
|
||||
frag.metallic,
|
||||
// frag.emissive,
|
||||
frag.roughness,
|
||||
frag.scattering,
|
||||
midNormalCurvature,
|
||||
lowNormalCurvature);
|
||||
_fragColor = vec4(color, 1.0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,17 +31,8 @@ void main(void) {
|
|||
|
||||
// Light mapped or not ?
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
// _fragColor = vec4(frag.diffuse, 1.0);
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
/* vec3 color = evalLightmappedColor(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
frag.obscurance,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.specularVal.xyz);
|
||||
_fragColor = vec4(color, 1.0);*/
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature;
|
||||
|
@ -55,9 +46,9 @@ void main(void) {
|
|||
frag.obscurance,
|
||||
frag.position.xyz,
|
||||
frag.normal,
|
||||
frag.diffuse,
|
||||
frag.albedo,
|
||||
frag.fresnel,
|
||||
frag.metallic,
|
||||
//frag.emissive,
|
||||
frag.roughness,
|
||||
frag.scattering,
|
||||
midNormalCurvature,
|
||||
|
|
|
@ -50,11 +50,17 @@ void main(void) {
|
|||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
vec3 fresnel = vec3(0.03); // Default Di-electric fresnel value
|
||||
if (metallic <= 0.5) {
|
||||
metallic = 0.0;
|
||||
} else {
|
||||
fresnel = albedo;
|
||||
metallic = 1.0;
|
||||
}
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
|
||||
vec3 fragPosition = _position.xyz;
|
||||
vec3 fragNormal = normalize(_normal);
|
||||
|
||||
|
@ -67,6 +73,7 @@ void main(void) {
|
|||
fragPosition,
|
||||
fragNormal,
|
||||
albedo,
|
||||
fresnel,
|
||||
metallic,
|
||||
emissive,
|
||||
roughness, opacity),
|
||||
|
|
|
@ -75,9 +75,9 @@ void main(void) {
|
|||
}
|
||||
evalLightingPoint(diffuse, specular, light,
|
||||
fragLightVecLen2.xyz, fragEyeDir, frag.normal, frag.roughness,
|
||||
frag.metallic, frag.specular, frag.diffuse, 1.0,
|
||||
frag.scattering * isScatteringEnabled(), midNormalCurvature, lowNormalCurvature);
|
||||
frag.metallic, frag.fresnel, frag.albedo, 1.0,
|
||||
frag.scattering, midNormalCurvature, lowNormalCurvature);
|
||||
|
||||
_fragColor.rgb += diffuse * isDiffuseEnabled() * isPointEnabled();
|
||||
_fragColor.rgb += specular * isSpecularEnabled() * isPointEnabled();
|
||||
_fragColor.rgb += diffuse;
|
||||
_fragColor.rgb += specular;
|
||||
}
|
||||
|
|
|
@ -77,10 +77,10 @@ void main(void) {
|
|||
}
|
||||
evalLightingSpot(diffuse, specular, light,
|
||||
fragLightDirLen.xyzw, cosSpotAngle, fragEyeDir, frag.normal, frag.roughness,
|
||||
frag.metallic, frag.specular, frag.diffuse, 1.0,
|
||||
frag.scattering * isScatteringEnabled(), midNormalCurvature, lowNormalCurvature);
|
||||
frag.metallic, frag.fresnel, frag.albedo, 1.0,
|
||||
frag.scattering, midNormalCurvature, lowNormalCurvature);
|
||||
|
||||
_fragColor.rgb += diffuse * isDiffuseEnabled() * isSpotEnabled();
|
||||
_fragColor.rgb += specular * isSpecularEnabled() * isSpotEnabled();
|
||||
_fragColor.rgb += diffuse;
|
||||
_fragColor.rgb += specular;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('deferredLighting.qml');
|
||||
var window = new OverlayWindow({
|
||||
title: 'Deferred Lighting Pass',
|
||||
title: 'Lighting',
|
||||
source: qml,
|
||||
width: 400, height: 100,
|
||||
width: 400, height: 150,
|
||||
});
|
||||
window.setPosition(250, 800);
|
||||
window.setPosition(250, 800);a
|
||||
window.closed.connect(function() { Script.stop(); });
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ var qml = Script.resolvePath('framebuffer.qml');
|
|||
var window = new OverlayWindow({
|
||||
title: 'Framebuffer Debug',
|
||||
source: qml,
|
||||
width: 400, height: 400,
|
||||
width: 400, height: 50,
|
||||
});
|
||||
window.setPosition(25, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
||||
|
|
|
@ -11,59 +11,91 @@ import QtQuick 2.5
|
|||
import QtQuick.Controls 1.4
|
||||
import "configSlider"
|
||||
|
||||
Row {
|
||||
Column {
|
||||
spacing: 8
|
||||
|
||||
|
||||
Column {
|
||||
spacing: 10
|
||||
Repeater {
|
||||
model: [
|
||||
"Unlit:LightingModel:enableUnlit",
|
||||
"Shaded:LightingModel:enableShaded",
|
||||
"Emissive:LightingModel:enableEmissive",
|
||||
"Lightmap:LightingModel:enableLightmap",
|
||||
]
|
||||
CheckBox {
|
||||
text: modelData.split(":")[0]
|
||||
checked: Render.getConfig(modelData.split(":")[1])
|
||||
onCheckedChanged: { Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] = checked }
|
||||
Row {
|
||||
spacing: 8
|
||||
Column {
|
||||
spacing: 10
|
||||
Repeater {
|
||||
model: [
|
||||
"Unlit:LightingModel:enableUnlit",
|
||||
"Shaded:LightingModel:enableShaded",
|
||||
"Emissive:LightingModel:enableEmissive",
|
||||
"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",
|
||||
"Diffuse:LightingModel:enableDiffuse",
|
||||
"Specular:LightingModel:enableSpecular",
|
||||
"Albedo:LightingModel:enableAlbedo",
|
||||
]
|
||||
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",
|
||||
"Directional:LightingModel:enableDirectionalLight",
|
||||
"Point:LightingModel:enablePointLight",
|
||||
"Spot:LightingModel:enableSpotLight"
|
||||
]
|
||||
CheckBox {
|
||||
text: modelData.split(":")[0]
|
||||
checked: Render.getConfig(modelData.split(":")[1])
|
||||
onCheckedChanged: { Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] = checked }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Column {
|
||||
spacing: 10
|
||||
spacing: 10
|
||||
Repeater {
|
||||
model: [
|
||||
"Scattering:LightingModel:enableScattering",
|
||||
"Diffuse:LightingModel:enableDiffuse",
|
||||
"Specular:LightingModel:enableSpecular",
|
||||
]
|
||||
CheckBox {
|
||||
text: modelData.split(":")[0]
|
||||
checked: Render.getConfig(modelData.split(":")[1])
|
||||
onCheckedChanged: { Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] = checked }
|
||||
model: [ "Tone Mapping exposure:ToneMapping:exposure:5.0:-5.0"
|
||||
]
|
||||
ConfigSlider {
|
||||
label: qsTr(modelData.split(":")[0])
|
||||
integral: false
|
||||
config: Render.getConfig(modelData.split(":")[1])
|
||||
property: modelData.split(":")[2]
|
||||
max: modelData.split(":")[3]
|
||||
min: modelData.split(":")[4]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 10
|
||||
Repeater {
|
||||
model: [
|
||||
"Ambient:LightingModel:enableAmbientLight",
|
||||
"Directional:LightingModel:enableDirectionalLight",
|
||||
"Point:LightingModel:enablePointLight",
|
||||
"Spot:LightingModel:enableSpotLight"
|
||||
]
|
||||
CheckBox {
|
||||
text: modelData.split(":")[0]
|
||||
checked: Render.getConfig(modelData.split(":")[1])
|
||||
onCheckedChanged: { Render.getConfig(modelData.split(":")[1])[modelData.split(":")[2]] = checked }
|
||||
ComboBox {
|
||||
currentIndex: 1
|
||||
model: ListModel {
|
||||
id: cbItems
|
||||
ListElement { text: "RGB"; color: "Yellow" }
|
||||
ListElement { text: "SRGB"; color: "Green" }
|
||||
ListElement { text: "Reinhard"; color: "Yellow" }
|
||||
ListElement { text: "Filmic"; color: "White" }
|
||||
}
|
||||
width: 200
|
||||
onCurrentIndexChanged: { Render.getConfig("ToneMapping")["curve"] = currentIndex }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,51 +23,35 @@ Column {
|
|||
debug.config.mode = mode;
|
||||
}
|
||||
|
||||
function setX(x) {
|
||||
print(x)
|
||||
|
||||
debug.config.size = Vec4({ x: x, y: -1, z: 1, w: 1 });
|
||||
}
|
||||
Slider {
|
||||
minimumValue: -1.0
|
||||
value: debug.config.size.x
|
||||
onValueChanged: {
|
||||
debug.setX( value);
|
||||
}
|
||||
}
|
||||
|
||||
ExclusiveGroup { id: bufferGroup }
|
||||
Repeater {
|
||||
model: [
|
||||
"Off",
|
||||
"Depth",
|
||||
"Albedo",
|
||||
"Normal",
|
||||
"Roughness",
|
||||
"Metallic",
|
||||
"Emissive",
|
||||
"Unlit",
|
||||
"Occlusion",
|
||||
"Lightmap",
|
||||
"Scattering",
|
||||
"Lighting",
|
||||
"Shadow",
|
||||
"Pyramid Depth",
|
||||
"Curvature",
|
||||
"NormalCurvature",
|
||||
"DiffusedCurvature",
|
||||
"DiffusedNormalCurvature",
|
||||
"Debug Scattering",
|
||||
"Ambient Occlusion",
|
||||
"Ambient Occlusion Blurred",
|
||||
"Custom Shader"
|
||||
]
|
||||
RadioButton {
|
||||
text: qsTr(modelData)
|
||||
exclusiveGroup: bufferGroup
|
||||
checked: index == 0
|
||||
onCheckedChanged: if (checked) debug.setDebugMode(index - 1);
|
||||
ComboBox {
|
||||
currentIndex: 0
|
||||
model: ListModel {
|
||||
id: cbItems
|
||||
ListElement { text: "Off"; color: "Yellow" }
|
||||
ListElement { text: "Depth"; color: "Green" }
|
||||
ListElement { text: "Albedo"; color: "Yellow" }
|
||||
ListElement { text: "Normal"; color: "White" }
|
||||
ListElement { text: "Roughness"; color: "White" }
|
||||
ListElement { text: "Metallic"; color: "White" }
|
||||
ListElement { text: "Emissive"; color: "White" }
|
||||
ListElement { text: "Unlit"; color: "White" }
|
||||
ListElement { text: "Occlusion"; color: "White" }
|
||||
ListElement { text: "Lightmap"; color: "White" }
|
||||
ListElement { text: "Scattering"; color: "White" }
|
||||
ListElement { text: "Lighting"; color: "White" }
|
||||
ListElement { text: "Shadow"; color: "White" }
|
||||
ListElement { text: "Linear Depth"; color: "White" }
|
||||
ListElement { text: "Mid Curvature"; color: "White" }
|
||||
ListElement { text: "Mid Normal"; color: "White" }
|
||||
ListElement { text: "Low Curvature"; color: "White" }
|
||||
ListElement { text: "Low Normal"; color: "White" }
|
||||
ListElement { text: "Debug Scattering"; color: "White" }
|
||||
ListElement { text: "Ambient Occlusion"; color: "White" }
|
||||
ListElement { text: "Ambient Occlusion Blurred"; color: "White" }
|
||||
ListElement { text: "Custom"; color: "White" }
|
||||
}
|
||||
width: 200
|
||||
onCurrentIndexChanged: { debug.setDebugMode(currentIndex - 1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -741,6 +741,7 @@ int TextTemplate::evalBlockGeneration(std::ostream& dst, const BlockPointer& blo
|
|||
std::vector< String > paramCache;
|
||||
paramCache.push_back("");
|
||||
String val;
|
||||
bool valIsVar = false;
|
||||
for (int i = 1; i < nbParams; i++) {
|
||||
val = block->command.arguments[i];
|
||||
if ((val[0] == Tag::VAR) && (val[val.length()-1] == Tag::VAR)) {
|
||||
|
@ -748,7 +749,10 @@ int TextTemplate::evalBlockGeneration(std::ostream& dst, const BlockPointer& blo
|
|||
Vars::iterator it = vars.find(val);
|
||||
if (it != vars.end()) {
|
||||
val = (*it).second;
|
||||
} else {
|
||||
val = Tag::NULL_VAR;
|
||||
}
|
||||
valIsVar = true;
|
||||
}
|
||||
|
||||
Vars::iterator it = vars.find(funcBlock->command.arguments[i]);
|
||||
|
@ -759,14 +763,19 @@ int TextTemplate::evalBlockGeneration(std::ostream& dst, const BlockPointer& blo
|
|||
if (val != Tag::NULL_VAR) {
|
||||
vars.insert(Vars::value_type(funcBlock->command.arguments[i], val));
|
||||
}
|
||||
paramCache.push_back("");
|
||||
|
||||
paramCache.push_back(Tag::NULL_VAR);
|
||||
}
|
||||
}
|
||||
|
||||
generateTree(dst, funcBlock, vars);
|
||||
|
||||
for (int i = 1; i < nbParams; i++) {
|
||||
vars[ funcBlock->command.arguments[i] ] = paramCache[i];
|
||||
if (paramCache[i] == Tag::NULL_VAR) {
|
||||
vars.erase(funcBlock->command.arguments[i]);
|
||||
} else {
|
||||
vars[funcBlock->command.arguments[i]] = paramCache[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,4 +240,5 @@ int main (int argc, char** argv) {
|
|||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue