Topper
15-02-2011 16:37:20
Hi,
i want to use the fluid position renderable from critter. but i don't understand how to use it.
i know it holds the hadware vertex buffer with all positions but i don't know how to get or use it. i tried a material with geometry shader but it doesn't work. i am not very familiar with geometry shader.
Maybe someone can help to make quads out of these points.
GEOMETRY SHADER:
Material:
i want to use the fluid position renderable from critter. but i don't understand how to use it.
i know it holds the hadware vertex buffer with all positions but i don't know how to get or use it. i tried a material with geometry shader but it doesn't work. i am not very familiar with geometry shader.
Maybe someone can help to make quads out of these points.
GEOMETRY SHADER:
#extension GL_EXT_geometry_shader4 : enable
uniform float sphere_radius;
varying out vec3 vertex_light_position;
varying out vec4 eye_position;
void main()
{
float halfsize = 0.5;//sphere_radius * 0.5;
gl_TexCoord[0] = gl_TexCoordIn[0][0];
gl_FrontColor = gl_FrontColorIn[0];
vertex_light_position = normalize(gl_LightSource[0].position.xyz);
eye_position = gl_PositionIn[0];
// Vertex 1
gl_TexCoord[0].st = vec2(-1.0,-1.0);
gl_Position = gl_PositionIn[0];
gl_Position.xy += vec2(-halfsize, -halfsize);
gl_Position = gl_ProjectionMatrix * gl_Position;
EmitVertex();
// Vertex 2
gl_TexCoord[0].st = vec2(-1.0,1.0);
gl_Position = gl_PositionIn[0];
gl_Position.xy += vec2(-halfsize, halfsize);
gl_Position = gl_ProjectionMatrix * gl_Position;
EmitVertex();
// Vertex 3
gl_TexCoord[0].st = vec2(1.0,-1.0);
gl_Position = gl_PositionIn[0];
gl_Position.xy += vec2(halfsize, -halfsize);
gl_Position = gl_ProjectionMatrix * gl_Position;
EmitVertex();
// Vertex 4
gl_TexCoord[0].st = vec2(1.0,1.0);
gl_Position = gl_PositionIn[0];
gl_Position.xy += vec2(halfsize, halfsize);
gl_Position = gl_ProjectionMatrix * gl_Position;
EmitVertex();
EndPrimitive();
}
Material:
geometry_program ParticleGS glsl
{
source ParticleGS.glsl
input_operation_type point_list
output_operation_type triangle_strip
max_output_vertices 4
default_params
{
param_named sphere_radius float 0.5
}
}