PDA

View Full Version : Point distance attenuation problem?



Dormouse
02-12-2010, 03:03 AM
Hello everyone here~

I am working with CGFX Shader. In my project, I used 3D points dataset. I've implemented CGGX Shader on 3d points to have the Point Size Attenuation effect. In my CGFX shader I found: 'PointDistanceAttenuation = float3(1.0, 0, 0);' in 'Renderstates of Vertex Pipeline'

I've tried with PointDistanceAttenuation = float3(0,1.0,0) to have a linear point size attenuation, but it doesn't work, all the points look like in a same size.

Actually, the 3D points which are far away should look smaller than those closer to the viewer.

Anybody knows:
--How to active PointDistanceAttenuation property in CGFX shader?
--or before activation of PointDistanceAttenuation I have to enable other states?
--PointDistanceAttnuation is used to set PointSize? or Point lighting?


Thx in advance~

Dark Photon
02-12-2010, 05:48 AM
I am working with CGFX Shader. In my project, I used 3D points dataset. I've implemented CGGX Shader on 3d points to have the Point Size Attenuation effect. In my CGFX shader I found: 'PointDistanceAttenuation = float3(1.0, 0, 0);' in 'Renderstates of Vertex Pipeline'

I've tried with PointDistanceAttenuation = float3(0,1.0,0) to have a linear point size attenuation, but it doesn't work, all the points look like in a same size.
Well, I'm no point sprite guru, but I'm guessing that PointDistanceAttenuation is POINT_DISTANCE_ATTENUATION in ARB_point_parameters (http://www.opengl.org/registry/specs/ARB/point_parameters.txt). This is the old pre-shaders way of controlling point spites.

You're using CgFX. So you're writing your own shaders. Just set the point size yourself! glEnable( GL_VERTEX_PROGRAM_POINT_SIZE ) -- aka GL_PROGRAM_POINT_SIZE in GL3.2 -- and then set gl_PointSize in the vertex shader. You'll need to map gl_PointSize (GLSL) to Cg language though.