mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #14293 from SamGondelman/branching
Case 19473: Reduce branching in our shaders
This commit is contained in:
commit
653974ca30
64 changed files with 366 additions and 516 deletions
|
@ -14,8 +14,6 @@ void main(void) {
|
|||
ivec2 texCoord = ivec2(floor(varTexCoord0 * vec2(textureData.textureSize)));
|
||||
texCoord.x /= 2;
|
||||
int row = int(floor(gl_FragCoord.y));
|
||||
if (row % 2 > 0) {
|
||||
texCoord.x += (textureData.textureSize.x / 2);
|
||||
}
|
||||
texCoord.x += int(row % 2 > 0) * (textureData.textureSize.x / 2);
|
||||
outFragColor = vec4(pow(texelFetch(colorMap, texCoord, 0).rgb, vec3(2.2)), 1.0);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ layout(location=0) out vec4 outFragColor;
|
|||
float sRGBFloatToLinear(float value) {
|
||||
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) {
|
||||
|
|
|
@ -80,10 +80,11 @@ float interpolate3Points(float y1, float y2, float y3, float u) {
|
|||
halfSlope = (y3 - y1) / 2.0f;
|
||||
float slope12 = y2 - y1;
|
||||
float slope23 = y3 - y2;
|
||||
if (abs(halfSlope) > abs(slope12)) {
|
||||
halfSlope = slope12;
|
||||
} else if (abs(halfSlope) > abs(slope23)) {
|
||||
halfSlope = slope23;
|
||||
|
||||
{
|
||||
float check = float(abs(halfSlope) > abs(slope12));
|
||||
halfSlope = mix(halfSlope, slope12, check);
|
||||
halfSlope = mix(halfSlope, slope23, (1.0 - check) * float(abs(halfSlope) > abs(slope23)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,7 +231,8 @@ float snoise(vec2 v) {
|
|||
|
||||
// Other corners
|
||||
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;
|
||||
x12.xy -= i1;
|
||||
|
||||
|
|
|
@ -152,28 +152,28 @@ float fetchScatteringMap(vec2 uv) {
|
|||
|
||||
<@func fetchMaterialTexturesCoord0(matKey, texcoord0, albedo, roughness, normal, metallic, emissive, scattering)@>
|
||||
<@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@>
|
||||
<@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@>
|
||||
<@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@>
|
||||
<@if metallic@>
|
||||
float <$metallic$> = (((<$matKey$> & METALLIC_MAP_BIT) != 0) ? fetchMetallicMap(<$texcoord0$>) : 0.0);
|
||||
float <$metallic$> = float((<$matKey$> & METALLIC_MAP_BIT) != 0) * fetchMetallicMap(<$texcoord0$>);
|
||||
<@endif@>
|
||||
<@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@>
|
||||
<@if scattering@>
|
||||
float <$scattering$> = (((<$matKey$> & SCATTERING_MAP_BIT) != 0) ? fetchScatteringMap(<$texcoord0$>) : 0.0);
|
||||
float <$scattering$> = float((<$matKey$> & SCATTERING_MAP_BIT) != 0) * fetchScatteringMap(<$texcoord0$>);
|
||||
<@endif@>
|
||||
<@endfunc@>
|
||||
|
||||
<@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmap)@>
|
||||
<@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@>
|
||||
<@if lightmap@>
|
||||
vec3 <$lightmap$> = fetchLightmapMap(<$texcoord1$>);
|
||||
|
@ -207,20 +207,19 @@ vec3 fetchLightmapMap(vec2 uv) {
|
|||
|
||||
<@func evalMaterialAlbedo(fetchedAlbedo, materialAlbedo, matKey, albedo)@>
|
||||
{
|
||||
<$albedo$>.xyz = (((<$matKey$> & ALBEDO_VAL_BIT) != 0) ? <$materialAlbedo$> : vec3(1.0));
|
||||
|
||||
if (((<$matKey$> & ALBEDO_MAP_BIT) != 0)) {
|
||||
<$albedo$>.xyz *= <$fetchedAlbedo$>.xyz;
|
||||
}
|
||||
<$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));
|
||||
}
|
||||
<@endfunc@>
|
||||
|
||||
<@func evalMaterialOpacity(fetchedOpacity, materialOpacity, matKey, opacity)@>
|
||||
{
|
||||
const float OPACITY_MASK_THRESHOLD = 0.5;
|
||||
<$opacity$> = (((<$matKey$> & (OPACITY_TRANSLUCENT_MAP_BIT | OPACITY_MASK_MAP_BIT)) != 0) ?
|
||||
(((<$matKey$> & OPACITY_MASK_MAP_BIT) != 0) ? step(OPACITY_MASK_THRESHOLD, <$fetchedOpacity$>) : <$fetchedOpacity$>) :
|
||||
1.0) * <$materialOpacity$>;
|
||||
<$opacity$> = mix(1.0,
|
||||
mix(<$fetchedOpacity$>,
|
||||
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@>
|
||||
|
||||
|
@ -241,19 +240,19 @@ vec3 fetchLightmapMap(vec2 uv) {
|
|||
|
||||
<@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@>
|
||||
|
||||
<@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@>
|
||||
|
||||
<@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@>
|
||||
|
||||
|
@ -265,7 +264,7 @@ vec3 fetchLightmapMap(vec2 uv) {
|
|||
|
||||
<@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@>
|
||||
|
||||
|
|
|
@ -30,11 +30,9 @@ void main(void) {
|
|||
vec3 color = skybox.color.rgb;
|
||||
|
||||
// blend is only set if there is a cubemap
|
||||
if (skybox.color.a > 0.0) {
|
||||
color = texture(cubeMap, coord).rgb;
|
||||
if (skybox.color.a < 1.0) {
|
||||
color *= skybox.color.rgb;
|
||||
}
|
||||
}
|
||||
float check = float(skybox.color.a > 0.0);
|
||||
color = mix(color, texture(cubeMap, coord).rgb, check);
|
||||
color *= mix(vec3(1.0), skybox.color.rgb, check * float(skybox.color.a < 1.0));
|
||||
|
||||
_fragColor = vec4(color, 0.0);
|
||||
}
|
||||
|
|
|
@ -76,15 +76,10 @@ DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) {
|
|||
|
||||
// Diffuse color and unpack the mode and the metallicness
|
||||
frag.albedo = diffuseVal.xyz;
|
||||
frag.scattering = 0.0;
|
||||
unpackModeMetallic(diffuseVal.w, frag.mode, frag.metallic);
|
||||
|
||||
frag.obscurance = min(specularVal.w, frag.obscurance);
|
||||
|
||||
if (frag.mode == FRAG_MODE_SCATTERING) {
|
||||
frag.scattering = specularVal.x;
|
||||
}
|
||||
|
||||
frag.scattering = float(frag.mode == FRAG_MODE_SCATTERING) * specularVal.x;
|
||||
frag.fresnel = getFresnelF0(frag.metallic, diffuseVal.xyz);
|
||||
|
||||
return frag;
|
||||
|
@ -122,14 +117,11 @@ DeferredFragment unpackDeferredFragmentNoPositionNoAmbient(vec2 texcoord) {
|
|||
<$declareDeferredFrameTransform()$>
|
||||
|
||||
vec4 unpackDeferredPosition(float depthValue, vec2 texcoord) {
|
||||
int side = 0;
|
||||
if (isStereo()) {
|
||||
if (texcoord.x > 0.5) {
|
||||
texcoord.x -= 0.5;
|
||||
side = 1;
|
||||
}
|
||||
texcoord.x *= 2.0;
|
||||
}
|
||||
float check = float(isStereo());
|
||||
float check2 = check * float(texcoord.x > 0.5);
|
||||
texcoord.x -= check2 * 0.5;
|
||||
int side = int(check2);
|
||||
texcoord.x *= 1.0 + check;
|
||||
|
||||
return vec4(evalEyePositionFromZdb(side, depthValue, texcoord), 1.0);
|
||||
}
|
||||
|
@ -142,19 +134,17 @@ vec4 unpackDeferredPositionFromZdb(vec2 texcoord) {
|
|||
|
||||
vec4 unpackDeferredPositionFromZeye(vec2 texcoord) {
|
||||
float Zeye = -texture(linearZeyeMap, texcoord).x;
|
||||
int side = 0;
|
||||
if (isStereo()) {
|
||||
if (texcoord.x > 0.5) {
|
||||
texcoord.x -= 0.5;
|
||||
side = 1;
|
||||
}
|
||||
texcoord.x *= 2.0;
|
||||
}
|
||||
|
||||
float check = float(isStereo());
|
||||
float check2 = check * float(texcoord.x > 0.5);
|
||||
texcoord.x -= check2 * 0.5;
|
||||
int side = int(check2);
|
||||
texcoord.x *= 1.0 + check;
|
||||
|
||||
return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0);
|
||||
}
|
||||
|
||||
DeferredFragment unpackDeferredFragment(DeferredFrameTransform deferredTransform, vec2 texcoord) {
|
||||
|
||||
float depthValue = texture(depthMap, texcoord).r;
|
||||
|
||||
DeferredFragment frag = unpackDeferredFragmentNoPosition(texcoord);
|
||||
|
|
|
@ -32,9 +32,11 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness
|
|||
if (alpha != 1.0) {
|
||||
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));
|
||||
_fragColor2 = vec4(((scattering > 0.0) ? vec3(scattering) : emissive), occlusion);
|
||||
_fragColor2 = vec4(mix(emissive, vec3(scattering), check), occlusion);
|
||||
|
||||
_fragColor3 = vec4(isEmissiveEnabled() * emissive, 1.0);
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ bool isStereo() {
|
|||
float getStereoSideWidth(int resolutionLevel) {
|
||||
return float(int(frameTransform._stereoInfo.y) >> resolutionLevel);
|
||||
}
|
||||
|
||||
float getStereoSideHeight(int resolutionLevel) {
|
||||
return float(int(frameTransform._pixelInfo.w) >> resolutionLevel);
|
||||
}
|
||||
|
@ -125,7 +126,7 @@ vec2 getStereoSideSize(int resolutionLevel) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -85,10 +85,8 @@ float evalFadeGradient(FadeObjectParams params, vec3 position) {
|
|||
}
|
||||
|
||||
float evalFadeAlpha(FadeObjectParams params, vec3 position) {
|
||||
float alpha = evalFadeGradient(params, position)-params.threshold;
|
||||
if (fadeParameters[params.category]._isInverted != 0) {
|
||||
alpha = -alpha;
|
||||
}
|
||||
float alpha = evalFadeGradient(params, position) - params.threshold;
|
||||
alpha *= 1.0 - 2.0 * float(fadeParameters[params.category]._isInverted);
|
||||
return alpha;
|
||||
}
|
||||
|
||||
|
@ -166,4 +164,4 @@ layout(location=RENDER_UTILS_ATTR_FADE3) out vec4 _fadeData3;
|
|||
_fadeData3 = inTexCoord4;
|
||||
<@endfunc@>
|
||||
|
||||
<@endif@>
|
||||
<@endif@>
|
||||
|
|
|
@ -25,14 +25,13 @@ LAYOUT(binding=RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH) uniform sampler2D linearD
|
|||
|
||||
vec4 unpackPositionFromZeye(vec2 texcoord) {
|
||||
float Zeye = -texture(linearDepthMap, texcoord).x;
|
||||
int side = 0;
|
||||
if (isStereo()) {
|
||||
if (texcoord.x > 0.5) {
|
||||
texcoord.x -= 0.5;
|
||||
side = 1;
|
||||
}
|
||||
texcoord.x *= 2.0;
|
||||
}
|
||||
|
||||
float check = float(isStereo());
|
||||
float check2 = check * float(texcoord.x > 0.5);
|
||||
texcoord.x -= check2 * 0.5;
|
||||
int side = int(check2);
|
||||
texcoord.x *= 1.0 + check;
|
||||
|
||||
return vec4(evalEyePositionFromZeye(side, Zeye, texcoord), 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
float height_95p = 2000.0;
|
||||
const float log_p_005 = log(0.05);
|
||||
|
||||
if (hazeParams.hazeKeyLightAltitudeFactor > 0.0f) {
|
||||
height_95p = -log_p_005 / hazeParams.hazeKeyLightAltitudeFactor;
|
||||
}
|
||||
|
||||
// Note that we need the sine to be positive
|
||||
float sin_pitch = abs(lightDirectionWS.y);
|
||||
|
||||
float distance;
|
||||
const float minimumSinPitch = 0.001;
|
||||
if (sin_pitch < minimumSinPitch) {
|
||||
distance = height_95p / minimumSinPitch;
|
||||
} else {
|
||||
distance = height_95p / sin_pitch;
|
||||
}
|
||||
float sin_pitch = abs(lightDirectionWS.y);
|
||||
sin_pitch = max(sin_pitch, minimumSinPitch);
|
||||
|
||||
float distance = height_95p / sin_pitch;
|
||||
|
||||
// Integration is from the fragment towards the light source
|
||||
// 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;
|
||||
const float EPSILON = 0.0000001f;
|
||||
|
||||
if ((hazeParams.hazeMode & HAZE_MODE_IS_MODULATE_COLOR) == HAZE_MODE_IS_MODULATE_COLOR) {
|
||||
// Compute separately for each colour
|
||||
|
@ -143,9 +141,9 @@ vec4 computeHazeColor(vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePosition
|
|||
|
||||
const float slopeThreshold = 0.01;
|
||||
float deltaHeight = fragPositionWS.y - eyeWorldHeight;
|
||||
if (abs(deltaHeight) > slopeThreshold) {
|
||||
float t = hazeParams.hazeHeightFactor * deltaHeight;
|
||||
hazeIntegral *= (1.0 - exp (-t)) / t;
|
||||
float t = hazeParams.hazeHeightFactor * deltaHeight;
|
||||
if (abs(t) > EPSILON) {
|
||||
hazeIntegral *= mix(1.0, (1.0 - exp(-t)) / t, float(abs(deltaHeight) > slopeThreshold));
|
||||
}
|
||||
|
||||
vec3 hazeAmount = 1.0 - exp(-hazeIntegral);
|
||||
|
@ -171,13 +169,9 @@ vec4 computeHazeColor(vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePosition
|
|||
|
||||
const float slopeThreshold = 0.01;
|
||||
float deltaHeight = fragPositionWS.y - eyeWorldHeight;
|
||||
if (abs(deltaHeight) > slopeThreshold) {
|
||||
float t = hazeParams.hazeHeightFactor * deltaHeight;
|
||||
// Protect from wild values
|
||||
const float EPSILON = 0.0000001f;
|
||||
if (abs(t) > EPSILON) {
|
||||
hazeIntegral *= (1.0 - exp (-t)) / t;
|
||||
}
|
||||
float t = hazeParams.hazeHeightFactor * deltaHeight;
|
||||
if (abs(t) > EPSILON) {
|
||||
hazeIntegral *= mix(1.0, (1.0 - exp(-t)) / t, float(abs(deltaHeight) > slopeThreshold));
|
||||
}
|
||||
|
||||
float hazeAmount = 1.0 - exp(-hazeIntegral);
|
||||
|
@ -189,9 +183,7 @@ vec4 computeHazeColor(vec3 fragPositionES, vec3 fragPositionWS, vec3 eyePosition
|
|||
// Mix with background at far range
|
||||
const float BLEND_DISTANCE = 27000.0f;
|
||||
vec4 outFragColor = potentialFragColor;
|
||||
if (distance > BLEND_DISTANCE) {
|
||||
outFragColor.a *= hazeParams.backgroundBlend;
|
||||
}
|
||||
outFragColor.a *= mix(1.0, hazeParams.backgroundBlend, float(distance > BLEND_DISTANCE));
|
||||
|
||||
return outFragColor;
|
||||
}
|
||||
|
|
|
@ -45,11 +45,9 @@ void main(void) {
|
|||
highlightedDepth = -evalZeyeFromZdb(highlightedDepth);
|
||||
sceneDepth = -evalZeyeFromZdb(sceneDepth);
|
||||
|
||||
if (sceneDepth < highlightedDepth) {
|
||||
outFragColor = vec4(params._fillOccludedColor, params._fillOccludedAlpha);
|
||||
} else {
|
||||
outFragColor = vec4(params._fillUnoccludedColor, params._fillUnoccludedAlpha);
|
||||
}
|
||||
outFragColor = mix(vec4(params._fillUnoccludedColor, params._fillUnoccludedAlpha),
|
||||
vec4(params._fillOccludedColor, params._fillOccludedAlpha),
|
||||
float(sceneDepth < highlightedDepth));
|
||||
<@else@>
|
||||
discard;
|
||||
<@endif@>
|
||||
|
@ -67,14 +65,13 @@ void main(void) {
|
|||
float outlinedDepth = 0.0;
|
||||
float sumOutlineDepth = 0.0;
|
||||
|
||||
for (y=0 ; y<params._blurKernelSize ; y++) {
|
||||
for (y = 0; y < params._blurKernelSize; y++) {
|
||||
uv = lineStartUv;
|
||||
lineStartUv.y += deltaUv.y;
|
||||
|
||||
if (uv.y>=0.0 && uv.y<=1.0) {
|
||||
for (x=0 ; x<params._blurKernelSize ; x++) {
|
||||
if (uv.x>=0.0 && uv.x<=1.0)
|
||||
{
|
||||
if (uv.y >= 0.0 && uv.y <= 1.0) {
|
||||
for (x = 0; x < params._blurKernelSize; x++) {
|
||||
if (uv.x >= 0.0 && uv.x <= 1.0) {
|
||||
outlinedDepth = texture(highlightedDepthMap, uv).x;
|
||||
float touch = (outlinedDepth < FAR_Z) ? 1.0 : 0.0;
|
||||
sumOutlineDepth = max(outlinedDepth * touch, sumOutlineDepth);
|
||||
|
@ -86,11 +83,7 @@ void main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (intensity > 0.0) {
|
||||
// sumOutlineDepth /= intensity;
|
||||
} else {
|
||||
sumOutlineDepth = FAR_Z;
|
||||
}
|
||||
sumOutlineDepth = mix(FAR_Z, sumOutlineDepth, float(intensity > 0.0));
|
||||
|
||||
intensity /= weight;
|
||||
if (intensity < OPACITY_EPSILON) {
|
||||
|
@ -106,11 +99,9 @@ void main(void) {
|
|||
sceneDepth = -evalZeyeFromZdb(sceneDepth);
|
||||
|
||||
// Are we occluded?
|
||||
if (sceneDepth < outlinedDepth) {
|
||||
outFragColor = vec4(params._outlineOccludedColor, intensity * params._outlineOccludedAlpha);
|
||||
} else {
|
||||
outFragColor = vec4(params._outlineUnoccludedColor, intensity * params._outlineUnoccludedAlpha);
|
||||
}
|
||||
outFragColor = mix(vec4(params._outlineUnoccludedColor, intensity * params._outlineUnoccludedAlpha),
|
||||
vec4(params._outlineOccludedColor, intensity * params._outlineOccludedAlpha),
|
||||
float(sceneDepth < outlinedDepth));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ int clusterGrid_getClusterLightId(int index, int offset) {
|
|||
return element;
|
||||
*/
|
||||
int element = _clusterGridContent[GRID_FETCH_BUFFER((elementIndex >> 1))];
|
||||
return (((elementIndex & 0x00000001) == 1) ? (element >> 16) : element) & 0x0000FFFF;
|
||||
return (element >> (16 * int((elementIndex & 0x00000001) == 1))) & 0x0000FFFF;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
#define float_exp2 exp2
|
||||
#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) {
|
||||
// return ngrid;
|
||||
// return sqrt(ngrid);
|
||||
|
@ -87,14 +95,9 @@ ivec3 frustumGrid_indexToCluster(int index) {
|
|||
}
|
||||
|
||||
vec3 frustumGrid_clusterPosToEye(vec3 clusterPos) {
|
||||
|
||||
vec3 cvpos = clusterPos;
|
||||
|
||||
|
||||
vec3 volumePos = frustumGrid_gridToVolume(cvpos, frustumGrid.dims);
|
||||
|
||||
vec3 eyePos = frustumGrid_volumeToEye(volumePos, frustumGrid.eyeToGridProj, frustumGrid.rangeNear, frustumGrid.rangeFar);
|
||||
|
||||
return eyePos;
|
||||
}
|
||||
|
||||
|
@ -116,27 +119,19 @@ int frustumGrid_eyeDepthToClusterLayer(float eyeZ) {
|
|||
|
||||
int gridZ = int(frustumGrid_volumeToGridDepth(volumeZ, frustumGrid.dims));
|
||||
|
||||
if (gridZ >= frustumGrid.dims.z) {
|
||||
gridZ = frustumGrid.dims.z;
|
||||
}
|
||||
|
||||
|
||||
return gridZ;
|
||||
return _MIN(gridZ, frustumGrid.dims.z);
|
||||
}
|
||||
|
||||
ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) {
|
||||
|
||||
// make sure the frontEyePos is always in the front to eval the grid pos correctly
|
||||
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 gridPos = frustumGrid_volumeToGrid(volumePos, frustumGrid.dims);
|
||||
|
||||
if (gridPos.z >= float(frustumGrid.dims.z)) {
|
||||
gridPos.z = float(frustumGrid.dims.z);
|
||||
}
|
||||
gridPos.z = _MIN(gridPos.z, float(frustumGrid.dims.z));
|
||||
|
||||
ivec3 igridPos = ivec3(floor(gridPos));
|
||||
|
||||
|
@ -154,7 +149,7 @@ ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) {
|
|||
|
||||
int frustumGrid_eyeToClusterDirH(vec3 eyeDir) {
|
||||
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;
|
||||
|
@ -168,7 +163,7 @@ int frustumGrid_eyeToClusterDirH(vec3 eyeDir) {
|
|||
|
||||
int frustumGrid_eyeToClusterDirV(vec3 eyeDir) {
|
||||
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;
|
||||
|
@ -196,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
|
||||
|
|
|
@ -41,12 +41,10 @@ void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
|
|||
specular *= lightEnergy * isSpecularEnabled();
|
||||
|
||||
if (isShowLightContour() > 0.0) {
|
||||
// Show edge
|
||||
// Show edges
|
||||
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);
|
||||
diffuse = vec3(edgeCoord * edgeCoord * getLightColor(light));
|
||||
}
|
||||
float edgeCoord = exp2(-8.0 * edge * edge);
|
||||
diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,13 +57,11 @@ bool evalLightPointEdge(out vec3 color, Light light, vec4 fragLightDirLen, vec3
|
|||
// Allright we re valid in the volume
|
||||
float fragLightDistance = fragLightDirLen.w;
|
||||
vec3 fragLightDir = fragLightDirLen.xyz;
|
||||
|
||||
|
||||
// Show edges
|
||||
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);
|
||||
color = vec3(edgeCoord * edgeCoord * getLightColor(light));
|
||||
}
|
||||
float edgeCoord = exp2(-8.0 * edge * edge);
|
||||
color = mix(color, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
|
||||
|
||||
return (edge < 1.0);
|
||||
}
|
||||
|
|
|
@ -46,11 +46,9 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light,
|
|||
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 / (0.1)) - 1.0);
|
||||
if (edge < 1.0) {
|
||||
float edgeCoord = exp2(-8.0*edge*edge);
|
||||
diffuse = vec3(edgeCoord * edgeCoord * getLightColor(light));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,15 +65,11 @@ bool evalLightSpotEdge(out vec3 color, Light light, vec4 fragLightDirLen, float
|
|||
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 / (0.1)) - 1.0);
|
||||
if (edge < 1.0) {
|
||||
float edgeCoord = exp2(-8.0*edge*edge);
|
||||
color = vec3(edgeCoord * edgeCoord * getLightColor(light));
|
||||
}
|
||||
float edge = abs(2.0 * (edgeDist * 10.0) - 1.0);
|
||||
float edgeCoord = exp2(-8.0 * edge * edge);
|
||||
color = mix(color, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
|
||||
|
||||
return (edge < 1.0);
|
||||
}
|
||||
|
||||
<@endfunc@>
|
||||
|
||||
|
||||
|
|
|
@ -115,18 +115,10 @@ float evalShadowAttenuation(vec3 worldLightDir, vec4 worldPosition, float viewDe
|
|||
isPixelOnCascade.z = isShadowCascadeProjectedOnPixel(cascadeShadowCoords[2]);
|
||||
isPixelOnCascade.w = isShadowCascadeProjectedOnPixel(cascadeShadowCoords[3]);
|
||||
|
||||
if (isPixelOnCascade.x) {
|
||||
cascadeAttenuations.x = evalShadowCascadeAttenuation(0, offsets, cascadeShadowCoords[0], oneMinusNdotL);
|
||||
}
|
||||
if (isPixelOnCascade.y) {
|
||||
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);
|
||||
}
|
||||
cascadeAttenuations.x = mix(1.0, evalShadowCascadeAttenuation(0, offsets, cascadeShadowCoords[0], oneMinusNdotL), float(isPixelOnCascade.x));
|
||||
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));
|
||||
cascadeAttenuations.w = mix(1.0, evalShadowCascadeAttenuation(3, offsets, cascadeShadowCoords[3], oneMinusNdotL), float(isPixelOnCascade.w));
|
||||
|
||||
cascadeWeights.x = evalShadowCascadeWeight(cascadeShadowCoords[0]);
|
||||
cascadeWeights.y = evalShadowCascadeWeight(cascadeShadowCoords[1]);
|
||||
|
|
|
@ -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.
|
||||
float dqClusterWeight = clusterWeight;
|
||||
if (dot(real, polarityReference) < 0.0) {
|
||||
dqClusterWeight = -clusterWeight;
|
||||
}
|
||||
dqClusterWeight *= mix(1.0, -1.0, float(dot(real, polarityReference) < 0.0));
|
||||
|
||||
sAccum += scale * clusterWeight;
|
||||
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.
|
||||
// 0 indicates no cauterization and 1 indicates full cauterization.
|
||||
// TODO: make this cauterization smoother or implement full dual-quaternion scale support.
|
||||
const float CAUTERIZATION_THRESHOLD = 0.1;
|
||||
if (sAccum.w > CAUTERIZATION_THRESHOLD) {
|
||||
skinnedPosition = cAccum;
|
||||
} else {
|
||||
sAccum.w = 1.0;
|
||||
skinnedPosition = m * (sAccum * inPosition);
|
||||
{
|
||||
const float CAUTERIZATION_THRESHOLD = 0.1;
|
||||
float check = float(sAccum.w > CAUTERIZATION_THRESHOLD);
|
||||
sAccum.w = mix(1.0, sAccum.w, check);
|
||||
skinnedPosition = mix(m * (sAccum * inPosition), cAccum, check);
|
||||
}
|
||||
|
||||
<@if USE_NORMAL@>
|
||||
|
|
|
@ -82,8 +82,6 @@ vec3 integrate(float cosTheta, float skinRadius) {
|
|||
while (a <= (_PI)) {
|
||||
float sampleAngle = theta + a;
|
||||
float diffuse = clamp(cos(sampleAngle), 0.0, 1.0);
|
||||
//if (diffuse < 0.0) diffuse = 0.0;
|
||||
//if (diffuse > 1.0) diffuse = 1.0;
|
||||
|
||||
// Distance.
|
||||
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);
|
||||
}
|
||||
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);
|
||||
|
|
|
@ -37,9 +37,7 @@ void main(void) {
|
|||
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||
#else
|
||||
if (cam_isStereo()) {
|
||||
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
||||
}
|
||||
projected.x = mix(projected.x, 0.5 * (projected.x + cam_getStereoSide()), float(cam_isStereo()));
|
||||
#endif
|
||||
#endif
|
||||
_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_STEREO_SPLIT_SCREEN
|
||||
#else
|
||||
if (cam_isStereo()) {
|
||||
_texCoord01.x = 0.5 * (_texCoord01.x + cam_getStereoSide());
|
||||
}
|
||||
_texCoord01.x = mix(_texCoord01.x, 0.5 * (_texCoord01.x + cam_getStereoSide()), float(cam_isStereo()));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,8 +47,6 @@ void main(void) {
|
|||
vec4 projected = gl_Position / gl_Position.w;
|
||||
projected.xy = (projected.xy + 1.0) * 0.5;
|
||||
|
||||
if (cam_isStereo()) {
|
||||
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
||||
}
|
||||
projected.x = mix(projected.x, 0.5 * (projected.x + cam_getStereoSide()), float(cam_isStereo()));
|
||||
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
|
||||
}
|
||||
|
|
|
@ -60,9 +60,7 @@ void main(void) {
|
|||
#ifdef GPU_TRANSFORM_IS_STEREO
|
||||
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
||||
#else
|
||||
if (cam_isStereo()) {
|
||||
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
||||
}
|
||||
projected.x = mix(projected.x, 0.5 * (projected.x + cam_getStereoSide()), float(cam_isStereo()));
|
||||
#endif
|
||||
#endif
|
||||
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
|
||||
|
|
|
@ -33,16 +33,15 @@ void main(void) {
|
|||
|
||||
float shadowAttenuation = 1.0;
|
||||
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature = 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(
|
||||
getViewInverse(),
|
||||
|
|
|
@ -35,16 +35,16 @@ void main(void) {
|
|||
vec3 worldLightDirection = getLightDirection(shadowLight);
|
||||
float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal);
|
||||
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature = 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(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
|
|
|
@ -31,16 +31,16 @@ void main(void) {
|
|||
float shadowAttenuation = 1.0;
|
||||
|
||||
// Light mapped or not ?
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature = 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(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
|
|
|
@ -36,16 +36,16 @@ void main(void) {
|
|||
float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal);
|
||||
|
||||
// Light mapped or not ?
|
||||
if (frag.mode == FRAG_MODE_UNLIT) {
|
||||
discard;
|
||||
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
||||
discard;
|
||||
} else {
|
||||
vec4 midNormalCurvature = 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(
|
||||
getViewInverse(),
|
||||
shadowAttenuation,
|
||||
|
|
|
@ -62,7 +62,5 @@ void main(void) {
|
|||
|
||||
varColor = vec4(REGION_COLOR[region].xyz, proxy.sphere.w);
|
||||
|
||||
if (region == 4) {
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
gl_Position = mix(gl_Position, vec4(0.0), float(region == 4));
|
||||
}
|
||||
|
|
|
@ -53,14 +53,9 @@ void main(void) {
|
|||
|
||||
// Add or subtract the orthogonal vector based on a different vertex ID
|
||||
// calculation
|
||||
if (gl_VertexID < 2) {
|
||||
distanceFromCenter = -1.0;
|
||||
eye.xyz -= orthogonal;
|
||||
} else {
|
||||
distanceFromCenter = 1.0;
|
||||
eye.xyz += orthogonal;
|
||||
}
|
||||
distanceFromCenter = 1.0 - 2.0 * float(gl_VertexID < 2);
|
||||
eye.xyz += distanceFromCenter * orthogonal;
|
||||
|
||||
// Finally, put the eyespace vertex into clip space
|
||||
<$transformEyeToClipPos(cam, eye, gl_Position)$>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,10 @@ layout(location=0) out vec4 outFragColor;
|
|||
void main(void) {
|
||||
Grid grid = getGrid();
|
||||
|
||||
float alpha;
|
||||
if (grid.edge.z == 0.0) {
|
||||
alpha = paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy);
|
||||
} else {
|
||||
alpha = paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge);
|
||||
}
|
||||
float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
|
||||
paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy),
|
||||
float(grid.edge.z == 0.0));
|
||||
|
||||
if (alpha == 0.0) {
|
||||
discard;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,6 @@ void main(void) {
|
|||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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()))), (numLights >0 ? 0.9 : 0.1));
|
||||
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), 0.1 + 0.8 * float(numLights > 0));
|
||||
}
|
|
@ -62,12 +62,10 @@ void main(void) {
|
|||
|
||||
float relClusterId = float(clusterPos.z * summedDims.x + clusterPos.y * summedDims.y + clusterPos.x) / float(frustumGrid_numClusters());
|
||||
|
||||
if (relClusterId < 0.0) {
|
||||
_fragColor = vec4(0.0);
|
||||
} else if (relClusterId >= 1.0) {
|
||||
_fragColor = vec4(vec3(1.0), 0.2);
|
||||
} else {
|
||||
_fragColor = vec4(colorWheel(fract(relClusterId)), (numLights > 0 ? 0.05 + 0.95 * numLightsScale : 0.0));
|
||||
}
|
||||
_fragColor = mix(mix(vec4(colorWheel(fract(relClusterId)), float(numLights > 0) * (0.05 + 0.95 * numLightsScale)),
|
||||
vec4(vec3(1.0), 0.2),
|
||||
float(relClusterId >= 1.0)),
|
||||
vec4(0.0),
|
||||
float(relClusterId < 0.0));
|
||||
}
|
||||
|
||||
|
|
|
@ -62,5 +62,5 @@ void main(void) {
|
|||
TransformCamera cam = getTransformCamera();
|
||||
<$transformWorldToClipPos(cam, worldPos, gl_Position)$>
|
||||
|
||||
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), 0.9);
|
||||
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), 0.9);
|
||||
}
|
|
@ -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()))), (numLights > 0 ? 0.9 : 0.0));
|
||||
varColor = vec4(colorWheel(fract(float(gpu_InstanceID()) / float(frustumGrid_numClusters()))), float(numLights > 0) * 0.9);
|
||||
}
|
|
@ -96,9 +96,8 @@ void main(void) {
|
|||
vec3 fragLightDir = fragLightDirLen.xyz;
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
if (evalLightPointEdge(color, light, fragLightDirLen, fragEyeDir)) {
|
||||
_fragColor.rgb += color;
|
||||
}
|
||||
float check = float(evalLightPointEdge(color, light, fragLightDirLen, fragEyeDir));
|
||||
_fragColor.rgb += check * color;
|
||||
}
|
||||
|
||||
for (int i = cluster.x; i < numLights; i++) {
|
||||
|
@ -130,10 +129,8 @@ void main(void) {
|
|||
numLightTouching++;
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
if (evalLightSpotEdge(color, light, fragLightDirLen, cosSpotAngle, fragEyeDir)) {
|
||||
_fragColor.rgb += color;
|
||||
}
|
||||
float check = float(evalLightSpotEdge(color, light, fragLightDirLen, cosSpotAngle, fragEyeDir));
|
||||
_fragColor.rgb += check * color;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,11 +48,8 @@ void main(void) {
|
|||
} else {
|
||||
normal = vec4(normalize(cross(_parabolaData.velocity, _parabolaData.acceleration)), 0);
|
||||
}
|
||||
if (gl_VertexID % 2 == 0) {
|
||||
pos += 0.5 * _parabolaData.width * normal;
|
||||
} else {
|
||||
pos -= 0.5 * _parabolaData.width * normal;
|
||||
}
|
||||
|
||||
pos += 0.5 * _parabolaData.width * normal * (-1.0 + 2.0 * float(gl_VertexID % 2 == 0));
|
||||
|
||||
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,13 +39,8 @@ 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;
|
||||
if (params.outline.x > 0.0) {
|
||||
if (sdf > interiorCutoff) {
|
||||
sdf = 1.0 - sdf;
|
||||
} else {
|
||||
sdf += outlineExpansion;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -57,16 +52,11 @@ void main() {
|
|||
// Perform 4x supersampling for anisotropic filtering
|
||||
float a;
|
||||
a = evalSDF(_texCoord0);
|
||||
a += evalSDF(_texCoord0+dxTexCoord);
|
||||
a += evalSDF(_texCoord0+dyTexCoord);
|
||||
a += evalSDF(_texCoord0+dxTexCoord+dyTexCoord);
|
||||
a += evalSDF(_texCoord0 + dxTexCoord);
|
||||
a += evalSDF(_texCoord0 + dyTexCoord);
|
||||
a += evalSDF(_texCoord0 + dxTexCoord + dyTexCoord);
|
||||
a *= 0.25;
|
||||
|
||||
// discard if invisible
|
||||
if (a < 0.01) {
|
||||
discard;
|
||||
}
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(_normalWS),
|
||||
a * params.color.a,
|
||||
|
|
|
@ -30,31 +30,32 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|||
#define _texCoord0 _texCoord01.xy
|
||||
#define _texCoord1 _texCoord01.zw
|
||||
|
||||
const float gamma = 2.2;
|
||||
const float smoothing = 32.0;
|
||||
#define TAA_TEXTURE_LOD_BIAS -3.0
|
||||
|
||||
const float interiorCutoff = 0.8;
|
||||
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() {
|
||||
// retrieve signed distance
|
||||
float sdf = texture(Font, _texCoord0).g;
|
||||
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
|
||||
if (a < 0.01) {
|
||||
discard;
|
||||
}
|
||||
vec2 dxTexCoord = dFdx(_texCoord0) * 0.5 * taaBias;
|
||||
vec2 dyTexCoord = dFdy(_texCoord0) * 0.5 * taaBias;
|
||||
|
||||
// Perform 4x supersampling for anisotropic filtering
|
||||
float a;
|
||||
a = evalSDF(_texCoord0);
|
||||
a += evalSDF(_texCoord0 + dxTexCoord);
|
||||
a += evalSDF(_texCoord0 + dyTexCoord);
|
||||
a += evalSDF(_texCoord0 + dxTexCoord + dyTexCoord);
|
||||
a *= 0.25;
|
||||
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normalWS),
|
||||
|
|
|
@ -54,7 +54,7 @@ void main(void) {
|
|||
vec3 specular = DEFAULT_SPECULAR;
|
||||
float shininess = DEFAULT_SHININESS;
|
||||
float emissiveAmount = 0.0;
|
||||
|
||||
|
||||
#ifdef PROCEDURAL
|
||||
|
||||
#ifdef PROCEDURAL_V1
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include gpu/Color.slh@>
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
@ -28,11 +29,13 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|||
|
||||
void main(void) {
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
|
||||
texel.rgb *= _color.rgb;
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(_normalWS),
|
||||
1.0,
|
||||
_color.rgb * texel.rgb,
|
||||
texel.rgb,
|
||||
DEFAULT_ROUGHNESS,
|
||||
DEFAULT_METALLIC,
|
||||
DEFAULT_EMISSIVE,
|
||||
|
|
|
@ -39,26 +39,24 @@ void main(void) {
|
|||
|
||||
<$fetchFadeObjectParamsInstanced(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
float colorAlpha = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = color_sRGBAToLinear(texel);
|
||||
colorAlpha = -_color.a;
|
||||
}
|
||||
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
|
||||
texel.rgb *= _color.rgb;
|
||||
texel.a = abs(_color.a);
|
||||
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (colorAlpha * texel.a < ALPHA_THRESHOLD) {
|
||||
if (texel.a < ALPHA_THRESHOLD) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normalWS),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb + fadeEmissive,
|
||||
texel.a,
|
||||
texel.rgb + fadeEmissive,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragment(
|
||||
normalize(_normalWS),
|
||||
1.0,
|
||||
_color.rgb * texel.rgb,
|
||||
texel.rgb,
|
||||
DEFAULT_ROUGHNESS,
|
||||
DEFAULT_METALLIC,
|
||||
DEFAULT_EMISSIVE + fadeEmissive,
|
||||
|
|
|
@ -28,24 +28,22 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|||
#define _texCoord1 _texCoord01.zw
|
||||
|
||||
void main(void) {
|
||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||
float colorAlpha = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = color_sRGBAToLinear(texel);
|
||||
colorAlpha = -_color.a;
|
||||
}
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
|
||||
texel.rgb *= _color.rgb;
|
||||
texel.a = abs(_color.a);
|
||||
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (colorAlpha * texel.a < ALPHA_THRESHOLD) {
|
||||
if (texel.a < ALPHA_THRESHOLD) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normalWS),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb,
|
||||
texel.a,
|
||||
texel.rgb,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragmentUnlit(
|
||||
normalize(_normalWS),
|
||||
1.0,
|
||||
_color.rgb * texel.rgb);
|
||||
texel.rgb);
|
||||
}
|
||||
}
|
|
@ -40,24 +40,22 @@ void main(void) {
|
|||
<$fetchFadeObjectParamsInstanced(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||
float colorAlpha = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = color_sRGBAToLinear(texel);
|
||||
colorAlpha = -_color.a;
|
||||
}
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
|
||||
texel.rgb *= _color.rgb;
|
||||
texel.a = abs(_color.a);
|
||||
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (colorAlpha * texel.a < ALPHA_THRESHOLD) {
|
||||
if (texel.a < ALPHA_THRESHOLD) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normalWS),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb+fadeEmissive,
|
||||
texel.a,
|
||||
texel.rgb + fadeEmissive,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragmentUnlit(
|
||||
normalize(_normalWS),
|
||||
1.0,
|
||||
_color.rgb * texel.rgb+fadeEmissive);
|
||||
texel.rgb + fadeEmissive);
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
<@include gpu/Color.slh@>
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include render-utils/ShaderConstants.h@>
|
||||
|
@ -28,11 +29,13 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|||
|
||||
void main(void) {
|
||||
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(
|
||||
normalize(_normalWS),
|
||||
colorAlpha,
|
||||
_color.rgb * texel.rgb,
|
||||
texel.a,
|
||||
texel.rgb,
|
||||
DEFAULT_ROUGHNESS);
|
||||
}
|
|
@ -46,14 +46,10 @@ void main(void) {
|
|||
<$fetchFadeObjectParamsInstanced(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||
float opacity = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = color_sRGBAToLinear(texel);
|
||||
opacity = -_color.a;
|
||||
}
|
||||
opacity *= texel.a;
|
||||
vec3 albedo = _color.rgb * texel.rgb;
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
|
||||
texel.rgb *= _color.rgb;
|
||||
texel.a *= abs(_color.a);
|
||||
|
||||
vec3 fragPosition = _positionES.xyz;
|
||||
vec3 fragNormal = normalize(_normalWS);
|
||||
|
@ -66,12 +62,11 @@ void main(void) {
|
|||
1.0,
|
||||
fragPosition,
|
||||
fragNormal,
|
||||
albedo,
|
||||
texel.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
0.0f,
|
||||
fadeEmissive,
|
||||
DEFAULT_ROUGHNESS,
|
||||
opacity),
|
||||
opacity);
|
||||
|
||||
texel.a),
|
||||
texel.a);
|
||||
}
|
|
@ -27,11 +27,10 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|||
layout(location=0) out vec4 _fragColor0;
|
||||
|
||||
void main(void) {
|
||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||
float colorAlpha = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = color_sRGBAToLinear(texel);
|
||||
colorAlpha = -_color.a;
|
||||
}
|
||||
_fragColor0 = vec4(_color.rgb * texel.rgb, colorAlpha * texel.a);
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
|
||||
texel.rgb *= _color.rgb;
|
||||
texel.a *= abs(_color.a);
|
||||
|
||||
_fragColor0 = texel;
|
||||
}
|
|
@ -39,11 +39,10 @@ void main(void) {
|
|||
<$fetchFadeObjectParamsInstanced(fadeParams)$>
|
||||
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
||||
|
||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||
float colorAlpha = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = color_sRGBAToLinear(texel);
|
||||
colorAlpha = -_color.a;
|
||||
}
|
||||
_fragColor0 = vec4(_color.rgb * texel.rgb + fadeEmissive, colorAlpha * texel.a);
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
texel = mix(color_sRGBAToLinear(texel), texel, float(_color.a <= 0.0));
|
||||
texel.rgb *= _color.rgb;
|
||||
texel.a *= abs(_color.a);
|
||||
|
||||
_fragColor0 = vec4(texel.rgb + fadeEmissive, texel.a);
|
||||
}
|
|
@ -219,26 +219,24 @@ vec3 getTapLocationClampedSSAO(int sampleNumber, float spinAngle, float outerRad
|
|||
}
|
||||
bool redoTap = false;
|
||||
|
||||
if ((tapPos.x < 0.5)) {
|
||||
tapPos.x = -tapPos.x;
|
||||
redoTap = true;
|
||||
} else if ((tapPos.x > sideImageSize.x - 0.5)) {
|
||||
tapPos.x -= (sideImageSize.x - tapPos.x);
|
||||
redoTap = true;
|
||||
{
|
||||
float check1 = float(tapPos.x < 0.5);
|
||||
float check2 = (1.0 - check1) * float(tapPos.x > sideImageSize.x - 0.5);
|
||||
tapPos.x = tapPos.x - 2.0 * tapPos.x * check1 - check2 * (sideImageSize.x - tapPos.x);
|
||||
redoTap = (check1 > 0.0 || check2 > 0.0);
|
||||
}
|
||||
|
||||
if ((tapPos.y < 0.5)) {
|
||||
tapPos.y = -tapPos.y;
|
||||
redoTap = true;
|
||||
} else if ((tapPos.y > sideImageSize.y - 0.5)) {
|
||||
tapPos.y -= (sideImageSize.y - tapPos.y);
|
||||
redoTap = true;
|
||||
{
|
||||
float check1 = float(tapPos.y < 0.5);
|
||||
float check2 = (1.0 - check1) * float(tapPos.y > sideImageSize.y - 0.5);
|
||||
tapPos.y = tapPos.y - 2.0 * tapPos.y * check1 - check2 * (sideImageSize.y - tapPos.y);
|
||||
redoTap = (check1 > 0.0 || check2 > 0.0);
|
||||
}
|
||||
|
||||
if (redoTap) {
|
||||
tap.xy = tapPos - pixelPos;
|
||||
tap.z = length(tap.xy);
|
||||
tap.z = 0.0;
|
||||
{
|
||||
float check = float(redoTap);
|
||||
tap.xy = mix(tap.xy, tapPos - pixelPos, check);
|
||||
tap.z = (1.0 - check) * tap.z;
|
||||
}
|
||||
|
||||
return tap;
|
||||
|
|
|
@ -39,6 +39,7 @@ layout(location=0) out vec4 outFragColor;
|
|||
void main(void) {
|
||||
// Stereo side info based on the real viewport size of this pass
|
||||
vec2 sideDepthSize = getDepthTextureSideSize(0);
|
||||
|
||||
// Pixel Debugged
|
||||
vec2 cursorUV = getDebugCursorTexcoord();
|
||||
vec2 cursorPixelPos = cursorUV * sideDepthSize;
|
||||
|
@ -46,6 +47,5 @@ void main(void) {
|
|||
ivec2 fragUVPos = ivec2(cursorPixelPos);
|
||||
|
||||
// TODO
|
||||
|
||||
outFragColor = packOcclusionOutput(0.0, 0.0, vec3(0.0, 0.0, 1.0));
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ void main(void) {
|
|||
} else {
|
||||
sideOcclusionSize = ivec2( getOcclusionSideSize() );
|
||||
}
|
||||
|
||||
ivec4 side = getStereoSideInfoFromWidth(fragPixelPos.x, sideOcclusionSize.x);
|
||||
// From now on, fragUVPos is the UV pos in the side
|
||||
fragUVPos = getSideUVFromFramebufferUV(side, fragUVPos);
|
||||
|
|
|
@ -18,6 +18,9 @@ float aspectRatio = 0.95;
|
|||
|
||||
void main(void) {
|
||||
vec2 pos = varTexCoord0 * 2.0 - vec2(1.0);
|
||||
pos.x = aspectRatio * (pos.x * (pos.x > 0.0 ? 2.0 : -2.0) - 1.0);
|
||||
if (1.0 - dot(pos.xy, pos.xy) > 0.0 ) discard;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,14 +93,14 @@ vec3 drawScatteringTableUV(vec2 cursor, vec2 texcoord) {
|
|||
vec3 color = vec3(0.0);
|
||||
bool keep = false;
|
||||
for (int c = 0; c < 3; c++) {
|
||||
if (distance[c] > threshold) {
|
||||
keep = true;
|
||||
color[c] += 1.0;
|
||||
}
|
||||
bool check = distance[c] > threshold;
|
||||
keep = keep || check;
|
||||
color[c] += float(check);
|
||||
}
|
||||
|
||||
if (!keep)
|
||||
discard;
|
||||
if (!keep) {
|
||||
discard;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -67,11 +67,7 @@ vec3 getRawNormal(vec2 texcoord) {
|
|||
|
||||
vec3 getWorldNormal(vec2 texcoord) {
|
||||
vec3 rawNormal = getRawNormal(texcoord);
|
||||
if (isFullResolution()) {
|
||||
return unpackNormal(rawNormal);
|
||||
} else {
|
||||
return normalize((rawNormal - vec3(0.5)) * 2.0);
|
||||
}
|
||||
return mix(normalize((rawNormal - vec3(0.5)) * 2.0), unpackNormal(rawNormal), float(isFullResolution()));
|
||||
}
|
||||
|
||||
vec3 getWorldNormalDiff(vec2 texcoord, vec2 delta) {
|
||||
|
@ -93,7 +89,7 @@ void main(void) {
|
|||
vec2 texcoordPos;
|
||||
ivec4 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
|
||||
// sideToFrameTexcoord(stereoSideClip, texcoordPos);
|
||||
|
@ -128,8 +124,8 @@ void main(void) {
|
|||
|
||||
// Calculate dF/du and dF/dv
|
||||
vec2 viewportScale = perspectiveScale * getInvWidthHeight();
|
||||
vec2 du = vec2( viewportScale.x * (float(stereoSide.w) > 0.0 ? 0.5 : 1.0), 0.0f );
|
||||
vec2 dv = vec2( 0.0f, viewportScale.y );
|
||||
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));
|
||||
vec4 dFdv = vec4(getWorldNormalDiff(frameTexcoordPos, dv), getEyeDepthDiff(frameTexcoordPos, dv));
|
||||
|
|
|
@ -35,17 +35,11 @@ void main() {
|
|||
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, sourceColor, historyColor);
|
||||
|
||||
vec3 nextColor = sourceColor;
|
||||
|
||||
if (taa_constrainColor()) {
|
||||
// clamp history to neighbourhood of current sample
|
||||
historyColor = taa_evalConstrainColor(sourceColor, fragUV, fragVel, historyColor);
|
||||
}
|
||||
|
||||
if (taa_feedbackColor()) {
|
||||
nextColor = taa_evalFeedbackColor(sourceColor, historyColor, params.blend);
|
||||
} else {
|
||||
nextColor = mix(historyColor, sourceColor, params.blend);
|
||||
}
|
||||
|
||||
// clamp history to neighbourhood of current sample
|
||||
historyColor = mix(historyColor, taa_evalConstrainColor(sourceColor, fragUV, fragVel, historyColor), float(taa_constrainColor()));
|
||||
|
||||
nextColor = mix(mix(historyColor, sourceColor, params.blend), taa_evalFeedbackColor(sourceColor, historyColor, params.blend), float(taa_feedbackColor()));
|
||||
|
||||
outFragColor = vec4(taa_resolveColor(nextColor), 1.0);
|
||||
}
|
||||
|
|
|
@ -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 imageSize = getWidthHeight(0);
|
||||
if (isStereo()) {
|
||||
imageSize.x *= 2.0;
|
||||
}
|
||||
imageSize.x *= 1.0 + float(isStereo());
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
vec2 taa_getTexelSize() {
|
||||
vec2 texelSize = getInvWidthHeight();
|
||||
if (isStereo()) {
|
||||
texelSize.x *= 0.5;
|
||||
}
|
||||
texelSize.x *= 1.0 - 0.5 * float(isStereo());
|
||||
return texelSize;
|
||||
}
|
||||
|
||||
|
@ -158,16 +154,16 @@ vec3 taa_findClosestFragment3x3(vec2 uv)
|
|||
vec3 dbr = vec3( 1, 1, taa_fetchDepth(uv + dv + du));
|
||||
|
||||
vec3 dmin = dtl;
|
||||
if (ZCMP_GT(dmin.z, dtc.z)) dmin = dtc;
|
||||
if (ZCMP_GT(dmin.z, dtr.z)) dmin = dtr;
|
||||
dmin = mix(dmin, dtc, ZCMP_GT(dmin.z, dtc.z));
|
||||
dmin = mix(dmin, dtr, ZCMP_GT(dmin.z, dtr.z));
|
||||
|
||||
if (ZCMP_GT(dmin.z, dml.z)) dmin = dml;
|
||||
if (ZCMP_GT(dmin.z, dmc.z)) dmin = dmc;
|
||||
if (ZCMP_GT(dmin.z, dmr.z)) dmin = dmr;
|
||||
dmin = mix(dmin, dml, ZCMP_GT(dmin.z, dml.z));
|
||||
dmin = mix(dmin, dmc, ZCMP_GT(dmin.z, dmc.z));
|
||||
dmin = mix(dmin, dmr, ZCMP_GT(dmin.z, dmr.z));
|
||||
|
||||
if (ZCMP_GT(dmin.z, dbl.z)) dmin = dbl;
|
||||
if (ZCMP_GT(dmin.z, dbc.z)) dmin = dbc;
|
||||
if (ZCMP_GT(dmin.z, dbr.z)) dmin = dbr;
|
||||
dmin = mix(dmin, dbl, ZCMP_GT(dmin.z, dbl.z));
|
||||
dmin = mix(dmin, dbc, ZCMP_GT(dmin.z, dbc.z));
|
||||
dmin = mix(dmin, dbr, ZCMP_GT(dmin.z, dbr.z));
|
||||
|
||||
return vec3(uv + dd.xy * dmin.xy, dmin.z);
|
||||
}
|
||||
|
@ -189,49 +185,46 @@ vec2 taa_fetchVelocityMapBest(vec2 uv) {
|
|||
vec2 dbc = taa_fetchVelocityMap(uv + dv);
|
||||
vec2 dbr = taa_fetchVelocityMap(uv + dv + du);
|
||||
|
||||
vec3 best = vec3(dtl, dot(dtl,dtl));
|
||||
vec3 best = vec3(dtl, dot(dtl, dtl));
|
||||
|
||||
float testSpeed = dot(dtc,dtc);
|
||||
if (testSpeed > best.z) { best = vec3(dtc, testSpeed); }
|
||||
testSpeed = dot(dtr,dtr);
|
||||
if (testSpeed > best.z) { best = vec3(dtr, testSpeed); }
|
||||
float testSpeed = dot(dtc, dtc);
|
||||
mix(best, vec3(dtc, testSpeed), float(testSpeed > best.z));
|
||||
testSpeed = dot(dtr, dtr);
|
||||
mix(best, vec3(dtr, testSpeed), float(testSpeed > best.z));
|
||||
|
||||
testSpeed = dot(dml,dml);
|
||||
if (testSpeed > best.z) { best = vec3(dml, testSpeed); }
|
||||
testSpeed = dot(dmc,dmc);
|
||||
if (testSpeed > best.z) { best = vec3(dmc, testSpeed); }
|
||||
testSpeed = dot(dmr,dmr);
|
||||
if (testSpeed > best.z) { best = vec3(dmr, testSpeed); }
|
||||
testSpeed = dot(dml, dml);
|
||||
mix(best, vec3(dml, testSpeed), float(testSpeed > best.z));
|
||||
testSpeed = dot(dmc, dmc);
|
||||
mix(best, vec3(dmc, testSpeed), float(testSpeed > best.z));
|
||||
testSpeed = dot(dmr, dmr);
|
||||
mix(best, vec3(dmr, testSpeed), float(testSpeed > best.z));
|
||||
|
||||
testSpeed = dot(dbl,dbl);
|
||||
if (testSpeed > best.z) { best = vec3(dbl, testSpeed); }
|
||||
testSpeed = dot(dbc,dbc);
|
||||
if (testSpeed > best.z) { best = vec3(dbc, testSpeed); }
|
||||
testSpeed = dot(dbr,dbr);
|
||||
if (testSpeed > best.z) { best = vec3(dbr, testSpeed); }
|
||||
testSpeed = dot(dbl, dbl);
|
||||
mix(best, vec3(dbl, testSpeed), float(testSpeed > best.z));
|
||||
testSpeed = dot(dbc, dbc);
|
||||
mix(best, vec3(dbc, testSpeed), float(testSpeed > best.z));
|
||||
testSpeed = dot(dbr, dbr);
|
||||
mix(best, vec3(dbr, testSpeed), float(testSpeed > best.z));
|
||||
|
||||
return best.xy;
|
||||
}
|
||||
|
||||
vec2 taa_fromFragUVToEyeUVAndSide(vec2 fragUV, out int stereoSide) {
|
||||
vec2 eyeUV = fragUV;
|
||||
stereoSide = 0;
|
||||
if (isStereo()) {
|
||||
if (eyeUV.x > 0.5) {
|
||||
eyeUV.x -= 0.5;
|
||||
stereoSide = 1;
|
||||
}
|
||||
eyeUV.x *= 2.0;
|
||||
}
|
||||
|
||||
float check = float(isStereo());
|
||||
float check2 = float(eyeUV.x > 0.5);
|
||||
eyeUV.x -= check * check2 * 0.5;
|
||||
stereoSide = int(check * check2);
|
||||
eyeUV.x *= 1.0 + check;
|
||||
return eyeUV;
|
||||
}
|
||||
|
||||
vec2 taa_fromEyeUVToFragUV(vec2 eyeUV, int stereoSide) {
|
||||
vec2 fragUV = eyeUV;
|
||||
if (isStereo()) {
|
||||
fragUV.x *= 0.5;
|
||||
fragUV.x += float(stereoSide)*0.5;
|
||||
}
|
||||
float check = float(isStereo());
|
||||
fragUV.x *= 1.0 - 0.5 * check;
|
||||
fragUV.x += check * float(stereoSide) * 0.5;
|
||||
return fragUV;
|
||||
}
|
||||
|
||||
|
@ -247,10 +240,8 @@ vec2 taa_fetchSourceAndHistory(vec2 fragUV, vec2 fragVelocity, out vec3 sourceCo
|
|||
vec2 prevFragUV = taa_computePrevFragAndEyeUV(fragUV, fragVelocity, prevEyeUV);
|
||||
sourceColor = taa_fetchSourceMap(fragUV).xyz;
|
||||
|
||||
historyColor = sourceColor;
|
||||
if (!(any(lessThan(prevEyeUV, vec2(0.0))) || any(greaterThan(prevEyeUV, vec2(1.0))))) {
|
||||
historyColor = taa_fetchHistoryMap(prevFragUV).xyz;
|
||||
}
|
||||
historyColor = mix(sourceColor, taa_fetchHistoryMap(prevFragUV).xyz, float(!(any(lessThan(prevEyeUV, vec2(0.0))) || any(greaterThan(prevEyeUV, vec2(1.0))))));
|
||||
|
||||
return prevFragUV;
|
||||
}
|
||||
|
||||
|
@ -405,10 +396,11 @@ vec3 taa_clampColor(vec3 colorMin, vec3 colorMax, vec3 colorSource, vec3 color)
|
|||
vec3 a_unit = abs(v_unit);
|
||||
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;
|
||||
else
|
||||
return q;// point inside aabb
|
||||
} else {
|
||||
return q;// point inside aabb
|
||||
}
|
||||
}
|
||||
|
||||
vec3 taa_evalConstrainColor(vec3 sourceColor, vec2 sourceUV, vec2 sourceVel, vec3 candidateColor) {
|
||||
|
@ -514,10 +506,6 @@ vec3 taa_evalFXAA(vec2 fragUV) {
|
|||
|
||||
// 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 (lumaB < lumaMin || lumaB > lumaMax) {
|
||||
return rgbA;
|
||||
} else {
|
||||
return rgbB;
|
||||
}
|
||||
return mix(rgbB, rgbA, float(lumaB < lumaMin || lumaB > lumaMax));
|
||||
}
|
||||
|
||||
|
|
|
@ -83,32 +83,21 @@ void main(void) {
|
|||
if ((prevOrbPosToPixLength < tenPercentHeight) && (cursorVelocityLength > 0.5)) {
|
||||
vec2 prevOrbPosToPix_uv = cursorPrevUV + prevOrbPosToPix * texelSize / taa_getDebugOrbZoom();
|
||||
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;
|
||||
}
|
||||
if (prevOrbPosToPixLength < orbPixThreshold) {
|
||||
preOrbColor = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
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));
|
||||
float distanceToNext = length(imageSize * (cursorUV - prevOrbPosToPix_uv));
|
||||
if (distanceToNext < orbPixThreshold) {
|
||||
preOrbColor = vec3(1.0, 0.5, 0.0);
|
||||
}
|
||||
preOrbColor = mix(preOrbColor, vec3(1.0, 0.5, 0.0), float(distanceToNext < orbPixThreshold));
|
||||
outFragColor = vec4(preOrbColor, 1.0);
|
||||
return;
|
||||
}
|
||||
if (nextOrbPosToPixLength < tenPercentHeight) {
|
||||
vec2 nextOrbPosToPix_uv = cursorUV + nextOrbPosToPix * texelSize / taa_getDebugOrbZoom();
|
||||
vec3 nextOrbColor = vec3(0.0);
|
||||
if (!(any(lessThan(nextOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(nextOrbPosToPix_uv, vec2(1.0))))) {
|
||||
nextOrbColor = texture(nextMap, nextOrbPosToPix_uv).xyz;
|
||||
}
|
||||
nextOrbColor = mix(nextOrbColor, texture(nextMap, nextOrbPosToPix_uv).xyz, float(!(any(lessThan(nextOrbPosToPix_uv, vec2(0.0))) || any(greaterThan(nextOrbPosToPix_uv, vec2(1.0))))));
|
||||
float distanceToPrev = length(imageSize * (cursorPrevUV - nextOrbPosToPix_uv));
|
||||
if (distanceToPrev < orbPixThreshold) {
|
||||
nextOrbColor = vec3(1.0, 0.0, 1.0);
|
||||
}
|
||||
if (nextOrbPosToPixLength < orbPixThreshold) {
|
||||
nextOrbColor = vec3(1.0, 0.5, 0.0);
|
||||
}
|
||||
nextOrbColor = mix(nextOrbColor, vec3(1.0, 0.0, 1.0), float(distanceToPrev < orbPixThreshold));
|
||||
nextOrbColor = mix(nextOrbColor, vec3(1.0, 0.5, 0.0), float(nextOrbPosToPixLength < orbPixThreshold));
|
||||
|
||||
outFragColor = vec4(nextOrbColor, 1.0);
|
||||
return;
|
||||
|
@ -141,16 +130,9 @@ void main(void) {
|
|||
outFragColor = vec4(nextColor, 1.0);
|
||||
|
||||
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) {
|
||||
vec3 speedColor = taa_getVelocityColorAboveThreshold(pixVelocityLength);
|
||||
|
||||
outFragColor = vec4(0.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
outFragColor = mix(outFragColor, vec4(0.0, 1.0, 1.0, 1.0), float(pixVelocityLength > params.debugShowVelocityThreshold));
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ void main(void) {
|
|||
// vec3 ambient = sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(lightAmbient), fragNormal).xyz;
|
||||
// _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;
|
||||
const float INV_GAMMA_22 = 1.0 / 2.2;
|
||||
|
|
|
@ -35,16 +35,11 @@ void main(void) {
|
|||
vec3 color = skybox.color.rgb;
|
||||
|
||||
// blend is only set if there is a cubemap
|
||||
if (skybox.color.a > 0.0) {
|
||||
color = texture(skyboxMap, direction).rgb;
|
||||
if (skybox.color.a < 1.0) {
|
||||
color *= skybox.color.rgb;
|
||||
}
|
||||
}
|
||||
float check = float(skybox.color.a > 0.0);
|
||||
color = mix(color, texture(skyboxMap, direction).rgb, check);
|
||||
color *= mix(vec3(1.0), skybox.color.rgb, check * float(skybox.color.a < 1.0));
|
||||
|
||||
color = color * 1.0 - base.w + base.xyz * base.w;
|
||||
const float INV_GAMMA_22 = 1.0 / 2.2;
|
||||
_fragColor = vec4(pow(color, vec3(INV_GAMMA_22)), 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,10 +98,11 @@ vec4 pixelShaderGaussian(vec2 texcoord, vec2 direction, vec2 pixelStep) {
|
|||
totalWeight += weight;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalWeight>0.0) {
|
||||
|
||||
if (totalWeight > 0.0) {
|
||||
srcBlurred /= totalWeight;
|
||||
}
|
||||
|
||||
srcBlurred.a = getOutputAlpha();
|
||||
return srcBlurred;
|
||||
}
|
||||
|
@ -159,10 +160,11 @@ vec4 pixelShaderGaussianDepthAware(vec2 texcoord, vec2 direction, vec2 pixelStep
|
|||
totalWeight += weight;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalWeight>0.0) {
|
||||
|
||||
if (totalWeight > 0.0) {
|
||||
srcBlurred /= totalWeight;
|
||||
}
|
||||
|
||||
return srcBlurred;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void main(void) {
|
|||
vec4 pos = UNIT_BOX[UNIT_BOX_LINE_INDICES[gl_VertexID]];
|
||||
|
||||
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);
|
||||
|
||||
pos.xyz = cellBound.xyz + vec3(cellBound.w) * pos.xyz;
|
||||
|
@ -62,4 +62,4 @@ void main(void) {
|
|||
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
|
||||
|
||||
varColor = vec4(colorWheel(fract(float(inCellLocation.w) / 5.0)), 0.8 + 0.2 * float(cellIsEmpty));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,7 @@ layout(location=0) out vec4 outFragColor;
|
|||
void main(void) {
|
||||
float var = step(fract(varTexcoord.x * varTexcoord.y * 1.0), 0.5);
|
||||
|
||||
if (varColor.a == 0.0) {
|
||||
outFragColor = vec4(mix(vec3(0.0), varColor.xyz, var), mix(0.0, 1.0, var));
|
||||
|
||||
} else {
|
||||
outFragColor = vec4(mix(vec3(1.0), varColor.xyz, var), varColor.a);
|
||||
}
|
||||
|
||||
outFragColor = mix(vec4(mix(vec3(1.0), varColor.xyz, var), varColor.a),
|
||||
vec4(mix(vec3(0.0), varColor.xyz, var), var),
|
||||
float(varColor.a == 0.0));
|
||||
}
|
||||
|
|
|
@ -98,11 +98,6 @@ void main(void) {
|
|||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, pos, gl_Position)$>
|
||||
|
||||
if (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);
|
||||
}
|
||||
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));
|
||||
varTexcoord = vec2(cubeVec.w, length(boundDim));
|
||||
|
||||
}
|
|
@ -22,10 +22,9 @@ vec2 getIconTexcoord(float icon, vec2 uv) {
|
|||
}
|
||||
|
||||
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;
|
||||
outFragColor = vec4(varColor.xyz, 1.0 - step(1.0f, dot(centerDir.xy, centerDir.xy)));
|
||||
}
|
||||
vec2 centerDir = varTexcoord.xy * 2.0f - 1.0f;
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue