From 44d5cad17be99be76c875df15fce718ea7ca684d Mon Sep 17 00:00:00 2001 From: Christian Adamsson Date: Wed, 8 Jul 2020 14:16:34 +0200 Subject: [PATCH] Rendering lines with flow --- .../rendering/renderablestreamnodes.cpp | 78 +++++++++---------- .../shaders/streamnodes_vs.glsl | 18 ++++- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp index db15c91ea2..abdc570b01 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp +++ b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp @@ -1192,45 +1192,45 @@ void RenderableStreamNodes::render(const RenderData& data, RendererTasks&) { _lineCount.data(), static_cast(_lineStart.size()) );*/ - - _shaderProgram->setUniform("firstrender", true); - GLint temp = 0; - glDrawArrays( - GL_POINTS, - temp, - static_cast(_vertexPositions.size()) - ); - - if (_pEnhancemethod == 2) { - //LDEBUG("Vi borde rendera vita punkter"); - _shaderProgram->setUniform("firstrender", false); - GLint temp = 0; - glDrawArrays( - GL_POINTS, - temp, - static_cast(_vertexPositions.size()) - ); - } - if (_pEnhancemethod == 3) { - //LDEBUG("Vi borde rendera linjer"); - _shaderProgram->setUniform("firstrender", false); - glLineWidth(_pLineWidth); - glMultiDrawArrays( - GL_LINE_STRIP, //_drawingOutputType, - _lineStart.data(), - _lineCount.data(), - static_cast(_lineStart.size())); - } - - // _shaderProgram->setUniform("firstrender", false); - // glDrawArrays( - // GL_POINTS, - // temp, - // static_cast(_vertexPositions.size()) - // ); - - glBindVertexArray(0); - _shaderProgram->deactivate(); + +_shaderProgram->setUniform("firstrender", true); +GLint temp = 0; +glDrawArrays( + GL_POINTS, + temp, + static_cast(_vertexPositions.size()) +); + +if (_pEnhancemethod == 2) { + //LDEBUG("Vi borde rendera vita punkter"); + _shaderProgram->setUniform("firstrender", false); + GLint temp = 0; + glDrawArrays( + GL_POINTS, + temp, + static_cast(_vertexPositions.size()) + ); +} +if (_pEnhancemethod == 3) { + //LDEBUG("Vi borde rendera linjer"); + _shaderProgram->setUniform("firstrender", false); + glLineWidth(_pLineWidth); + glMultiDrawArrays( + GL_LINE_STRIP, //_drawingOutputType, + _lineStart.data(), + _lineCount.data(), + static_cast(_lineStart.size())); +} + +// _shaderProgram->setUniform("firstrender", false); +// glDrawArrays( +// GL_POINTS, +// temp, +// static_cast(_vertexPositions.size()) +// ); + +glBindVertexArray(0); +_shaderProgram->deactivate(); } } inline void unbindGL() { diff --git a/modules/fieldlinessequence/shaders/streamnodes_vs.glsl b/modules/fieldlinessequence/shaders/streamnodes_vs.glsl index daf047c128..091db5a685 100644 --- a/modules/fieldlinessequence/shaders/streamnodes_vs.glsl +++ b/modules/fieldlinessequence/shaders/streamnodes_vs.glsl @@ -72,6 +72,7 @@ uniform int activestreamnumber; uniform bool firstrender; uniform int EnhanceMethod; uniform double time; +//uniform float interestingStreams[4]; // Inputs // Should be provided in meters @@ -146,6 +147,8 @@ vec4 getTransferFunctionColor(sampler1D InColorTable) { bool CheckvertexIndex(){ if(EnhanceMethod == 3) return false; + int nodeIndex = gl_VertexID; + //if(EnhanceMethod == 3) return false; if(NodeskipMethod == uniformskip){ if(mod(nodeIndex, Nodeskip) == 0){ return true; @@ -181,7 +184,7 @@ bool CheckvertexIndex(){ //is Particle?: bool isParticle(){ - int modulusResult = int(double(particleSpeed) * time + nodeIndex) % particleSpacing; + int modulusResult = int(double(particleSpeed) * time + gl_VertexID) % particleSpacing; return modulusResult > 0 && modulusResult <= particleSize; return false; @@ -206,18 +209,29 @@ void DecidehowtoshowClosetoEarth(){ vs_color = vec4(streamColor.xyz, fluxColorAlpha); } } + //lines if(EnhanceMethod == 3){ - if(!firstrender){ + // float interestingStreams[4] = float[](154, 156, 153, 163); + float interestingStreams[26] = float[](135, 138, 145, 146, 147, 149, 153, 154, 155, 156, 157, 158, 159, 160, 167, 163, + 168, 169, 170, 172, 174, 180, 181, 183, 356, 364); + for(int i = 0; i < interestingStreams.length(); i++){ + if(Streamnumber == interestingStreams[i]){ + + // if(!firstrender){ // vs_color = vec4(streamColor.xyz, fluxColorAlpha); if(usingParticles && isParticle()){ vs_color = flowColor; + gl_PointSize = 1; } else{ vec4 fluxColor3 = getTransferFunctionColor(colorTable); vs_color = vec4(fluxColor3.xyz, fluxColor3.w); } } + } + // } } + //SizeandColor if(EnhanceMethod == 4){ vec4 fluxColor3 = getTransferFunctionColor(colorTable); vs_color = vec4(fluxColor3.xyz, fluxColor3.w);