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 8875103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:53:34+00:00 2026-06-14T18:53:34+00:00

In my shader I already have a special variable that has the entire content

  • 0

In my shader I already have a special variable that has the entire content of previously rendered screen. It is stored in

uniform sampler2D _GrabTexture;

Which it’s content should be:
Screen content

(As a side note, I’m using Unity’s GrabPass{} to get the entire screen. Also please ignore Unity’s GUI)

Now how can I render one more pass, using _GrabTexture as a texture for my plane model, so the result is exactly the same as my _GrabTexture?

(The point is, I can apply some effects like blur,sharpen,etc to that screen texture before render one more pass so the plane’s texture is now stylized.)

I’m trying this in the final pass. The variable is declared in both Vertex & Fragment Shader.

uniform sampler2D _GrabTexture;
varying vec4 v_Position;

Vertex Shader :

void main()
        {
            gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
            v_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

        }

Store the screen coordinate of each model’s vertex as varying, to be used in Fragment Shader.

Fragment Shader :

void main()
        {
            gl_FragColor = texture2D(_GrabTexture,vec2(v_Position)); 
        }

Now use that stored varying position to access the _GrabTexture screen texture. Since it’s entire screen my v_Position which is already in screen coordinate should correctly got the right pixel.

But the result is

enter image description here

As you can see the plane’s texture is ‘sorts of’ showing previously rendered screen but the coordinate is not right. How can I fix it so the result is the same as first image?

  • 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-14T18:53:36+00:00Added an answer on June 14, 2026 at 6:53 pm

    You’re thinking too complicated. OpenGL tells you the on-screen fragment position in the fragment shader built in variable gl_FragCoord.

    With GLSL-1.30 or newer you have texelFetch which you can give gl_FragCoord as source coordinate directly. Or you use translate gl_FragCoord into texture space coordinates, see https://stackoverflow.com/a/5879551/524368

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

Sidebar

Related Questions

Please note that I have already been through similar questions and their answers here
I was having previously already the problem that I wanted to blend color values
I have some questions derived from a problem that I have already solved through
I have a fragment shader with the following attributes: varying highp vec2 coordinate; precision
When managing shader's, does it make sense to have all of them compiled and
I have a GLSL shader program running my iPhone app (it's a very very
I introduced a geometry shader to my OpenGL application. My shaders have quite a
I have successfully implemented a cel shader using glsl. But my problem is about
I have a project that is coming around the bend this summer that is
Frag shader: out vec4 Color; uniform samplerBuffer sampler; uniform int index; void main() {

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.