Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

Equivalent of glHint(GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST);

This topic is 1492 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

Hi Guys,

 

Is there an equivalent for glHint(GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST) in DirectX 9c?

 

Thanks in advance smile.png

Share this post


Link to post
Share on other sites
Advertisement
Such a hint doesn’t make sense in the world of shaders. It exists neither in modern OpenGL nor in Direct3D.
In fixed-function Direct3D pipelines it would be enabled by default, if such an option existed.

Otherwise, changing how things are interpolated requires flags in the shader, and by default both OpenGL and Direct3D will perform “nicest” interpolations.

Short answer: No, because that is how Direct3D is already.


L. Spiro

Share this post


Link to post
Share on other sites

DirectX and GL will both perform perspective correction by default.
 
GL_PERSPECTIVE_CORRECTION_HINT in GL is a very weak request (not a demand) to the driver, where you can tell it that you'd like it to perform perspective correction at a lower-quality in exchange for better performance, if possible... It's not a very useful feature.
 

Hence the texture issue I have

What texture issue?

Share this post


Link to post
Share on other sites

For DirectX 3 and 5 perspective-correct texturing was disabled by default; I don't have SDKs currently available and so can't tell you the API used.

 

With DirectX 6 and 7 it was enabled by default and the API used to control it was SetRenderState with D3DRENDERSTATE_TEXTUREPERSPECTIVE (which had a value of 4 and used TRUE or FALSE to enable or disable).

 

From DirectX 8 onwards this render state was removed and an entry with a value of 4 is no longer present in the D3DRENDERSTATETYPE enum.  Perspective-correct texturing is always on.

 

Now, you might be able to call SetRenderState (4, TRUE) or SetRenderState (4, FALSE) and actually have your driver respect it (I suspect that an old Intel 965 I once had trouble with did), but that would mean that you're relying on your driver doing undocumented and unsupported behaviour, which is never a good idea.

 

As Hodgman said and I agree, it sounds like you've got a totallly different problem here and it would help a lot if you actually told us what that problem was rather than telling us what you think the solution might be.

Share this post


Link to post
Share on other sites

The problem is this;

 

400px-Perspective_correct_texture_mappin

 

I am getting what is happening in the second image, where I want the third.

 

I am getting this with DirectX 9c and DirectX 11.

 

This is happening on two different systems one with a Radeon HD5570 and the other with a Geforce GTX 750. So, both graphics cards a reasonably recent.

Edited by lonewolff

Share this post


Link to post
Share on other sites

If that shape is actually a square, but it's being viewed in a 3D environment at an angle, such that the top two verts are further away, the D3D/GL will give you the image on the right.

 

If the shape is 2D, and you've manually moved the top two verts closer together, you'll get the image in the middle. D3D/GL cannot magically fix this for you.

 

[edit] For others: here's a link to the original thread http://www.gamedev.net/topic/656573-texturing-issue/#entry5153177

Edited by Hodgman

Share this post


Link to post
Share on other sites

If the shape is 2D, and you've manually moved the top two verts closer together, you'll get the image in the middle. D3D/GL cannot magically fix this for you.


Exactly, this is the purpose for the original question. It seems that this GL Hint does 'magically' fix it.

Share this post


Link to post
Share on other sites

If the shape is 2D, and you've manually moved the top two verts closer together, you'll get the image in the middle. D3D/GL cannot magically fix this for you.


Exactly, this is the purpose for the original question. It seems that this GL Hint does 'magically' fix it.
You've use the hint in GL to fix your problem?

Share this post


Link to post
Share on other sites

 

If the shape is 2D, and you've manually moved the top two verts closer together, you'll get the image in the middle. D3D/GL cannot magically fix this for you.


Exactly, this is the purpose for the original question. It seems that this GL Hint does 'magically' fix it.

 

I highly doubt OpenGL can fix this also.

 

The hint is called "PERSPECTIVE". Which means it doesn't work for 2D. It needs the z (depth) value to calculate this correctly. In 2D no such things. The GPU can not know the context of that triangle in a 2d environement. And doesn't understand it is a quad at low level.

 

If all 4 points have the same z value in your 2D render (let say, 0), and GL gives you the right picture, then the driver or opengl is wrong. What about I want to skew a rectangle on the side?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!