Hi, Frank

With vertex arrays disabled your program ignored.
You should use setDefaultAttributesUsingShaders, and set your program with 
override flag. If you use vertex shaders - set mode 
GL_VERTEX_PROGRAM_POINT_SIZE on, mode GL_POINT_SPRITE on,  and in vertex shader 
write to gl_PointSize  -> value in pixels. Cant say if this even works without 
them. Particles size will be different from what you getting without shaders 
and depending on screen resolution so you need to use some uniforms with screen 
size etc to sort this out.

If you dont see anything try to change particles size (i'd say raise in 1-2 
orders of magnitude) just to see if problem here.
example shaders that should draw something:

    char vertexShaderSource[] =
        "#version 120\n"
        "uniform float visibilityDistance;\n"
        "varying vec3 basic_prop;\n"
        "\n"
        "void main(void)\n"
        "{\n"
        "    basic_prop = gl_MultiTexCoord0.xyz;\n"
        "    vec4 ecPos = gl_ModelViewMatrix * gl_Vertex;\n"
        "    gl_Position = ftransform();\n"
        "    gl_PointSize = basic_prop.y/length(ecPos.xyz);\n"
        "    gl_ClipVertex = ecPos;\n"
        "}\n";
    char fragmentShaderSource[] =
        "#version 120\n"
        "\n"
        "void main(void)\n"
        "{\n"
        "    vec4 color = vec4(abs(gl_PointCoord.xy), 1.0, 1.0);\n"
        "    gl_FragColor = color;\n"
        "}\n";

Cheers.

06.01.2012, 04:55, "Frank Sullivan" <knarf.navil...@gmail.com>:
> Hi,
>
> I need to render the particles using a custom shader that includes a special 
> lighting system that I'm using. If I can just get the Particle System to pay 
> attention to the shader that I wrote, I think everything will be dandy. 
> However, I am having some trouble with this, and I am hoping for some insight.
>
> In order to test this, I wrote a simple shader program with a fragment shader 
> that outputs the color red. There is no vertex or geometry shader. This way, 
> if I'm using the shader program correctly, I should see flat red particles. 
> If I'm using the shader program incorrectly, depending on the problem, I'll 
> either see black particles, or invisible particles, or perhaps particles that 
> look as if they're being rendered without shaders (i.e., how they looked 
> before I embarked on this task).
>
> The first thing I tried is to simply follow the osgparticleshader example, 
> without using my red shader at all, just to see if I could get particles 
> working with shaders. Unfortunately, if I call 
> setDefaultAttributesUsingShaders, the result is invisible particles. After 
> much debugging, I discovered that I can get the particles to come back if I 
> call setUseVertexArray(false). So, I think there is something that it doesn't 
> like about using vertex arrays (at least in the context of my program).
>
> With vertex arrays disabled, the particle system seems to be using immediate 
> mode draw calls, which I don't mind. However, I can't tell if it's actually 
> using the shader or not, because the particles look the same either way.
>
> So, I tried adding my "red" shader program to the state set, and that did not 
> help. The particles drew normally, as if it was ignoring my program and using 
> the fixed function pipeline instead.
>
> I suppose it's possible that the particle system now had two programs -- the 
> one set by setDefaultAttributesUsingShaders and the one set by me. So, to 
> rule out such a conflict, I omitted the call to 
> setDefaultAttributesUsingShaders and instead replaced it with everything the 
> method does (essentially inlining the method myself), with the exception that 
> it uses my "red" shader program instead of the stock one. Still, however, it 
> seemed to ignore my shader.
>
> Can anyone think of what I might be doing wrong? My next step will be to try 
> to accomplish this in isolation in a stand-alone program, but I just wanted 
> to check and see if there are any ideas.
>
> Thank you!
>
> Cheers,
> Frank
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=44648#44648
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to