Tuesday, October 18, 2022
HomeGame Development3d Line drawing utilizing OpenGL shaders, the way to repair this damaged...

3d Line drawing utilizing OpenGL shaders, the way to repair this damaged instance?


Why do not these shaders offered on this web site work?
https://vitaliburkov.wordpress.com/2016/09/17/simple-and-fast-high-quality-antialiased-lines-with-opengl/

I attempted adapting it to a extra ‘current’ model of OpenGL, with the next consequence.

vertex shader

#model 330
in vec4 Vertex;
uniform vec2 uViewPort; //Width and Top of the viewport
uniform mat4 ModelViewProjectionMatrix;
out vec2 vLineCenter;
void predominant(void)
{
  vec4 pp = ModelViewProjectionMatrix * Vertex;
  gl_Position = pp;
  vec2 vp = uViewPort;
  vLineCenter = 0.5*(pp.xy + vec2(1, 1))*vp;
};

fragment shader

#model 330
uniform float uLineWidth;
uniform vec4 uColor;
uniform float uBlendFactor; //1.5..2.5
in vec2 vLineCenter;
out vec4 LFragment;
void predominant(void)
{
      vec4 col = uColor;        
      float d = size(vLineCenter-gl_FragCoord.xy);
      float w = uLineWidth;
      if (d>w)
        col.w = 0;
      else
        col.w *= pow(float((w-d)/w), uBlendFactor);
      LFragment = col;
};

And I’m giving it a sound MVP matrix.

    glm::mat4 View = glm::lookAt(
            glm::vec3(0,0,2), 
            glm::vec3(0,0,0), 
            glm::vec3(0,1,0)  
            );
    glm::mat4 Mannequin = glm::mat4(1.0f);
    glm::mat4 mvp = Projection * View * Mannequin; 

And the opposite inputs/uniforms are set, too.
I even checked it with ‘renderdoc’.
(viewport is pixel values, proper? 1920x 1080 ?)

However all I get is a strong sq..

I simply need some depth/overlap conforming 3d strains for debugging…
Principally, I need this spoon fed.

The vertices all have a 1 for the w element, by the way in which.
Does that matter?
The vertex buffer is crammed appropriately, too.

Is that this simply outdated? I haven’t got the data/understanding to research this.
I am a brainlet ignoramus on the subject of this sort of factor. Please assist.

This appears so good and easy, but when this doesn’t work out then I am going to go for a kind of ‘single move’ approaches from the NVIDIA examples and whatnot.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments