diff --git a/include/osgVolume/RayTracedTechnique b/include/osgVolume/RayTracedTechnique index 6d08818a5..23c06b703 100644 --- a/include/osgVolume/RayTracedTechnique +++ b/include/osgVolume/RayTracedTechnique @@ -15,6 +15,7 @@ #define OSGVOLUME_RAYTRACEDTECHNIQUE 1 #include +#include namespace osgVolume { @@ -44,7 +45,7 @@ class OSGVOLUME_EXPORT RayTracedTechnique : public VolumeTechnique virtual ~RayTracedTechnique(); - osg::ref_ptr _geode; + osg::ref_ptr _transform; }; } diff --git a/src/osgManipulator/Dragger.cpp b/src/osgManipulator/Dragger.cpp index 4cd0586eb..69c508e26 100644 --- a/src/osgManipulator/Dragger.cpp +++ b/src/osgManipulator/Dragger.cpp @@ -57,34 +57,34 @@ bool DraggerTransformCallback::receive(const MotionCommand& command) switch (command.getStage()) { case MotionCommand::START: - { - // Save the current matrix - _startMotionMatrix = _transform->getMatrix(); + { + // Save the current matrix + _startMotionMatrix = _transform->getMatrix(); - // Get the LocalToWorld and WorldToLocal matrix for this node. - osg::NodePath nodePathToRoot; - computeNodePathToRoot(*_transform,nodePathToRoot); - _localToWorld = osg::computeLocalToWorld(nodePathToRoot); - _worldToLocal = osg::Matrix::inverse(_localToWorld); + // Get the LocalToWorld and WorldToLocal matrix for this node. + osg::NodePath nodePathToRoot; + computeNodePathToRoot(*_transform,nodePathToRoot); + _localToWorld = osg::computeLocalToWorld(nodePathToRoot); + _worldToLocal = osg::Matrix::inverse(_localToWorld); - return true; - } + return true; + } case MotionCommand::MOVE: - { - // Transform the command's motion matrix into local motion matrix. - osg::Matrix localMotionMatrix = _localToWorld * command.getWorldToLocal() - * command.getMotionMatrix() - * command.getLocalToWorld() * _worldToLocal; + { + // Transform the command's motion matrix into local motion matrix. + osg::Matrix localMotionMatrix = _localToWorld * command.getWorldToLocal() + * command.getMotionMatrix() + * command.getLocalToWorld() * _worldToLocal; - // Transform by the localMotionMatrix - _transform->setMatrix(localMotionMatrix * _startMotionMatrix); + // Transform by the localMotionMatrix + _transform->setMatrix(localMotionMatrix * _startMotionMatrix); - return true; - } + return true; + } case MotionCommand::FINISH: - { - return true; - } + { + return true; + } case MotionCommand::NONE: default: return false; diff --git a/src/osgVolume/RayTracedTechnique.cpp b/src/osgVolume/RayTracedTechnique.cpp index c54e50231..acd0e0668 100644 --- a/src/osgVolume/RayTracedTechnique.cpp +++ b/src/osgVolume/RayTracedTechnique.cpp @@ -74,11 +74,16 @@ void RayTracedTechnique::init() ShadingModel shadingModel = Isosurface; float alphaFuncValue = 0.1; - _geode = new osg::Geode; + _transform = new osg::MatrixTransform; + + osg::ref_ptr geode = new osg::Geode; + + _transform->addChild(geode.get()); osg::Image* image_3d = 0; osg::TransferFunction1D* tf = 0; - osgVolume::Locator* masterLocator = _volumeTile->getLocator(); + Locator* masterLocator = _volumeTile->getLocator(); + Locator* layerLocator = _volumeTile->getLayer()->getLocator(); image_3d = _volumeTile->getLayer()->getImage(); @@ -118,19 +123,25 @@ void RayTracedTechnique::init() } - if (_volumeTile->getLayer() && !masterLocator) - { - masterLocator = _volumeTile->getLayer()->getLocator(); - } + if (!masterLocator && layerLocator) masterLocator = _volumeTile->getLayer()->getLocator(); + if (!layerLocator && masterLocator) layerLocator = layerLocator; - osg::Matrix matrix; + + osg::Matrix geometryMatrix; if (masterLocator) { - matrix = masterLocator->getTransform(); + geometryMatrix = masterLocator->getTransform(); + _transform->setMatrix(geometryMatrix); } + osg::Matrix imageMatrix; + if (layerLocator) + { + imageMatrix = layerLocator->getTransform(); + } - osg::notify(osg::INFO)<<"RayTracedTechnique::init() : matrix = "<addShader(fragmentShader); } else { - osg::notify(osg::NOTICE)<<"No Shader found"<addShader(new osg::Shader(osg::Shader::FRAGMENT, volume_iso_frag)); @@ -398,7 +410,7 @@ void RayTracedTechnique::init() osg::TexGen* texgen = new osg::TexGen; texgen->setMode(osg::TexGen::OBJECT_LINEAR); - texgen->setPlanesFromMatrix(osg::Matrix::inverse(matrix)); + texgen->setPlanesFromMatrix( geometryMatrix * osg::Matrix::inverse(imageMatrix)); stateset->setTextureAttributeAndModes(0, texgen, osg::StateAttribute::ON); @@ -408,14 +420,14 @@ void RayTracedTechnique::init() osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* coords = new osg::Vec3Array(8); - (*coords)[0] = osg::Vec3d(0.0,0.0,0.0) * matrix; - (*coords)[1] = osg::Vec3d(1.0,0.0,0.0) * matrix; - (*coords)[2] = osg::Vec3d(1.0,1.0,0.0) * matrix; - (*coords)[3] = osg::Vec3d(0.0,1.0,0.0) * matrix; - (*coords)[4] = osg::Vec3d(0.0,0.0,1.0) * matrix; - (*coords)[5] = osg::Vec3d(1.0,0.0,1.0) * matrix; - (*coords)[6] = osg::Vec3d(1.0,1.0,1.0) * matrix; - (*coords)[7] = osg::Vec3d(0.0,1.0,1.0) * matrix; + (*coords)[0] = osg::Vec3d(0.0,0.0,0.0); + (*coords)[1] = osg::Vec3d(1.0,0.0,0.0); + (*coords)[2] = osg::Vec3d(1.0,1.0,0.0); + (*coords)[3] = osg::Vec3d(0.0,1.0,0.0); + (*coords)[4] = osg::Vec3d(0.0,0.0,1.0); + (*coords)[5] = osg::Vec3d(1.0,0.0,1.0); + (*coords)[6] = osg::Vec3d(1.0,1.0,1.0); + (*coords)[7] = osg::Vec3d(0.0,1.0,1.0); geom->setVertexArray(coords); osg::Vec4Array* colours = new osg::Vec4Array(1); @@ -462,7 +474,7 @@ void RayTracedTechnique::init() geom->addPrimitiveSet(drawElements); - _geode->addDrawable(geom); + geode->addDrawable(geom); } @@ -476,9 +488,9 @@ void RayTracedTechnique::update(osgUtil::UpdateVisitor* uv) void RayTracedTechnique::cull(osgUtil::CullVisitor* cv) { //osg::notify(osg::NOTICE)<<"RayTracedTechnique::cull(osgUtil::CullVisitor* nv)"<accept(*cv); + _transform->accept(*cv); } } diff --git a/src/osgVolume/Shaders/volume_frag.cpp b/src/osgVolume/Shaders/volume_frag.cpp index d2e97f362..96b23a739 100644 --- a/src/osgVolume/Shaders/volume_frag.cpp +++ b/src/osgVolume/Shaders/volume_frag.cpp @@ -9,8 +9,8 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" "\n" "void main(void)\n" "{ \n" - " vec3 t0 = (texgen * vertexPos).xyz;\n" - " vec3 te = (texgen * cameraPos).xyz;\n" + " vec4 t0 = vertexPos;\n" + " vec4 te = cameraPos;\n" "\n" " if (te.x>=0.0 && te.x<=1.0 &&\n" " te.y>=0.0 && te.y<=1.0 &&\n" @@ -57,8 +57,11 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" " }\n" " }\n" "\n" + " t0 = t0 * texgen;\n" + " te = te * texgen;\n" + "\n" " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length(te-t0)/SampleDensityValue);\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " if (num_iterations<2.0) num_iterations = 2.0;\n" "\n" " if (num_iterations>max_iteratrions) \n" @@ -66,8 +69,8 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" " num_iterations = max_iteratrions;\n" " }\n" "\n" - " vec3 deltaTexCoord=(te-t0)/float(num_iterations-1.0);\n" - " vec3 texcoord = t0;\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" " while(num_iterations>0.0)\n" @@ -95,4 +98,5 @@ char volume_frag[] = "uniform sampler3D baseTexture;\n" " if (fragColor.w=0.0 && te.x<=1.0 &&\n" " te.y>=0.0 && te.y<=1.0 &&\n" @@ -60,8 +58,11 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n" " }\n" " }\n" "\n" + " t0 = t0 * texgen;\n" + " te = te * texgen;\n" + "\n" " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length(te-t0)/SampleDensityValue);\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " if (num_iterations<2.0) num_iterations = 2.0;\n" "\n" " if (num_iterations>max_iteratrions) \n" @@ -69,8 +70,8 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n" " num_iterations = max_iteratrions;\n" " }\n" "\n" - " vec3 deltaTexCoord=(t0-te)/float(num_iterations-1.0);\n" - " vec3 texcoord = te;\n" + " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1.0);\n" + " vec3 texcoord = te.xyz;\n" "\n" " vec4 previousColor = texture3D( baseTexture, texcoord);\n" " \n" diff --git a/src/osgVolume/Shaders/volume_lit_frag.cpp b/src/osgVolume/Shaders/volume_lit_frag.cpp index cb2ca122a..83aeb9a8a 100644 --- a/src/osgVolume/Shaders/volume_lit_frag.cpp +++ b/src/osgVolume/Shaders/volume_lit_frag.cpp @@ -9,10 +9,8 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" "\n" "void main(void)\n" "{ \n" - " vec3 t0 = (texgen * vertexPos).xyz;\n" - " vec3 te = (texgen * cameraPos).xyz;\n" - " \n" - " vec3 eyeDirection = normalize(te-t0);\n" + " vec4 t0 = vertexPos;\n" + " vec4 te = cameraPos;\n" "\n" " if (te.x>=0.0 && te.x<=1.0 &&\n" " te.y>=0.0 && te.y<=1.0 &&\n" @@ -59,8 +57,13 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" " }\n" " }\n" "\n" + " t0 = t0 * texgen;\n" + " te = te * texgen;\n" + "\n" + " vec3 eyeDirection = normalize((te-t0).xyz);\n" + "\n" " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length(te-t0)/SampleDensityValue);\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " if (num_iterations<2.0) num_iterations = 2.0;\n" "\n" " if (num_iterations>max_iteratrions) \n" @@ -68,8 +71,8 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" " num_iterations = max_iteratrions;\n" " }\n" "\n" - " vec3 deltaTexCoord=(te-t0)/float(num_iterations-1.0);\n" - " vec3 texcoord = t0;\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 texcoord = t0.xyz;\n" "\n" " float normalSampleDistance = 1.0/512.0;\n" " vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n" @@ -123,4 +126,5 @@ char volume_lit_frag[] = "uniform sampler3D baseTexture;\n" " if (fragColor.w=0.0 && te.x<=1.0 &&\n" " te.y>=0.0 && te.y<=1.0 &&\n" @@ -60,8 +58,13 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n" " }\n" " }\n" "\n" + " t0 = t0 * texgen;\n" + " te = te * texgen;\n" + "\n" + " vec3 eyeDirection = normalize((te-t0).xyz);\n" + "\n" " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length(te-t0)/SampleDensityValue);\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " if (num_iterations<2.0) num_iterations = 2.0;\n" "\n" " if (num_iterations>max_iteratrions) \n" @@ -69,14 +72,14 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n" " num_iterations = max_iteratrions;\n" " }\n" "\n" - " vec3 deltaTexCoord=(te-t0)/float(num_iterations-1.0);\n" - " vec3 texcoord = t0;\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 texcoord = t0.xyz;\n" "\n" " float normalSampleDistance = 1.0/512.0;\n" " vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n" " vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n" " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" - " \n" + "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" " while(num_iterations>0.0)\n" " {\n" @@ -126,4 +129,5 @@ char volume_lit_tf_frag[] = "uniform sampler3D baseTexture;\n" " if (fragColor.w=0.0 && te.x<=1.0 &&\n" " te.y>=0.0 && te.y<=1.0 &&\n" @@ -57,8 +57,11 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n" " }\n" " }\n" "\n" + " t0 = t0 * texgen;\n" + " te = te * texgen;\n" + "\n" " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length(te-t0)/SampleDensityValue);\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " if (num_iterations<2.0) num_iterations = 2.0;\n" "\n" " if (num_iterations>max_iteratrions) \n" @@ -66,8 +69,8 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n" " num_iterations = max_iteratrions;\n" " }\n" "\n" - " vec3 deltaTexCoord=(te-t0)/float(num_iterations-1.0);\n" - " vec3 texcoord = t0;\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" " while(num_iterations>0.0)\n" @@ -88,4 +91,5 @@ char volume_mip_frag[] = "uniform sampler3D baseTexture;\n" " if (fragColor.w=0.0 && te.x<=1.0 &&\n" " te.y>=0.0 && te.y<=1.0 &&\n" @@ -58,8 +58,11 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n" " }\n" " }\n" "\n" + " t0 = t0 * texgen;\n" + " te = te * texgen;\n" + "\n" " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length(te-t0)/SampleDensityValue);\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" " if (num_iterations<2.0) num_iterations = 2.0;\n" "\n" " if (num_iterations>max_iteratrions) \n" @@ -67,8 +70,8 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n" " num_iterations = max_iteratrions;\n" " }\n" "\n" - " vec3 deltaTexCoord=(te-t0)/float(num_iterations-1.0);\n" - " vec3 texcoord = t0;\n" + " vec3 deltaTexCoord=(te-t0).xyz/float(num_iterations-1.0);\n" + " vec3 texcoord = t0.xyz;\n" "\n" " vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n" " while(num_iterations>0.0)\n" @@ -98,4 +101,5 @@ char volume_tf_frag[] = "uniform sampler3D baseTexture;\n" " if (fragColor.w=0.0 && te.x<=1.0 &&\n" + " te.y>=0.0 && te.y<=1.0 &&\n" + " te.z>=0.0 && te.z<=1.0)\n" + " {\n" + " // do nothing... te inside volume\n" + " }\n" + " else\n" + " {\n" + " if (te.x<0.0)\n" + " {\n" + " float r = -te.x / (t0.x-te.x);\n" + " te = te + (t0-te)*r;\n" + " }\n" "\n" - " if (te.x>=0.0 && te.x<=1.0 &&\n" - " te.y>=0.0 && te.y<=1.0 &&\n" - " te.z>=0.0 && te.z<=1.0)\n" - " {\n" - " // do nothing... te inside volume\n" - " }\n" - " else\n" - " {\n" - " if (te.x<0.0)\n" - " {\n" - " float r = -te.x / (t0.x-te.x);\n" - " te = te + (t0-te)*r;\n" - " }\n" + " if (te.x>1.0)\n" + " {\n" + " float r = (1.0-te.x) / (t0.x-te.x);\n" + " te = te + (t0-te)*r;\n" + " }\n" "\n" - " if (te.x>1.0)\n" - " {\n" - " float r = (1.0-te.x) / (t0.x-te.x);\n" - " te = te + (t0-te)*r;\n" - " }\n" + " if (te.y<0.0)\n" + " {\n" + " float r = -te.y / (t0.y-te.y);\n" + " te = te + (t0-te)*r;\n" + " }\n" "\n" - " if (te.y<0.0)\n" - " {\n" - " float r = -te.y / (t0.y-te.y);\n" - " te = te + (t0-te)*r;\n" - " }\n" + " if (te.y>1.0)\n" + " {\n" + " float r = (1.0-te.y) / (t0.y-te.y);\n" + " te = te + (t0-te)*r;\n" + " }\n" "\n" - " if (te.y>1.0)\n" - " {\n" - " float r = (1.0-te.y) / (t0.y-te.y);\n" - " te = te + (t0-te)*r;\n" - " }\n" + " if (te.z<0.0)\n" + " {\n" + " float r = -te.z / (t0.z-te.z);\n" + " te = te + (t0-te)*r;\n" + " }\n" "\n" - " if (te.z<0.0)\n" - " {\n" - " float r = -te.z / (t0.z-te.z);\n" - " te = te + (t0-te)*r;\n" - " }\n" + " if (te.z>1.0)\n" + " {\n" + " float r = (1.0-te.z) / (t0.z-te.z);\n" + " te = te + (t0-te)*r;\n" + " }\n" + " }\n" "\n" - " if (te.z>1.0)\n" - " {\n" - " float r = (1.0-te.z) / (t0.z-te.z);\n" - " te = te + (t0-te)*r;\n" - " }\n" - " }\n" + " t0 = t0 * texgen;\n" + " te = te * texgen;\n" "\n" - " const float max_iteratrions = 2048.0;\n" - " float num_iterations = ceil(length(te-t0)/SampleDensityValue);\n" - " if (num_iterations<2.0) num_iterations = 2.0;\n" + " const float max_iteratrions = 2048.0;\n" + " float num_iterations = ceil(length((te-t0).xyz)/SampleDensityValue);\n" + " if (num_iterations<2.0) num_iterations = 2.0;\n" "\n" - " if (num_iterations>max_iteratrions) \n" - " {\n" - " num_iterations = max_iteratrions;\n" - " }\n" + " if (num_iterations>max_iteratrions)\n" + " {\n" + " num_iterations = max_iteratrions;\n" + " }\n" "\n" - " vec3 deltaTexCoord=(t0-te)/float(num_iterations-1.0);\n" - " vec3 texcoord = te;\n" - " float previousV = texture3D( baseTexture, texcoord).a;\n" + " vec3 deltaTexCoord=(t0-te).xyz/float(num_iterations-1.0);\n" + " vec3 texcoord = te.xyz;\n" + " float previousV = texture3D( baseTexture, texcoord).a;\n" "\n" - " float normalSampleDistance = 1.0/512.0;\n" - " vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n" - " vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n" - " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" + " float normalSampleDistance = 1.0/512.0;\n" + " vec3 deltaX = vec3(normalSampleDistance, 0.0, 0.0);\n" + " vec3 deltaY = vec3(0.0, normalSampleDistance, 0.0);\n" + " vec3 deltaZ = vec3(0.0, 0.0, normalSampleDistance);\n" "\n" - " while(num_iterations>0.0)\n" - " {\n" + " while(num_iterations>0.0)\n" + " {\n" "\n" - " float v = texture3D( baseTexture, texcoord).a;\n" + " float v = texture3D( baseTexture, texcoord).a;\n" "\n" - " float m = (previousV-IsoSurfaceValue) * (v-IsoSurfaceValue);\n" - " if (m <= 0.0)\n" - " {\n" - " float r = (IsoSurfaceValue-v)/(previousV-v);\n" - " texcoord = texcoord - r*deltaTexCoord;\n" + " float m = (previousV-IsoSurfaceValue) * (v-IsoSurfaceValue);\n" + " if (m <= 0.0)\n" + " {\n" + " float r = (IsoSurfaceValue-v)/(previousV-v);\n" + " texcoord = texcoord - r*deltaTexCoord;\n" "\n" - " v = texture3D( baseTexture, texcoord).a;\n" - " vec4 color = texture1D( tfTexture, v);\n" + " v = texture3D( baseTexture, texcoord).a;\n" + " vec4 color = texture1D( tfTexture, v);\n" "\n" - " float px = texture3D( baseTexture, texcoord + deltaX).a;\n" - " float py = texture3D( baseTexture, texcoord + deltaY).a;\n" - " float pz = texture3D( baseTexture, texcoord + deltaZ).a;\n" + " float px = texture3D( baseTexture, texcoord + deltaX).a;\n" + " float py = texture3D( baseTexture, texcoord + deltaY).a;\n" + " float pz = texture3D( baseTexture, texcoord + deltaZ).a;\n" "\n" - " float nx = texture3D( baseTexture, texcoord - deltaX).a;\n" - " float ny = texture3D( baseTexture, texcoord - deltaY).a;\n" - " float nz = texture3D( baseTexture, texcoord - deltaZ).a;\n" + " float nx = texture3D( baseTexture, texcoord - deltaX).a;\n" + " float ny = texture3D( baseTexture, texcoord - deltaY).a;\n" + " float nz = texture3D( baseTexture, texcoord - deltaZ).a;\n" "\n" - " vec3 grad = vec3(px-nx, py-ny, pz-nz);\n" - " if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)\n" - " {\n" - " vec3 normal = normalize(grad);\n" - " float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection))*0.9;\n" + " vec3 grad = vec3(px-nx, py-ny, pz-nz);\n" + " if (grad.x!=0.0 || grad.y!=0.0 || grad.z!=0.0)\n" + " {\n" + " vec3 normal = normalize(grad);\n" + " float lightScale = 0.1 + abs(dot(normal.xyz, eyeDirection))*0.9;\n" "\n" - " color.x *= lightScale;\n" - " color.y *= lightScale;\n" - " color.z *= lightScale;\n" - " }\n" + " color.x *= lightScale;\n" + " color.y *= lightScale;\n" + " color.z *= lightScale;\n" + " }\n" "\n" - " gl_FragColor = color;\n" + " gl_FragColor = color;\n" "\n" - " return;\n" - " }\n" + " return;\n" + " }\n" "\n" - " previousV = v;\n" + " previousV = v;\n" "\n" - " texcoord += deltaTexCoord; \n" + " texcoord += deltaTexCoord;\n" "\n" - " --num_iterations;\n" - " }\n" + " --num_iterations;\n" + " }\n" "\n" - " // we didn't find an intersection so just discard fragment\n" - " discard;\n" + " // we didn't find an intersection so just discard fragment\n" + " discard;\n" "\n" - "}\n"; + "}\n" + "\n"; diff --git a/src/osgVolume/Shaders/volume_tf_mip_frag.cpp b/src/osgVolume/Shaders/volume_tf_mip_frag.cpp index 4c208c128..49ef80443 100644 --- a/src/osgVolume/Shaders/volume_tf_mip_frag.cpp +++ b/src/osgVolume/Shaders/volume_tf_mip_frag.cpp @@ -89,4 +89,5 @@ char volume_tf_mip_frag[] = "uniform sampler3D baseTexture;\n" " if (fragColor.w>1.0) fragColor.w = 1.0; \n" " if (fragColor.w