Merge pull request #14293 from SamGondelman/branching

Case 19473: Reduce branching in our shaders
This commit is contained in:
Adam Smith 2018-12-05 16:42:42 -08:00 committed by GitHub
commit 653974ca30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 366 additions and 516 deletions

View file

@ -14,8 +14,6 @@ void main(void) {
ivec2 texCoord = ivec2(floor(varTexCoord0 * vec2(textureData.textureSize))); ivec2 texCoord = ivec2(floor(varTexCoord0 * vec2(textureData.textureSize)));
texCoord.x /= 2; texCoord.x /= 2;
int row = int(floor(gl_FragCoord.y)); int row = int(floor(gl_FragCoord.y));
if (row % 2 > 0) { texCoord.x += int(row % 2 > 0) * (textureData.textureSize.x / 2);
texCoord.x += (textureData.textureSize.x / 2);
}
outFragColor = vec4(pow(texelFetch(colorMap, texCoord, 0).rgb, vec3(2.2)), 1.0); outFragColor = vec4(pow(texelFetch(colorMap, texCoord, 0).rgb, vec3(2.2)), 1.0);
} }

View file

@ -9,7 +9,7 @@ layout(location=0) out vec4 outFragColor;
float sRGBFloatToLinear(float value) { float sRGBFloatToLinear(float value) {
const float SRGB_ELBOW = 0.04045; const float SRGB_ELBOW = 0.04045;
return (value <= SRGB_ELBOW) ? value / 12.92 : pow((value + 0.055) / 1.055, 2.4); return mix(pow((value + 0.055) / 1.055, 2.4), value / 12.92, float(value <= SRGB_ELBOW));
} }
vec3 colorToLinearRGB(vec3 srgb) { vec3 colorToLinearRGB(vec3 srgb) {

View file

@ -80,10 +80,11 @@ float interpolate3Points(float y1, float y2, float y3, float u) {
halfSlope = (y3 - y1) / 2.0f; halfSlope = (y3 - y1) / 2.0f;
float slope12 = y2 - y1; float slope12 = y2 - y1;
float slope23 = y3 - y2; float slope23 = y3 - y2;
if (abs(halfSlope) > abs(slope12)) {
halfSlope = slope12; {
} else if (abs(halfSlope) > abs(slope23)) { float check = float(abs(halfSlope) > abs(slope12));
halfSlope = slope23; halfSlope = mix(halfSlope, slope12, check);
halfSlope = mix(halfSlope, slope23, (1.0 - check) * float(abs(halfSlope) > abs(slope23)));
} }
} }

View file

@ -231,7 +231,8 @@ float snoise(vec2 v) {
// Other corners // Other corners
vec2 i1; vec2 i1;
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); float check = float(x0.x > x0.y);
i1 = vec2(check, 1.0 - check);
vec4 x12 = x0.xyxy + C.xxzz; vec4 x12 = x0.xyxy + C.xxzz;
x12.xy -= i1; x12.xy -= i1;

View file

@ -152,28 +152,28 @@ float fetchScatteringMap(vec2 uv) {
<@func fetchMaterialTexturesCoord0(matKey, texcoord0, albedo, roughness, normal, metallic, emissive, scattering)@> <@func fetchMaterialTexturesCoord0(matKey, texcoord0, albedo, roughness, normal, metallic, emissive, scattering)@>
<@if albedo@> <@if albedo@>
vec4 <$albedo$> = (((<$matKey$> & (ALBEDO_MAP_BIT | OPACITY_MASK_MAP_BIT | OPACITY_TRANSLUCENT_MAP_BIT)) != 0) ? fetchAlbedoMap(<$texcoord0$>) : vec4(1.0)); vec4 <$albedo$> = mix(vec4(1.0), fetchAlbedoMap(<$texcoord0$>), float((<$matKey$> & (ALBEDO_MAP_BIT | OPACITY_MASK_MAP_BIT | OPACITY_TRANSLUCENT_MAP_BIT)) != 0));
<@endif@> <@endif@>
<@if roughness@> <@if roughness@>
float <$roughness$> = (((<$matKey$> & ROUGHNESS_MAP_BIT) != 0) ? fetchRoughnessMap(<$texcoord0$>) : 1.0); float <$roughness$> = mix(1.0, fetchRoughnessMap(<$texcoord0$>), float((<$matKey$> & ROUGHNESS_MAP_BIT) != 0));
<@endif@> <@endif@>
<@if normal@> <@if normal@>
vec3 <$normal$> = (((<$matKey$> & NORMAL_MAP_BIT) != 0) ? fetchNormalMap(<$texcoord0$>) : vec3(0.0, 1.0, 0.0)); vec3 <$normal$> = mix(vec3(0.0, 1.0, 0.0), fetchNormalMap(<$texcoord0$>), float((<$matKey$> & NORMAL_MAP_BIT) != 0));
<@endif@> <@endif@>
<@if metallic@> <@if metallic@>
float <$metallic$> = (((<$matKey$> & METALLIC_MAP_BIT) != 0) ? fetchMetallicMap(<$texcoord0$>) : 0.0); float <$metallic$> = float((<$matKey$> & METALLIC_MAP_BIT) != 0) * fetchMetallicMap(<$texcoord0$>);
<@endif@> <@endif@>
<@if emissive@> <@if emissive@>
vec3 <$emissive$> = (((<$matKey$> & EMISSIVE_MAP_BIT) != 0) ? fetchEmissiveMap(<$texcoord0$>) : vec3(0.0)); vec3 <$emissive$> = float((<$matKey$> & EMISSIVE_MAP_BIT) != 0) * fetchEmissiveMap(<$texcoord0$>);
<@endif@> <@endif@>
<@if scattering@> <@if scattering@>
float <$scattering$> = (((<$matKey$> & SCATTERING_MAP_BIT) != 0) ? fetchScatteringMap(<$texcoord0$>) : 0.0); float <$scattering$> = float((<$matKey$> & SCATTERING_MAP_BIT) != 0) * fetchScatteringMap(<$texcoord0$>);
<@endif@> <@endif@>
<@endfunc@> <@endfunc@>
<@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmap)@> <@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmap)@>
<@if occlusion@> <@if occlusion@>
float <$occlusion$> = (((<$matKey$> & OCCLUSION_MAP_BIT) != 0) ? fetchOcclusionMap(<$texcoord1$>) : 1.0); float <$occlusion$> = mix(1.0, fetchOcclusionMap(<$texcoord1$>), float((<$matKey$> & OCCLUSION_MAP_BIT) != 0));
<@endif@> <@endif@>
<@if lightmap@> <@if lightmap@>
vec3 <$lightmap$> = fetchLightmapMap(<$texcoord1$>); vec3 <$lightmap$> = fetchLightmapMap(<$texcoord1$>);
@ -207,20 +207,19 @@ vec3 fetchLightmapMap(vec2 uv) {
<@func evalMaterialAlbedo(fetchedAlbedo, materialAlbedo, matKey, albedo)@> <@func evalMaterialAlbedo(fetchedAlbedo, materialAlbedo, matKey, albedo)@>
{ {
<$albedo$>.xyz = (((<$matKey$> & ALBEDO_VAL_BIT) != 0) ? <$materialAlbedo$> : vec3(1.0)); <$albedo$>.xyz = mix(vec3(1.0), <$materialAlbedo$>, float((<$matKey$> & ALBEDO_VAL_BIT) != 0));
<$albedo$>.xyz *= mix(vec3(1.0), <$fetchedAlbedo$>.xyz, float((<$matKey$> & ALBEDO_MAP_BIT) != 0));
if (((<$matKey$> & ALBEDO_MAP_BIT) != 0)) {
<$albedo$>.xyz *= <$fetchedAlbedo$>.xyz;
}
} }
<@endfunc@> <@endfunc@>
<@func evalMaterialOpacity(fetchedOpacity, materialOpacity, matKey, opacity)@> <@func evalMaterialOpacity(fetchedOpacity, materialOpacity, matKey, opacity)@>
{ {
const float OPACITY_MASK_THRESHOLD = 0.5; const float OPACITY_MASK_THRESHOLD = 0.5;
<$opacity$> = (((<$matKey$> & (OPACITY_TRANSLUCENT_MAP_BIT | OPACITY_MASK_MAP_BIT)) != 0) ? <$opacity$> = mix(1.0,
(((<$matKey$> & OPACITY_MASK_MAP_BIT) != 0) ? step(OPACITY_MASK_THRESHOLD, <$fetchedOpacity$>) : <$fetchedOpacity$>) : mix(<$fetchedOpacity$>,
1.0) * <$materialOpacity$>; step(OPACITY_MASK_THRESHOLD, <$fetchedOpacity$>),
float((<$matKey$> & OPACITY_MASK_MAP_BIT) != 0)),
float((<$matKey$> & (OPACITY_TRANSLUCENT_MAP_BIT | OPACITY_MASK_MAP_BIT)) != 0)) * <$materialOpacity$>;
} }
<@endfunc@> <@endfunc@>
@ -241,19 +240,19 @@ vec3 fetchLightmapMap(vec2 uv) {
<@func evalMaterialRoughness(fetchedRoughness, materialRoughness, matKey, roughness)@> <@func evalMaterialRoughness(fetchedRoughness, materialRoughness, matKey, roughness)@>
{ {
<$roughness$> = (((<$matKey$> & ROUGHNESS_MAP_BIT) != 0) ? <$fetchedRoughness$> : <$materialRoughness$>); <$roughness$> = mix(<$materialRoughness$>, <$fetchedRoughness$>, float((<$matKey$> & ROUGHNESS_MAP_BIT) != 0));
} }
<@endfunc@> <@endfunc@>
<@func evalMaterialMetallic(fetchedMetallic, materialMetallic, matKey, metallic)@> <@func evalMaterialMetallic(fetchedMetallic, materialMetallic, matKey, metallic)@>
{ {
<$metallic$> = (((<$matKey$> & METALLIC_MAP_BIT) != 0) ? <$fetchedMetallic$> : <$materialMetallic$>); <$metallic$> = mix(<$materialMetallic$>, <$fetchedMetallic$>, float((<$matKey$> & METALLIC_MAP_BIT) != 0));
} }
<@endfunc@> <@endfunc@>
<@func evalMaterialEmissive(fetchedEmissive, materialEmissive, matKey, emissive)@> <@func evalMaterialEmissive(fetchedEmissive, materialEmissive, matKey, emissive)@>
{ {
<$emissive$> = (((<$matKey$> & EMISSIVE_MAP_BIT) != 0) ? <$fetchedEmissive$> : <$materialEmissive$>); <$emissive$> = mix(<$materialEmissive$>, <$fetchedEmissive$>, float((<$matKey$> & EMISSIVE_MAP_BIT) != 0));
} }
<@endfunc@> <@endfunc@>
@ -265,7 +264,7 @@ vec3 fetchLightmapMap(vec2 uv) {
<@func evalMaterialScattering(fetchedScattering, materialScattering, matKey, scattering)@> <@func evalMaterialScattering(fetchedScattering, materialScattering, matKey, scattering)@>
{ {
<$scattering$> = (((<$matKey$> & SCATTERING_MAP_BIT) != 0) ? <$fetchedScattering$> : <$materialScattering$>); <$scattering$> = mix(<$materialScattering$>, <$fetchedScattering$>, float((<$matKey$> & SCATTERING_MAP_BIT) != 0));
} }
<@endfunc@> <@endfunc@>

View file

@ -30,11 +30,9 @@ void main(void) {
vec3 color = skybox.color.rgb; vec3 color = skybox.color.rgb;
// blend is only set if there is a cubemap // blend is only set if there is a cubemap
if (skybox.color.a > 0.0) { float check = float(skybox.color.a > 0.0);
color = texture(cubeMap, coord).rgb; color = mix(color, texture(cubeMap, coord).rgb, check);
if (skybox.color.a < 1.0) { color *= mix(vec3(1.0), skybox.color.rgb, check * float(skybox.color.a < 1.0));
color *= skybox.color.rgb;
}
}
_fragColor = vec4(color, 0.0); _fragColor = vec4(color, 0.0);
} }

View file

@ -76,15 +76,10 @@ DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
// Diffuse color and unpack the mode and the metallicness // Diffuse color and unpack the mode and the metallicness
frag.albedo = diffuseVal.xyz; frag.albedo = diffuseVal.xyz;
frag.scattering = 0.0;
unpackModeMetallic(diffuseVal.w, frag.mode, frag.metallic); unpackModeMetallic(diffuseVal.w, frag.mode, frag.metallic);
frag.obscurance = min(specularVal.w, frag.obscurance); frag.obscurance = min(specularVal.w, frag.obscurance);
frag.scattering = float(frag.mode == FRAG_MODE_SCATTERING) * specularVal.x;
if (frag.mode == FRAG_MODE_SCATTERING) {
frag.scattering = specularVal.x;
}
frag.fresnel = getFresnelF0(frag.metallic, diffuseVal.xyz); frag.fresnel = getFresnelF0(frag.metallic, diffuseVal.xyz);
return frag; return frag;
@ -122,14 +117,11 @@ DeferredFragment unpackDeferredFragmentNoPositionNoAmbient(vec2 texcoord) {
<$declareDeferredFrameTransform()$> <$declareDeferredFrameTransform()$>
vec4 unpackDeferredPosition(float depthValue, vec2 texcoord) { vec4 unpackDeferredPosition(float depthValue, vec2 texcoord) {
int side = 0; float check = float(isStereo());
if (isStereo()) { float check2 = check * float(texcoord.x > 0.5);
if (texcoord.x > 0.5) { texcoord.x -= check2 * 0.5;
texcoord.x -= 0.5; int side = int(check2);
side = 1; texcoord.x *= 1.0 + check;
}
texcoord.x *= 2.0;
}
return vec4(evalEyePositionFromZdb(side, depthValue, texcoord), 1.0); return vec4(evalEyePositionFromZdb(side, depthValue, texcoord), 1.0);
} }
@ -142,19 +134,17 @@ vec4 unpackDeferredPositionFromZdb(vec2 texcoord) {
vec4 unpackDeferredPositionFromZeye(vec2 texcoord) { vec4 unpackDeferredPositionFromZeye(vec2 texcoord) {
float Zeye = -texture(linearZeyeMap, texcoord).x; float Zeye = -texture(linearZeyeMap, texcoord).x;
int side = 0;
if (isStereo()) { float check = float(isStereo());
if (texcoord.x > 0.5) { float check2 = check * float(texcoord.x > 0.5);
texcoord.x -= 0.5; texcoord.x -= check2 * 0.5;
side = 1; int side = int(check2);
} texcoord.x *= 1.0 + check;
texcoord.x *= 2.0;
}
return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0); return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0);
} }
DeferredFragment unpackDeferredFragment(DeferredFrameTransform deferredTransform, vec2 texcoord) { DeferredFragment unpackDeferredFragment(DeferredFrameTransform deferredTransform, vec2 texcoord) {
float depthValue = texture(depthMap, texcoord).r; float depthValue = texture(depthMap, texcoord).r;
DeferredFragment frag = unpackDeferredFragmentNoPosition(texcoord); DeferredFragment frag = unpackDeferredFragmentNoPosition(texcoord);

View file

@ -32,9 +32,11 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness
if (alpha != 1.0) { if (alpha != 1.0) {
discard; discard;
} }
_fragColor0 = vec4(albedo, ((scattering > 0.0) ? packScatteringMetallic(metallic) : packShadedMetallic(metallic)));
float check = float(scattering > 0.0);
_fragColor0 = vec4(albedo, mix(packShadedMetallic(metallic), packScatteringMetallic(metallic), check));
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0)); _fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
_fragColor2 = vec4(((scattering > 0.0) ? vec3(scattering) : emissive), occlusion); _fragColor2 = vec4(mix(emissive, vec3(scattering), check), occlusion);
_fragColor3 = vec4(isEmissiveEnabled() * emissive, 1.0); _fragColor3 = vec4(isEmissiveEnabled() * emissive, 1.0);
} }

View file

@ -116,6 +116,7 @@ bool isStereo() {
float getStereoSideWidth(int resolutionLevel) { float getStereoSideWidth(int resolutionLevel) {
return float(int(frameTransform._stereoInfo.y) >> resolutionLevel); return float(int(frameTransform._stereoInfo.y) >> resolutionLevel);
} }
float getStereoSideHeight(int resolutionLevel) { float getStereoSideHeight(int resolutionLevel) {
return float(int(frameTransform._pixelInfo.w) >> resolutionLevel); return float(int(frameTransform._pixelInfo.w) >> resolutionLevel);
} }
@ -125,7 +126,7 @@ vec2 getStereoSideSize(int resolutionLevel) {
} }
ivec4 getStereoSideInfoFromWidth(int xPos, int sideWidth) { ivec4 getStereoSideInfoFromWidth(int xPos, int sideWidth) {
return ivec4(xPos < sideWidth ? ivec2(0, 0) : ivec2(1, sideWidth), sideWidth, isStereo()); return ivec4((1 - int(xPos < sideWidth)) * ivec2(1, sideWidth), sideWidth, isStereo());
} }
ivec4 getStereoSideInfo(int xPos, int resolutionLevel) { ivec4 getStereoSideInfo(int xPos, int resolutionLevel) {

View file

@ -86,9 +86,7 @@ float evalFadeGradient(FadeObjectParams params, vec3 position) {
float evalFadeAlpha(FadeObjectParams params, vec3 position) { float evalFadeAlpha(FadeObjectParams params, vec3 position) {
float alpha = evalFadeGradient(params, position) - params.threshold; float alpha = evalFadeGradient(params, position) - params.threshold;
if (fadeParameters[params.category]._isInverted != 0) { alpha *= 1.0 - 2.0 * float(fadeParameters[params.category]._isInverted);
alpha = -alpha;
}
return alpha; return alpha;
} }

View file

@ -25,14 +25,13 @@ LAYOUT(binding=RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH) uniform sampler2D linearD
vec4 unpackPositionFromZeye(vec2 texcoord) { vec4 unpackPositionFromZeye(vec2 texcoord) {
float Zeye = -texture(linearDepthMap, texcoord).x; float Zeye = -texture(linearDepthMap, texcoord).x;
int side = 0;
if (isStereo()) { float check = float(isStereo());
if (texcoord.x > 0.5) { float check2 = check * float(texcoord.x > 0.5);
texcoord.x -= 0.5; texcoord.x -= check2 * 0.5;
side = 1; int side = int(check2);
} texcoord.x *= 1.0 + check;
texcoord.x *= 2.0;
}
return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0); return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0);
} }

View file

@ -63,20 +63,17 @@ vec3 computeHazeColorKeyLightAttenuation(vec3 color, vec3 lightDirectionWS, vec3
// Height at which haze density is reduced by 95% (default set to 2000.0 for safety ,this should never happen) // Height at which haze density is reduced by 95% (default set to 2000.0 for safety ,this should never happen)
float height_95p = 2000.0; float height_95p = 2000.0;
const float log_p_005 = log(0.05); const float log_p_005 = log(0.05);
if (hazeParams.hazeKeyLightAltitudeFactor > 0.0f) { if (hazeParams.hazeKeyLightAltitudeFactor > 0.0f) {
height_95p = -log_p_005 / hazeParams.hazeKeyLightAltitudeFactor; height_95p = -log_p_005 / hazeParams.hazeKeyLightAltitudeFactor;
} }
// Note that we need the sine to be positive // Note that we need the sine to be positive
float sin_pitch = abs(lightDirectionWS.y);
float distance;
const float minimumSinPitch = 0.001; const float minimumSinPitch = 0.001;
if (sin_pitch < minimumSinPitch) { float sin_pitch = abs(lightDirectionWS.y);
distance = height_95p / minimumSinPitch; sin_pitch = max(sin_pitch, minimumSinPitch);
} else {
distance = height_95p / sin_pitch; float distance = height_95p / sin_pitch;
}
// Integration is from the fragment towards the light source // Integration is from the fragment towards the light source
// Note that the haze base reference affects only the haze density as function of altitude // Note that the haze base reference affects only the haze density as function of altitude
@ -128,6 +125,7 @@ vec4 computeHazeColor(vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePosition
} }
vec4 potentialFragColor; vec4 potentialFragColor;
const float EPSILON = 0.0000001f;
if ((hazeParams.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR) { if ((hazeParams.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR) {
// Compute separately for each colour // Compute separately for each colour
@ -143,9 +141,9 @@ vec4 computeHazeColor(vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePosition
const float slopeThreshold = 0.01; const float slopeThreshold = 0.01;
float deltaHeight = fragPositionWS.y - eyeWorldHeight; float deltaHeight = fragPositionWS.y - eyeWorldHeight;
if (abs(deltaHeight) > slopeThreshold) {
float t = hazeParams.hazeHeightFactor * deltaHeight; float t = hazeParams.hazeHeightFactor * deltaHeight;
hazeIntegral *= (1.0 - exp (-t)) / t; if (abs(t) > EPSILON) {
hazeIntegral *= mix(1.0, (1.0 - exp(-t)) / t, float(abs(deltaHeight) > slopeThreshold));
} }
vec3 hazeAmount = 1.0 - exp(-hazeIntegral); vec3 hazeAmount = 1.0 - exp(-hazeIntegral);
@ -171,13 +169,9 @@ vec4 computeHazeColor(vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePosition
const float slopeThreshold = 0.01; const float slopeThreshold = 0.01;
float deltaHeight = fragPositionWS.y - eyeWorldHeight; float deltaHeight = fragPositionWS.y - eyeWorldHeight;
if (abs(deltaHeight) > slopeThreshold) {
float t = hazeParams.hazeHeightFactor * deltaHeight; float t = hazeParams.hazeHeightFactor * deltaHeight;
// Protect from wild values
const float EPSILON = 0.0000001f;
if (abs(t) > EPSILON) { if (abs(t) > EPSILON) {
hazeIntegral *= (1.0 - exp (-t)) / t; hazeIntegral *= mix(1.0, (1.0 - exp(-t)) / t, float(abs(deltaHeight) > slopeThreshold));
}
} }
float hazeAmount = 1.0 - exp(-hazeIntegral); float hazeAmount = 1.0 - exp(-hazeIntegral);
@ -189,9 +183,7 @@ vec4 computeHazeColor(vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePosition
// Mix with background at far range // Mix with background at far range
const float BLEND_DISTANCE = 27000.0f; const float BLEND_DISTANCE = 27000.0f;
vec4 outFragColor = potentialFragColor; vec4 outFragColor = potentialFragColor;
if (distance > BLEND_DISTANCE) { outFragColor.a *= mix(1.0, hazeParams.backgroundBlend, float(distance > BLEND_DISTANCE));
outFragColor.a *= hazeParams.backgroundBlend;
}
return outFragColor; return outFragColor;
} }

View file

@ -45,11 +45,9 @@ void main(void) {
highlightedDepth = -evalZeyeFromZdb(highlightedDepth); highlightedDepth = -evalZeyeFromZdb(highlightedDepth);
sceneDepth = -evalZeyeFromZdb(sceneDepth); sceneDepth = -evalZeyeFromZdb(sceneDepth);
if (sceneDepth < highlightedDepth) { outFragColor = mix(vec4(params._fillUnoccludedColor, params._fillUnoccludedAlpha),
outFragColor = vec4(params._fillOccludedColor, params._fillOccludedAlpha); vec4(params._fillOccludedColor, params._fillOccludedAlpha),
} else { float(sceneDepth < highlightedDepth));
outFragColor = vec4(params._fillUnoccludedColor, params._fillUnoccludedAlpha);
}
<@else@> <@else@>
discard; discard;
<@endif@> <@endif@>
@ -73,8 +71,7 @@ void main(void) {
if (uv.y >= 0.0 && uv.y <= 1.0) { if (uv.y >= 0.0 && uv.y <= 1.0) {
for (x = 0; x < params._blurKernelSize; x++) { for (x = 0; x < params._blurKernelSize; x++) {
if (uv.x>=0.0 && uv.x<=1.0) if (uv.x >= 0.0 && uv.x <= 1.0) {
{
outlinedDepth = texture(highlightedDepthMap, uv).x; outlinedDepth = texture(highlightedDepthMap, uv).x;
float touch = (outlinedDepth < FAR_Z) ? 1.0 : 0.0; float touch = (outlinedDepth < FAR_Z) ? 1.0 : 0.0;
sumOutlineDepth = max(outlinedDepth * touch, sumOutlineDepth); sumOutlineDepth = max(outlinedDepth * touch, sumOutlineDepth);
@ -86,11 +83,7 @@ void main(void) {
} }
} }
if (intensity > 0.0) { sumOutlineDepth = mix(FAR_Z, sumOutlineDepth, float(intensity > 0.0));
// sumOutlineDepth /= intensity;
} else {
sumOutlineDepth = FAR_Z;
}
intensity /= weight; intensity /= weight;
if (intensity < OPACITY_EPSILON) { if (intensity < OPACITY_EPSILON) {
@ -106,11 +99,9 @@ void main(void) {
sceneDepth = -evalZeyeFromZdb(sceneDepth); sceneDepth = -evalZeyeFromZdb(sceneDepth);
// Are we occluded? // Are we occluded?
if (sceneDepth < outlinedDepth) { outFragColor = mix(vec4(params._outlineUnoccludedColor, intensity * params._outlineUnoccludedAlpha),
outFragColor = vec4(params._outlineOccludedColor, intensity * params._outlineOccludedAlpha); vec4(params._outlineOccludedColor, intensity * params._outlineOccludedAlpha),
} else { float(sceneDepth < outlinedDepth));
outFragColor = vec4(params._outlineUnoccludedColor, intensity * params._outlineUnoccludedAlpha);
}
} }
} }

View file

@ -83,7 +83,7 @@ int clusterGrid_getClusterLightId(int index, int offset) {
return element; return element;
*/ */
int element = _clusterGridContent[GRID_FETCH_BUFFER((elementIndex >> 1))]; int element = _clusterGridContent[GRID_FETCH_BUFFER((elementIndex >> 1))];
return (((elementIndex & 0x00000001) == 1) ? (element >> 16) : element) & 0x0000FFFF; return (element >> (16 * int((elementIndex & 0x00000001) == 1))) & 0x0000FFFF;
} }

View file

@ -5,6 +5,14 @@
#define float_exp2 exp2 #define float_exp2 exp2
#endif #endif
#ifdef __cplusplus
# define _MIN glm::min
# define _ABS(x) (int)fabsf(x)
#else
# define _MIN min
# define _ABS abs
#endif
float frustumGrid_depthRampGridToVolume(float ngrid) { float frustumGrid_depthRampGridToVolume(float ngrid) {
// return ngrid; // return ngrid;
// return sqrt(ngrid); // return sqrt(ngrid);
@ -87,14 +95,9 @@ ivec3 frustumGrid_indexToCluster(int index) {
} }
vec3 frustumGrid_clusterPosToEye(vec3 clusterPos) { vec3 frustumGrid_clusterPosToEye(vec3 clusterPos) {
vec3 cvpos = clusterPos; vec3 cvpos = clusterPos;
vec3 volumePos = frustumGrid_gridToVolume(cvpos, frustumGrid.dims); vec3 volumePos = frustumGrid_gridToVolume(cvpos, frustumGrid.dims);
vec3 eyePos = frustumGrid_volumeToEye(volumePos, frustumGrid.eyeToGridProj, frustumGrid.rangeNear, frustumGrid.rangeFar); vec3 eyePos = frustumGrid_volumeToEye(volumePos, frustumGrid.eyeToGridProj, frustumGrid.rangeNear, frustumGrid.rangeFar);
return eyePos; return eyePos;
} }
@ -116,27 +119,19 @@ int frustumGrid_eyeDepthToClusterLayer(float eyeZ) {
int gridZ = int(frustumGrid_volumeToGridDepth(volumeZ, frustumGrid.dims)); int gridZ = int(frustumGrid_volumeToGridDepth(volumeZ, frustumGrid.dims));
if (gridZ >= frustumGrid.dims.z) { return _MIN(gridZ, frustumGrid.dims.z);
gridZ = frustumGrid.dims.z;
}
return gridZ;
} }
ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) { ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) {
// make sure the frontEyePos is always in the front to eval the grid pos correctly // make sure the frontEyePos is always in the front to eval the grid pos correctly
vec3 frontEyePos = eyePos; vec3 frontEyePos = eyePos;
frontEyePos.z = (eyePos.z > 0.0f ? -eyePos.z : eyePos.z); frontEyePos.z = -_ABS(eyePos.z);
vec3 volumePos = frustumGrid_eyeToVolume(frontEyePos, frustumGrid.eyeToGridProj, frustumGrid.rangeNear, frustumGrid.rangeFar); vec3 volumePos = frustumGrid_eyeToVolume(frontEyePos, frustumGrid.eyeToGridProj, frustumGrid.rangeNear, frustumGrid.rangeFar);
vec3 gridPos = frustumGrid_volumeToGrid(volumePos, frustumGrid.dims); vec3 gridPos = frustumGrid_volumeToGrid(volumePos, frustumGrid.dims);
gridPos.z = _MIN(gridPos.z, float(frustumGrid.dims.z));
if (gridPos.z >= float(frustumGrid.dims.z)) {
gridPos.z = float(frustumGrid.dims.z);
}
ivec3 igridPos = ivec3(floor(gridPos)); ivec3 igridPos = ivec3(floor(gridPos));
@ -154,7 +149,7 @@ ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) {
int frustumGrid_eyeToClusterDirH(vec3 eyeDir) { int frustumGrid_eyeToClusterDirH(vec3 eyeDir) {
if (eyeDir.z >= 0.0f) { if (eyeDir.z >= 0.0f) {
return (eyeDir.x > 0.0f ? frustumGrid.dims.x : -1); return int(eyeDir.x > 0.0f) * (frustumGrid.dims.x + 1) - 1;
} }
float eyeDepth = -eyeDir.z; float eyeDepth = -eyeDir.z;
@ -168,7 +163,7 @@ int frustumGrid_eyeToClusterDirH(vec3 eyeDir) {
int frustumGrid_eyeToClusterDirV(vec3 eyeDir) { int frustumGrid_eyeToClusterDirV(vec3 eyeDir) {
if (eyeDir.z >= 0.0f) { if (eyeDir.z >= 0.0f) {
return (eyeDir.y > 0.0f ? frustumGrid.dims.y : -1); return int(eyeDir.y > 0.0f) * (frustumGrid.dims.y + 1) - 1;
} }
float eyeDepth = -eyeDir.z; float eyeDepth = -eyeDir.z;

View file

@ -41,12 +41,10 @@ void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
specular *= lightEnergy * isSpecularEnabled(); specular *= lightEnergy * isSpecularEnabled();
if (isShowLightContour() > 0.0) { if (isShowLightContour() > 0.0) {
// Show edge // Show edges
float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0); float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0);
if (edge < 1.0) {
float edgeCoord = exp2(-8.0 * edge * edge); float edgeCoord = exp2(-8.0 * edge * edge);
diffuse = vec3(edgeCoord * edgeCoord * getLightColor(light)); diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
}
} }
} }
@ -62,10 +60,8 @@ bool evalLightPointEdge(out vec3 color, Light light, vec4 fragLightDirLen, vec3
// Show edges // Show edges
float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0); float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0);
if (edge < 1.0) {
float edgeCoord = exp2(-8.0 * edge * edge); float edgeCoord = exp2(-8.0 * edge * edge);
color = vec3(edgeCoord * edgeCoord * getLightColor(light)); color = mix(color, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
}
return (edge < 1.0); return (edge < 1.0);
} }

View file

@ -46,11 +46,9 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
float edgeDistR = (lightVolume_getRadius(light.volume) - fragLightDistance); float edgeDistR = (lightVolume_getRadius(light.volume) - fragLightDistance);
float edgeDistS = dot(fragLightDistance * vec2(cosSpotAngle, sqrt(1.0 - cosSpotAngle * cosSpotAngle)), -lightVolume_getSpotOutsideNormal2(light.volume)); float edgeDistS = dot(fragLightDistance * vec2(cosSpotAngle, sqrt(1.0 - cosSpotAngle * cosSpotAngle)), -lightVolume_getSpotOutsideNormal2(light.volume));
float edgeDist = min(edgeDistR, edgeDistS); float edgeDist = min(edgeDistR, edgeDistS);
float edge = abs(2.0 * (edgeDist / (0.1)) - 1.0); float edge = abs(2.0 * (edgeDist * 10.0) - 1.0);
if (edge < 1.0) {
float edgeCoord = exp2(-8.0 * edge * edge); float edgeCoord = exp2(-8.0 * edge * edge);
diffuse = vec3(edgeCoord * edgeCoord * getLightColor(light)); diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
}
} }
} }
@ -67,15 +65,11 @@ bool evalLightSpotEdge(out vec3 color, Light light, vec4 fragLightDirLen, float
float edgeDistR = (lightVolume_getRadius(light.volume) - fragLightDistance); float edgeDistR = (lightVolume_getRadius(light.volume) - fragLightDistance);
float edgeDistS = dot(fragLightDistance * vec2(cosSpotAngle, sqrt(1.0 - cosSpotAngle * cosSpotAngle)), -lightVolume_getSpotOutsideNormal2(light.volume)); float edgeDistS = dot(fragLightDistance * vec2(cosSpotAngle, sqrt(1.0 - cosSpotAngle * cosSpotAngle)), -lightVolume_getSpotOutsideNormal2(light.volume));
float edgeDist = min(edgeDistR, edgeDistS); float edgeDist = min(edgeDistR, edgeDistS);
float edge = abs(2.0 * (edgeDist / (0.1)) - 1.0); float edge = abs(2.0 * (edgeDist * 10.0) - 1.0);
if (edge < 1.0) {
float edgeCoord = exp2(-8.0 * edge * edge); float edgeCoord = exp2(-8.0 * edge * edge);
color = vec3(edgeCoord * edgeCoord * getLightColor(light)); color = mix(color, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
}
return (edge < 1.0); return (edge < 1.0);
} }
<@endfunc@> <@endfunc@>

View file

@ -115,18 +115,10 @@ float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDe
isPixelOnCascade.z = isShadowCascadeProjectedOnPixel(cascadeShadowCoords[2]); isPixelOnCascade.z = isShadowCascadeProjectedOnPixel(cascadeShadowCoords[2]);
isPixelOnCascade.w = isShadowCascadeProjectedOnPixel(cascadeShadowCoords[3]); isPixelOnCascade.w = isShadowCascadeProjectedOnPixel(cascadeShadowCoords[3]);
if (isPixelOnCascade.x) { cascadeAttenuations.x = mix(1.0, evalShadowCascadeAttenuation(0, offsets, cascadeShadowCoords[0], oneMinusNdotL), float(isPixelOnCascade.x));
cascadeAttenuations.x = evalShadowCascadeAttenuation(0, offsets, cascadeShadowCoords[0], oneMinusNdotL); cascadeAttenuations.y = mix(1.0, evalShadowCascadeAttenuation(1, offsets, cascadeShadowCoords[1], oneMinusNdotL), float(isPixelOnCascade.y));
} cascadeAttenuations.z = mix(1.0, evalShadowCascadeAttenuation(2, offsets, cascadeShadowCoords[2], oneMinusNdotL), float(isPixelOnCascade.z));
if (isPixelOnCascade.y) { cascadeAttenuations.w = mix(1.0, evalShadowCascadeAttenuation(3, offsets, cascadeShadowCoords[3], oneMinusNdotL), float(isPixelOnCascade.w));
cascadeAttenuations.y = evalShadowCascadeAttenuation(1, offsets, cascadeShadowCoords[1], oneMinusNdotL);
}
if (isPixelOnCascade.z) {
cascadeAttenuations.z = evalShadowCascadeAttenuation(2, offsets, cascadeShadowCoords[2], oneMinusNdotL);
}
if (isPixelOnCascade.w) {
cascadeAttenuations.w = evalShadowCascadeAttenuation(3, offsets, cascadeShadowCoords[3], oneMinusNdotL);
}
cascadeWeights.x = evalShadowCascadeWeight(cascadeShadowCoords[0]); cascadeWeights.x = evalShadowCascadeWeight(cascadeShadowCoords[0]);
cascadeWeights.y = evalShadowCascadeWeight(cascadeShadowCoords[1]); cascadeWeights.y = evalShadowCascadeWeight(cascadeShadowCoords[1]);

View file

@ -81,9 +81,7 @@ void evalSkinning(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPositio
// to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity. // to ensure that we rotate along the shortest arc, reverse dual quaternions with negative polarity.
float dqClusterWeight = clusterWeight; float dqClusterWeight = clusterWeight;
if (dot(real, polarityReference) < 0.0) { dqClusterWeight *= mix(1.0, -1.0, float(dot(real, polarityReference) < 0.0));
dqClusterWeight = -clusterWeight;
}
sAccum += scale * clusterWeight; sAccum += scale * clusterWeight;
rAccum += real * dqClusterWeight; rAccum += real * dqClusterWeight;
@ -102,12 +100,11 @@ void evalSkinning(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPositio
// sAccum.w indicates the amount of cauterization for this vertex. // sAccum.w indicates the amount of cauterization for this vertex.
// 0 indicates no cauterization and 1 indicates full cauterization. // 0 indicates no cauterization and 1 indicates full cauterization.
// TODO: make this cauterization smoother or implement full dual-quaternion scale support. // TODO: make this cauterization smoother or implement full dual-quaternion scale support.
{
const float CAUTERIZATION_THRESHOLD = 0.1; const float CAUTERIZATION_THRESHOLD = 0.1;
if (sAccum.w > CAUTERIZATION_THRESHOLD) { float check = float(sAccum.w > CAUTERIZATION_THRESHOLD);
skinnedPosition = cAccum; sAccum.w = mix(1.0, sAccum.w, check);
} else { skinnedPosition = mix(m * (sAccum * inPosition), cAccum, check);
sAccum.w = 1.0;
skinnedPosition = m * (sAccum * inPosition);
} }
<@if USE_NORMAL@> <@if USE_NORMAL@>

View file

@ -82,8 +82,6 @@ vec3 integrate(float cosTheta, float skinRadius) {
while (a <= (_PI)) { while (a <= (_PI)) {
float sampleAngle = theta + a; float sampleAngle = theta + a;
float diffuse = clamp(cos(sampleAngle), 0.0, 1.0); float diffuse = clamp(cos(sampleAngle), 0.0, 1.0);
//if (diffuse < 0.0) diffuse = 0.0;
//if (diffuse > 1.0) diffuse = 1.0;
// Distance. // Distance.
float sampleDist = abs(2.0 * skinRadius * sin(a * 0.5)); float sampleDist = abs(2.0 * skinRadius * sin(a * 0.5));
@ -180,7 +178,8 @@ vec3 evalSkinBRDF(vec3 lightDir, vec3 normal, vec3 midNormal, vec3 lowNormal, fl
return lowNormal * 0.5 + vec3(0.5); return lowNormal * 0.5 + vec3(0.5);
} }
if (showCurvature()) { if (showCurvature()) {
return (curvature > 0.0 ? vec3(curvature, 0.0, 0.0) : vec3(0.0, 0.0, -curvature)); float check = float(curvature > 0.0);
return vec3(check * curvature, 0.0, (1.0 - check) * -curvature);
} }
vec3 bentNdotL = evalScatteringBentNdotL(normal, midNormal, lowNormal, lightDir); vec3 bentNdotL = evalScatteringBentNdotL(normal, midNormal, lowNormal, lightDir);

View file

@ -37,9 +37,7 @@ void main(void) {
#ifdef GPU_TRANSFORM_IS_STEREO #ifdef GPU_TRANSFORM_IS_STEREO
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN #ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
#else #else
if (cam_isStereo()) { projected.x = mix(projected.x, 0.5 * (projected.x + cam_getStereoSide()), float(cam_isStereo()));
projected.x = 0.5 * (projected.x + cam_getStereoSide());
}
#endif #endif
#endif #endif
_texCoord01 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w; _texCoord01 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
@ -66,9 +64,7 @@ void main(void) {
#ifdef GPU_TRANSFORM_IS_STEREO #ifdef GPU_TRANSFORM_IS_STEREO
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN #ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
#else #else
if (cam_isStereo()) { _texCoord01.x = mix(_texCoord01.x, 0.5 * (_texCoord01.x + cam_getStereoSide()), float(cam_isStereo()));
_texCoord01.x = 0.5 * (_texCoord01.x + cam_getStereoSide());
}
#endif #endif
#endif #endif

View file

@ -47,8 +47,6 @@ void main(void) {
vec4 projected = gl_Position / gl_Position.w; vec4 projected = gl_Position / gl_Position.w;
projected.xy = (projected.xy + 1.0) * 0.5; projected.xy = (projected.xy + 1.0) * 0.5;
if (cam_isStereo()) { projected.x = mix(projected.x, 0.5 * (projected.x + cam_getStereoSide()), float(cam_isStereo()));
projected.x = 0.5 * (projected.x + cam_getStereoSide());
}
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w; _texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
} }

View file

@ -60,9 +60,7 @@ void main(void) {
#ifdef GPU_TRANSFORM_IS_STEREO #ifdef GPU_TRANSFORM_IS_STEREO
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN #ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
#else #else
if (cam_isStereo()) { projected.x = mix(projected.x, 0.5 * (projected.x + cam_getStereoSide()), float(cam_isStereo()));
projected.x = 0.5 * (projected.x + cam_getStereoSide());
}
#endif #endif
#endif #endif
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w; _texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;

View file

@ -33,16 +33,15 @@ void main(void) {
float shadowAttenuation = 1.0; float shadowAttenuation = 1.0;
if (frag.mode == FRAG_MODE_UNLIT) { if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard;
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard; discard;
} else { } else {
vec4 midNormalCurvature = vec4(0); vec4 midNormalCurvature = vec4(0);
vec4 lowNormalCurvature = vec4(0); vec4 lowNormalCurvature = vec4(0);
if (frag.mode == FRAG_MODE_SCATTERING) {
unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature); unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature);
} float check = float(frag.mode == FRAG_MODE_SCATTERING);
midNormalCurvature = check * midNormalCurvature;
lowNormalCurvature = check * lowNormalCurvature;
vec3 color = evalAmbientSphereGlobalColor( vec3 color = evalAmbientSphereGlobalColor(
getViewInverse(), getViewInverse(),

View file

@ -35,16 +35,16 @@ void main(void) {
vec3 worldLightDirection = getLightDirection(shadowLight); vec3 worldLightDirection = getLightDirection(shadowLight);
float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal); float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal);
if (frag.mode == FRAG_MODE_UNLIT) { if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard;
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard; discard;
} else { } else {
vec4 midNormalCurvature = vec4(0); vec4 midNormalCurvature = vec4(0);
vec4 lowNormalCurvature = vec4(0); vec4 lowNormalCurvature = vec4(0);
if (frag.mode == FRAG_MODE_SCATTERING) {
unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature); unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature);
} float check = float(frag.mode == FRAG_MODE_SCATTERING);
midNormalCurvature = check * midNormalCurvature;
lowNormalCurvature = check * lowNormalCurvature;
vec3 color = evalAmbientSphereGlobalColor( vec3 color = evalAmbientSphereGlobalColor(
getViewInverse(), getViewInverse(),
shadowAttenuation, shadowAttenuation,

View file

@ -31,16 +31,16 @@ void main(void) {
float shadowAttenuation = 1.0; float shadowAttenuation = 1.0;
// Light mapped or not ? // Light mapped or not ?
if (frag.mode == FRAG_MODE_UNLIT) { if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard;
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard; discard;
} else { } else {
vec4 midNormalCurvature = vec4(0); vec4 midNormalCurvature = vec4(0);
vec4 lowNormalCurvature = vec4(0); vec4 lowNormalCurvature = vec4(0);
if (frag.mode == FRAG_MODE_SCATTERING) {
unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature); unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature);
} float check = float(frag.mode == FRAG_MODE_SCATTERING);
midNormalCurvature = check * midNormalCurvature;
lowNormalCurvature = check * lowNormalCurvature;
vec3 color = evalSkyboxGlobalColor( vec3 color = evalSkyboxGlobalColor(
getViewInverse(), getViewInverse(),
shadowAttenuation, shadowAttenuation,

View file

@ -36,16 +36,16 @@ void main(void) {
float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal); float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal);
// Light mapped or not ? // Light mapped or not ?
if (frag.mode == FRAG_MODE_UNLIT) { if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard;
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard; discard;
} else { } else {
vec4 midNormalCurvature = vec4(0); vec4 midNormalCurvature = vec4(0);
vec4 lowNormalCurvature = vec4(0); vec4 lowNormalCurvature = vec4(0);
if (frag.mode == FRAG_MODE_SCATTERING) {
unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature); unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature);
} float check = float(frag.mode == FRAG_MODE_SCATTERING);
midNormalCurvature = check * midNormalCurvature;
lowNormalCurvature = check * lowNormalCurvature;
vec3 color = evalSkyboxGlobalColor( vec3 color = evalSkyboxGlobalColor(
getViewInverse(), getViewInverse(),
shadowAttenuation, shadowAttenuation,

View file

@ -62,7 +62,5 @@ void main(void) {
varColor = vec4(REGION_COLOR[region].xyz, proxy.sphere.w); varColor = vec4(REGION_COLOR[region].xyz, proxy.sphere.w);
if (region == 4) { gl_Position = mix(gl_Position, vec4(0.0), float(region == 4));
gl_Position = vec4(0.0);
}
} }

View file

@ -53,13 +53,8 @@ void main(void) {
// Add or subtract the orthogonal vector based on a different vertex ID // Add or subtract the orthogonal vector based on a different vertex ID
// calculation // calculation
if (gl_VertexID < 2) { distanceFromCenter = 1.0 - 2.0 * float(gl_VertexID < 2);
distanceFromCenter = -1.0; eye.xyz += distanceFromCenter * orthogonal;
eye.xyz -= orthogonal;
} else {
distanceFromCenter = 1.0;
eye.xyz += orthogonal;
}
// Finally, put the eyespace vertex into clip space // Finally, put the eyespace vertex into clip space
<$transformEyeToClipPos(cam, eye, gl_Position)$> <$transformEyeToClipPos(cam, eye, gl_Position)$>

View file

@ -34,12 +34,10 @@ layout(location=0) out vec4 outFragColor;
void main(void) { void main(void) {
Grid grid = getGrid(); Grid grid = getGrid();
float alpha; float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
if (grid.edge.z == 0.0) { paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy),
alpha = paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy); float(grid.edge.z == 0.0));
} else {
alpha = paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge);
}
if (alpha == 0.0) { if (alpha == 0.0) {
discard; discard;
} }

View file

@ -90,6 +90,6 @@ void main(void) {
numLightTouching++; numLightTouching++;
} }
_fragColor = vec4(colorRamp(1.0 - (float(numLightTouching) / 12.0f)), (numLightTouching > 0 ? 0.5 + 0.5 * numLightsScale : 0.0)); _fragColor = vec4(colorRamp(1.0 - (float(numLightTouching) / 12.0f)), float(numLightTouching > 0) * (0.5 + 0.5 * numLightsScale));
} }

View file

@ -69,5 +69,5 @@ void main(void) {
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();
<$transformWorldToClipPos(cam, worldPos, gl_Position)$> <$transformWorldToClipPos(cam, worldPos, gl_Position)$>
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), (numLights >0 ? 0.9 : 0.1)); varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), 0.1 + 0.8 * float(numLights > 0));
} }

View file

@ -62,12 +62,10 @@ void main(void) {
float relClusterId = float(clusterPos.z * summedDims.x + clusterPos.y * summedDims.y + clusterPos.x) / float(frustumGrid_numClusters()); float relClusterId = float(clusterPos.z * summedDims.x + clusterPos.y * summedDims.y + clusterPos.x) / float(frustumGrid_numClusters());
if (relClusterId < 0.0) { _fragColor = mix(mix(vec4(colorWheel(fract(relClusterId)), float(numLights > 0) * (0.05 + 0.95 * numLightsScale)),
_fragColor = vec4(0.0); vec4(vec3(1.0), 0.2),
} else if (relClusterId >= 1.0) { float(relClusterId >= 1.0)),
_fragColor = vec4(vec3(1.0), 0.2); vec4(0.0),
} else { float(relClusterId < 0.0));
_fragColor = vec4(colorWheel(fract(relClusterId)), (numLights > 0 ? 0.05 + 0.95 * numLightsScale : 0.0));
}
} }

View file

@ -69,5 +69,5 @@ void main(void) {
TransformCamera cam = getTransformCamera(); TransformCamera cam = getTransformCamera();
<$transformWorldToClipPos(cam, worldPos, gl_Position)$> <$transformWorldToClipPos(cam, worldPos, gl_Position)$>
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), (numLights > 0 ? 0.9 : 0.0)); varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), float(numLights > 0) * 0.9);
} }

View file

@ -96,9 +96,8 @@ void main(void) {
vec3 fragLightDir = fragLightDirLen.xyz; vec3 fragLightDir = fragLightDirLen.xyz;
vec3 color = vec3(0.0); vec3 color = vec3(0.0);
if (evalLightPointEdge(color, light, fragLightDirLen, fragEyeDir)) { float check = float(evalLightPointEdge(color, light, fragLightDirLen, fragEyeDir));
_fragColor.rgb += color; _fragColor.rgb += check * color;
}
} }
for (int i = cluster.x; i < numLights; i++) { for (int i = cluster.x; i < numLights; i++) {
@ -130,10 +129,8 @@ void main(void) {
numLightTouching++; numLightTouching++;
vec3 color = vec3(0.0); vec3 color = vec3(0.0);
float check = float(evalLightSpotEdge(color, light, fragLightDirLen, cosSpotAngle, fragEyeDir));
if (evalLightSpotEdge(color, light, fragLightDirLen, cosSpotAngle, fragEyeDir)) { _fragColor.rgb += check * color;
_fragColor.rgb += color;
}
} }
} }

View file

@ -48,11 +48,8 @@ void main(void) {
} else { } else {
normal = vec4(normalize(cross(_parabolaData.velocity, _parabolaData.acceleration)), 0); normal = vec4(normalize(cross(_parabolaData.velocity, _parabolaData.acceleration)), 0);
} }
if (gl_VertexID % 2 == 0) {
pos += 0.5 * _parabolaData.width * normal; pos += 0.5 * _parabolaData.width * normal * (-1.0 + 2.0 * float(gl_VertexID % 2 == 0));
} else {
pos -= 0.5 * _parabolaData.width * normal;
}
<$transformModelToClipPos(cam, obj, pos, gl_Position)$> <$transformModelToClipPos(cam, obj, pos, gl_Position)$>
} }

View file

@ -39,13 +39,8 @@ const float taaBias = pow(2.0, TAA_TEXTURE_LOD_BIAS);
float evalSDF(vec2 texCoord) { float evalSDF(vec2 texCoord) {
// retrieve signed distance // retrieve signed distance
float sdf = textureLod(Font, texCoord, TAA_TEXTURE_LOD_BIAS).g; float sdf = textureLod(Font, texCoord, TAA_TEXTURE_LOD_BIAS).g;
if (params.outline.x > 0.0) { sdf = mix(sdf, mix(sdf + outlineExpansion, 1.0 - sdf, float(sdf > interiorCutoff)), float(params.outline.x > 0.0));
if (sdf > interiorCutoff) {
sdf = 1.0 - sdf;
} else {
sdf += outlineExpansion;
}
}
// Rely on TAA for anti-aliasing // Rely on TAA for anti-aliasing
return step(0.5, sdf); return step(0.5, sdf);
} }
@ -62,11 +57,6 @@ void main() {
a += evalSDF(_texCoord0 + dxTexCoord + dyTexCoord); a += evalSDF(_texCoord0 + dxTexCoord + dyTexCoord);
a *= 0.25; a *= 0.25;
// discard if invisible
if (a < 0.01) {
discard;
}
packDeferredFragment( packDeferredFragment(
normalize(_normalWS), normalize(_normalWS),
a * params.color.a, a * params.color.a,

View file

@ -30,31 +30,32 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy #define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw #define _texCoord1 _texCoord01.zw
const float gamma = 2.2; #define TAA_TEXTURE_LOD_BIAS -3.0
const float smoothing = 32.0;
const float interiorCutoff = 0.8; const float interiorCutoff = 0.8;
const float outlineExpansion = 0.2; const float outlineExpansion = 0.2;
const float taaBias = pow(2.0, TAA_TEXTURE_LOD_BIAS);
float evalSDF(vec2 texCoord) {
// retrieve signed distance
float sdf = textureLod(Font, texCoord, TAA_TEXTURE_LOD_BIAS).g;
sdf = mix(sdf, mix(sdf + outlineExpansion, 1.0 - sdf, float(sdf > interiorCutoff)), float(params.outline.x > 0.0));
// Rely on TAA for anti-aliasing
return step(0.5, sdf);
}
void main() { void main() {
// retrieve signed distance vec2 dxTexCoord = dFdx(_texCoord0) * 0.5 * taaBias;
float sdf = texture(Font, _texCoord0).g; vec2 dyTexCoord = dFdy(_texCoord0) * 0.5 * taaBias;
if (params.outline.x > 0.0) {
if (sdf > interiorCutoff) {
sdf = 1.0 - sdf;
} else {
sdf += outlineExpansion;
}
}
// perform adaptive anti-aliasing of the edges
// The larger we're rendering, the less anti-aliasing we need
float s = smoothing * length(fwidth(_texCoord0));
float w = clamp(s, 0.0, 0.5);
float a = smoothstep(0.5 - w, 0.5 + w, sdf);
// discard if invisible // Perform 4x supersampling for anisotropic filtering
if (a < 0.01) { float a;
discard; a = evalSDF(_texCoord0);
} a += evalSDF(_texCoord0 + dxTexCoord);
a += evalSDF(_texCoord0 + dyTexCoord);
a += evalSDF(_texCoord0 + dxTexCoord + dyTexCoord);
a *= 0.25;
packDeferredFragmentTranslucent( packDeferredFragmentTranslucent(
normalize(_normalWS), normalize(_normalWS),

View file

@ -12,6 +12,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
<@include gpu/Color.slh@>
<@include DeferredBufferWrite.slh@> <@include DeferredBufferWrite.slh@>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
@ -28,11 +29,13 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
void main(void) { void main(void) {
vec4 texel = texture(originalTexture, _texCoord0); vec4 texel = texture(originalTexture, _texCoord0);
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
texel.rgb *= _color.rgb;
packDeferredFragment( packDeferredFragment(
normalize(_normalWS), normalize(_normalWS),
1.0, 1.0,
_color.rgb * texel.rgb, texel.rgb,
DEFAULT_ROUGHNESS, DEFAULT_ROUGHNESS,
DEFAULT_METALLIC, DEFAULT_METALLIC,
DEFAULT_EMISSIVE, DEFAULT_EMISSIVE,

View file

@ -41,24 +41,22 @@ void main(void) {
applyFade(fadeParams, _positionWS.xyz, fadeEmissive); applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
vec4 texel = texture(originalTexture, _texCoord0); vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a; texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
if (_color.a <= 0.0) { texel.rgb *= _color.rgb;
texel = color_sRGBAToLinear(texel); texel.a = abs(_color.a);
colorAlpha = -_color.a;
}
const float ALPHA_THRESHOLD = 0.999; const float ALPHA_THRESHOLD = 0.999;
if (colorAlpha * texel.a < ALPHA_THRESHOLD) { if (texel.a < ALPHA_THRESHOLD) {
packDeferredFragmentTranslucent( packDeferredFragmentTranslucent(
normalize(_normalWS), normalize(_normalWS),
colorAlpha * texel.a, texel.a,
_color.rgb * texel.rgb + fadeEmissive, texel.rgb + fadeEmissive,
DEFAULT_ROUGHNESS); DEFAULT_ROUGHNESS);
} else { } else {
packDeferredFragment( packDeferredFragment(
normalize(_normalWS), normalize(_normalWS),
1.0, 1.0,
_color.rgb * texel.rgb, texel.rgb,
DEFAULT_ROUGHNESS, DEFAULT_ROUGHNESS,
DEFAULT_METALLIC, DEFAULT_METALLIC,
DEFAULT_EMISSIVE + fadeEmissive, DEFAULT_EMISSIVE + fadeEmissive,

View file

@ -28,24 +28,22 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord1 _texCoord01.zw #define _texCoord1 _texCoord01.zw
void main(void) { void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st); vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a; texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
if (_color.a <= 0.0) { texel.rgb *= _color.rgb;
texel = color_sRGBAToLinear(texel); texel.a = abs(_color.a);
colorAlpha = -_color.a;
}
const float ALPHA_THRESHOLD = 0.999; const float ALPHA_THRESHOLD = 0.999;
if (colorAlpha * texel.a < ALPHA_THRESHOLD) { if (texel.a < ALPHA_THRESHOLD) {
packDeferredFragmentTranslucent( packDeferredFragmentTranslucent(
normalize(_normalWS), normalize(_normalWS),
colorAlpha * texel.a, texel.a,
_color.rgb * texel.rgb, texel.rgb,
DEFAULT_ROUGHNESS); DEFAULT_ROUGHNESS);
} else { } else {
packDeferredFragmentUnlit( packDeferredFragmentUnlit(
normalize(_normalWS), normalize(_normalWS),
1.0, 1.0,
_color.rgb * texel.rgb); texel.rgb);
} }
} }

View file

@ -40,24 +40,22 @@ void main(void) {
<$fetchFadeObjectParamsInstanced(fadeParams)$> <$fetchFadeObjectParamsInstanced(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive); applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
vec4 texel = texture(originalTexture, _texCoord0.st); vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a; texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
if (_color.a <= 0.0) { texel.rgb *= _color.rgb;
texel = color_sRGBAToLinear(texel); texel.a = abs(_color.a);
colorAlpha = -_color.a;
}
const float ALPHA_THRESHOLD = 0.999; const float ALPHA_THRESHOLD = 0.999;
if (colorAlpha * texel.a < ALPHA_THRESHOLD) { if (texel.a < ALPHA_THRESHOLD) {
packDeferredFragmentTranslucent( packDeferredFragmentTranslucent(
normalize(_normalWS), normalize(_normalWS),
colorAlpha * texel.a, texel.a,
_color.rgb * texel.rgb+fadeEmissive, texel.rgb + fadeEmissive,
DEFAULT_ROUGHNESS); DEFAULT_ROUGHNESS);
} else { } else {
packDeferredFragmentUnlit( packDeferredFragmentUnlit(
normalize(_normalWS), normalize(_normalWS),
1.0, 1.0,
_color.rgb * texel.rgb+fadeEmissive); texel.rgb + fadeEmissive);
} }
} }

View file

@ -12,6 +12,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
<@include gpu/Color.slh@>
<@include DeferredBufferWrite.slh@> <@include DeferredBufferWrite.slh@>
<@include render-utils/ShaderConstants.h@> <@include render-utils/ShaderConstants.h@>
@ -28,11 +29,13 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
void main(void) { void main(void) {
vec4 texel = texture(originalTexture, _texCoord0); vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a * texel.a; texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
texel.rgb *= _color.rgb;
texel.a *= abs(_color.a);
packDeferredFragmentTranslucent( packDeferredFragmentTranslucent(
normalize(_normalWS), normalize(_normalWS),
colorAlpha, texel.a,
_color.rgb * texel.rgb, texel.rgb,
DEFAULT_ROUGHNESS); DEFAULT_ROUGHNESS);
} }

View file

@ -46,14 +46,10 @@ void main(void) {
<$fetchFadeObjectParamsInstanced(fadeParams)$> <$fetchFadeObjectParamsInstanced(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive); applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
vec4 texel = texture(originalTexture, _texCoord0.st); vec4 texel = texture(originalTexture, _texCoord0);
float opacity = _color.a; texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
if (_color.a <= 0.0) { texel.rgb *= _color.rgb;
texel = color_sRGBAToLinear(texel); texel.a *= abs(_color.a);
opacity = -_color.a;
}
opacity *= texel.a;
vec3 albedo = _color.rgb * texel.rgb;
vec3 fragPosition = _positionES.xyz; vec3 fragPosition = _positionES.xyz;
vec3 fragNormal = normalize(_normalWS); vec3 fragNormal = normalize(_normalWS);
@ -66,12 +62,11 @@ void main(void) {
1.0, 1.0,
fragPosition, fragPosition,
fragNormal, fragNormal,
albedo, texel.rgb,
DEFAULT_FRESNEL, DEFAULT_FRESNEL,
0.0f, 0.0f,
fadeEmissive, fadeEmissive,
DEFAULT_ROUGHNESS, DEFAULT_ROUGHNESS,
opacity), texel.a),
opacity); texel.a);
} }

View file

@ -27,11 +27,10 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
layout(location=0) out vec4 _fragColor0; layout(location=0) out vec4 _fragColor0;
void main(void) { void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st); vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a; texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
if (_color.a <= 0.0) { texel.rgb *= _color.rgb;
texel = color_sRGBAToLinear(texel); texel.a *= abs(_color.a);
colorAlpha = -_color.a;
} _fragColor0 = texel;
_fragColor0 = vec4(_color.rgb * texel.rgb, colorAlpha * texel.a);
} }

View file

@ -39,11 +39,10 @@ void main(void) {
<$fetchFadeObjectParamsInstanced(fadeParams)$> <$fetchFadeObjectParamsInstanced(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive); applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
vec4 texel = texture(originalTexture, _texCoord0.st); vec4 texel = texture(originalTexture, _texCoord0);
float colorAlpha = _color.a; texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
if (_color.a <= 0.0) { texel.rgb *= _color.rgb;
texel = color_sRGBAToLinear(texel); texel.a *= abs(_color.a);
colorAlpha = -_color.a;
} _fragColor0 = vec4(texel.rgb + fadeEmissive, texel.a);
_fragColor0 = vec4(_color.rgb * texel.rgb + fadeEmissive, colorAlpha * texel.a);
} }

View file

@ -219,26 +219,24 @@ vec3 getTapLocationClampedSSAO(int sampleNumber, float spinAngle, float outerRad
} }
bool redoTap = false; bool redoTap = false;
if ((tapPos.x < 0.5)) { {
tapPos.x = -tapPos.x; float check1 = float(tapPos.x < 0.5);
redoTap = true; float check2 = (1.0 - check1) * float(tapPos.x > sideImageSize.x - 0.5);
} else if ((tapPos.x > sideImageSize.x - 0.5)) { tapPos.x = tapPos.x - 2.0 * tapPos.x * check1 - check2 * (sideImageSize.x - tapPos.x);
tapPos.x -= (sideImageSize.x - tapPos.x); redoTap = (check1 > 0.0 || check2 > 0.0);
redoTap = true;
} }
if ((tapPos.y < 0.5)) { {
tapPos.y = -tapPos.y; float check1 = float(tapPos.y < 0.5);
redoTap = true; float check2 = (1.0 - check1) * float(tapPos.y > sideImageSize.y - 0.5);
} else if ((tapPos.y > sideImageSize.y - 0.5)) { tapPos.y = tapPos.y - 2.0 * tapPos.y * check1 - check2 * (sideImageSize.y - tapPos.y);
tapPos.y -= (sideImageSize.y - tapPos.y); redoTap = (check1 > 0.0 || check2 > 0.0);
redoTap = true;
} }
if (redoTap) { {
tap.xy = tapPos - pixelPos; float check = float(redoTap);
tap.z = length(tap.xy); tap.xy = mix(tap.xy, tapPos - pixelPos, check);
tap.z = 0.0; tap.z = (1.0 - check) * tap.z;
} }
return tap; return tap;

View file

@ -39,6 +39,7 @@ layout(location=0) out vec4 outFragColor;
void main(void) { void main(void) {
// Stereo side info based on the real viewport size of this pass // Stereo side info based on the real viewport size of this pass
vec2 sideDepthSize = getDepthTextureSideSize(0); vec2 sideDepthSize = getDepthTextureSideSize(0);
// Pixel Debugged // Pixel Debugged
vec2 cursorUV = getDebugCursorTexcoord(); vec2 cursorUV = getDebugCursorTexcoord();
vec2 cursorPixelPos = cursorUV * sideDepthSize; vec2 cursorPixelPos = cursorUV * sideDepthSize;
@ -46,6 +47,5 @@ void main(void) {
ivec2 fragUVPos = ivec2(cursorPixelPos); ivec2 fragUVPos = ivec2(cursorPixelPos);
// TODO // TODO
outFragColor = packOcclusionOutput(0.0, 0.0, vec3(0.0, 0.0, 1.0)); outFragColor = packOcclusionOutput(0.0, 0.0, vec3(0.0, 0.0, 1.0));
} }

View file

@ -43,6 +43,7 @@ void main(void) {
} else { } else {
sideOcclusionSize = ivec2( getOcclusionSideSize() ); sideOcclusionSize = ivec2( getOcclusionSideSize() );
} }
ivec4 side = getStereoSideInfoFromWidth(fragPixelPos.x, sideOcclusionSize.x); ivec4 side = getStereoSideInfoFromWidth(fragPixelPos.x, sideOcclusionSize.x);
// From now on, fragUVPos is the UV pos in the side // From now on, fragUVPos is the UV pos in the side
fragUVPos = getSideUVFromFramebufferUV(side, fragUVPos); fragUVPos = getSideUVFromFramebufferUV(side, fragUVPos);

View file

@ -18,6 +18,9 @@ float aspectRatio = 0.95;
void main(void) { void main(void) {
vec2 pos = varTexCoord0 * 2.0 - vec2(1.0); vec2 pos = varTexCoord0 * 2.0 - vec2(1.0);
pos.x = aspectRatio * (pos.x * (pos.x > 0.0 ? 2.0 : -2.0) - 1.0); pos.x = aspectRatio * (pos.x * mix(-2.0, 2.0, float(pos.x > 0.0)) - 1.0);
if (1.0 - dot(pos.xy, pos.xy) > 0.0 ) discard;
if (1.0 - dot(pos.xy, pos.xy) > 0.0) {
discard;
}
} }

View file

@ -93,14 +93,14 @@ vec3 drawScatteringTableUV(vec2 cursor, vec2 texcoord) {
vec3 color = vec3(0.0); vec3 color = vec3(0.0);
bool keep = false; bool keep = false;
for (int c = 0; c < 3; c++) { for (int c = 0; c < 3; c++) {
if (distance[c] > threshold) { bool check = distance[c] > threshold;
keep = true; keep = keep || check;
color[c] += 1.0; color[c] += float(check);
}
} }
if (!keep) if (!keep) {
discard; discard;
}
return color; return color;
} }

View file

@ -67,11 +67,7 @@ vec3 getRawNormal(vec2 texcoord) {
vec3 getWorldNormal(vec2 texcoord) { vec3 getWorldNormal(vec2 texcoord) {
vec3 rawNormal = getRawNormal(texcoord); vec3 rawNormal = getRawNormal(texcoord);
if (isFullResolution()) { return mix(normalize((rawNormal - vec3(0.5)) * 2.0), unpackNormal(rawNormal), float(isFullResolution()));
return unpackNormal(rawNormal);
} else {
return normalize((rawNormal - vec3(0.5)) * 2.0);
}
} }
vec3 getWorldNormalDiff(vec2 texcoord, vec2 delta) { vec3 getWorldNormalDiff(vec2 texcoord, vec2 delta) {
@ -93,7 +89,7 @@ void main(void) {
vec2 texcoordPos; vec2 texcoordPos;
ivec4 stereoSide; ivec4 stereoSide;
ivec2 framePixelPos = getPixelPosTexcoordPosAndSide(gl_FragCoord.xy, pixelPos, texcoordPos, stereoSide); ivec2 framePixelPos = getPixelPosTexcoordPosAndSide(gl_FragCoord.xy, pixelPos, texcoordPos, stereoSide);
vec2 stereoSideClip = vec2(stereoSide.x, (isStereo() ? 0.5 : 1.0)); 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 // Texcoord to fetch in the deferred texture are the exact UVs comming from vertex shader
// sideToFrameTexcoord(stereoSideClip, texcoordPos); // sideToFrameTexcoord(stereoSideClip, texcoordPos);
@ -128,7 +124,7 @@ void main(void) {
// Calculate dF/du and dF/dv // Calculate dF/du and dF/dv
vec2 viewportScale = perspectiveScale * getInvWidthHeight(); vec2 viewportScale = perspectiveScale * getInvWidthHeight();
vec2 du = vec2( viewportScale.x * (float(stereoSide.w) > 0.0 ? 0.5 : 1.0), 0.0f ); vec2 du = vec2(viewportScale.x * (1.0 - 0.5 * float(stereoSide.w > 0)), 0.0);
vec2 dv = vec2( 0.0f, viewportScale.y); vec2 dv = vec2( 0.0f, viewportScale.y);
vec4 dFdu = vec4(getWorldNormalDiff(frameTexcoordPos, du), getEyeDepthDiff(frameTexcoordPos, du)); vec4 dFdu = vec4(getWorldNormalDiff(frameTexcoordPos, du), getEyeDepthDiff(frameTexcoordPos, du));

View file

@ -36,16 +36,10 @@ void main() {
vec3 nextColor = sourceColor; vec3 nextColor = sourceColor;
if (taa_constrainColor()) {
// clamp history to neighbourhood of current sample // clamp history to neighbourhood of current sample
historyColor = taa_evalConstrainColor(sourceColor, fragUV, fragVel, historyColor); historyColor = mix(historyColor, taa_evalConstrainColor(sourceColor, fragUV, fragVel, historyColor), float(taa_constrainColor()));
}
if (taa_feedbackColor()) { nextColor = mix(mix(historyColor, sourceColor, params.blend), taa_evalFeedbackColor(sourceColor, historyColor, params.blend), float(taa_feedbackColor()));
nextColor = taa_evalFeedbackColor(sourceColor, historyColor, params.blend);
} else {
nextColor = mix(historyColor, sourceColor, params.blend);
}
outFragColor = vec4(taa_resolveColor(nextColor), 1.0); outFragColor = vec4(taa_resolveColor(nextColor), 1.0);
} }

View file

@ -121,21 +121,17 @@ float taa_fetchDepth(vec2 uv) {
} }
#define ZCMP_GT(a, b) (a > b) #define ZCMP_GT(a, b) float(a > b)
vec2 taa_getImageSize() { vec2 taa_getImageSize() {
vec2 imageSize = getWidthHeight(0); vec2 imageSize = getWidthHeight(0);
if (isStereo()) { imageSize.x *= 1.0 + float(isStereo());
imageSize.x *= 2.0;
}
return imageSize; return imageSize;
} }
vec2 taa_getTexelSize() { vec2 taa_getTexelSize() {
vec2 texelSize = getInvWidthHeight(); vec2 texelSize = getInvWidthHeight();
if (isStereo()) { texelSize.x *= 1.0 - 0.5 * float(isStereo());
texelSize.x *= 0.5;
}
return texelSize; return texelSize;
} }
@ -158,16 +154,16 @@ vec3 taa_findClosestFragment3x3(vec2 uv)
vec3 dbr = vec3( 1, 1, taa_fetchDepth(uv + dv + du)); vec3 dbr = vec3( 1, 1, taa_fetchDepth(uv + dv + du));
vec3 dmin = dtl; vec3 dmin = dtl;
if (ZCMP_GT(dmin.z, dtc.z)) dmin = dtc; dmin = mix(dmin, dtc, ZCMP_GT(dmin.z, dtc.z));
if (ZCMP_GT(dmin.z, dtr.z)) dmin = dtr; dmin = mix(dmin, dtr, ZCMP_GT(dmin.z, dtr.z));
if (ZCMP_GT(dmin.z, dml.z)) dmin = dml; dmin = mix(dmin, dml, ZCMP_GT(dmin.z, dml.z));
if (ZCMP_GT(dmin.z, dmc.z)) dmin = dmc; dmin = mix(dmin, dmc, ZCMP_GT(dmin.z, dmc.z));
if (ZCMP_GT(dmin.z, dmr.z)) dmin = dmr; dmin = mix(dmin, dmr, ZCMP_GT(dmin.z, dmr.z));
if (ZCMP_GT(dmin.z, dbl.z)) dmin = dbl; dmin = mix(dmin, dbl, ZCMP_GT(dmin.z, dbl.z));
if (ZCMP_GT(dmin.z, dbc.z)) dmin = dbc; dmin = mix(dmin, dbc, ZCMP_GT(dmin.z, dbc.z));
if (ZCMP_GT(dmin.z, dbr.z)) dmin = dbr; dmin = mix(dmin, dbr, ZCMP_GT(dmin.z, dbr.z));
return vec3(uv + dd.xy * dmin.xy, dmin.z); return vec3(uv + dd.xy * dmin.xy, dmin.z);
} }
@ -192,46 +188,43 @@ vec2 taa_fetchVelocityMapBest(vec2 uv) {
vec3 best = vec3(dtl, dot(dtl, dtl)); vec3 best = vec3(dtl, dot(dtl, dtl));
float testSpeed = dot(dtc, dtc); float testSpeed = dot(dtc, dtc);
if (testSpeed > best.z) { best = vec3(dtc, testSpeed); } mix(best, vec3(dtc, testSpeed), float(testSpeed > best.z));
testSpeed = dot(dtr, dtr); testSpeed = dot(dtr, dtr);
if (testSpeed > best.z) { best = vec3(dtr, testSpeed); } mix(best, vec3(dtr, testSpeed), float(testSpeed > best.z));
testSpeed = dot(dml, dml); testSpeed = dot(dml, dml);
if (testSpeed > best.z) { best = vec3(dml, testSpeed); } mix(best, vec3(dml, testSpeed), float(testSpeed > best.z));
testSpeed = dot(dmc, dmc); testSpeed = dot(dmc, dmc);
if (testSpeed > best.z) { best = vec3(dmc, testSpeed); } mix(best, vec3(dmc, testSpeed), float(testSpeed > best.z));
testSpeed = dot(dmr, dmr); testSpeed = dot(dmr, dmr);
if (testSpeed > best.z) { best = vec3(dmr, testSpeed); } mix(best, vec3(dmr, testSpeed), float(testSpeed > best.z));
testSpeed = dot(dbl, dbl); testSpeed = dot(dbl, dbl);
if (testSpeed > best.z) { best = vec3(dbl, testSpeed); } mix(best, vec3(dbl, testSpeed), float(testSpeed > best.z));
testSpeed = dot(dbc, dbc); testSpeed = dot(dbc, dbc);
if (testSpeed > best.z) { best = vec3(dbc, testSpeed); } mix(best, vec3(dbc, testSpeed), float(testSpeed > best.z));
testSpeed = dot(dbr, dbr); testSpeed = dot(dbr, dbr);
if (testSpeed > best.z) { best = vec3(dbr, testSpeed); } mix(best, vec3(dbr, testSpeed), float(testSpeed > best.z));
return best.xy; return best.xy;
} }
vec2 taa_fromFragUVToEyeUVAndSide(vec2 fragUV, out int stereoSide) { vec2 taa_fromFragUVToEyeUVAndSide(vec2 fragUV, out int stereoSide) {
vec2 eyeUV = fragUV; vec2 eyeUV = fragUV;
stereoSide = 0;
if (isStereo()) { float check = float(isStereo());
if (eyeUV.x > 0.5) { float check2 = float(eyeUV.x > 0.5);
eyeUV.x -= 0.5; eyeUV.x -= check * check2 * 0.5;
stereoSide = 1; stereoSide = int(check * check2);
} eyeUV.x *= 1.0 + check;
eyeUV.x *= 2.0;
}
return eyeUV; return eyeUV;
} }
vec2 taa_fromEyeUVToFragUV(vec2 eyeUV, int stereoSide) { vec2 taa_fromEyeUVToFragUV(vec2 eyeUV, int stereoSide) {
vec2 fragUV = eyeUV; vec2 fragUV = eyeUV;
if (isStereo()) { float check = float(isStereo());
fragUV.x *= 0.5; fragUV.x *= 1.0 - 0.5 * check;
fragUV.x += float(stereoSide)*0.5; fragUV.x += check * float(stereoSide) * 0.5;
}
return fragUV; return fragUV;
} }
@ -247,10 +240,8 @@ vec2 taa_fetchSourceAndHistory(vec2 fragUV, vec2 fragVelocity, out vec3 sourceCo
vec2 prevFragUV = taa_computePrevFragAndEyeUV(fragUV, fragVelocity, prevEyeUV); vec2 prevFragUV = taa_computePrevFragAndEyeUV(fragUV, fragVelocity, prevEyeUV);
sourceColor = taa_fetchSourceMap(fragUV).xyz; sourceColor = taa_fetchSourceMap(fragUV).xyz;
historyColor = sourceColor; historyColor = mix(sourceColor, taa_fetchHistoryMap(prevFragUV).xyz, float(!(any(lessThan(prevEyeUV, vec2(0.0))) || any(greaterThan(prevEyeUV, vec2(1.0))))));
if (!(any(lessThan(prevEyeUV, vec2(0.0))) || any(greaterThan(prevEyeUV, vec2(1.0))))) {
historyColor = taa_fetchHistoryMap(prevFragUV).xyz;
}
return prevFragUV; return prevFragUV;
} }
@ -405,11 +396,12 @@ vec3 taa_clampColor(vec3 colorMin, vec3 colorMax, vec3 colorSource, vec3 color)
vec3 a_unit = abs(v_unit); vec3 a_unit = abs(v_unit);
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z)); float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
if (ma_unit > 1.0) if (ma_unit > 1.0) {
return p_clip + v_clip / ma_unit; return p_clip + v_clip / ma_unit;
else } else {
return q;// point inside aabb return q;// point inside aabb
} }
}
vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, vec3 candidateColor) { vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, vec3 candidateColor) {
mat3 colorMinMaxAvg; mat3 colorMinMaxAvg;
@ -514,10 +506,6 @@ vec3 taa_evalFXAA(vec2 fragUV) {
// compare luma of new samples to the luma range of the original neighborhood // compare luma of new samples to the luma range of the original neighborhood
// if the new samples exceed this range, just use the first two samples instead of all four // if the new samples exceed this range, just use the first two samples instead of all four
if (lumaB < lumaMin || lumaB > lumaMax) { return mix(rgbB, rgbA, float(lumaB < lumaMin || lumaB > lumaMax));
return rgbA;
} else {
return rgbB;
}
} }

View file

@ -83,32 +83,21 @@ void main(void) {
if ((prevOrbPosToPixLength < tenPercentHeight) && (cursorVelocityLength > 0.5)) { if ((prevOrbPosToPixLength < tenPercentHeight) && (cursorVelocityLength > 0.5)) {
vec2 prevOrbPosToPix_uv = cursorPrevUV + prevOrbPosToPix * texelSize / taa_getDebugOrbZoom(); vec2 prevOrbPosToPix_uv = cursorPrevUV + prevOrbPosToPix * texelSize / taa_getDebugOrbZoom();
vec3 preOrbColor = vec3(0.0); vec3 preOrbColor = vec3(0.0);
if (!(any(lessThan(prevOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(prevOrbPosToPix_uv, vec2(1.0))))) {
preOrbColor = texture(historyMap, prevOrbPosToPix_uv).xyz; preOrbColor = mix(preOrbColor, texture(historyMap, prevOrbPosToPix_uv).xyz, float(!(any(lessThan(prevOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(prevOrbPosToPix_uv, vec2(1.0))))));
} preOrbColor = mix(preOrbColor, vec3(1.0, 0.0, 1.0), float(prevOrbPosToPixLength < orbPixThreshold));
if (prevOrbPosToPixLength < orbPixThreshold) {
preOrbColor = vec3(1.0, 0.0, 1.0);
}
float distanceToNext = length(imageSize * (cursorUV - prevOrbPosToPix_uv)); float distanceToNext = length(imageSize * (cursorUV - prevOrbPosToPix_uv));
if (distanceToNext < orbPixThreshold) { preOrbColor = mix(preOrbColor, vec3(1.0, 0.5, 0.0), float(distanceToNext < orbPixThreshold));
preOrbColor = vec3(1.0, 0.5, 0.0);
}
outFragColor = vec4(preOrbColor, 1.0); outFragColor = vec4(preOrbColor, 1.0);
return; return;
} }
if (nextOrbPosToPixLength < tenPercentHeight) { if (nextOrbPosToPixLength < tenPercentHeight) {
vec2 nextOrbPosToPix_uv = cursorUV + nextOrbPosToPix * texelSize / taa_getDebugOrbZoom(); vec2 nextOrbPosToPix_uv = cursorUV + nextOrbPosToPix * texelSize / taa_getDebugOrbZoom();
vec3 nextOrbColor = vec3(0.0); vec3 nextOrbColor = vec3(0.0);
if (!(any(lessThan(nextOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(nextOrbPosToPix_uv, vec2(1.0))))) { nextOrbColor = mix(nextOrbColor, texture(nextMap, nextOrbPosToPix_uv).xyz, float(!(any(lessThan(nextOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(nextOrbPosToPix_uv, vec2(1.0))))));
nextOrbColor = texture(nextMap, nextOrbPosToPix_uv).xyz;
}
float distanceToPrev = length(imageSize * (cursorPrevUV - nextOrbPosToPix_uv)); float distanceToPrev = length(imageSize * (cursorPrevUV - nextOrbPosToPix_uv));
if (distanceToPrev < orbPixThreshold) { nextOrbColor = mix(nextOrbColor, vec3(1.0, 0.0, 1.0), float(distanceToPrev < orbPixThreshold));
nextOrbColor = vec3(1.0, 0.0, 1.0); nextOrbColor = mix(nextOrbColor, vec3(1.0, 0.5, 0.0), float(nextOrbPosToPixLength < orbPixThreshold));
}
if (nextOrbPosToPixLength < orbPixThreshold) {
nextOrbColor = vec3(1.0, 0.5, 0.0);
}
outFragColor = vec4(nextOrbColor, 1.0); outFragColor = vec4(nextOrbColor, 1.0);
return; return;
@ -141,16 +130,9 @@ void main(void) {
outFragColor = vec4(nextColor, 1.0); outFragColor = vec4(nextColor, 1.0);
vec3 prevColor = nextColor; vec3 prevColor = nextColor;
prevColor = mix(prevColor, texture(historyMap, prevTexCoord).xyz, float(!(any(lessThan(prevTexCoord, vec2(0.0))) || any(greaterThan(prevTexCoord, vec2(1.0))))));
if (!(any(lessThan(prevTexCoord, vec2(0.0))) || any(greaterThan(prevTexCoord, vec2(1.0))))) {
prevColor = texture(historyMap, prevTexCoord).xyz;
}
outFragColor.xyz = mix(prevColor, vec3(1, 0, 1), clamp(distance(prevColor, nextColor) - 0.01, 0.0, 1.0)); outFragColor.xyz = mix(prevColor, vec3(1, 0, 1), clamp(distance(prevColor, nextColor) - 0.01, 0.0, 1.0));
if (pixVelocityLength > params.debugShowVelocityThreshold) { outFragColor = mix(outFragColor, vec4(0.0, 1.0, 1.0, 1.0), float(pixVelocityLength > params.debugShowVelocityThreshold));
vec3 speedColor = taa_getVelocityColorAboveThreshold(pixVelocityLength);
outFragColor = vec4(0.0, 1.0, 1.0, 1.0);
}
} }

View file

@ -44,7 +44,7 @@ void main(void) {
// vec3 ambient = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(lightAmbient), fragNormal).xyz; // vec3 ambient = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(lightAmbient), fragNormal).xyz;
// _fragColor = vec4( 0.5 * (fragNormal + vec3(1.0)), 1.0); // _fragColor = vec4( 0.5 * (fragNormal + vec3(1.0)), 1.0);
vec3 color = (sphereUV.x > 0.0 ? ambientMap : ambientSH); vec3 color = mix(ambientSH, ambientMap, float(sphereUV.x > 0.0));
color = color * 1.0 - base.w + base.xyz * base.w; color = color * 1.0 - base.w + base.xyz * base.w;
const float INV_GAMMA_22 = 1.0 / 2.2; const float INV_GAMMA_22 = 1.0 / 2.2;

View file

@ -35,16 +35,11 @@ void main(void) {
vec3 color = skybox.color.rgb; vec3 color = skybox.color.rgb;
// blend is only set if there is a cubemap // blend is only set if there is a cubemap
if (skybox.color.a > 0.0) { float check = float(skybox.color.a > 0.0);
color = texture(skyboxMap, direction).rgb; color = mix(color, texture(skyboxMap, direction).rgb, check);
if (skybox.color.a < 1.0) { color *= mix(vec3(1.0), skybox.color.rgb, check * float(skybox.color.a < 1.0));
color *= skybox.color.rgb;
}
}
color = color * 1.0 - base.w + base.xyz * base.w; color = color * 1.0 - base.w + base.xyz * base.w;
const float INV_GAMMA_22 = 1.0 / 2.2; const float INV_GAMMA_22 = 1.0 / 2.2;
_fragColor = vec4(pow(color, vec3(INV_GAMMA_22)), 1.0); _fragColor = vec4(pow(color, vec3(INV_GAMMA_22)), 1.0);
} }

View file

@ -102,6 +102,7 @@ vec4 pixelShaderGaussian(vec2 texcoord, vec2 direction, vec2 pixelStep) {
if (totalWeight > 0.0) { if (totalWeight > 0.0) {
srcBlurred /= totalWeight; srcBlurred /= totalWeight;
} }
srcBlurred.a = getOutputAlpha(); srcBlurred.a = getOutputAlpha();
return srcBlurred; return srcBlurred;
} }
@ -163,6 +164,7 @@ vec4 pixelShaderGaussianDepthAware(vec2 texcoord, vec2 direction, vec2 pixelStep
if (totalWeight > 0.0) { if (totalWeight > 0.0) {
srcBlurred /= totalWeight; srcBlurred /= totalWeight;
} }
return srcBlurred; return srcBlurred;
} }

View file

@ -51,7 +51,7 @@ void main(void) {
vec4 pos = UNIT_BOX[UNIT_BOX_LINE_INDICES[gl_VertexID]]; vec4 pos = UNIT_BOX[UNIT_BOX_LINE_INDICES[gl_VertexID]];
int cellIsEmpty = sign(inCellLocation.w); int cellIsEmpty = sign(inCellLocation.w);
ivec4 cellLocation = ivec4(inCellLocation.xyz, (inCellLocation.w < 0 ? -inCellLocation.w : inCellLocation.w)); ivec4 cellLocation = ivec4(inCellLocation.xyz, abs(inCellLocation.w));
vec4 cellBound = evalBound(cellLocation); vec4 cellBound = evalBound(cellLocation);
pos.xyz = cellBound.xyz + vec3(cellBound.w) * pos.xyz; pos.xyz = cellBound.xyz + vec3(cellBound.w) * pos.xyz;

View file

@ -18,11 +18,7 @@ layout(location=0) out vec4 outFragColor;
void main(void) { void main(void) {
float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5); float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5);
if (varColor.a == 0.0) { outFragColor = mix(vec4(mix(vec3(1.0), varColor.xyz, var), varColor.a),
outFragColor = 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));
} else {
outFragColor = vec4(mix(vec3(1.0), varColor.xyz, var), varColor.a);
}
} }

View file

@ -98,11 +98,6 @@ void main(void) {
TransformObject obj = getTransformObject(); TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, pos, gl_Position)$> <$transformModelToClipPos(cam, obj, pos, gl_Position)$>
if (params.color.w < 0.0) { varColor = mix(vec4(colorWheel(float(params.color.w)), 1.0), vec4(colorWheel(float(boundID)/(-params.color.w)), 1.0), float(params.color.w < 0.0));
varColor = vec4(colorWheel(float(boundID)/(-params.color.w)), 1.0);
} else {
varColor = vec4(colorWheel(float(params.color.w)), 1.0);
}
varTexcoord = vec2(cubeVec.w, length(boundDim)); varTexcoord = vec2(cubeVec.w, length(boundDim));
} }

View file

@ -22,10 +22,9 @@ vec2 getIconTexcoord(float icon, vec2 uv) {
} }
void main(void) { void main(void) {
if (varTexcoord.z < 254.5) {
outFragColor = texture(_icons, getIconTexcoord(varTexcoord.z, varTexcoord.xy)) * varColor;
} else {
vec2 centerDir = varTexcoord.xy * 2.0f - 1.0f; vec2 centerDir = varTexcoord.xy * 2.0f - 1.0f;
outFragColor = vec4(varColor.xyz, 1.0 - step(1.0f, dot(centerDir.xy, centerDir.xy)));
} outFragColor = mix(vec4(varColor.xyz, 1.0 - step(1.0f, dot(centerDir.xy, centerDir.xy))),
texture(_icons, getIconTexcoord(varTexcoord.z, varTexcoord.xy)) * varColor,
float(varTexcoord.z < 254.5));
} }