Added ID for sampler

This commit is contained in:
Jonas Strandstedt
2014-06-24 15:29:31 -04:00
parent 633c95a44b
commit ec115030a4
5 changed files with 12 additions and 10 deletions
@@ -45,7 +45,7 @@ public:
VolumeRaycasterBox();
~VolumeRaycasterBox();
bool initialize();
void render(const glm::mat4& MVP,const glm::mat4& transform = glm::mat4(1.0));
void render(const glm::mat4& MVP, const glm::mat4& transform = glm::mat4(1.0), int type = 0);
ghoul::opengl::Texture* backFace();
ghoul::opengl::Texture* frontFace();
@@ -56,7 +56,7 @@ private:
ghoul::opengl::Texture *_backTexture, *_frontTexture;
ghoul::opengl::ProgramObject *_boxProgram;
sgct_utils::SGCTBox* _boundingBox;
GLint _MVPLocation, _modelTransformLocation;
GLint _MVPLocation, _modelTransformLocation, _typeLocation;
glm::size2_t _dimensions;
};
+3 -1
View File
@@ -1,5 +1,7 @@
#version 430 core
uniform int volumeType;
in vec3 vPosition;
in vec3 worldPosition;
out vec4 fragColor;
@@ -13,7 +15,7 @@ void main() {
ABufferStruct_t frag;
_col_(frag, fragColor);
_z_(frag, gl_FragCoord.z);
_type_(frag, 1);
_type_(frag, volumeType);
_pos_(frag, vec4(worldPosition,0));
addToBuffer(frag);
+3 -3
View File
@@ -148,10 +148,10 @@ int ABuffer::addSamplerfile(const std::string& filename) {
ghoul::filesystem::File* file = new ghoul::filesystem::File(filename);
file->setCallback(fileCallback);
_samplerFiles.push_back(file);
int size = _samplers.size();
_samplers.push_back("");
return size;
// ID is one more than "actual" position since ID=0 is considered geometry
return _samplers.size();
}
bool ABuffer::updateShader() {
+1 -1
View File
@@ -166,7 +166,7 @@ void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition) {
transform = glm::scale(transform, _boxScaling);
// TODO: Use _id to identify this volume
_colorBoxRenderer->render(camera->viewProjectionMatrix(), transform);
_colorBoxRenderer->render(camera->viewProjectionMatrix(), transform, _id);
}
+3 -3
View File
@@ -63,6 +63,7 @@ bool VolumeRaycasterBox::initialize() {
OsEng.configurationManager().getValue("RaycastProgram", _boxProgram);
_MVPLocation = _boxProgram->uniformLocation("modelViewProjection");
_modelTransformLocation = _boxProgram->uniformLocation("modelTransform");
_typeLocation = _boxProgram->uniformLocation("volumeType");
// ------ SETUP FBO ---------------------
_fbo = new FramebufferObject();
@@ -70,8 +71,6 @@ bool VolumeRaycasterBox::initialize() {
// changed from getActiveXResolution to getCurrentViewportPixelCoords because
// if there are more viewports in the same screen.
//size_t x = sgct::Engine::instance()->getActiveXResolution();
//size_t y = sgct::Engine::instance()->getActiveYResolution();
int x1, xSize, y1, ySize;
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
size_t x = xSize;
@@ -90,12 +89,13 @@ bool VolumeRaycasterBox::initialize() {
return true;
}
void VolumeRaycasterBox::render(const glm::mat4& MVP,const glm::mat4& transform) {
void VolumeRaycasterBox::render(const glm::mat4& MVP,const glm::mat4& transform, int type) {
GLuint activeFBO = FramebufferObject::getActiveObject(); // Save SGCTs main FBO
_fbo->activate();
_boxProgram->activate();
_boxProgram->setUniform(_MVPLocation, MVP);
_boxProgram->setUniform(_modelTransformLocation, transform);
_boxProgram->setUniform(_typeLocation, type);
sgct_core::Frustum::FrustumMode mode = sgct::Engine::instance()->
getActiveWindowPtr()->