Testing new AA algorithm for current lines.

This commit is contained in:
Jonathas Costa
2019-08-20 23:03:49 -04:00
parent aa3ac0e3f2
commit 5c65801bd9
4 changed files with 29 additions and 3 deletions
+8 -2
View File
@@ -38,10 +38,10 @@ namespace {
constexpr const char* ProgramName = "EphemerisProgram";
constexpr const char* KeyTranslation = "Translation";
constexpr const std::array<const char*, 12> UniformNames = {
constexpr const std::array<const char*, 13> UniformNames = {
"opacity", "modelViewTransform", "projectionTransform", "color", "useLineFade",
"lineFade", "vertexSortingMethod", "idOffset", "nVertices", "stride", "pointSize",
"renderPhase"
"renderPhase", "resolution"
};
// The possible values for the _renderingModes property
@@ -301,6 +301,9 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
_programObject->setUniform(_uniformCache.lineFade, _appearance.lineFade);
}
/*glm::ivec2 resolution = global::renderEngine.renderingResolution();
_programObject->setUniform(_uniformCache.resolution, resolution);*/
static std::map<RenderInformation::VertexSorting, int> SortingMapping = {
// Fragile! Keep in sync with shader
{ RenderInformation::VertexSorting::NewestFirst, 0 },
@@ -352,6 +355,9 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
p->setUniform(c.nVertices, nVertices);
glm::ivec2 resolution = global::renderEngine.renderingResolution();
p->setUniform(c.resolution, resolution);
if (renderPoints) {
// The stride parameter determines the distance between larger points and
// smaller ones
+2 -1
View File
@@ -182,7 +182,8 @@ private:
ghoul::opengl::ProgramObject* _programObject = nullptr;
UniformCache(opacity, modelView, projection, color, useLineFade, lineFade,
vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase) _uniformCache;
vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase,
resolution) _uniformCache;
};
} // namespace openspace
@@ -28,6 +28,7 @@ in vec4 vs_positionScreenSpace;
in vec4 vs_gPosition;
in float fade;
in float v_pointSize;
in vec2 lineCenterArray;
uniform vec3 color;
uniform int renderPhase;
@@ -60,6 +61,18 @@ Fragment getFragment() {
frag.color.a = transparencyCorrection;
}
double distanceCenter = length(lineCenterArray - vec2(gl_FragCoord.xy));
double lineWidth = 1E20;//4.0;
float blendFactor = 1.5;
//if (distanceCenter > lineWidth) {
// if (distanceCenter > 1E20) {
// frag.color = vec4(1.0, 0.0, 0.0, 1.0);
// //frag.color.w = 0;
// } else {
frag.color.w = pow( float((lineWidth - distanceCenter) / lineWidth), blendFactor);
//frag.color.w = 1.0;
//}
frag.gPosition = vs_gPosition;
// There is no normal here
@@ -32,6 +32,7 @@ out vec4 vs_positionScreenSpace;
out vec4 vs_gPosition;
out float fade;
out float v_pointSize;
out vec2 lineCenterArray;
uniform dmat4 modelViewTransform;
uniform mat4 projectionTransform;
@@ -43,6 +44,8 @@ uniform int vertexSortingMethod;
uniform int pointSize;
uniform int stride;
uniform ivec2 resolution;
// Fragile! Keep in sync with RenderableTrail::render
#define VERTEX_SORTING_NEWESTFIRST 0
#define VERTEX_SORTING_OLDESTFIRST 1
@@ -78,4 +81,7 @@ void main() {
gl_PointSize = (stride == 1 || int(modId) % stride == 0) ? float(pointSize) : float(pointSize) / 2;
v_pointSize = gl_PointSize;
gl_Position = vs_positionScreenSpace;
vec2 vp = vec2(resolution);
lineCenterArray = 0.5 * (vs_positionScreenSpace.xy + vec2(1.0)) * vp;
}