Translucent mesh sorting fixes and improvements.

This commit is contained in:
Leonardo Zide 2019-11-16 12:15:49 -08:00
parent 8cfddcefa3
commit 081373742e
4 changed files with 14 additions and 5 deletions

View file

@ -45,7 +45,7 @@ void lcScene::End()
auto TranslucentMeshCompare = [this](int Index1, int Index2)
{
return mRenderMeshes[Index1].Distance < mRenderMeshes[Index2].Distance;
return mRenderMeshes[Index1].Distance > mRenderMeshes[Index2].Distance;
};
std::sort(mTranslucentMeshes.begin(), mTranslucentMeshes.end(), TranslucentMeshCompare);

View file

@ -27,6 +27,11 @@ public:
return mActiveSubmodelInstance;
}
const lcMatrix44& GetViewMatrix() const
{
return mViewMatrix;
}
void SetDrawInterface(bool DrawInterface)
{
mDrawInterface = DrawInterface;

View file

@ -874,6 +874,12 @@ void View::OnDraw()
mContext->SetProjectionMatrix(GetProjectionMatrix());
}
if (DrawInterface)
{
mContext->SetViewMatrix(mScene.GetViewMatrix());
DrawGrid();
}
mContext->SetLineWidth(Preferences.mLineWidth);
mScene.Draw(mContext);
@ -912,8 +918,6 @@ void View::OnDraw()
mContext->SetLineWidth(1.0f);
DrawGrid();
if (Preferences.mDrawAxes)
DrawAxes();

View file

@ -12,6 +12,6 @@ void main()
{
LC_PIXEL_FAKE_LIGHTING
LC_SHADER_PRECISION vec4 TexelColor = texture2D(Texture, PixelTexCoord);
LC_SHADER_PRECISION vec4 DiffuseColor = mix(MaterialColor, TexelColor, TexelColor.a);
gl_FragColor = vec4(vec3(DiffuseColor) * Diffuse + SpecularColor, DiffuseColor.a);
LC_SHADER_PRECISION vec3 DiffuseColor = mix(MaterialColor.rgb, TexelColor.rgb, TexelColor.a);
gl_FragColor = vec4(DiffuseColor * Diffuse + SpecularColor, max(TexelColor.a, MaterialColor.a));
}