Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

Presumably the issue is with the interior codecs and my understanding of that, however I have been caught some time, acquired this form of approaching working fantastic on a extra straight ahead color picker, however right here I am choosing pos coordinates saved as information at places.

Could be actually grateful for anybody who will help me throguh this.

So I’ve a fbo, a texture2d attachment in shade 0 and primarily I move my vertices (XYZ) (GLfloat) to the vertex shader in location 0 ‘place’.

Since my terrain is a sq. at all times, 100×100 3000×3000 and many others, I solely want the X and Z since they’ll all be distinctive, so I out a vec2 of the place.XZ to the fragment shader after which within the fragment shader I do that on an if assertion

frag
...
structure(location = 0) out vec4 FragColor;
structure(location = 1 )out vec4 FragColor2;

primary...
if (terrainEditMode == 1)
{
   
   
   FragColor2 = vec4(vecIDs.x, vecIDs.y, 0.1,0.1);
}

I arrange the attachment like this

glGenFramebuffers(1, &terrainPickFBO);
        glBindFramebuffer(GL_FRAMEBUFFER, terrainPickFBO);
        glGenTextures(1, &terrainPickTexture);
        glBindTexture(GL_TEXTURE_2D, terrainPickTexture);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, window_width, window_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, terrainPickTexture, 0);

and skim pixels on the certain fbo

GLuint pickpixelColor[4];
    glReadBuffer(GL_COLOR_ATTACHMENT1);
    //glReadPixels(xpos, ypos, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixelColor);
    glReadPixels(static_cast<GLint>(xpos), static_cast<GLint>(ypos), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pickpixelColor2);

Then render:

glBindFramebuffer(GL_FRAMEBUFFER, terrain.terrainPickFBO);
GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
glDrawBuffers(1, drawBuffers);
terrain.render();

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *