//**************************************************************************/ // Copyright (c) 2015 Autodesk, Inc. // All rights reserved. // // These coded instructions, statements, and computer programs contain // unpublished proprietary information written by Autodesk, Inc., and are // protected by Federal copyright law. They may not be disclosed to third // parties or copied or duplicated in any form, in whole or in part, without // the prior written consent of Autodesk, Inc. //**************************************************************************/ // Geometry shader that convert a point to a quad (2 triangles) // For input/output user variables you will need to define GS_FATPOINT_EMIT_USERDATA(index) // so that the geomtry shader can emit your data for new geometry uniform vec2 gsFatPointScreenSize : ViewportPixelSize ; uniform vec2 gsFatPointSize = {1, 1}; GLSLShader GS_FatPoint { layout (points) in; layout (triangle_strip, max_vertices = 4) out; struct GEO_OUT_struct { vec4 gsPosition; int gsPrimitiveID; int gsIndex; }; GEO_OUT_struct readGeoStructIn(int index) { GEO_OUT_struct outS; outS.gsPosition = gl_in[index].gl_Position; outS.gsPrimitiveID = gl_PrimitiveIDIn; outS.gsIndex = index; return outS; } void EmitGeoStruct(GEO_OUT_struct outS) { gl_Position = outS.gsPosition; gl_PrimitiveID = outS.gsPrimitiveID; #ifdef GS_FATPOINT_EMIT_USERDATA GS_FATPOINT_EMIT_USERDATA(outS.gsIndex) #endif EmitVertex(); } vec4 cQuadPts[4] = vec4[4]( vec4( -1.0, 1.0, 0, 0 ), vec4( -1.0, -1.0, 0, 0 ), vec4( 1.0, 1.0, 0, 0 ), vec4( 1.0, -1.0, 0, 0 )); void main() { GEO_OUT_struct outS = readGeoStructIn(0); vec4 Pc = outS.gsPosition; float depthPriority = 0.001; Pc.z -= depthPriority; float size = max(0, max(gsFatPointSize.x, gsFatPointSize.y)); vec4 sizeInZ = vec4(gsFatPointSize.xy / gsFatPointScreenSize.xy, 0, 0) * outS.gsPosition.w; for( int i = 0; i < 4; ++i ) { outS.gsPosition = Pc + sizeInZ * cQuadPts[i]; EmitGeoStruct( outS ); } EndPrimitive(); } }