Commit 9c8e1222 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri Committed by Code Review

Merge topic 'positional_light_other_fixes' into master

3b473ddb Silenced compiler warnings
58bf3e07 Fixed various lighting and formatting issues
39d54d5b Fixed style issues
761a2898 Fixing variable names
85240e2f Fixed variable not found
7a40c5e8 Compute appropriate matrix for normal transformation
adc0b49f Clean up code
cc41e9bb Fixing positional light bugs
94f5a754 Fixed positional light calculation
2c613d98 Test new volume mapper against positional lights
parents ee560143 3b473ddb
......@@ -40,7 +40,10 @@ set (OpenGLNew_OR_OpenGL2_CxxTests
)
if ("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
list(APPEND OpenGLNew_OR_OpenGL2_CxxTests TestGPURayCastVolumeLightKit.cxx)
list(APPEND OpenGLNew_OR_OpenGL2_CxxTests
TestGPURayCastVolumeLightKit.cxx
TestGPURayCastPositionalLights.cxx
)
endif()
# These tests are built for the OpenGL backend
......
......@@ -116,8 +116,7 @@ int TestGPURayCastCompositeBinaryMask(int argc, char *argv[])
opacityFun->AddPoint( 4095.0, 1.0);
mapper->SetBlendModeToComposite();
property->ShadeOn();
property->ShadeOn();
// Make the mask
vtkSmartPointer< vtkImageData > mask
......
......@@ -35,9 +35,6 @@
#include "vtkCullerCollection.h"
#include "vtkCuller.h"
#include "vtkFrustumCoverageCuller.h"
#include "vtkVolumeTextureMapper3D.h"
//#define USE_TEXTURE_MAPPER_3D
int TestGPURayCastCropping(int argc, char *argv[])
{
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestGPURayCastPositionalLights.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This test volume renders a synthetic dataset with four different
// positional lights in the scene.
#include <vtkCamera.h>
#include <vtkColorTransferFunction.h>
#include <vtkGPUVolumeRayCastMapper.h>
#include <vtkImageData.h>
#include <vtkLight.h>
#include <vtkNew.h>
#include <vtkPiecewiseFunction.h>
#include <vtkRegressionTestImage.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkTestUtilities.h>
#include <vtkVolumeProperty.h>
#include <vtkXMLImageDataReader.h>
#include <vtkLightActor.h>
#include <vtkContourFilter.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
int TestGPURayCastPositionalLights(int argc, char *argv[])
{
double scalarRange[2];
vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
vtkNew<vtkXMLImageDataReader> reader;
const char* volumeFile = vtkTestUtilities::ExpandDataFileName(
argc, argv, "Data/vase_1comp.vti");
reader->SetFileName(volumeFile);
volumeMapper->SetInputConnection(reader->GetOutputPort());
volumeMapper->GetInput()->GetScalarRange(scalarRange);
volumeMapper->SetBlendModeToComposite();
volumeMapper->SetAutoAdjustSampleDistances(0);
volumeMapper->SetSampleDistance(0.1);
vtkNew<vtkRenderWindow> renWin;
vtkNew<vtkRenderer> ren;
ren->SetBackground(0.0, 0.0, 0.4);
ren->AutomaticLightCreationOff();
ren->RemoveAllLights();
vtkNew<vtkLight> light1;
light1->SetLightTypeToSceneLight();
light1->SetPositional(true);
light1->SetDiffuseColor(1,0,0);
light1->SetAmbientColor(0,0,0);
light1->SetSpecularColor(1,1,1);
light1->SetConeAngle(60);
light1->SetPosition(0.0, 0.0, 100.0);
light1->SetFocalPoint(0.0, 0.0, 0.0);
// light1->SetColor(1,0,0);
// light1->SetPosition(40,40,301);
// light1->SetPosition(-57, -50, -360);
vtkNew<vtkLightActor> lightActor;
lightActor->SetLight(light1.GetPointer());
ren->AddViewProp(lightActor.GetPointer());
vtkNew<vtkLight> light2;
vtkNew<vtkLight> light3;
vtkNew<vtkLight> light4;
renWin->AddRenderer(ren.GetPointer());
renWin->SetSize(400, 400);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
vtkNew<vtkPiecewiseFunction> scalarOpacity;
scalarOpacity->AddPoint(50, 0.0);
scalarOpacity->AddPoint(75, 1.0);
vtkNew<vtkVolumeProperty> volumeProperty;
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
volumeProperty->SetScalarOpacity(scalarOpacity.GetPointer());
vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction =
volumeProperty->GetRGBTransferFunction(0);
colorTransferFunction->RemoveAllPoints();
colorTransferFunction->AddRGBPoint(scalarRange[0], 1.0, 1.0, 1.0);
colorTransferFunction->AddRGBPoint(scalarRange[1], 1.0, 1.0, 1.0);
vtkNew<vtkVolume> volume;
volume->SetMapper(volumeMapper.GetPointer());
volume->SetProperty(volumeProperty.GetPointer());
ren->AddViewProp(volume.GetPointer());
vtkNew<vtkPolyDataMapper> pm;
vtkNew<vtkActor> ac;
vtkNew<vtkContourFilter> cf;
ac->SetMapper(pm.GetPointer());
pm->SetInputConnection(cf->GetOutputPort());
pm->SetScalarVisibility(0);
cf->SetValue(0, 60.0);
cf->SetInputConnection(reader->GetOutputPort());
ac->SetPosition(-89.0, 0.0, 0.0);
volume->SetPosition(-30.0, 0.0, 0.0);
ren->AddActor(ac.GetPointer());
vtkNew<vtkActor> ac1;
ac1->SetMapper(pm.GetPointer());
ac1->SetPosition(0,0,0);
ren->SetTwoSidedLighting(0);
ren->AddLight(light1.GetPointer());
renWin->Render();
ren->ResetCamera();
iren->Initialize();
int retVal = vtkRegressionTestImage( renWin.GetPointer() );
if( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
......@@ -40,9 +40,6 @@
#include <vtkVolumeProperty.h>
#include <vtkXMLImageDataReader.h>
// For debugging purposes only
//#include <vtkContourFilter.h>
int TestGPURayCastVolumeLightKit(int argc, char *argv[])
{
double scalarRange[2];
......@@ -96,19 +93,6 @@ int TestGPURayCastVolumeLightKit(int argc, char *argv[])
vtkNew<vtkVolume> volume;
volume->SetMapper(volumeMapper.GetPointer());
volume->SetProperty(volumeProperty.GetPointer());
// For debugging purposes only
// vtkNew<vtkPolyDataMapper> pm;
// vtkNew<vtkActor> ac;
// vtkNew<vtkContourFilter> cf;
// ac->SetMapper(pm.GetPointer());
// pm->SetInputConnection(cf->GetOutputPort());
// pm->SetScalarVisibility(0);
// cf->SetValue(0, 60.0);
// cf->SetInputConnection(reader->GetOutputPort());
// ac->SetPosition(-50.0, 0.0, 0.0);
// ren->AddActor(ac.GetPointer());
ren->AddViewProp(volume.GetPointer());
renWin->Render();
......
13ab8a916786fb3d62e002f7ffb60a35
d65a545d88ee701f93cc03fe7a2ecd2c
......@@ -25,8 +25,8 @@
//////////////////////////////////////////////////////////////////////////////
/// 3D texture coordinates form vertex shader
varying vec3 m_texture_coords;
varying vec3 m_vertex_pos;
varying vec3 ip_textureCoords;
varying vec3 ip_vertexPos;
//////////////////////////////////////////////////////////////////////////////
///
......@@ -34,15 +34,17 @@ varying vec3 m_vertex_pos;
///
//////////////////////////////////////////////////////////////////////////////
vec4 g_frag_color;
vec4 g_fragColor;
//////////////////////////////////////////////////////////////////////////////
///
/// Uniforms, attributes, and globals
///
//////////////////////////////////////////////////////////////////////////////
vec3 g_data_pos;
vec3 g_dir_step;
vec3 g_dataPos;
vec3 g_dirStep;
vec4 g_srcColor;
vec4 g_eyePosObj;
//VTK::Base::Dec
//VTK::Termination::Dec
......@@ -61,7 +63,7 @@ vec3 g_dir_step;
/// We support only 8 clipping planes for now
/// The first value is the size of the data array for clipping
/// planes (origin, normal)
uniform float m_clipping_planes[49];
uniform float in_clippingPlanes[49];
//////////////////////////////////////////////////////////////////////////////
///
......@@ -69,10 +71,10 @@ uniform float m_clipping_planes[49];
///
//////////////////////////////////////////////////////////////////////////////
void main()
{
/// Initialize g_frag_color (output) to 0
g_frag_color = vec4(0.0);
g_dir_step = vec3(0.0);
{
/// Initialize g_fragColor (output) to 0
g_fragColor = vec4(0.0);
g_dirStep = vec3(0.0);
//VTK::Base::Init
//VTK::Terminate::Init
......@@ -91,8 +93,8 @@ void main()
//VTK::CompositeMask::Impl
//VTK::Shading::Impl
/// Advance ray by m_dir_step
g_data_pos += g_dir_step;
/// Advance ray
g_dataPos += g_dirStep;
}
//VTK::Base::Exit
......@@ -101,5 +103,5 @@ void main()
//VTK::Clipping::Exit
//VTK::Shading::Exit
gl_FragColor = g_frag_color;
}
gl_FragColor = g_fragColor;
}
......@@ -36,7 +36,7 @@
/// Inputs
///
//////////////////////////////////////////////////////////////////////////////
attribute vec3 m_in_vertex_pos;
attribute vec3 in_vertexPos;
//////////////////////////////////////////////////////////////////////////////
///
......@@ -44,8 +44,8 @@ attribute vec3 m_in_vertex_pos;
///
//////////////////////////////////////////////////////////////////////////////
/// 3D texture coordinates for texture lookup in the fragment shader
varying vec3 m_texture_coords;
varying vec3 m_vertex_pos;
varying vec3 ip_textureCoords;
varying vec3 ip_vertexPos;
void main()
{
......@@ -56,5 +56,5 @@ void main()
//VTK::ComputeTextureCoords::Impl
/// Copy incoming vertex position for the fragment shader
m_vertex_pos = m_in_vertex_pos;
ip_vertexPos = in_vertexPos;
}
......@@ -31,7 +31,7 @@ class vtkVolumeStateRAII
this->CullFaceEnabled = (glIsEnabled(GL_CULL_FACE) != 0);
// Enable texture 1D and 3D as we are using it
// for transfer functions and m_volume data
// for transfer functions and in_volume data
glEnable(GL_TEXTURE_1D);
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_3D);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment