Added outline to the view sphere. Closes #281.

This commit is contained in:
Leonardo Zide 2019-01-21 16:54:10 -08:00
parent 40ad756348
commit dfa1a66906
3 changed files with 9 additions and 4 deletions

View file

@ -1179,7 +1179,10 @@ void lcContext::FlushState()
if (mHighlightParamsDirty && Program.HighlightParamsLocation != -1)
{
glUniform4fv(Program.HighlightParamsLocation, 4, mHighlightParams[0]);
lcMatrix44 InverseViewMatrix = lcMatrix44AffineInverse(mViewMatrix);
mHighlightParams[4] = InverseViewMatrix[2];
glUniform4fv(Program.HighlightParamsLocation, 5, mHighlightParams[0]);
mHighlightParamsDirty = false;
}
}

View file

@ -229,7 +229,7 @@ protected:
lcMatrix44 mViewMatrix;
lcMatrix44 mProjectionMatrix;
lcMatrix44 mViewProjectionMatrix;
lcVector4 mHighlightParams[4];
lcVector4 mHighlightParams[5];
bool mColorDirty;
bool mWorldMatrixDirty;
bool mViewMatrixDirty;

View file

@ -1,7 +1,7 @@
LC_PIXEL_INPUT vec3 PixelNormal;
LC_PIXEL_OUTPUT
uniform mediump vec4 HighlightParams[4];
uniform mediump vec4 HighlightParams[5];
uniform samplerCube Texture;
void main()
@ -9,5 +9,7 @@ void main()
LC_SHADER_PRECISION float TexelAlpha = textureCube(Texture, PixelNormal).a;
LC_SHADER_PRECISION float Distance = length(vec3(HighlightParams[0]) - PixelNormal);
LC_SHADER_PRECISION float Highlight = step(Distance, HighlightParams[0].w);
gl_FragColor = mix(mix(HighlightParams[2], HighlightParams[3], Highlight), HighlightParams[1], TexelAlpha);
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;
}