mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Better way of drawing the view sphere outline.
This commit is contained in:
parent
dfa1a66906
commit
90b8409017
3 changed files with 19 additions and 9 deletions
|
@ -374,6 +374,7 @@ void lcContext::SetMaterial(lcMaterialType MaterialType)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LC_MATERIAL_UNLIT_VIEW_SPHERE:
|
||||||
case LC_NUM_MATERIALS:
|
case LC_NUM_MATERIALS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,23 @@ void lcViewSphere::Draw()
|
||||||
int Bottom = (Location == lcViewSphereLocation::BOTTOM_LEFT || Location == lcViewSphereLocation::BOTTOM_RIGHT) ? 0 : Height - ViewportSize;
|
int Bottom = (Location == lcViewSphereLocation::BOTTOM_LEFT || Location == lcViewSphereLocation::BOTTOM_RIGHT) ? 0 : Height - ViewportSize;
|
||||||
Context->SetViewport(Left, Bottom, ViewportSize, ViewportSize);
|
Context->SetViewport(Left, Bottom, ViewportSize, ViewportSize);
|
||||||
|
|
||||||
|
glDepthFunc(GL_ALWAYS);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
Context->SetVertexBuffer(mVertexBuffer);
|
||||||
|
Context->SetVertexFormatPosition(3);
|
||||||
|
Context->SetIndexBuffer(mIndexBuffer);
|
||||||
|
|
||||||
|
Context->SetMaterial(LC_MATERIAL_UNLIT_COLOR);
|
||||||
|
Context->SetColor(lcVector4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
|
float Scale = 1.005f + 2.0f / (float)ViewportSize;
|
||||||
|
Context->SetWorldMatrix(lcMatrix44Scale(lcVector3(Scale, Scale, Scale)));
|
||||||
|
Context->SetViewMatrix(GetViewMatrix());
|
||||||
|
Context->SetProjectionMatrix(GetProjectionMatrix());
|
||||||
|
|
||||||
|
Context->DrawIndexedPrimitives(GL_TRIANGLES, mSubdivisions * mSubdivisions * 6 * 6, GL_UNSIGNED_SHORT, 0);
|
||||||
|
|
||||||
Context->SetMaterial(LC_MATERIAL_UNLIT_VIEW_SPHERE);
|
Context->SetMaterial(LC_MATERIAL_UNLIT_VIEW_SPHERE);
|
||||||
Context->BindTextureCubeMap(mTexture->mTexture);
|
Context->BindTextureCubeMap(mTexture->mTexture);
|
||||||
|
|
||||||
|
@ -173,13 +190,6 @@ void lcViewSphere::Draw()
|
||||||
Context->SetViewMatrix(GetViewMatrix());
|
Context->SetViewMatrix(GetViewMatrix());
|
||||||
Context->SetProjectionMatrix(GetProjectionMatrix());
|
Context->SetProjectionMatrix(GetProjectionMatrix());
|
||||||
|
|
||||||
glDepthFunc(GL_ALWAYS);
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
|
|
||||||
Context->SetVertexBuffer(mVertexBuffer);
|
|
||||||
Context->SetVertexFormatPosition(3);
|
|
||||||
Context->SetIndexBuffer(mIndexBuffer);
|
|
||||||
|
|
||||||
lcVector4 HighlightPosition(0.0f, 0.0f, 0.0f, 0.0f);
|
lcVector4 HighlightPosition(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
if (mIntersectionFlags.any())
|
if (mIntersectionFlags.any())
|
||||||
|
|
|
@ -9,7 +9,6 @@ void main()
|
||||||
LC_SHADER_PRECISION float TexelAlpha = textureCube(Texture, PixelNormal).a;
|
LC_SHADER_PRECISION float TexelAlpha = textureCube(Texture, PixelNormal).a;
|
||||||
LC_SHADER_PRECISION float Distance = length(vec3(HighlightParams[0]) - PixelNormal);
|
LC_SHADER_PRECISION float Distance = length(vec3(HighlightParams[0]) - PixelNormal);
|
||||||
LC_SHADER_PRECISION float Highlight = step(Distance, HighlightParams[0].w);
|
LC_SHADER_PRECISION float Highlight = step(Distance, HighlightParams[0].w);
|
||||||
LC_SHADER_PRECISION float Edge = smoothstep(0.05, 0.15, dot(PixelNormal, vec3(HighlightParams[4])));
|
|
||||||
|
|
||||||
gl_FragColor = mix(mix(HighlightParams[2], HighlightParams[3], Highlight), HighlightParams[1], TexelAlpha) * Edge;
|
gl_FragColor = mix(mix(HighlightParams[2], HighlightParams[3], Highlight), HighlightParams[1], TexelAlpha);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue