Обводка выбранного объекта

This commit is contained in:
2023-04-03 18:19:18 +03:00
committed by re.kovalev
parent 68a8f4d0d0
commit 329bea7124
2 changed files with 24 additions and 1 deletions

View File

@@ -40,6 +40,9 @@ uniform sampler2D gAmbientSpecular;
uniform sampler2DArray sunShadowDepth;
uniform samplerCubeArray pointShadowDepth;
uniform sampler2D ssao;
uniform usampler2D gID;
uniform uvec3 selectedID;
layout(std140, binding = 4) uniform gamma
{
@@ -198,4 +201,21 @@ void main()
// Применение гамма-коррекции
color.rgb = pow(color.rgb, vec3(inv_gamma));
vec3 ID = texture(gID, texCoord).rgb;
// Обводка выбранного объекта
if (length(selectedID.rg) > 0 && selectedID.rg == ID.rg && ID.b == 0)
{
int border_width = 3;
vec2 size = 1.0f / textureSize(gID, 0);
for (int i = -border_width; i <= +border_width; i++)
for (int j = -border_width; j <= +border_width; j++)
{
if (i == 0 && j == 0)
continue;
if (texture(gID, texCoord + vec2(i, j) * size).rg != selectedID.rg)
color.rgb = vec3(1.0);
}
}
}