Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9210231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:01:21+00:00 2026-06-18T01:01:21+00:00

How are texture coordinates interpolated in a GLSL shader? I’m trying to downsample an

  • 0

How are texture coordinates interpolated in a GLSL shader?

I’m trying to downsample an image from screen size to 1/4 its original size. This is a pretty simple procedure but it doesn’t seem to be correct. I have an FBO, with a single colour attachment to use as a target that is 1/4 screen size.

In order to downsample the texture, I have a simple full-size quad that I’m going to draw, where coordinates are as follows:

v[0].v.position.x = -1.f; v[0].v.position.y = -1.f; v[0].v.position.z = 0.f;
v[1].v.position.x = -1.f; v[1].v.position.y =  1.f; v[1].v.position.z = 0.f;
v[2].v.position.x =  1.f; v[2].v.position.y = -1.f; v[2].v.position.z = 0.f;
v[3].v.position.x =  1.f; v[3].v.position.y =  1.f; v[3].v.position.z = 0.f;

Now, my vertex shader simply scales and biases the input coordinates in order to generate texture coordinates, passing through the vertices without need to transform them and without the need for me to pass texture coordinates in with the geometry, as follows:

#version 420

layout(location = 0) in vec3 attrib_Position;

out vec2 attrib_Fragment_Texture;

void main()
{
    attrib_Fragment_Texture = attrib_Position.xy * 0.5 + 0.5; 

    gl_Position = vec4(attrib_Position.xy, 0.0, 1.0);
}

So the texture coordinates output as *attrib_Fragment_Texture* will go from 0.0 to 1.0 as the vertex coordinates go from -1 to 1. A little test of this with the following shader however, seems to show that uv.x and uv.y only go from 0.0 to 0.25. I expected them to interpolate from 0.0 to 1.0!

#version 420

in vec2 attrib_Fragment_Texture;

out vec4 Out_Colour;

void main(void)
{
    vec2 uv = attrib_Fragment_Texture.xy;

    Out_Colour = vec4(uv.x, uv.y, 1.0, 1.0);
}

Can anyone spot what my obviously simple mistake/misunderstanding might be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:01:22+00:00Added an answer on June 18, 2026 at 1:01 am

    I suspect you’re rendering with the original viewport, which is 4x the size of your FBO, resulting in most of the primitive being clipped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm debating the pros and cons of passing texture coordinates to a GLSL shader
I have some vertex data. Positions, normals, texture coordinates. I probably loaded it from
I am trying to understand how to specify texture coordinates for a GL_QUAD_STRIP. I
I'm trying to load an image into a texture, then draw into the texture.
I'm trying to figure out how to do texture mapping using GLSL version 4.10.
I am trying to use element indexes with my vertex and texture coordinates stored
This information doesn't exist on Google somehow. I need to transfer texture coordinates to
What I currently have: Generating of texture coordinates given the width and height of
I'm currently using a VBO for the texture coordinates, normals and the vertices of
I load a texture with grayscale image using GL_LUMINANCE format. when i use float

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.