BLT-With-Graphics-Template/include/blt/gfx/renderer/shaders/pp_outline_step.frag

60 lines
1.5 KiB
GLSL
Raw Permalink Normal View History

#ifdef __cplusplus
#include <string>
const std::string shader_pp_outline_step_frag = R"("
#version 300 es
precision mediump float;
out vec4 FragColor;
in vec2 uv;
in vec2 pos;
uniform vec2 viewportSize;
uniform sampler2D albedo;
uniform sampler2D mask;
2024-05-05 02:29:45 -04:00
vec4 outline_color = vec4(1.0f, 0.0f, 0.0f, 1.0f);
float longest(vec3 v){
return max(v.r, max(v.b, v.g));
}
2024-05-05 17:03:50 -04:00
#define LINE_WEIGHT 1.0
void main() {
2024-05-05 17:03:50 -04:00
// float dx = (1.0 / viewportSize.x) * LINE_WEIGHT;
// float dy = (1.0 / viewportSize.y) * LINE_WEIGHT;
//
// vec2 uvCenter = uv;
// vec2 uvRight = vec2(uvCenter.x + dx, uvCenter.y);
// vec2 uvTop = vec2(uvCenter.x, uvCenter.y - dy);
// vec2 uvTopRight = vec2(uvCenter.x + dx, uvCenter.y - dy);
//
// float mCenter = longest(texture(mask, uvCenter).rgb);
// float mTop = longest(texture(mask, uvTop).rgb);
// float mRight = longest(texture(mask, uvRight).rgb);
// float mTopRight = longest(texture(mask, uvTopRight).rgb);
//
// float dT = abs(mCenter - mTop);
// float dR = abs(mCenter - mRight);
// float dTR = abs(mCenter - mTopRight);
//
// float delta = 0.0f;
// delta = max(delta, dT);
// delta = max(delta, dR);
// delta = max(delta, dTR);
//
// vec4 outline = vec4(delta, delta, delta, 1.0);
// vec4 albedo = texture(albedo, uv);
//
// if (delta <= 0.0)
// FragColor = albedo;
// else
// FragColor = outline_color;
FragColor = texture(albedo, uv);
if (FragColor.a == 0.0)
FragColor = texture(mask, uv);
}
")";
#endif