I'm still pretty new to GLGraphics and I just wanted to ask what the best way to create a semi-transparent shape was. I have rendered a sphere based on the globe example, but need to be able to see through it to an extent.
Should I then just apply colours with an alpha value to each vertex, or do I need to use a sprite or texture or something which is semitransparent? I'm after a very basic example or explanation. This sphere must be a GLModel.
And then how should I combine rendering that sphere with rendering other lines/point/shape GLModels which surround the sphere which may or may not be semi-transparent themselves? Blending modes and depth masking etc
hi, you can either use a semitransparent texture for your model, or set the alpha value of its vertices. Both approaches should give you same visual results.
The problem with semi-transparent geometry is that, unless you depth-sort it every frame to make sure that the closest faces to the camera are drawn first, then you will get artifacts due to the alpha blending. A cheap trick to take care of these artifacts somewhat is to disable the depth mask when drawing your semi-transparent model:
although there might be better ways of doing this.
Is there another way to depth sort things? I've disabled the depth mask, however the problem I'm getting is that it doesn't seem to depth sort by vertex, but it depth sorts by GLModel's overall position (or something similar). So I'm getting this:
the geography GLModel has a slightly larger radius here to show the sphere (which is inside the geography, consdering the cartesian coordinates of all of the vertices) is blocking everything inside, in front of and behind it. You can then see a ring of unobscured geography lines around the outside. I should be seeing the geography on the back side of the planet, but much more faintly, while the geography on the front should be solid untransparent white.
Is there a way around this problem? The red dots, the geography and the sphere are all GLModels, but the meridian lines are drawn with arc().
By disabling the depth mask you are not doing depth sorting, but simply stopping to write to the depth buffer. The consequence of this, the way I understand it, is that a piece of semi-transparent geometry that is in the back of the view and gets drawn last will be still alpha blended with the things that are in the front (and drawn first) because the former is not occluded by the later (since the depth information is not being recorded).
Do you want the entire surface of the earth globe to be semi-transparent, or only the area that corresponds to the oceans?
Ok that completely explains the results I am getting, thanks!
What I want to do is hopefully quite simple. The geography lines are completely opaque, but I want this 'sphere' in the middle to be semi-transparent so that all of the lines on the far side of the earth appear faded out. Would it be better to test the position of each vertex for whether it is on the front or the back of the planet and then change its colour correspondingly, or is there a way to properly depth sort every vertex?
Leave a comment on rafe.copeland's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic