Barycentrics solid wireframe shader

const vec3 vectors[3] = {
	vec3(1.0, 0.0 ,0.0),
	vec3(0.0, 1.0 ,0.0),
	vec3(0.0, 0.0 ,1.0)
};

varying vec3 barycentrics;

void vertex() {
	barycentrics = vectors[VERTEX_ID % 3];
}

void fragment() {
	vec3 dBaryCoordX = dFdx(barycentrics);
	vec3 dBaryCoordY = dFdy(barycentrics);
	vec3 dBaryCoord  = sqrt(dBaryCoordX * dBaryCoordX + dBaryCoordY * dBaryCoordY);
	vec3 Remap = smoothstep(vec3(0.0), dBaryCoord, barycentrics);
	float ClosestEdge = min(min(Remap.x, Remap.y), Remap.z);
	ALBEDO = vec3(ClosestEdge);
}

When I apply the shader to object, I am seeting weird thing that some of surfaces (mostly top/bottom) are appears as black, what can be the reason?
Is it because of wrong normal set to its surface?

Thanks,

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.