Skip to content

Instantly share code, notes, and snippets.

@mousebird
Created March 9, 2020 23:06
Show Gist options
  • Save mousebird/f9fc90f197e7a07913f5d43dcc62baf2 to your computer and use it in GitHub Desktop.
Save mousebird/f9fc90f197e7a07913f5d43dcc62baf2 to your computer and use it in GitHub Desktop.
struct VertexArgBufferA {
const device Uniforms *uniforms [[ id(WKSUniformArgBuffer) ]];
const device UniformDrawStateA *uniDrawState [[ id(WKSUniformDrawStateArgBuffer) ]];
};
// Vertex shader for simple line on the globe
vertex ProjVertexA vertexLineOnly_globe(
VertexA vert [[stage_in]],
const device VertexArgBufferA & vertArgs [[buffer(WKSVertexArgBuffer)]])
{
ProjVertexA outVert;
outVert.color = float4(vert.color) * vertArgs.uniDrawState->fade;
if (vertArgs.uniDrawState->clipCoords) {
outVert.dotProd = 1.0;
outVert.position = vertArgs.uniforms->mvpMatrix * float4(vert.position,1.0);
} else {
float4 pt = vertArgs.uniforms->mvMatrix * float4(vert.position, 1.0);
pt /= pt.w;
float4 testNorm = vertArgs.uniforms->mvNormalMatrix * float4(vert.normal,0.0);
outVert.dotProd = dot(-pt.xyz,testNorm.xyz);
outVert.position = vertArgs.uniforms->mvpMatrix * float4(vert.position,1.0);
}
return outVert;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment