fix fieldlines modules shaders

This commit is contained in:
Michael Nilsson
2016-04-26 17:04:26 -04:00
committed by Sebastian Piwell
parent b67180e325
commit d759d3fe03
3 changed files with 41 additions and 16 deletions

View File

@@ -16,7 +16,7 @@ return {
Type = "RenderableFieldlines",
VectorField = {
Type = "VolumeKameleon",
File = "${OPENSPACE_DATA}/batsrus.cdf",
File = "${OPENSPACE_DATA}/BATSRUS.cdf",
Model = "BATSRUS",
Variables = {"bx", "by", "bz"}
},
@@ -42,7 +42,7 @@ return {
Type = "RenderableFieldlines",
VectorField = {
Type = "VolumeKameleon",
File = "${OPENSPACE_DATA}/batsrus.cdf",
File = "${OPENSPACE_DATA}/BATSRUS.cdf",
Model = "BATSRUS",
Variables = {"bx", "by", "bz"}
},
@@ -68,7 +68,7 @@ return {
Type = "RenderableFieldlines",
VectorField = {
Type = "VolumeKameleon",
File = "${OPENSPACE_DATA}/batsrus.cdf",
File = "${OPENSPACE_DATA}/BATSRUS.cdf",
Model = "BATSRUS",
Variables = {"bx", "by", "bz"}
},
@@ -94,7 +94,7 @@ return {
Type = "RenderableFieldlines",
VectorField = {
Type = "VolumeKameleon",
File = "${OPENSPACE_DATA}/batsrus.cdf",
File = "${OPENSPACE_DATA}/BATSRUS.cdf",
Model = "BATSRUS",
Variables = {"bx", "by", "bz"}
},
@@ -120,7 +120,7 @@ return {
Type = "RenderableFieldlines",
VectorField = {
Type = "VolumeKameleon",
File = "${OPENSPACE_DATA}/batsrus.cdf",
File = "${OPENSPACE_DATA}/BATSRUS.cdf",
Model = "BATSRUS",
Variables = {"bx", "by", "bz"}
},

View File

@@ -24,6 +24,7 @@
#include <modules/fieldlines/rendering/renderablefieldlines.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/powerscaledcoordinate.h>
#include <modules/kameleon/include/kameleonwrapper.h>
#include <openspace/scene/scenegraphnode.h>
@@ -200,12 +201,13 @@ bool RenderableFieldlines::initialize() {
return false;
}
_program = ghoul::opengl::ProgramObject::Build(
_program = OsEng.renderEngine().buildRenderProgram(
"Fieldline",
"${MODULE_FIELDLINES}/shaders/fieldline_vs.glsl",
"${MODULE_FIELDLINES}/shaders/fieldline_fs.glsl",
"${MODULE_FIELDLINES}/shaders/fieldline_gs.glsl"
);
if (!_program)
return false;
@@ -225,7 +227,7 @@ void RenderableFieldlines::render(const RenderData& data) {
_program->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
_program->setUniform("modelTransform", glm::mat4(1.0));
_program->setUniform("cameraViewDir", data.camera.viewDirection());
glDisable(GL_CULL_FACE);
setPscUniforms(*_program, data.camera, data.position);
_program->setUniform("classification", _classification);
@@ -240,7 +242,7 @@ void RenderableFieldlines::render(const RenderData& data) {
static_cast<GLsizei>(_lineStart.size())
);
glBindVertexArray(0);
glEnable(GL_CULL_FACE);
_program->deactivate();
}

View File

@@ -22,8 +22,6 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#version __CONTEXT__
in vec4 gs_color;
in vec4 gs_position;
in vec3 gs_normal;
@@ -31,11 +29,14 @@ in vec3 gs_normal;
uniform bool classification;
uniform vec4 fieldLineColor;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "fragment.glsl"
#include "PowerScaling/powerScaling_fs.hglsl"
void main() {
Fragment getFragment()
{
float alpha = 1-length(gs_normal)*length(gs_normal);
vec4 fragColor;
if (classification)
@@ -44,6 +45,28 @@ void main() {
fragColor = vec4(fieldLineColor.rgb, fieldLineColor.a * alpha);
float depth = pscDepth(gs_position);
ABufferStruct_t frag = createGeometryFragment(fragColor, gs_position, depth);
addToBuffer(frag);
}
Fragment frag;
frag.depth = depth;
frag.color = fragColor;
return frag;
}
// #include "ABuffer/abufferStruct.hglsl"
// #include "ABuffer/abufferAddToBuffer.hglsl"
// #include "PowerScaling/powerScaling_fs.hglsl"
// void main() {
// float alpha = 1-length(gs_normal)*length(gs_normal);
// vec4 fragColor;
// if (classification)
// fragColor = vec4(gs_color.rgb, alpha);
// else
// fragColor = vec4(fieldLineColor.rgb, fieldLineColor.a * alpha);
// float depth = pscDepth(gs_position);
// ABufferStruct_t frag = createGeometryFragment(fragColor, gs_position, depth);
// addToBuffer(frag);
// }