mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:07:07 +02:00
Trying to fix the forwaard rendering
This commit is contained in:
parent
fd007e845d
commit
caacd3e5cf
7 changed files with 28 additions and 77 deletions
|
@ -11,17 +11,8 @@
|
||||||
<@if not FORWARD_BUFFER_WRITE_SLH@>
|
<@if not FORWARD_BUFFER_WRITE_SLH@>
|
||||||
<@def FORWARD_BUFFER_WRITE_SLH@>
|
<@def FORWARD_BUFFER_WRITE_SLH@>
|
||||||
|
|
||||||
<@include ForwardBuffer.slh@>
|
|
||||||
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 _fragColor0;
|
layout(location = 0) out vec4 _fragColor0;
|
||||||
|
|
||||||
// the alpha threshold
|
|
||||||
const float alphaThreshold = 0.5;
|
|
||||||
float evalOpaqueFinalAlpha(float alpha, float mapAlpha) {
|
|
||||||
return mix(alpha, 1.0 - alpha, step(mapAlpha, alphaThreshold));
|
|
||||||
}
|
|
||||||
|
|
||||||
const float DEFAULT_ROUGHNESS = 0.9;
|
const float DEFAULT_ROUGHNESS = 0.9;
|
||||||
const float DEFAULT_SHININESS = 10.0;
|
const float DEFAULT_SHININESS = 10.0;
|
||||||
const float DEFAULT_METALLIC = 0.0;
|
const float DEFAULT_METALLIC = 0.0;
|
||||||
|
@ -31,33 +22,4 @@ const float DEFAULT_OCCLUSION = 1.0;
|
||||||
const float DEFAULT_SCATTERING = 0.0;
|
const float DEFAULT_SCATTERING = 0.0;
|
||||||
const vec3 DEFAULT_FRESNEL = DEFAULT_EMISSIVE;
|
const vec3 DEFAULT_FRESNEL = DEFAULT_EMISSIVE;
|
||||||
|
|
||||||
void packForwardFragment(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 emissive, float occlusion, float scattering) {
|
|
||||||
if (alpha != 1.0) {
|
|
||||||
discard;
|
|
||||||
}
|
|
||||||
_fragColor0 = vec4(albedo, ((scattering > 0.0) ? packScatteringMetallic(metallic) : packShadedMetallic(metallic)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void packForwardFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float roughness, float metallic, vec3 fresnel, vec3 lightmap) {
|
|
||||||
if (alpha != 1.0) {
|
|
||||||
discard;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fragColor0 = vec4(albedo, packLightmappedMetallic(metallic));
|
|
||||||
}
|
|
||||||
|
|
||||||
void packForwardFragmentUnlit(vec3 normal, float alpha, vec3 color) {
|
|
||||||
if (alpha != 1.0) {
|
|
||||||
discard;
|
|
||||||
}
|
|
||||||
_fragColor0 = vec4(color, packUnlit());
|
|
||||||
}
|
|
||||||
|
|
||||||
void packForwardFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, vec3 fresnel, float roughness) {
|
|
||||||
if (alpha <= 0.0) {
|
|
||||||
discard;
|
|
||||||
}
|
|
||||||
_fragColor0 = vec4(albedo.rgb, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
|
@ -135,11 +135,12 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
||||||
color += directionalSpecular;
|
color += directionalSpecular;
|
||||||
|
|
||||||
// Attenuate the light if haze effect selected
|
// Attenuate the light if haze effect selected
|
||||||
if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
|
// if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
|
||||||
color = computeHazeColorKeyLightAttenuation(color, lightDirection, position);
|
// color = computeHazeColorKeyLightAttenuation(color, lightDirection, position);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return color;
|
return normal;
|
||||||
|
// return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
|
@ -155,6 +155,7 @@ vec3 fetchLightmapMap(vec2 uv) {
|
||||||
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
|
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
|
||||||
vec3 localNormal = <$fetchedNormal$>;
|
vec3 localNormal = <$fetchedNormal$>;
|
||||||
<$normal$> = vec3(normalizedTangent * localNormal.x + normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z);
|
<$normal$> = vec3(normalizedTangent * localNormal.x + normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z);
|
||||||
|
<$normal$> = normalizedNormal;
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,8 @@ void main(void) {
|
||||||
|
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
vec3 fragNormal;
|
vec3 fragNormal;
|
||||||
<$transformEyeToWorldDir(cam, _normal, fragNormal)$>
|
fragNormal = normalize(_normal);
|
||||||
fragNormal = normalize(fragNormal);
|
|
||||||
|
|
||||||
vec4 color = vec4(evalSkyboxGlobalColor(
|
vec4 color = vec4(evalSkyboxGlobalColor(
|
||||||
cam._viewInverse,
|
cam._viewInverse,
|
||||||
1.0,
|
1.0,
|
||||||
|
|
|
@ -63,8 +63,8 @@ void main(void) {
|
||||||
vec3 emissive = getMaterialEmissive(mat);
|
vec3 emissive = getMaterialEmissive(mat);
|
||||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||||
|
|
||||||
vec3 viewNormal;
|
vec3 fragNormal;
|
||||||
<$tangentToViewSpace(normalTex, _normal, _tangent, viewNormal)$>
|
<$tangentToViewSpace(normalTex, _normal, _tangent, fragNormal)$>
|
||||||
|
|
||||||
float scattering = getMaterialScattering(mat);
|
float scattering = getMaterialScattering(mat);
|
||||||
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
||||||
|
@ -78,7 +78,7 @@ void main(void) {
|
||||||
1.0,
|
1.0,
|
||||||
1.0,
|
1.0,
|
||||||
fragPosition,
|
fragPosition,
|
||||||
viewNormal,
|
fragNormal,
|
||||||
albedo,
|
albedo,
|
||||||
fresnel,
|
fresnel,
|
||||||
metallic,
|
metallic,
|
||||||
|
|
|
@ -63,36 +63,24 @@ void main(void) {
|
||||||
else {
|
else {
|
||||||
fresnel = albedo;
|
fresnel = albedo;
|
||||||
metallic = 1.0;
|
metallic = 1.0;
|
||||||
}/*
|
}
|
||||||
float scattering = getMaterialScattering(mat);
|
|
||||||
|
|
||||||
packForwardFragment(
|
|
||||||
normalize(_normal),
|
|
||||||
opacity,
|
|
||||||
albedo,
|
|
||||||
roughness,
|
|
||||||
metallic,
|
|
||||||
emissive,
|
|
||||||
occlusionTex,
|
|
||||||
scattering);
|
|
||||||
*/
|
|
||||||
vec3 fragPosition = _position.xyz;
|
vec3 fragPosition = _position.xyz;
|
||||||
|
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
vec3 fragNormal;
|
vec3 fragNormal;
|
||||||
<$transformEyeToWorldDir(cam, _normal, fragNormal)$>
|
fragNormal = normalize(_normal);
|
||||||
|
|
||||||
vec4 color = vec4(evalSkyboxGlobalColor(
|
vec4 color = vec4(evalSkyboxGlobalColor(
|
||||||
cam._viewInverse,
|
cam._viewInverse,
|
||||||
1.0,
|
1.0,
|
||||||
1.0,
|
1.0,
|
||||||
fragPosition,
|
fragPosition,
|
||||||
fragNormal,
|
fragNormal,
|
||||||
albedo,
|
albedo,
|
||||||
fresnel,
|
fresnel,
|
||||||
metallic,
|
metallic,
|
||||||
roughness),
|
roughness),
|
||||||
opacity);
|
opacity);
|
||||||
color.rgb += emissive * isEmissiveEnabled();
|
color.rgb += emissive * isEmissiveEnabled();
|
||||||
|
|
||||||
// _fragColor = vec4(albedo, opacity);
|
// _fragColor = vec4(albedo, opacity);
|
||||||
|
|
|
@ -38,8 +38,8 @@ void main(void) {
|
||||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
albedo *= _color;
|
albedo *= _color;
|
||||||
|
|
||||||
packForwardFragmentUnlit(
|
if (opacity != 1.0) {
|
||||||
normalize(_normal),
|
discard;
|
||||||
opacity,
|
}
|
||||||
albedo * isUnlitEnabled());
|
_fragColor0 = vec4(albedo * isUnlitEnabled(), 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue