somewhat better edge marking

This commit is contained in:
Arisotura 2019-06-12 02:23:40 +02:00
parent 711fda469e
commit a3fed77da3
2 changed files with 23 additions and 5 deletions

View File

@ -447,6 +447,7 @@ void UpdateDisplaySettings()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, FramebufferTex[4]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH32F_STENCIL8, ScreenW, ScreenH, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL);
glBindTexture(GL_TEXTURE_2D, FramebufferTex[5]);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8UI, ScreenW, ScreenH, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, ScreenW, ScreenH, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
@ -476,7 +477,8 @@ void UpdateDisplaySettings()
glBindBuffer(GL_PIXEL_PACK_BUFFER, PixelbufferID);
glBufferData(GL_PIXEL_PACK_BUFFER, 256*192*4, NULL, GL_DYNAMIC_READ);
glLineWidth(scale);
//glLineWidth(scale);
glLineWidth(1.5);
}

View File

@ -88,16 +88,28 @@ out vec4 oColor;
// make up for crapo zbuffer precision
bool isless(float a, float b)
{return true;
{
return a < b;
// a < b
float diff = a - b;
return diff < (256.0 / 16777216.0);
}
bool isgood(vec4 attr, float depth, int refPolyID, float refDepth)
{
int polyid = int(attr.r * 63.0);
if (polyid != refPolyID && isless(refDepth, depth))
return true;
return false;
}
void main()
{
ivec2 coord = ivec2(gl_FragCoord.xy);
int scale = int(uScreenSize.x / 256);
int scale = 1;//int(uScreenSize.x / 256);
vec4 ret = vec4(0,0,0,0);
vec4 depth = texelFetch(DepthBuffer, coord, 0);
@ -116,10 +128,14 @@ void main()
vec4 depthR = texelFetch(DepthBuffer, coord + ivec2(scale,0), 0);
vec4 attrR = texelFetch(AttrBuffer, coord + ivec2(scale,0), 0);
if ((polyid != int(attrU.r * 63.0) && isless(depth.r, depthU.r)) ||
/*if ((polyid != int(attrU.r * 63.0) && isless(depth.r, depthU.r)) ||
(polyid != int(attrD.r * 63.0) && isless(depth.r, depthD.r)) ||
(polyid != int(attrL.r * 63.0) && isless(depth.r, depthL.r)) ||
(polyid != int(attrR.r * 63.0) && isless(depth.r, depthR.r)))
(polyid != int(attrR.r * 63.0) && isless(depth.r, depthR.r)))*/
if (isgood(attrU, depthU.r, polyid, depth.r) ||
isgood(attrD, depthD.r, polyid, depth.r) ||
isgood(attrL, depthL.r, polyid, depth.r) ||
isgood(attrR, depthR.r, polyid, depth.r))
{
// mark this pixel!