mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 06:55:39 +02:00
Merge pull request #12873 from Zvork/haze
Fix for weird color shifting of teleportation target in Rust domain
This commit is contained in:
commit
11f509e57a
27 changed files with 269 additions and 262 deletions
libraries
graphics/src/graphics
render-utils/src
DeferredGlobalLight.slhForwardGlobalLight.slhHaze.slfHaze.slhMaterialTextures.slhforward_model_normal_map.slfmodel_fade.slfmodel_fade.slvmodel_normal_map.slfmodel_normal_map.slvmodel_normal_map_fade.slfmodel_normal_map_fade.slvmodel_translucent.slfmodel_translucent.slvmodel_translucent_fade.slfmodel_translucent_normal_map.slfmodel_translucent_normal_map.slvmodel_translucent_normal_map_fade.slfmodel_translucent_unlit_fade.slfmodel_unlit_fade.slfskin_model_fade.slvskin_model_fade_dq.slvskin_model_normal_map.slvskin_model_normal_map_dq.slvskin_model_normal_map_fade.slvskin_model_normal_map_fade_dq.slv
|
@ -57,7 +57,7 @@ namespace graphics {
|
|||
// limit range and altitude to no less than 1.0 metres
|
||||
static inline float convertHazeRangeToHazeRangeFactor(const float hazeRange) { return -LOG_P_005 / glm::max(hazeRange, 1.0f); }
|
||||
|
||||
static inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight) { return -LOG_P_005 / glm::max(hazeHeight, 1.0f); }
|
||||
static inline float convertHazeAltitudeToHazeAltitudeFactor(const float hazeHeight) { return -(LOG_P_005 * glm::sign(hazeHeight)) / glm::max(glm::abs(hazeHeight), 1.0f); }
|
||||
|
||||
// Derivation (s is the proportion of sun blend, a is the angle at which the blend is 50%, solve for m = 0.5
|
||||
// s = dot(lookAngle, sunAngle) = cos(a)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
<@include LightAmbient.slh@>
|
||||
<@include LightDirectional.slh@>
|
||||
|
||||
|
||||
<@func fetchGlobalLight()@>
|
||||
// Get light
|
||||
Light light = getKeyLight();
|
||||
|
@ -32,12 +31,13 @@
|
|||
vec3 color = vec3(0.0);
|
||||
<@endfunc@>
|
||||
|
||||
<@func prepareGlobalLight(isScattering)@>
|
||||
<@func prepareGlobalLight(positionES, normalWS)@>
|
||||
// prepareGlobalLight
|
||||
// Transform directions to worldspace
|
||||
vec3 fragNormal = vec3((normal));
|
||||
vec3 fragEyeVector = vec3(invViewMat * vec4(-position, 0.0));
|
||||
vec3 fragEyeDir = normalize(fragEyeVector);
|
||||
vec3 fragNormalWS = vec3(<$normalWS$>);
|
||||
vec3 fragPositionWS = vec3(invViewMat * vec4(<$positionES$>, 1.0));
|
||||
vec3 fragEyeVectorWS = invViewMat[3].xyz - fragPositionWS;
|
||||
vec3 fragEyeDirWS = normalize(fragEyeVectorWS);
|
||||
|
||||
<$fetchGlobalLight()$>
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
|
||||
<@func declareEvalAmbientGlobalColor()@>
|
||||
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness) {
|
||||
<$prepareGlobalLight()$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
color += albedo * getLightColor(light) * obscurance * getLightAmbientIntensity(lightAmbient);
|
||||
return color;
|
||||
}
|
||||
|
@ -67,14 +67,14 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
|||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||
<@endif@> ) {
|
||||
|
||||
<$prepareGlobalLight($supportScattering$)$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@> );
|
||||
|
@ -85,7 +85,7 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
|||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@> );
|
||||
|
@ -114,14 +114,14 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||
<@endif@>
|
||||
) {
|
||||
<$prepareGlobalLight($supportScattering$)$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
|
@ -131,7 +131,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
|
@ -141,7 +141,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
|
||||
// Attenuate the light if haze effect selected
|
||||
if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
|
||||
color = computeHazeColorKeyLightAttenuation(color, lightDirection, position);
|
||||
color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
|
||||
}
|
||||
|
||||
return color;
|
||||
|
@ -180,9 +180,9 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur
|
|||
<$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, vec3 prevLighting) {
|
||||
<$prepareGlobalLight()$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
color = prevLighting;
|
||||
color += emissive * isEmissiveEnabled();
|
||||
|
@ -190,16 +190,15 @@ vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, fl
|
|||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance);
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
|
||||
color += ambientDiffuse;
|
||||
color += ambientSpecular / opacity;
|
||||
|
||||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation);
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
|
||||
color += directionalDiffuse;
|
||||
color += directionalSpecular / opacity;
|
||||
color += (ambientSpecular + directionalSpecular) / opacity;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@ -211,37 +210,37 @@ vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, fl
|
|||
<$declareLightingDirectional()$>
|
||||
|
||||
vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
||||
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
|
||||
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS,
|
||||
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity)
|
||||
{
|
||||
<$prepareGlobalLight()$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
<$prepareGlobalLight(positionES, normalWS)$>
|
||||
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
color += emissive * isEmissiveEnabled();
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance);
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
|
||||
color += ambientDiffuse;
|
||||
color += ambientSpecular / opacity;
|
||||
|
||||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation);
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
|
||||
color += directionalDiffuse;
|
||||
color += directionalSpecular / opacity;
|
||||
color += (ambientSpecular + directionalSpecular) / opacity;
|
||||
|
||||
// Haze
|
||||
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
|
||||
vec4 colorV4 = computeHazeColor(
|
||||
vec4(color, 1.0), // fragment original color
|
||||
position, // fragment position in eye coordinates
|
||||
fragEyeVector, // fragment position in world coordinates
|
||||
invViewMat[3].y, // eye height in world coordinates
|
||||
lightDirection // keylight direction vector
|
||||
positionES, // fragment position in eye coordinates
|
||||
fragPositionWS, // fragment position in world coordinates
|
||||
invViewMat[3].xyz, // eye position in world coordinates
|
||||
lightDirection // keylight direction vector in world coordinates
|
||||
);
|
||||
|
||||
color = colorV4.rgb;
|
||||
|
@ -251,7 +250,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
|||
}
|
||||
|
||||
vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
||||
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position,
|
||||
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 positionWS,
|
||||
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting)
|
||||
{
|
||||
<$fetchGlobalLight()$>
|
||||
|
@ -276,9 +275,9 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
|||
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
|
||||
vec4 colorV4 = computeHazeColor(
|
||||
vec4(color, 1.0), // fragment original color
|
||||
position, // fragment position in eye coordinates
|
||||
surface.eyeDir, // fragment eye vector in world coordinates
|
||||
invViewMat[3].y, // eye height in world coordinates
|
||||
positionES, // fragment position in eye coordinates
|
||||
positionWS, // fragment position in world coordinates
|
||||
invViewMat[3].xyz, // eye position in world coordinates
|
||||
lightDirection // keylight direction vector
|
||||
);
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
<@include LightAmbient.slh@>
|
||||
<@include LightDirectional.slh@>
|
||||
|
||||
|
||||
<@func prepareGlobalLight(isScattering)@>
|
||||
<@func prepareGlobalLight(positionES, normalWS)@>
|
||||
// prepareGlobalLight
|
||||
// Transform directions to worldspace
|
||||
vec3 fragNormal = vec3((normal));
|
||||
vec3 fragEyeVector = vec3(invViewMat * vec4(-1.0*position, 0.0));
|
||||
vec3 fragEyeDir = normalize(fragEyeVector);
|
||||
vec3 fragNormalWS = vec3(<$normalWS$>);
|
||||
vec3 fragPositionWS = vec3(invViewMat * vec4(<$positionES$>, 1.0));
|
||||
vec3 fragEyeVectorWS = invViewMat[3].xyz - fragPositionWS;
|
||||
vec3 fragEyeDirWS = normalize(fragEyeVectorWS);
|
||||
|
||||
// Get light
|
||||
Light light = getKeyLight();
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
<@func declareEvalAmbientGlobalColor()@>
|
||||
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness) {
|
||||
<$prepareGlobalLight()$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
color += albedo * getLightColor(light) * obscurance * getLightAmbientIntensity(lightAmbient);
|
||||
return color;
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
|||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||
<@endif@> ) {
|
||||
|
||||
<$prepareGlobalLight($supportScattering$)$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@> );
|
||||
|
@ -81,7 +81,7 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
|
|||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@> );
|
||||
|
@ -109,14 +109,14 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
|
||||
<@endif@>
|
||||
) {
|
||||
<$prepareGlobalLight($supportScattering$)$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
|
@ -126,7 +126,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
|
||||
<@if supportScattering@>
|
||||
,scattering, midNormalCurvature, lowNormalCurvature
|
||||
<@endif@>
|
||||
|
@ -137,7 +137,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
// FIXME - temporarily removed until we support it for forward...
|
||||
// Attenuate the light if haze effect selected
|
||||
// if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
|
||||
// color = computeHazeColorKeyLightAttenuation(color, lightDirection, position);
|
||||
// color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
|
||||
// }
|
||||
|
||||
return color;
|
||||
|
@ -180,25 +180,24 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur
|
|||
<$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()$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
color += emissive * isEmissiveEnabled();
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance);
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
|
||||
color += ambientDiffuse;
|
||||
color += ambientSpecular / opacity;
|
||||
|
||||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation);
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
|
||||
color += directionalDiffuse;
|
||||
color += directionalSpecular / opacity;
|
||||
color += (ambientSpecular + directionalSpecular) / opacity;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@ -207,34 +206,33 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
|
|||
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
|
||||
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity)
|
||||
{
|
||||
<$prepareGlobalLight()$>
|
||||
<$prepareGlobalLight(position, normal)$>
|
||||
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
|
||||
|
||||
color += emissive * isEmissiveEnabled();
|
||||
|
||||
// Ambient
|
||||
vec3 ambientDiffuse;
|
||||
vec3 ambientSpecular;
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surface, metallic, fresnel, albedo, obscurance);
|
||||
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
|
||||
color += ambientDiffuse;
|
||||
color += ambientSpecular / opacity;
|
||||
|
||||
// Directional
|
||||
vec3 directionalDiffuse;
|
||||
vec3 directionalSpecular;
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surface, metallic, fresnel, albedo, shadowAttenuation);
|
||||
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
|
||||
color += directionalDiffuse;
|
||||
color += directionalSpecular / opacity;
|
||||
color += (ambientSpecular + directionalSpecular) / opacity;
|
||||
|
||||
// Haze
|
||||
// FIXME - temporarily removed until we support it for forward...
|
||||
/* if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
|
||||
vec4 colorV4 = computeHazeColor(
|
||||
vec4(color, 1.0), // fragment original color
|
||||
position, // fragment position in eye coordinates
|
||||
fragEyeVector, // fragment position in world coordinates
|
||||
invViewMat[3].y, // eye height in world coordinates
|
||||
positionES, // fragment position in eye coordinates
|
||||
fragPositionWS, // fragment position in world coordinates
|
||||
invViewMat[3].xyz, // eye position in world coordinates
|
||||
lightDirection // keylight direction vector
|
||||
);
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ void main(void) {
|
|||
}
|
||||
|
||||
vec4 fragColor = texture(colorMap, varTexCoord0);
|
||||
vec4 eyeFragPos = unpackPositionFromZeye(varTexCoord0);
|
||||
vec4 fragPositionES = unpackPositionFromZeye(varTexCoord0);
|
||||
|
||||
mat4 viewInverse = getViewInverse();
|
||||
vec4 worldFragPos = viewInverse * eyeFragPos;
|
||||
vec4 worldEyePos = viewInverse[3];
|
||||
vec4 fragPositionWS = viewInverse * fragPositionES;
|
||||
vec4 eyePositionWS = viewInverse[3];
|
||||
|
||||
Light light = getKeyLight();
|
||||
vec3 lightDirection = getLightDirection(light);
|
||||
vec3 lightDirectionWS = getLightDirection(light);
|
||||
|
||||
outFragColor = computeHazeColor(fragColor, eyeFragPos.xyz, worldFragPos.xyz, worldEyePos.y, lightDirection);
|
||||
outFragColor = computeHazeColor(fragColor, fragPositionES.xyz, fragPositionWS.xyz, eyePositionWS.xyz, lightDirectionWS);
|
||||
}
|
||||
|
|
|
@ -43,16 +43,16 @@ layout(std140) uniform hazeBuffer {
|
|||
|
||||
// Input:
|
||||
// color - fragment original color
|
||||
// lightDirection - parameters of the keylight
|
||||
// worldFragPos - fragment position in world coordinates
|
||||
// lightDirectionWS - parameters of the keylight
|
||||
// fragPositionWS - fragment position in world coordinates
|
||||
// Output:
|
||||
// fragment colour after haze effect
|
||||
//
|
||||
// General algorithm taken from http://www.iquilezles.org/www/articles/fog/fog.htm, with permission
|
||||
//
|
||||
vec3 computeHazeColorKeyLightAttenuation(vec3 color, vec3 lightDirection, vec3 worldFragPos) {
|
||||
vec3 computeHazeColorKeyLightAttenuation(vec3 color, vec3 lightDirectionWS, vec3 fragPositionWS) {
|
||||
// Directional light attenuation is simulated by assuming the light source is at a fixed height above the
|
||||
// fragment. This height is where the haze density is reduced by 95% from the haze at the fragment's height
|
||||
// fragment. This height is where the haze density is reduced by 95% from the haze at the fragment's height
|
||||
//
|
||||
// The distance is computed from the height and the directional light orientation
|
||||
// The distance is limited to height * 1,000, which gives an angle of ~0.057 degrees
|
||||
|
@ -65,7 +65,7 @@ vec3 computeHazeColorKeyLightAttenuation(vec3 color, vec3 lightDirection, vec3 w
|
|||
}
|
||||
|
||||
// Note that we need the sine to be positive
|
||||
float sin_pitch = abs(lightDirection.y);
|
||||
float sin_pitch = abs(lightDirectionWS.y);
|
||||
|
||||
float distance;
|
||||
const float minimumSinPitch = 0.001;
|
||||
|
@ -79,7 +79,7 @@ vec3 computeHazeColorKeyLightAttenuation(vec3 color, vec3 lightDirection, vec3 w
|
|||
// Note that the haze base reference affects only the haze density as function of altitude
|
||||
float hazeDensityDistribution =
|
||||
hazeParams.hazeKeyLightRangeFactor *
|
||||
exp(-hazeParams.hazeKeyLightAltitudeFactor * (worldFragPos.y - hazeParams.hazeBaseReference));
|
||||
exp(-hazeParams.hazeKeyLightAltitudeFactor * (fragPositionWS.y - hazeParams.hazeBaseReference));
|
||||
|
||||
float hazeIntegral = hazeDensityDistribution * distance;
|
||||
|
||||
|
@ -92,33 +92,34 @@ vec3 computeHazeColorKeyLightAttenuation(vec3 color, vec3 lightDirection, vec3 w
|
|||
}
|
||||
|
||||
// Input:
|
||||
// fragColor - fragment original color
|
||||
// eyeFragPos - fragment position in eye coordinates
|
||||
// worldFragPos - fragment position in world coordinates
|
||||
// worldEyeHeight - eye height in world coordinates
|
||||
// fragColor - fragment original color
|
||||
// fragPositionES - fragment position in eye coordinates
|
||||
// fragPositionWS - fragment position in world coordinates
|
||||
// eyePositionWS - eye position in world coordinates
|
||||
// Output:
|
||||
// fragment colour after haze effect
|
||||
//
|
||||
// General algorithm taken from http://www.iquilezles.org/www/articles/fog/fog.htm, with permission
|
||||
//
|
||||
vec4 computeHazeColor(vec4 fragColor, vec3 eyeFragPos, vec3 worldFragPos, float worldEyeHeight, vec3 lightDirection) {
|
||||
vec4 computeHazeColor(vec4 fragColor, vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePositionWS, vec3 lightDirectionWS) {
|
||||
// Distance to fragment
|
||||
float distance = length(eyeFragPos);
|
||||
float distance = length(fragPositionES);
|
||||
float eyeWorldHeight = eyePositionWS.y;
|
||||
|
||||
// Convert haze colour from uniform into a vec4
|
||||
vec4 hazeColor = vec4(hazeParams.hazeColor, 1.0);
|
||||
|
||||
// Directional light component is a function of the angle from the eye, between the fragment and the sun
|
||||
vec3 eyeFragDir = normalize(worldFragPos);
|
||||
|
||||
float glareComponent = max(0.0, dot(eyeFragDir, -lightDirection));
|
||||
float power = min(1.0, pow(glareComponent, hazeParams.hazeGlareBlend));
|
||||
|
||||
vec4 glareColor = vec4(hazeParams.hazeGlareColor, 1.0);
|
||||
|
||||
// Use the haze colour for the glare colour, if blend is not enabled
|
||||
vec4 blendedHazeColor;
|
||||
if ((hazeParams.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) {
|
||||
// Directional light component is a function of the angle from the eye, between the fragment and the sun
|
||||
vec3 fragToEyeDirWS = normalize(fragPositionWS - eyePositionWS);
|
||||
|
||||
float glareComponent = max(0.0, dot(fragToEyeDirWS, -lightDirectionWS));
|
||||
float power = min(1.0, pow(glareComponent, hazeParams.hazeGlareBlend));
|
||||
|
||||
vec4 glareColor = vec4(hazeParams.hazeGlareColor, 1.0);
|
||||
|
||||
blendedHazeColor = mix(hazeColor, glareColor, power);
|
||||
} else {
|
||||
blendedHazeColor = hazeColor;
|
||||
|
@ -134,12 +135,12 @@ vec4 computeHazeColor(vec4 fragColor, vec3 eyeFragPos, vec3 worldFragPos, float
|
|||
// Note that the haze base reference affects only the haze density as function of altitude
|
||||
vec3 hazeDensityDistribution =
|
||||
hazeParams.colorModulationFactor *
|
||||
exp(-hazeParams.hazeHeightFactor * (worldEyeHeight - hazeParams.hazeBaseReference));
|
||||
exp(-hazeParams.hazeHeightFactor * (eyeWorldHeight - hazeParams.hazeBaseReference));
|
||||
|
||||
vec3 hazeIntegral = hazeDensityDistribution * distance;
|
||||
vec3 hazeIntegral = hazeDensityDistribution * distance;
|
||||
|
||||
const float slopeThreshold = 0.01;
|
||||
float deltaHeight = worldFragPos.y - worldEyeHeight;
|
||||
float deltaHeight = fragPositionWS.y - eyeWorldHeight;
|
||||
if (abs(deltaHeight) > slopeThreshold) {
|
||||
float t = hazeParams.hazeHeightFactor * deltaHeight;
|
||||
hazeIntegral *= (1.0 - exp (-t)) / t;
|
||||
|
@ -162,12 +163,12 @@ vec4 computeHazeColor(vec4 fragColor, vec3 eyeFragPos, vec3 worldFragPos, float
|
|||
// Note that the haze base reference affects only the haze density as function of altitude
|
||||
float hazeDensityDistribution =
|
||||
hazeParams.hazeRangeFactor *
|
||||
exp(-hazeParams.hazeHeightFactor * (worldEyeHeight - hazeParams.hazeBaseReference));
|
||||
exp(-hazeParams.hazeHeightFactor * (eyeWorldHeight - hazeParams.hazeBaseReference));
|
||||
|
||||
float hazeIntegral = hazeDensityDistribution * distance;
|
||||
|
||||
const float slopeThreshold = 0.01;
|
||||
float deltaHeight = worldFragPos.y - worldEyeHeight;
|
||||
float deltaHeight = fragPositionWS.y - eyeWorldHeight;
|
||||
if (abs(deltaHeight) > slopeThreshold) {
|
||||
float t = hazeParams.hazeHeightFactor * deltaHeight;
|
||||
// Protect from wild values
|
||||
|
|
|
@ -228,14 +228,14 @@ vec3 fetchLightmapMap(vec2 uv) {
|
|||
}
|
||||
<@endfunc@>
|
||||
|
||||
<@func evalMaterialNormalLOD(fragPos, fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
|
||||
<@func evalMaterialNormalLOD(fragPosES, fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
|
||||
{
|
||||
vec3 normalizedNormal = normalize(<$interpolatedNormal$>.xyz);
|
||||
vec3 normalizedTangent = normalize(<$interpolatedTangent$>.xyz);
|
||||
vec3 normalizedBitangent = cross(normalizedNormal, normalizedTangent);
|
||||
// attenuate the normal map divergence from the mesh normal based on distance
|
||||
// The attenuation range [20,100] meters from the eye is arbitrary for now
|
||||
vec3 localNormal = mix(<$fetchedNormal$>, vec3(0.0, 1.0, 0.0), smoothstep(20.0, 100.0, (-<$fragPos$>).z));
|
||||
vec3 localNormal = mix(<$fetchedNormal$>, vec3(0.0, 1.0, 0.0), smoothstep(20.0, 100.0, (-<$fragPosES$>).z));
|
||||
<$normal$> = vec3(normalizedBitangent * localNormal.x + normalizedNormal * localNormal.y + normalizedTangent * localNormal.z);
|
||||
}
|
||||
<@endfunc@>
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec4 _positionES;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _tangentWS;
|
||||
in vec3 _color;
|
||||
|
||||
layout(location = 0) out vec4 _fragColor0;
|
||||
|
@ -56,9 +56,9 @@ void main(void) {
|
|||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
vec3 fresnel = getFresnelF0(metallic, albedo);
|
||||
|
||||
vec3 fragPosition = _position.xyz;
|
||||
vec3 fragPosition = _positionES.xyz;
|
||||
vec3 fragNormal;
|
||||
<$evalMaterialNormal(normalTex, _normal, _tangent, fragNormal)$>
|
||||
<$evalMaterialNormal(normalTex, _normalWS, _tangentWS, fragNormal)$>
|
||||
|
||||
TransformCamera cam = getTransformCamera();
|
||||
|
||||
|
|
|
@ -22,19 +22,19 @@
|
|||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec4 _positionES;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _color;
|
||||
in vec4 _worldPosition;
|
||||
in vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
|
@ -61,7 +61,7 @@ void main(void) {
|
|||
float scattering = getMaterialScattering(mat);
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(_normal),
|
||||
normalize(_normalWS),
|
||||
opacity,
|
||||
albedo,
|
||||
roughness,
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
out float _alpha;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec4 _position;
|
||||
out vec4 _worldPosition;
|
||||
out vec3 _normal;
|
||||
out vec4 _positionES;
|
||||
out vec4 _positionWS;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
|
@ -38,7 +38,7 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _worldPosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec4 _positionES;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _tangentWS;
|
||||
in vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
|
@ -46,8 +46,8 @@ void main(void) {
|
|||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 fragNormal;
|
||||
<$evalMaterialNormalLOD(_position, normalTex, _normal, _tangent, fragNormal)$>
|
||||
vec3 fragNormalWS;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
@ -56,7 +56,7 @@ void main(void) {
|
|||
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(fragNormal.xyz),
|
||||
normalize(fragNormalWS.xyz),
|
||||
opacity,
|
||||
albedo,
|
||||
roughness,
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _positionES;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _tangentWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
|
||||
|
@ -40,7 +40,7 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangent)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangentWS)$>
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_specular_map_fade.frag
|
||||
// model_normal_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
|
@ -22,20 +22,20 @@
|
|||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec4 _positionES;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _tangentWS;
|
||||
in vec3 _color;
|
||||
in vec4 _worldPosition;
|
||||
in vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
|
@ -56,8 +56,8 @@ void main(void) {
|
|||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 fragNormal;
|
||||
<$evalMaterialNormalLOD(_position, normalTex, _normal, _tangent, fragNormal)$>
|
||||
vec3 fragNormalWS;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
@ -65,12 +65,12 @@ void main(void) {
|
|||
float scattering = getMaterialScattering(mat);
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(fragNormal.xyz),
|
||||
normalize(fragNormalWS.xyz),
|
||||
opacity,
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
emissive+fadeEmissive,
|
||||
emissive + fadeEmissive,
|
||||
occlusionTex,
|
||||
scattering);
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _worldPosition;
|
||||
out vec4 _positionES;
|
||||
out vec4 _positionWS;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _tangentWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
|
||||
|
@ -41,8 +41,8 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _worldPosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangent)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangentWS)$>
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec4 _position;
|
||||
in vec4 _worldPosition;
|
||||
in vec3 _normal;
|
||||
in vec4 _positionES;
|
||||
in vec4 _positionWS;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _color;
|
||||
in float _alpha;
|
||||
|
||||
|
@ -58,33 +58,35 @@ void main(void) {
|
|||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 fragPosition = _position.xyz;
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
vec3 fragNormal = normalize(_normal);
|
||||
vec3 fragNormalWS = normalize(_normalWS);
|
||||
|
||||
TransformCamera cam = getTransformCamera();
|
||||
vec3 fragEyeVector = vec3(cam._viewInverse * vec4(-fragPosition, 0.0));
|
||||
vec3 fragEyeDir = normalize(fragEyeVector);
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
|
||||
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_worldPosition)$>;
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, _worldPosition.xyz, surface,
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
metallic, fresnel, albedo, 0.0,
|
||||
vec4(0), vec4(0), opacity);
|
||||
}
|
||||
|
||||
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
||||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
fragPosition,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
fresnel,
|
||||
metallic,
|
||||
emissive,
|
||||
surface, opacity, localLighting.rgb),
|
||||
surfaceWS, opacity, localLighting.rgb),
|
||||
opacity);
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
out float _alpha;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec4 _position;
|
||||
out vec4 _worldPosition;
|
||||
out vec3 _normal;
|
||||
out vec4 _positionES;
|
||||
out vec4 _positionWS;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
|
@ -38,7 +38,7 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _worldPosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec4 _position;
|
||||
in vec3 _normal;
|
||||
in vec4 _positionES;
|
||||
in vec4 _positionWS;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _color;
|
||||
in float _alpha;
|
||||
in vec4 _worldPosition;
|
||||
|
||||
out vec4 _fragColor;
|
||||
|
||||
|
@ -37,7 +37,7 @@ void main(void) {
|
|||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
|
@ -60,20 +60,21 @@ void main(void) {
|
|||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 fragPosition = _position.xyz;
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
vec3 fragNormal = normalize(_normal);
|
||||
vec3 fragNormalWS = normalize(_normalWS);
|
||||
|
||||
TransformCamera cam = getTransformCamera();
|
||||
vec3 fragEyeVector = vec3(cam._viewInverse * vec4(-fragPosition, 0.0));
|
||||
vec3 fragEyeDir = normalize(fragEyeVector);
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
|
||||
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_worldPosition)$>;
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, _worldPosition.xyz, surface,
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
metallic, fresnel, albedo, 0.0,
|
||||
vec4(0), vec4(0), opacity);
|
||||
}
|
||||
|
@ -82,11 +83,12 @@ void main(void) {
|
|||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
fragPosition,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
fresnel,
|
||||
metallic,
|
||||
emissive+fadeEmissive,
|
||||
surface, opacity, localLighting.rgb),
|
||||
emissive + fadeEmissive,
|
||||
surfaceWS, opacity, localLighting.rgb),
|
||||
opacity);
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec4 _position;
|
||||
in vec4 _worldPosition;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec4 _positionES;
|
||||
in vec4 _positionWS;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _tangentWS;
|
||||
in vec3 _color;
|
||||
in float _alpha;
|
||||
|
||||
|
@ -59,20 +59,22 @@ void main(void) {
|
|||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 fragPosition = _position.xyz;
|
||||
vec3 fragNormal;
|
||||
<$evalMaterialNormalLOD(_position, normalTex, _normal, _tangent, fragNormal)$>
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
vec3 fragNormalWS;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
||||
|
||||
TransformCamera cam = getTransformCamera();
|
||||
vec3 fragEyeVector = vec3(cam._viewInverse * vec4(-fragPosition, 0.0));
|
||||
vec3 fragEyeDir = normalize(fragEyeVector);
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
|
||||
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_worldPosition)$>;
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, _worldPosition.xyz, surface,
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
metallic, fresnel, albedo, 0.0,
|
||||
vec4(0), vec4(0), opacity);
|
||||
}
|
||||
|
@ -81,11 +83,12 @@ void main(void) {
|
|||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
fragPosition,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
fresnel,
|
||||
metallic,
|
||||
emissive,
|
||||
surface, opacity, localLighting.rgb),
|
||||
surfaceWS, opacity, localLighting.rgb),
|
||||
opacity);
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
out float _alpha;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec4 _position;
|
||||
out vec4 _worldPosition;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec4 _positionES;
|
||||
out vec4 _positionWS;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _tangentWS;
|
||||
out vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
|
@ -39,8 +39,8 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _worldPosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangent)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, inPosition, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangentWS)$>
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec4 _position;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec4 _positionES;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _tangentWS;
|
||||
in vec3 _color;
|
||||
in float _alpha;
|
||||
in vec4 _worldPosition;
|
||||
in vec4 _positionWS;
|
||||
|
||||
out vec4 _fragColor;
|
||||
|
||||
|
@ -45,7 +45,7 @@ void main(void) {
|
|||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
|
@ -68,21 +68,22 @@ void main(void) {
|
|||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 fragPosition = _position.xyz;
|
||||
vec3 fragPositionES = _positionES.xyz;
|
||||
vec3 fragPositionWS = _positionWS.xyz;
|
||||
// Lighting is done in world space
|
||||
vec3 fragNormal;
|
||||
<$evalMaterialNormalLOD(_position, normalTex, _normal, _tangent, fragNormal)$>
|
||||
vec3 fragNormalWS;
|
||||
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
||||
|
||||
TransformCamera cam = getTransformCamera();
|
||||
vec3 fragEyeVector = vec3(cam._viewInverse * vec4(-fragPosition, 0.0));
|
||||
vec3 fragEyeDir = normalize(fragEyeVector);
|
||||
SurfaceData surface = initSurfaceData(roughness, fragNormal, fragEyeDir);
|
||||
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
|
||||
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
|
||||
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
||||
|
||||
vec4 localLighting = vec4(0.0);
|
||||
|
||||
<$fetchClusterInfo(_worldPosition)$>;
|
||||
<$fetchClusterInfo(_positionWS)$>;
|
||||
if (hasLocalLights(numLights, clusterPos, dims)) {
|
||||
localLighting = evalLocalLighting(cluster, numLights, _worldPosition.xyz, surface,
|
||||
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
||||
metallic, fresnel, albedo, 0.0,
|
||||
vec4(0), vec4(0), opacity);
|
||||
}
|
||||
|
@ -91,11 +92,12 @@ void main(void) {
|
|||
cam._viewInverse,
|
||||
1.0,
|
||||
occlusionTex,
|
||||
fragPosition,
|
||||
fragPositionES,
|
||||
fragPositionWS,
|
||||
albedo,
|
||||
fresnel,
|
||||
metallic,
|
||||
emissive+fadeEmissive,
|
||||
surface, opacity, localLighting.rgb),
|
||||
emissive + fadeEmissive,
|
||||
surfaceWS, opacity, localLighting.rgb),
|
||||
opacity);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
in vec2 _texCoord0;
|
||||
in vec3 _color;
|
||||
in float _alpha;
|
||||
in vec4 _worldPosition;
|
||||
in vec4 _positionWS;
|
||||
|
||||
out vec4 _fragColor;
|
||||
|
||||
|
@ -33,7 +33,7 @@ void main(void) {
|
|||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
|
|
|
@ -23,17 +23,17 @@
|
|||
<$declareMaterialTextures(ALBEDO)$>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
in vec3 _normal;
|
||||
in vec3 _normalWS;
|
||||
in vec3 _color;
|
||||
in float _alpha;
|
||||
in vec4 _worldPosition;
|
||||
in vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec3 fadeEmissive;
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFade(fadeParams, _worldPosition.xyz, fadeEmissive);
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
Material mat = getMaterial();
|
||||
BITFIELD matKey = getMaterialKey(mat);
|
||||
|
@ -48,7 +48,7 @@ void main(void) {
|
|||
albedo *= _color;
|
||||
albedo += fadeEmissive;
|
||||
packDeferredFragmentUnlit(
|
||||
normalize(_normal),
|
||||
normalize(_normalWS),
|
||||
opacity,
|
||||
albedo * isUnlitEnabled());
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _positionES;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
out vec4 _worldPosition;
|
||||
out vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -48,7 +48,7 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _worldPosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, _normal.xyz)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, _normalWS.xyz)$>
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _positionES;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
out vec4 _worldPosition;
|
||||
out vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -48,7 +48,7 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _worldPosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, _normal.xyz)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, _normalWS.xyz)$>
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _positionES;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _tangentWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
|
||||
|
@ -52,10 +52,10 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
|
||||
|
||||
_normal = interpolatedNormal.xyz;
|
||||
_tangent = interpolatedTangent.xyz;
|
||||
_normalWS = interpolatedNormal.xyz;
|
||||
_tangentWS = interpolatedTangent.xyz;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _positionES;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _tangentWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
|
||||
|
@ -52,10 +52,10 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
|
||||
|
||||
_normal = interpolatedNormal.xyz;
|
||||
_tangent = interpolatedTangent.xyz;
|
||||
_normalWS = interpolatedNormal.xyz;
|
||||
_tangentWS = interpolatedTangent.xyz;
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _positionES;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _tangentWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
out vec4 _worldPosition;
|
||||
out vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -53,11 +53,11 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _worldPosition)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
|
||||
|
||||
_normal = interpolatedNormal.xyz;
|
||||
_tangent = interpolatedTangent.xyz;
|
||||
_normalWS = interpolatedNormal.xyz;
|
||||
_tangentWS = interpolatedTangent.xyz;
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec4 _positionES;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _normalWS;
|
||||
out vec3 _tangentWS;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
out vec4 _worldPosition;
|
||||
out vec4 _positionWS;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
@ -53,11 +53,11 @@ void main(void) {
|
|||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _worldPosition)$>
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _positionES, gl_Position)$>
|
||||
<$transformModelToWorldPos(obj, position, _positionWS)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
|
||||
|
||||
_normal = interpolatedNormal.xyz;
|
||||
_tangent = interpolatedTangent.xyz;
|
||||
_normalWS = interpolatedNormal.xyz;
|
||||
_tangentWS = interpolatedTangent.xyz;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue