c++ - Fully transparent torus in OpenGL -


I have a Torres provided by OpenGL and can map a texture; There is no problem till the texture is not opaque. But when I make the color selectively transparent, it does not work. Or rather: this works but only in some areas based on the order of the triangle in the top buffer; See the difference with the outer equator black and white torus with problem Torus should be equally covered by spots .

The source image will be PNG, however for now I work with BMP because it is easy to load (Texture loading is part of the tutorial tutorial). The white background of the image and above it is the different color spots; It is not transparent, with the desired result spots, there is almost transparent torus. Both the front and rear side spots should appear. Rendering will be offline, so I do not need speed; I need to create an image of Torus with an image of its surface.

So far my code looks like this (it's a merge of two examples):

The piece is cinematographer:

#Version 330 core / Interpolated value with peak shaders in VPC2 / UV; // Ouput data vec4 color out; // Valid Sampler Uniform Sampler 2D Matures Sampler for Entire Traps; Zero Main () {// Output Color = Texture Texture (myTextureSampler, UV) on specified UV color.rgb = texture2D .rgb; If (color.r == 1 & amp; amp; color.g == 1 & amp; amp; color.b == 1) {color.a = 0.2; } And {color.a = 1; }}

I know that this order is related to the order, what can I do (but do not know what will work):

  1. Input Add transparency to the image (and find the code that loads such an image).
  2. Something in two vertex shaders (see)
  3. Sorting will solve my problem, but if I get it correctly, then I have to implement it myself. Each triangle has to get a center (easy), it must be projected with my matrix and comparing z values.
  4. Change the blending and depth handling in some way:

      glEnable (GL_BLEND); Globefenk (GLICCR_ALPHA, GL_ONMINUSISUSRCCLAAPHA); GlEnable (GL_DEPTH_TEST); GlDepthMask (GL_TRUE); GlDepthFunc (GL_LEQUAL); Gloditrange (0.0 f, 1.0f);       

    I need a suggestion, how to continue.


    Update , it fixes almost the problem: glDisable (GL_DEPTH_TEST); // glDepthMask (GL_TRUE); GlDepthFunc (GL_NEVER); // glDepthRange (2.0.0 f, 1.0f);

    I want to write that this game does not separate front and back, but then I realized that they are almost white and there is no difference in blending with white color.

    The new image of Taurus with colorful texture is: color

    The remaining problems are:

    1. The red spots are blue - it is related to the BMP (no matter) loading function
    2. All the spots in the input images are the same The size, big spots should be on the top and therefore saturated and does not mix with the white body of the taurus. It seems that the order should be opposite. If you compare it with the previous image, then being present there, bigger places were prepared correctly and the little ones were hidden (behind the taurus).

    ? First problem was solved by disabling the depth test (see update in question)

The second problem was solved by the manual sorting of the array of all triangles. It works well for the 20000 triangle even in real time, which is more than enough for my purpose

Resultant source code:

It is based on and used in OpenGL Tutorial Includes:


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

javascript - amcharts makechart not working -