vec2 offSet[4];
offSet[0] = vec2(0.,0.);
offSet[1] = vec2(0.,1.);
offSet[2] = vec2(1.,0.);
offSet[3] = vec2(1.,1.);
vec3 zAxis = normalize( vNormal[0] );
vec3 yAxis = vec3( 0.0, 1.0, 0.0 );
vec3 xAxis = normalize( cross(zAxis, yAxis) );
yAxis = normalize( cross(xAxis, zAxis) );
xAxis *= pointSize;
yAxis *= pointSize;
for(int i = 0; i < 4; i++){
vec3 dir = ((offSet[i].x*2.-1.)*xAxis) + ((offSet[i].y*2.-1.)*yAxis);
gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_PositionIn[0].xyz+dir,1.0);
gl_TexCoord[0].xy = offSet[i].xy;
gl_FrontColor = gl_FrontColorIn[0];
EmitVertex();
}
EndPrimitive();
Forked from patriciogonzalezvivo/GLSL-geom-billboard.md
Created
February 13, 2016 03:06
-
-
Save motoishmz/003f7e76e032147e5009 to your computer and use it in GitHub Desktop.
GLSL Geom shader billboard
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment