mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 16:42:08 +02:00
add haze to skybox
This commit is contained in:
parent
d545ba5bc6
commit
9539664749
3 changed files with 26 additions and 3 deletions
|
@ -319,6 +319,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
|
|||
unset(SHADER_FILE)
|
||||
unset(SHADER_FILE CACHE)
|
||||
find_file(SHADER_FILE "${VERTEX_NAME}.slv" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..")
|
||||
message("boop ${SHADER_FILE} ${VERTEX_NAME} ${PROGRAM_FOLDER}")
|
||||
AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS})
|
||||
string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "${SHADER_LIST}")
|
||||
else()
|
||||
|
@ -337,6 +338,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
|
|||
unset(SHADER_FILE)
|
||||
unset(SHADER_FILE CACHE)
|
||||
find_file(SHADER_FILE "${FRAGMENT_NAME}.slf" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..")
|
||||
message("boop2 ${SHADER_FILE} ${FRAGMENT_NAME} ${PROGRAM_FOLDER}")
|
||||
AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS})
|
||||
string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "${SHADER_LIST}")
|
||||
else()
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
<@include graphics/ShaderConstants.h@>
|
||||
|
||||
<@if HIFI_USE_FORWARD@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardCameraTransform()$>
|
||||
|
||||
<@include graphics/Light.slh@>
|
||||
<$declareLightBuffer()$>
|
||||
|
||||
<@include graphics/Haze.slh@>
|
||||
<@endif@>
|
||||
|
||||
|
@ -35,13 +41,28 @@ void main(void) {
|
|||
// mix(skyboxColor, skyboxTexel, skybox.color.a)
|
||||
// and the blend factor should be user controlled
|
||||
|
||||
vec3 skyboxTexel = texture(cubeMap, normalize(_normal)).rgb;
|
||||
vec3 normal = normalize(_normal);
|
||||
vec3 skyboxTexel = texture(cubeMap, normal).rgb;
|
||||
vec3 skyboxColor = skybox.color.rgb;
|
||||
_fragColor = vec4(mix(vec3(1.0), skyboxTexel, float(skybox.color.a > 0.0)) *
|
||||
mix(vec3(1.0), skyboxColor, float(skybox.color.a < 1.0)), 1.0);
|
||||
|
||||
<@if HIFI_USE_FORWARD@>
|
||||
_fragColor = vec4(hazeParams.hazeColor, 1);
|
||||
// FIXME: either move this elsewhere or give it access to isHazeEnabled() (which is in render-utils/LightingModel.slh)
|
||||
if (/*(isHazeEnabled() > 0.0) && */(hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
|
||||
TransformCamera cam = getTransformCamera();
|
||||
vec4 eyePositionWS = cam._viewInverse[3];
|
||||
// We choose an arbitrary large number > BLEND_DISTANCE in Haze.slh
|
||||
const float SKYBOX_DISTANCE = 32000.0;
|
||||
vec4 fragPositionWS = eyePositionWS + SKYBOX_DISTANCE * vec4(normal, 0.0);
|
||||
vec4 fragPositionES = cam._view * fragPositionWS;
|
||||
|
||||
Light light = getKeyLight();
|
||||
vec3 lightDirectionWS = getLightDirection(light);
|
||||
|
||||
vec4 hazeColor = computeHazeColor(fragPositionES.xyz, fragPositionWS.xyz, eyePositionWS.xyz, lightDirectionWS);
|
||||
_fragColor.rgb = mix(_fragColor.rgb, hazeColor.rgb, hazeColor.a);
|
||||
}
|
||||
<@endif@>
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
<$declareDeferredFrameTransform()$>
|
||||
|
||||
<@include graphics/Light.slh@>
|
||||
<$declareLightBuffer()$>
|
||||
|
||||
<@include LightingModel.slh@>
|
||||
<$declareLightBuffer()$>
|
||||
|
||||
<@include graphics/Haze.slh@>
|
||||
|
||||
|
|
Loading…
Reference in a new issue