mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 06:51:15 +02:00
Ajusting the pure Ambient SH lighting pass and more review issues
This commit is contained in:
parent
7120b64a33
commit
9fb318570b
6 changed files with 32 additions and 15 deletions
|
@ -882,7 +882,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
propertyName = "P";
|
||||
index = 4;
|
||||
}
|
||||
if (properties && !material.isPBSMaterial) {
|
||||
if (!material.isPBSMaterial && properties) {
|
||||
foreach (const FBXNode& property, subobject.children) {
|
||||
if (property.name == propertyName) {
|
||||
if (property.properties.at(0) == "DiffuseColor") {
|
||||
|
@ -917,7 +917,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
#endif
|
||||
}
|
||||
}
|
||||
} else if (properties && material.isPBSMaterial) {
|
||||
} else if (material.isPBSMaterial && properties) {
|
||||
std::vector<std::string> unknowns;
|
||||
foreach(const FBXNode& property, subobject.children) {
|
||||
if (property.name == propertyName) {
|
||||
|
@ -1095,7 +1095,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
|||
} else if (type.contains("emissive")) {
|
||||
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("tex_emissive_map")) {
|
||||
roughnessTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("ambient")) {
|
||||
ambientTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||
} else if (type.contains("tex_ao_map")) {
|
||||
|
|
|
@ -45,6 +45,12 @@ vec4 evalSkyboxLight(vec3 direction, float lod) {
|
|||
color += emissive;
|
||||
<@endfunc@>
|
||||
|
||||
<@func declareAmbientFresnel()@>
|
||||
vec3 fresnelSchlickAmbient(vec3 fresnelColor, vec3 lightDir, vec3 halfDir, float gloss) {
|
||||
return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * pow(1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5);
|
||||
}
|
||||
<@endfunc@>
|
||||
|
||||
<@func declareEvalAmbientGlobalColor()@>
|
||||
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness) {
|
||||
<$prepareGlobalLight()$>
|
||||
|
@ -54,24 +60,35 @@ vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obsc
|
|||
<@endfunc@>
|
||||
|
||||
<@func declareEvalAmbientSphereGlobalColor()@>
|
||||
<$declareAmbientFresnel()$>
|
||||
|
||||
vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness) {
|
||||
<$prepareGlobalLight()$>
|
||||
color += (1 - (metallic * 0.5)) * albedo * evalSphericalLight(getLightAmbientSphere(light), fragNormal).xyz * obscurance * getLightAmbientIntensity(light);
|
||||
|
||||
// Diffuse from ambient
|
||||
color += (1 - metallic) * albedo * evalSphericalLight(getLightAmbientSphere(light), fragNormal).xyz * obscurance * getLightAmbientIntensity(light);
|
||||
|
||||
// Specular highlight from ambient
|
||||
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
||||
vec3 skyboxLight = evalSphericalLight(getLightAmbientSphere(light), direction).xyz;
|
||||
vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1 - roughness);
|
||||
color += ambientFresnel * skyboxLight.rgb * obscurance * getLightAmbientIntensity(light);
|
||||
|
||||
return color;
|
||||
}
|
||||
<@endfunc@>
|
||||
|
||||
<@func declareEvalSkyboxGlobalColor()@>
|
||||
<$declareSkyboxMap()$>
|
||||
|
||||
vec3 fresnelSchlickAmbient(vec3 fresnelColor, vec3 lightDir, vec3 halfDir, float gloss) {
|
||||
return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * pow(1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5);
|
||||
}
|
||||
<$declareAmbientFresnel()$>
|
||||
|
||||
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, float metallic, vec3 emissive, float roughness) {
|
||||
<$prepareGlobalLight()$>
|
||||
|
||||
// Diffuse from ambient
|
||||
color += (1 - metallic) * albedo * evalSphericalLight(getLightAmbientSphere(light), fragNormal).xyz * obscurance * getLightAmbientIntensity(light);
|
||||
|
||||
|
||||
// Specular highlight from ambient
|
||||
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
||||
float levels = getLightAmbientMapNumMips(light);
|
||||
float lod = min(floor((roughness) * levels), levels);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<@func declareEvalPBRShading()@>
|
||||
|
||||
vec3 fresnelSchlick(vec3 fresnelColor, vec3 lightDir, vec3 halfDir) {
|
||||
return fresnelColor + (1.0f - fresnelColor) * pow(1.0f - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5);
|
||||
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) {
|
||||
|
|
|
@ -35,9 +35,9 @@ vec3 fetchNormalMap(vec2 uv) {
|
|||
<@endif@>
|
||||
|
||||
<@if withMetallic@>
|
||||
uniform sampler2D specularMap;
|
||||
uniform sampler2D metallicMap;
|
||||
float fetchMetallicMap(vec2 uv) {
|
||||
return (texture(specularMap, uv).r);
|
||||
return (texture(metallicMap, uv).r);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
|
|||
slotBindings.insert(gpu::Shader::Binding(std::string("albedoMap"), Slot::ALBEDO_MAP));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("roughnessMap"), Slot::ROUGHNESS_MAP));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slot::NORMAL_MAP));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), Slot::METALLIC_MAP));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("metallicMap"), Slot::METALLIC_MAP));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slot::EMISSIVE_LIGHTMAP_MAP));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("occlusionMap"), Slot::OCCLUSION_MAP));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), Slot::LIGHT_BUFFER));
|
||||
|
@ -71,7 +71,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
|
|||
locations->albedoTextureUnit = program->getTextures().findLocation("albedoMap");
|
||||
locations->roughnessTextureUnit = program->getTextures().findLocation("roughnessMap");
|
||||
locations->normalTextureUnit = program->getTextures().findLocation("normalMap");
|
||||
locations->specularTextureUnit = program->getTextures().findLocation("specularMap");
|
||||
locations->metallicTextureUnit = program->getTextures().findLocation("metallicMap");
|
||||
locations->emissiveTextureUnit = program->getTextures().findLocation("emissiveMap");
|
||||
locations->occlusionTextureUnit = program->getTextures().findLocation("occlusionMap");
|
||||
locations->skinClusterBufferUnit = program->getBuffers().findLocation("skinClusterBuffer");
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
int albedoTextureUnit;
|
||||
int normalTextureUnit;
|
||||
int roughnessTextureUnit;
|
||||
int specularTextureUnit;
|
||||
int metallicTextureUnit;
|
||||
int emissiveTextureUnit;
|
||||
int occlusionTextureUnit;
|
||||
int emissiveParams;
|
||||
|
|
Loading…
Reference in a new issue