Jump to content
  • Advertisement
Sign in to follow this  
lifeless

Can one calculate the glViewport inside a vertex shader

This topic is 3082 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have the unfortunate pleasure of working with an Intel GMA 500. The thing is buggy in every little corner you find but I have been able to drive around all of these except for one. The glViewport. So, I need to do different render passes all of them rendering in different parts of the screen (sometimes overlapping). This works fine in my desktop machine with glViewport, but it is just not working on the GMA500. For some reason, however, vertex shaders are (sort of) working fine. As far as my understanding goes, I think I could apply the glViewport transformation here myself, but the problem is that I have no idea how this looks. Has anybody tried this?, any hints or pointers would be appreciated, thanks!

Share this post


Link to post
Share on other sites
Advertisement

The projection matrix gives out verticies in a cube surrounding the origin between -1 and 1 in the XY directions.

The viewport mapping ought to be something like; (width*x+width/2 + left), (height*y+height/2 + top) where x&y are the outputs from the regular projection transform. (z runs 0..1 IIRC).

The only thing I can't recall off the top of my head is who copes with the aspect ratio of the viewport. I think it may be the projection matrix -- I wrote an inverse of this operation recently and didn't need to do anything to handle it, so it would seem reasonable that the projection's X & Y range are both -1..1 regardless of the shape of the window.

I would say though, that I don't recall there being a way to inform the rasterizer stage that you're supplying screen coords...

Share this post


Link to post
Share on other sites
Yes, that seems to be the case. Naively I thought that the mapping could be just added to the vertex position but it looks like the glViewport equations happen after rasterization and before they are delivered to the fragment shader.

Will have to look for another solution. I guess if I had Framebuffer Objects I could do the remapping myself.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!