When I tried to pass an integer from a vertex shader to a fragment shader, i get “invalid operation”. I can expect it may have some trouble with interpolation performed in the rasterization stage. What I want to know is whether this is actually a prohibited operation or not. I think if integer passing is available, item buffer generation would be much easier.
When I tried to pass an integer from a vertex shader to a fragment shader, i get “invalid operation”.
Did the program link successfully? If there was a problem with the shader, it should have failed to link. So are you sure that the problem is with the integer value?
I think if integer passing is available, item buffer generation would be much easier.
Link was successful, but I get errors when I do glUseProgram(program).
Item buffer is an image where each pixel has an unique id of its primitive. If we generate an item buffer of a cube, then pixels of 3 visible faces will have IDs of faces. It is used for ray tracing acceleration and line visibility testing.
WEGHORST, H., HOOPER, G., AND GREENBERG, D. P. 1984.
Improved computational methods for ray tracing. ACM Transactions
on Graphics 3, 1 (Jan.), 52–69.
MARKOSIAN, L., KOWALSKI, M. A., GOLDSTEIN, D.,
TRYCHIN, S. J., HUGHES, J. F., AND BOURDEV, L. D. 1997.
Real-time nonphotorealistic rendering. In SIGGRAPH ’97: Proceedings
of the 24th annual conference on Computer graphics
and interactive techniques, 415–420
glUseProgram only generates errors if the program object is not a valid program object (ie: not returned by glCreateProgram) or if it was not successfully linked. So it looks like there’s something going on there.
Thank you for your answer.
It was my mistake. My program only displayed compile errors but link errors printing part was commented out. The link error said
“error C5215: Integer varying id must be flat”
I added ‘flat’ in front of ‘out’ like
Wow, I had to dig deep into the spec to find that one. I found it in the section on clipping of all things. I’d never have guessed it (but it does make some sense), but apparently this is true.