Hi there,
Im try to draw points on screen from point data only ( comes from gpu direct sop or regular sop ). Currently I
m not sure about how to get point position,
this is my current try:
Vertex :
out Vertex
{
vec4 color;
vec3 worldSpacePos;
flat int cameraIndex;
} oVert;void main()
{// First deform the vertex and normal
// TDDeform always returns values in world space
vec4 worldSpacePos = TDDeform(P);
// Let the geometry shader do the conversion to projection space.
gl_Position = worldSpacePos;// This is here to ensure we only execute lighting etc. code
// when we need it. If picking is active we don’t need lighting, so
// this entire block of code will be ommited from the compile.
// The TD_PICKING_ACTIVE define will be set automatically when
// picking is active.
#ifndef TD_PICKING_ACTIVEint cameraIndex = TDCameraIndex();
oVert.cameraIndex = cameraIndex;
oVert.worldSpacePos.xyz = worldSpacePos.xyz;
oVert.color = TDInstanceColor(Cd);#else // TD_PICKING_ACTIVE
// This will automatically write out the nessessary values
// for this shader to work with picking.
// See the documentation if you want to write custom values for picking.
TDWritePickingValues();#endif // TD_PICKING_ACTIVE
}
Geometry :
layout(points, max_vertices = 1) out;
layout(points) in;in vec3 ioUVUnwrapCoord;
in Vertex
{
vec4 color;
vec3 worldSpacePos;flat int cameraIndex;
} iVert;out Vertex
{
vec4 color;
vec3 worldSpacePos;
flat int cameraIndex;
} oVert;void main()
{oVert.color = iVert[0].color;
oVert.worldSpacePos = iVert[0].worldSpacePos;oVert.cameraIndex = iVert[0].cameraIndex;
gl_Position = TDWorldToProj(gl_in[0].gl_Position, ioUVUnwrapCoord[0], iVert[0].cameraIndex);gl_PointSize = 1;
EmitVertex();EndPrimitive();
}
pixel:
in Vertex
{
vec4 color;
vec3 worldSpacePos;
flat int cameraIndex;
} iVert;// Output variable for the color
layout(location = 0) out vec4 oFragColor[TD_NUM_COLOR_BUFFERS];
void main()
{
// This allows things such as order independent transparency
// and Dual-Paraboloid rendering to work properly
TDCheckDiscard();vec4 outcol = vec4(0.0, 0.0, 0.0, 0.0);
vec3 viewVec = normalize(uTDMats[iVert.cameraIndex].camInverse[3].xyz - iVert.worldSpacePos.xyz );
// Alpha Calculation
float alpha = iVert.color.a ;// Dithering, does nothing if dithering is disabled
outcol = TDDither(outcol);outcol.rgb *= alpha;
// Modern GL removed the implicit alpha test, so we need to apply
// it manually here. This function does nothing if alpha test is disabled.
TDAlphaTest(alpha);outcol.a = alpha;
oFragColor[0] = TDOutputSwizzle( iVert.color );// TD_NUM_COLOR_BUFFERS will be set to the number of color buffers
// active in the render. By default we want to output zero to every
// buffer except the first one.
for (int i = 1; i < TD_NUM_COLOR_BUFFERS; i++)
{
oFragColor[i] = vec4(0.0);
}
}