Why does my openGL glasses shader program have grouping artifacts?

For each point that my OpenGL shader program executes, it creates a red ring that seamlessly transitions between opaque and fully transparent. My shader program works, but has grouping artifacts.

Fragment shader below.

#version 110 precision mediump float; void main() { float dist = distance(gl_PointCoord.xy, vec2(0.5, 0.5)); // Edge value is 0.5, it should be 1. // Inner most value is 0 it should stay 0. float inner_circle = 2.0 * dist; float circle = 1.0 - inner_circle; vec4 pixel = vec4(1.0, 0.0, 0.0, inner_circle * circle ); gl_FragColor = pixel; } 

Here's a less interesting vertex shader, which I think is not the cause of the problem.

 #version 110 attribute vec2 aPosition; uniform float uSize; uniform vec2 uCamera; void main() { // Square the view and map the top of the screen to 1 and the bottom to -1. gl_Position = vec4(aPosition, 0.0, 1.0); gl_Position.x = gl_Position.x * uCamera.y / uCamera.x; // Set point size gl_PointSize = (uSize + 1.0) * 100.0; } 

Please help me figure out why my OpenGL shader program has grouping artifacts?

PS By the way, this is for Android Acer Iconia.

+6
source share
1 answer

Android GLSurfaceView uses the RGB565 surface by default. Either enable anti-aliasing ( glEnable(GL_DITHER) ), or set a custom EGLConfigChooser to select an RGBA or RGBX surface configuration with 8 bits per channel.

+2
source

Source: https://habr.com/ru/post/918310/


All Articles