mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 15:07:29 +02:00
wip adding haze to forward rendering
This commit is contained in:
parent
41e8a08484
commit
68b2c8c2fb
9 changed files with 19 additions and 93 deletions
|
@ -1,5 +1,5 @@
|
|||
<!
|
||||
// DeferredGlobalLight.slh
|
||||
// GlobalLight.slh
|
||||
// libraries/render-utils/src
|
||||
//
|
||||
// Created by Sam Gateau on 2/5/15.
|
||||
|
@ -98,9 +98,7 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa
|
|||
|
||||
<@endfunc@>
|
||||
|
||||
<@if not HIFI_USE_FORWARD@>
|
||||
<@include Haze.slh@>
|
||||
<@endif@>
|
||||
|
||||
<@func declareEvalSkyboxGlobalColor(supportScattering)@>
|
||||
|
||||
|
@ -142,12 +140,10 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
color += directionalDiffuse;
|
||||
color += directionalSpecular;
|
||||
|
||||
<@if not HIFI_USE_FORWARD@>
|
||||
// Attenuate the light if haze effect selected
|
||||
if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
|
||||
color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@ -184,61 +180,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, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) {
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
color += emissive * isEmissiveEnabled();
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
|
||||
color += ambientDiffuse;
|
||||
|
||||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
|
||||
color += directionalDiffuse;
|
||||
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity, vec3 prevLighting) {
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
color = prevLighting;
|
||||
color += emissive * isEmissiveEnabled();
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
|
||||
color += ambientDiffuse;
|
||||
|
||||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
|
||||
color += directionalDiffuse;
|
||||
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
||||
<@func declareEvalGlobalLightingAlphaBlendedWithHaze()@>
|
||||
|
||||
<$declareLightingAmbient(1, 1, 1)$>
|
||||
<$declareLightingDirectional()$>
|
||||
|
||||
vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
||||
vec3 evalGlobalLightingAlphaBlended(
|
||||
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS,
|
||||
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity)
|
||||
{
|
||||
|
@ -261,7 +203,6 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
|||
color += directionalDiffuse;
|
||||
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
|
||||
|
||||
<@if not HIFI_USE_FORWARD@>
|
||||
// Haze
|
||||
if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
|
||||
vec4 hazeColor = computeHazeColor(
|
||||
|
@ -273,12 +214,11 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
|||
|
||||
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
||||
vec3 evalGlobalLightingAlphaBlended(
|
||||
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 positionWS,
|
||||
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting)
|
||||
{
|
||||
|
@ -300,7 +240,6 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
|||
color += ambientDiffuse + directionalDiffuse;
|
||||
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
|
||||
|
||||
<@if not HIFI_USE_FORWARD@>
|
||||
// Haze
|
||||
if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
|
||||
vec4 hazeColor = computeHazeColor(
|
||||
|
@ -312,7 +251,6 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
|||
|
||||
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -11,15 +11,10 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
|
||||
<@include DeferredBufferRead.slh@>
|
||||
<@include GlobalLight.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
|
||||
<@include GlobalLight.slh@>
|
||||
<$declareEvalAmbientSphereGlobalColor(supportScattering)$>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
|
|
|
@ -11,15 +11,14 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include Shadow.slh@>
|
||||
<@include DeferredBufferRead.slh@>
|
||||
<@include GlobalLight.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<@include GlobalLight.slh@>
|
||||
<$declareEvalAmbientSphereGlobalColor(isScattering)$>
|
||||
|
||||
<@include Shadow.slh@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
|
|
|
@ -11,12 +11,10 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include DeferredBufferRead.slh@>
|
||||
<@include GlobalLight.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<@include GlobalLight.slh@>
|
||||
<$declareEvalSkyboxGlobalColor(isScattering)$>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
|
|
|
@ -11,15 +11,14 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//!>
|
||||
|
||||
<@include Shadow.slh@>
|
||||
<@include DeferredBufferRead.slh@>
|
||||
<@include GlobalLight.slh@>
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
||||
<$declareEvalLightmappedColor()$>
|
||||
<@include GlobalLight.slh@>
|
||||
<$declareEvalSkyboxGlobalColor(isScattering)$>
|
||||
|
||||
<@include Shadow.slh@>
|
||||
|
||||
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
||||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
|
@ -35,7 +34,6 @@ void main(void) {
|
|||
vec3 worldLightDirection = getLightDirection(shadowLight);
|
||||
float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal);
|
||||
|
||||
// Light mapped or not ?
|
||||
if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
discard;
|
||||
} else {
|
||||
|
|
|
@ -23,10 +23,8 @@
|
|||
<@elif HIFI_USE_TRANSLUCENT@>
|
||||
<@if not HIFI_USE_FORWARD@>
|
||||
<@include LightLocal.slh@>
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
<@else@>
|
||||
<$declareEvalGlobalLightingAlphaBlended()$>
|
||||
<@endif@>
|
||||
<$declareEvalGlobalLightingAlphaBlended()$>
|
||||
<@else@>
|
||||
<$declareEvalSkyboxGlobalColor()$>
|
||||
<@endif@>
|
||||
|
@ -298,7 +296,7 @@ void main(void) {
|
|||
vec4(0), vec4(0), opacity);
|
||||
}
|
||||
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlended(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusion,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<@if HIFI_USE_FORWARD@>
|
||||
<$declareEvalSkyboxGlobalColor()$>
|
||||
<@else@>
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
<$declareEvalGlobalLightingAlphaBlended()$>
|
||||
<@endif@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
@ -78,7 +78,7 @@ void main() {
|
|||
DEFAULT_ROUGHNESS),
|
||||
alpha);
|
||||
<@else@>
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlended(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
DEFAULT_OCCLUSION,
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<$declareEvalSkyboxGlobalColor()$>
|
||||
<@elif HIFI_USE_TRANSLUCENT@>
|
||||
<@include GlobalLight.slh@>
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
<$declareEvalGlobalLightingAlphaBlended()$>
|
||||
<@else@>
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
<@endif@>
|
||||
|
@ -101,7 +101,7 @@ void main(void) {
|
|||
DEFAULT_ROUGHNESS),
|
||||
texel.a);
|
||||
<@elif HIFI_USE_TRANSLUCENT@>
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlended(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
DEFAULT_OCCLUSION,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<@include DefaultMaterials.slh@>
|
||||
|
||||
<@include GlobalLight.slh@>
|
||||
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
||||
<$declareEvalGlobalLightingAlphaBlended()$>
|
||||
|
||||
layout(location=0) out vec4 _fragColor0;
|
||||
<@endif@>
|
||||
|
@ -167,7 +167,7 @@ void main(void) {
|
|||
if (emissiveAmount > 0.0) {
|
||||
_fragColor0 = vec4(diffuse, alpha);
|
||||
} else {
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
_fragColor0 = vec4(evalGlobalLightingAlphaBlended(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusion,
|
||||
|
|
Loading…
Reference in a new issue