I would like to have the option to change framebuffer types from the standard RGBA8 to RGBA16F to allow a true-edge shader (A true-edge shader is an edgetrace shader that uses the pixels distance from the camera, instead of the color.) Example:
#version 330
uniform sampler2D InSampler;
layout(std140) uniform SamplerInfo {
vec2 OutSize;
vec2 InSize;
};
in vec2 texCoord;
out vec4 fragColor;
float gray(vec4 c) {
return c.r;
}
void main(){
vec4 color=texture(InSampler, texCoord);
if((color.b>1.734)&&(color.b<1.736)){
vec2 oneTexel = 1.0 / InSize;
vec2 xTexel=vec2(oneTexel.x,0);
vec2 yTexel=vec2(0,oneTexel.y);
float diffx=(gray(texture(InSampler, texCoord+xTexel))-2*gray(texture(InSampler, texCoord))+gray(texture(InSampler, texCoord-xTexel)));
float diffy=(gray(texture(InSampler, texCoord+yTexel))-2*gray(texture(InSampler, texCoord))+gray(texture(InSampler, texCoord-yTexel)));
float cmulta=max(min(max(diffx,diffy)/0.005/gray(texture(InSampler, texCoord)),1),0);
if(cmulta<0.5){
cmulta=0;
}
float cmultb=max(min(-min(diffx,diffy)/0.005/gray(texture(InSampler, texCoord)),1),0);
if(cmultb<0.5){
cmultb=0;
}
if((cmulta>0.5)||(cmultb>0.5)){
fragColor=vec4(1*cmulta,1*cmultb,1,1);
}else{
fragColor=vec4(0,0,0,1);
}
}else{
fragColor=color;
}
}
0 Comments
Please sign in to leave a comment.
Post a new comment: