PDA

View Full Version : GL_POLYGON_SMOOTH



Leadwerks
08-10-2007, 12:21 PM
I have read all about GL_POLYGON_SMOOTH, and it seems simple. I am rendering some simple projected shadows to an FBO, so I thought this type of antialiasing would be perfect.

The important parts of my code are this:


glclearcolor 0,0,0,0
glClear GL_COLOR_BUFFER_BIT

gldisable GL_DEPTH_TEST
gldepthmask 0

glenable GL_BLEND
glBlendFunc GL_SRC_ALPHA_SATURATE,GL_ONE
glenable GL_POLYGON_SMOOTH
glHint GL_POLYGON_SMOOTH_HINT, GL_NICEST

glcolor4f 1,1,1,1
// Now draw stuffBut it looks like this (using GL_NEAREST for the filter so I can see it better):
http://www.leadwerks.com/post/smooth.jpg

Trenki
08-10-2007, 12:51 PM
If you want to get soft shadows GL_POLYGON_SMOOTH won't help you.

ZbuffeR
08-10-2007, 01:24 PM
Are you sure that your FBO has an alpha channel ?

Trenki, for oldskool projected shadows (http://www.sgi.com/products/software/opengl/examples/glut/examples/images/dinoshade.jpg) it should work.

Leadwerks
08-10-2007, 01:27 PM
The FBO is format GL_RGBA.

I am guessing this is just an old techique that isn't even supported on current drivers.

Trenki
08-11-2007, 02:46 AM
@ZbuffeR: I think the shadow in the image from the link you posted is just a normal planar shadow which does NOT use a texture at all! GL_POLYGON_SMOOTH won't make the shadow image in the texture soft!

zeoverlord
08-11-2007, 04:06 AM
PCF shadows (http://www.flashbang.se/postbreak.php?id=36) is what you need.

ZbuffeR
08-11-2007, 12:23 PM
@Trenki: my understanding of OP technique is to render shadow caster object with polygon smooth to a an FBO (instead of rendering to main framebuffer using stencil), and then using the FBO as darken texture.

@Leadwerks : speaking about basic tricks, maybe you can simply replace polygon smooth by multisampling if supported, or render to larger FBO and smooth it yourself. Whether these hacks are better than proper PCF is another question ...

Leadwerks
08-11-2007, 02:09 PM
This is for the old renderer, so it isn't using shadow maps at all. The new one already uses PCF.

Multisampling in the FBO is probably the best bet.

Trenki
08-12-2007, 03:30 AM
Multisampling in an FBO is not supported on all cards (e.g. ATI)! And Multisampling alone won't make the shadows less blocky. For that you would have to increase the size of the rendered to texture.

ZbuffeR
08-12-2007, 07:58 AM
I just tried, I got GL_POLYGON_SMOOTH working perfectly on FBO.
Started with this sample app :
http://www.reallyslick.com/src/fbo.tar.gz (thx to mogumbo)

Then added your settings for the part rendered to FBO.
It did not work with glBlendFunc GL_SRC_ALPHA_SATURATE,GL_ONE, dunno why.
A simple glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); did the trick instead.

An RGBA FBO is not needed, RGB is enough (only src component sampled).

Tested on Ubuntu Edgy with quite oldish drivers:
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce 6800 LE/AGP/SSE2/3DNOW!
OpenGL version string: 2.0.2 NVIDIA 87.76

HTH

Leadwerks
08-12-2007, 05:02 PM
Missing dll

ZbuffeR
08-13-2007, 11:45 AM
Oh, come on :)
Did you try to simply replace the blendfunc in your own code ?

zed
08-13-2007, 01:12 PM
It did not work with glBlendFunc GL_SRC_ALPHA_SATURATE,GL_ONE, dunno why.
A simple glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); did the trick instead. http://www.opengl.org/resources/faq/technical/rasterization.htm#rast0150

ZbuffeR
08-13-2007, 01:58 PM
True but http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/blendfunc.html
search for GL_POLYGON_SMOOTH.
So I guess the API reference is wrong ... or I really failed to get dest alpha on my FBO.
Anyway I hope Leadwerks' software is better now :p