PDA

View Full Version : Points disappear with MSAA anabled



Ruskialt
05-29-2016, 01:28 PM
I have used 1D texture mapping for ages to render color by depth. This works nicely for lines and points. But when enabling MSAA, the points disappear. The lines are still drawing.

I've searched the internet, and I've stripped down my application to a bear minimum, played with toggling smoothing on/off, played with blendfunc, shade model... But now I'm running out of ideas. This is old school OpenGL, no shaders.

Here I'm uploading the texture
Gl.glGenTextures(1, out id);
Gl.glBindTexture(Gl.GL_TEXTURE_1D, id);
Gl.glTexParameteri( Gl.GL_TEXTURE_1D , Gl.GL_TEXTURE_WRAP_S , Gl.GL_CLAMP_TO_EDGE );
Gl.glTexImage1D(Gl.GL_TEXTURE_1D, 0, 4, texture1dpixels.Length, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, texture1dpixels);

Then I do this at every frame
Gl.glPushAttrib(Gl.GL_ENABLE_BIT | Gl.GL_TEXTURE_BIT );
Gl.glEnable(Gl.GL_TEXTURE_1D);
Gl.glEnable(Gl.GL_TEXTURE_GEN_S);
Gl.glBindTexture( Gl.GL_TEXTURE_1D , id );
Gl.glTexParameteri(Gl.GL_TEXTURE_1D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_1D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexGeni(Gl.GL_S, Gl.GL_TEXTURE_GEN_MODE, Gl.GL_OBJECT_LINEAR);

double u_per_x = 0;
double u_per_y = 0;
double u_per_z = 1.0/range_cm; //1 texture per per cm
double u0 = (playCenter_z-colorCenter_z) * u_per_z + 0.5; //u at (x,y,z)=(0,0,0) => the current matrix
double[] ps = { u_per_x , u_per_y , u_per_z , u0 };
Gl.glTexGendv(Gl.GL_S, Gl.GL_OBJECT_PLANE, ps);

//drawpoints
//draw lines


It works when just drawing solid points without texture mapping. But before I list more code, I can't see what could be wrong with this, as it works without MSAA. What am I missing with MSAA?

I couldn't attach image, so here's a link to my dropbox

https://dl.dropboxusercontent.com/u/57348330/msaa.png

Dark Photon
06-07-2016, 07:41 PM
... points. But when enabling MSAA, the points disappear. The lines are still drawing. ... It works when just drawing solid points without texture mapping.

But before I list more code, I can't see what could be wrong with this, as it works without MSAA. What am I missing with MSAA?

Interesting. Especially that the texturing seems to be causing the issue.

You might try drawing the points on an MSAA drawable with this:

1) glEnable( GL_MULTISAMPLE ); glEnable(GL_POINT_SPRITE)

or with:

2) glDisable( GL_MULTISAMPLE).

You also have some control over the point size in a few different ways, so you could try tweaking that. Failing that, you can definitely send a point sprite "quad" down the pipe (with one of several different methods).

Ref:
* https://www.opengl.org/discussion_boards/archive/index.php/t-181561.html