Read sample coverage in fragment shader?

Started by
2 comments, last by coderchris 9 years, 1 month ago

I know through some recent extensions (NV_sample_mask_override_coverage) it is possible to overwrite the coverage mask used to ultimately decide which samples get written to by the rasterizer.

What I want to do is is not override the coverage mask, rather I just want to read it and output to an integer texture. It appears gl_SampleMask is output only...

Is it possible through the core API or an extension?

I could manually compute pixel coverage in the fragment shader by doing a bunch of point in triangle tests, but if the hardware can already do this, I would rather not repeat the work...

Advertisement

You're in luck biggrin.png There's an input version of gl_SampleMask, suitably named gl_SampleMaskIn

https://www.opengl.org/sdk/docs/man/html/gl_SampleMaskIn.xhtml

You still can sample your cover information in fragment shader and discard fragment output. But you did not describe your scenario very much so I am just stabing in the dark so to speak

Perfect thanks!

gl_SampleMaskIn is exactly what I was looking for.

This topic is closed to new replies.

Advertisement