mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 05:33:55 +02:00
Update LightClusterGrid_shared.slh
This commit is contained in:
parent
dc9405775f
commit
e534e09801
12 changed files with 35 additions and 33 deletions
|
@ -121,7 +121,7 @@ vec4 unpackDeferredPosition(float depthValue, vec2 texcoord) {
|
|||
float check2 = check * float(texcoord.x > 0.5);
|
||||
texcoord.x -= check2 * 0.5;
|
||||
int side = int(check2);
|
||||
texcoord.x *= mix(1.0, 2.0, check);
|
||||
texcoord.x *= 1.0 + check;
|
||||
|
||||
return vec4(evalEyePositionFromZdb(side, depthValue, texcoord), 1.0);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ vec4 unpackDeferredPositionFromZeye(vec2 texcoord) {
|
|||
float check2 = check * float(texcoord.x > 0.5);
|
||||
texcoord.x -= check2 * 0.5;
|
||||
int side = int(check2);
|
||||
texcoord.x *= mix(1.0, 2.0, check);
|
||||
texcoord.x *= 1.0 + check;
|
||||
|
||||
return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ vec4 unpackPositionFromZeye(vec2 texcoord) {
|
|||
float check2 = check * float(texcoord.x > 0.5);
|
||||
texcoord.x -= check2 * 0.5;
|
||||
int side = int(check2);
|
||||
texcoord.x *= mix(1.0, 2.0, check);
|
||||
texcoord.x *= 1.0 + check;
|
||||
|
||||
return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ int clusterGrid_getClusterLightId(int index, int offset) {
|
|||
return element;
|
||||
*/
|
||||
int element = _clusterGridContent[GRID_FETCH_BUFFER((elementIndex >> 1))];
|
||||
return int(mix(element, element >> 16, int((elementIndex & 0x00000001) == 1))) & 0x0000FFFF;
|
||||
return (element >> (16 * int((elementIndex & 0x00000001) == 1))) & 0x0000FFFF;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,11 +7,9 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
# define _MIN glm::min
|
||||
# define _MIX(x, y, a) glm::mix((float)x, (float)y, (float)a)
|
||||
# define _ABS(x) (int)fabsf()
|
||||
# define _ABS(x) (int)fabsf(x)
|
||||
#else
|
||||
# define _MIN min
|
||||
# define _MIX mix
|
||||
# define _ABS abs
|
||||
#endif
|
||||
|
||||
|
@ -151,7 +149,7 @@ ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) {
|
|||
|
||||
int frustumGrid_eyeToClusterDirH(vec3 eyeDir) {
|
||||
if (eyeDir.z >= 0.0f) {
|
||||
return int(_MIX(-1, frustumGrid.dims.x, int(eyeDir.x > 0.0f)));
|
||||
return int(eyeDir.x > 0.0f) * (frustumGrid.dims.x + 1) - 1;
|
||||
}
|
||||
|
||||
float eyeDepth = -eyeDir.z;
|
||||
|
@ -165,7 +163,7 @@ int frustumGrid_eyeToClusterDirH(vec3 eyeDir) {
|
|||
|
||||
int frustumGrid_eyeToClusterDirV(vec3 eyeDir) {
|
||||
if (eyeDir.z >= 0.0f) {
|
||||
return int(_MIX(-1, frustumGrid.dims.y, int(eyeDir.y > 0.0f)));
|
||||
return int(eyeDir.y > 0.0f) * (frustumGrid.dims.y + 1) - 1;
|
||||
}
|
||||
|
||||
float eyeDepth = -eyeDir.z;
|
||||
|
@ -193,4 +191,4 @@ vec4 frustumGrid_worldToEye(vec4 worldPos) {
|
|||
|
||||
// <@if 1@>
|
||||
// Trigger Scribe include
|
||||
// <@endif@> <!def that !> End C++ compatible
|
||||
// <@endif@> <!def that !> End C++ compatible
|
||||
|
|
|
@ -40,10 +40,12 @@ void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
|
|||
diffuse *= lightEnergy * isDiffuseEnabled();
|
||||
specular *= lightEnergy * isSpecularEnabled();
|
||||
|
||||
// Show edges
|
||||
float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0);
|
||||
float edgeCoord = exp2(-8.0 * edge * edge);
|
||||
diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(isShowLightContour() > 0.0 && edge < 1.0));
|
||||
if (isShowLightContour() > 0.0) {
|
||||
// Show edges
|
||||
float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0);
|
||||
float edgeCoord = exp2(-8.0 * edge * edge);
|
||||
diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
|
|
@ -41,13 +41,15 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
|||
diffuse *= lightEnergy * isDiffuseEnabled();
|
||||
specular *= lightEnergy * isSpecularEnabled();
|
||||
|
||||
// Show edges
|
||||
float edgeDistR = (lightVolume_getRadius(light.volume) - fragLightDistance);
|
||||
float edgeDistS = dot(fragLightDistance * vec2(cosSpotAngle, sqrt(1.0 - cosSpotAngle * cosSpotAngle)), -lightVolume_getSpotOutsideNormal2(light.volume));
|
||||
float edgeDist = min(edgeDistR, edgeDistS);
|
||||
float edge = abs(2.0 * (edgeDist * 10.0) - 1.0);
|
||||
float edgeCoord = exp2(-8.0 * edge * edge);
|
||||
diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(isShowLightContour() > 0.0 && edge < 1.0));
|
||||
if (isShowLightContour() > 0.0) {
|
||||
// Show edges
|
||||
float edgeDistR = (lightVolume_getRadius(light.volume) - fragLightDistance);
|
||||
float edgeDistS = dot(fragLightDistance * vec2(cosSpotAngle, sqrt(1.0 - cosSpotAngle * cosSpotAngle)), -lightVolume_getSpotOutsideNormal2(light.volume));
|
||||
float edgeDist = min(edgeDistR, edgeDistS);
|
||||
float edge = abs(2.0 * (edgeDist * 10.0) - 1.0);
|
||||
float edgeCoord = exp2(-8.0 * edge * edge);
|
||||
diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
|
|
@ -53,9 +53,8 @@ void main(void) {
|
|||
|
||||
// Add or subtract the orthogonal vector based on a different vertex ID
|
||||
// calculation
|
||||
float check = float(gl_VertexID < 2);
|
||||
distanceFromCenter = mix(1.0, -1.0, check);
|
||||
eye.xyz += mix(orthogonal, -orthogonal, check);
|
||||
distanceFromCenter = mix(1.0, -1.0, float(gl_VertexID < 2));
|
||||
eye.xyz += distanceFromCenter * orthogonal;
|
||||
|
||||
// Finally, put the eyespace vertex into clip space
|
||||
<$transformEyeToClipPos(cam, eye, gl_Position)$>
|
||||
|
|
|
@ -69,5 +69,5 @@ void main(void) {
|
|||
TransformCamera cam = getTransformCamera();
|
||||
<$transformWorldToClipPos(cam, worldPos, gl_Position)$>
|
||||
|
||||
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), mix(0.1, 0.9, float(numLights > 0)));
|
||||
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), 0.1 + 0.8 * float(numLights > 0));
|
||||
}
|
|
@ -93,7 +93,8 @@ void main(void) {
|
|||
{
|
||||
bool check = dot(fragToTap,fragToTap) < keepTapRadius;
|
||||
keep = keep || check;
|
||||
keepedMip = int(mix(keepedMip, evalMipFromRadius(tap.z * float(doFetchMips())), int(check)));
|
||||
int checki = int(check);
|
||||
keepedMip = checki * evalMipFromRadius(tap.z * float(doFetchMips())) + (1 - checki) * keepedMip;
|
||||
}
|
||||
|
||||
vec3 tapUVZ = fetchTap(side, ssC, tap, imageSize);
|
||||
|
|
|
@ -89,7 +89,7 @@ void main(void) {
|
|||
vec2 texcoordPos;
|
||||
ivec4 stereoSide;
|
||||
ivec2 framePixelPos = getPixelPosTexcoordPosAndSide(gl_FragCoord.xy, pixelPos, texcoordPos, stereoSide);
|
||||
vec2 stereoSideClip = vec2(stereoSide.x, mix(1.0, 0.5, float(isStereo())));
|
||||
vec2 stereoSideClip = vec2(stereoSide.x, 1.0 - 0.5 * float(isStereo()));
|
||||
|
||||
// Texcoord to fetch in the deferred texture are the exact UVs comming from vertex shader
|
||||
// sideToFrameTexcoord(stereoSideClip, texcoordPos);
|
||||
|
@ -124,7 +124,7 @@ void main(void) {
|
|||
|
||||
// Calculate dF/du and dF/dv
|
||||
vec2 viewportScale = perspectiveScale * getInvWidthHeight();
|
||||
vec2 du = vec2(viewportScale.x * mix(1.0, 0.5, float(float(stereoSide.w) > 0.0)), 0.0);
|
||||
vec2 du = vec2(viewportScale.x * (1.0 - 0.5 * float(stereoSide.w > 0)), 0.0);
|
||||
vec2 dv = vec2( 0.0f, viewportScale.y);
|
||||
|
||||
vec4 dFdu = vec4(getWorldNormalDiff(frameTexcoordPos, du), getEyeDepthDiff(frameTexcoordPos, du));
|
||||
|
|
|
@ -125,13 +125,13 @@ float taa_fetchDepth(vec2 uv) {
|
|||
|
||||
vec2 taa_getImageSize() {
|
||||
vec2 imageSize = getWidthHeight(0);
|
||||
imageSize.x *= mix(1.0, 2.0, float(isStereo()));
|
||||
imageSize.x *= 1.0 + float(isStereo());
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
vec2 taa_getTexelSize() {
|
||||
vec2 texelSize = getInvWidthHeight();
|
||||
texelSize.x *= mix(1.0, 0.5, float(isStereo()));
|
||||
texelSize.x *= 1.0 - 0.5 * float(isStereo());
|
||||
return texelSize;
|
||||
}
|
||||
|
||||
|
@ -216,14 +216,14 @@ vec2 taa_fromFragUVToEyeUVAndSide(vec2 fragUV, out int stereoSide) {
|
|||
float check2 = float(eyeUV.x > 0.5);
|
||||
eyeUV.x -= check * check2 * 0.5;
|
||||
stereoSide = int(check * check2);
|
||||
eyeUV.x *= mix(1.0, 2.0, check);
|
||||
eyeUV.x *= 1.0 + check;
|
||||
return eyeUV;
|
||||
}
|
||||
|
||||
vec2 taa_fromEyeUVToFragUV(vec2 eyeUV, int stereoSide) {
|
||||
vec2 fragUV = eyeUV;
|
||||
float check = float(isStereo());
|
||||
fragUV.x *= mix(1.0, 0.5, check);
|
||||
fragUV.x *= 1.0 - 0.5 * check;
|
||||
fragUV.x += check * float(stereoSide) * 0.5;
|
||||
return fragUV;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@ void main(void) {
|
|||
float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5);
|
||||
|
||||
outFragColor = mix(vec4(mix(vec3(1.0), varColor.xyz, var), varColor.a),
|
||||
vec4(mix(vec3(0.0), varColor.xyz, var), mix(0.0, 1.0, var)),
|
||||
vec4(mix(vec3(0.0), varColor.xyz, var), var),
|
||||
float(varColor.a == 0.0));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue