Commit 6671660f authored by Ken Martin's avatar Ken Martin

Add eye dome lighting into VTK

Add eye dome lighting into VTK. This appears to work but there
are some sections of code that look like they may be left over
from some earlier attempts. I did fix a couple issues so YMMV.
parent 84e5248b
......@@ -18,7 +18,9 @@ set(Module_SRCS
vtkClearZPass.cxx
vtkCompositePolyDataMapper2.cxx
vtkDefaultPass.cxx
vtkDepthImageProcessingPass.cxx
vtkDepthPeelingPass.cxx
vtkEDLShading.cxx
vtkFrameBufferObject.cxx
vtkGaussianBlurPass.cxx
vtkGenericCompositePolyDataMapper2.cxx
......@@ -118,6 +120,9 @@ set_source_files_properties(
set(shader_files
glsl/vtkDepthPeelingPassFinalFS.glsl
glsl/vtkDepthPeelingPassIntermediateFS.glsl
glsl/vtkEDLComposeFS.glsl
glsl/vtkEDLShadeFS.glsl
glsl/vtkEDLBilateralFilterFS.glsl
glsl/vtkGaussianBlurPassFS.glsl
glsl/vtkGaussianBlurPassVS.glsl
glsl/vtkSobelGradientMagnitudePass1FS.glsl
......
......@@ -11,6 +11,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestShadowMapBakerPass.cxx
TestShadowMapPass.cxx
TestSobelGradientMagnitudePass.cxx
TestEDLPass.cxx
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests RENDERING_FACTORY)
/*=========================================================================
Program: Visualization Toolkit
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.
=========================================================================*/
// test baking shadow maps
//
// The command line arguments are:
// -I => run in interactive mode; unless this is used, the program will
// not allow interaction and exit
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCellArray.h"
#include "vtkEDLShading.h"
#include "vtkNew.h"
#include "vtkOpenGLRenderer.h"
#include "vtkPLYReader.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderStepsPass.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestUtilities.h"
#include "vtkTimerLog.h"
//----------------------------------------------------------------------------
int TestEDLPass(int argc, char *argv[])
{
vtkNew<vtkRenderer> renderer;
renderer->SetBackground(0.3, 0.4, 0.6);
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(600, 600);
renderWindow->AddRenderer(renderer.Get());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow.Get());
const char* fileName =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/dragon.ply");
vtkNew<vtkPLYReader> reader;
reader->SetFileName(fileName);
reader->Update();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(reader->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());
actor->GetProperty()->SetAmbientColor(0.135, 0.2225, 0.3);
actor->GetProperty()->SetDiffuseColor(0.54, 0.89, 0.63);
actor->GetProperty()->SetDiffuse(0.7);
actor->GetProperty()->SetAmbient(0.7);
actor->GetProperty()->LightingOff();
renderer->AddActor(actor.Get());
//actor->GetProperty()->SetRepresentationToWireframe();
renderWindow->SetMultiSamples(0);
// create the basic VTK render steps
vtkNew<vtkRenderStepsPass> basicPasses;
// finally blur the resulting image
// The blur delegates rendering the unblured image
// to the basicPasses
vtkNew<vtkEDLShading> edl;
edl->SetDelegatePass(basicPasses.Get());
// tell the renderer to use our render pass pipeline
vtkOpenGLRenderer *glrenderer =
vtkOpenGLRenderer::SafeDownCast(renderer.GetPointer());
glrenderer->SetPass(edl.Get());
vtkNew<vtkTimerLog> timer;
timer->StartTimer();
renderWindow->Render();
timer->StopTimer();
double firstRender = timer->GetElapsedTime();
cerr << "first render time: " << firstRender << endl;
timer->StartTimer();
int numRenders = 8;
for (int i = 0; i < numRenders; ++i)
{
renderer->GetActiveCamera()->Azimuth(80.0/numRenders);
renderer->GetActiveCamera()->Elevation(80.0/numRenders);
renderWindow->Render();
}
timer->StopTimer();
double elapsed = timer->GetElapsedTime();
cerr << "interactive render time: " << elapsed / numRenders << endl;
unsigned int numTris = reader->GetOutput()->GetPolys()->GetNumberOfCells();
cerr << "number of triangles: " << numTris << endl;
cerr << "triangles per second: " << numTris*(numRenders/elapsed) << endl;
renderer->GetActiveCamera()->SetPosition(-0.2,0.2,1);
renderer->GetActiveCamera()->SetFocalPoint(0,0,0);
renderer->GetActiveCamera()->SetViewUp(0,1,0);
renderer->GetActiveCamera()->OrthogonalizeViewUp();
renderer->ResetCamera();
renderWindow->Render();
int retVal = vtkRegressionTestImage( renderWindow.Get() );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return EXIT_SUCCESS;
}
/*=========================================================================
Program: VTK
Module: vtkEDLBilateralFilterFS.glsl
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
/*----------------------------------------------------------------------
Acknowledgement:
This algorithm is the result of joint work by Electricité de France,
CNRS, Collège de France and Université J. Fourier as part of the
Ph.D. thesis of Christian BOUCHENY.
------------------------------------------------------------------------*/
//////////////////////////////////////////////////////////////////////////
//
//
// Bilateral filtering
//
// C.B. - 16 aout 2008
//
// IN:
// s2_I - Image to blur
// s2_D - Modulating depth image
//
// OUT:
// Filtered image
//
//////////////////////////////////////////////////////////////////////////
// The following line handle system declarations such a
// default precisions, or defining precisions to null
//VTK::System::Dec
// the output of this shader
//VTK::Output::Dec
varying vec2 tcoordVC;
/****************************************************/
uniform sampler2D s2_I;
uniform sampler2D s2_D;
uniform float SX;
uniform float SY;
uniform int N;
// filter size (full width, necessarily odd, like 3, 5...)
uniform float sigma;
/****************************************************/
/****************************************************/
vec3 C;
float z;
float sigmaz = 0.005;
/****************************************************/
void main (void)
{
C = texture2D(s2_I, tcoordVC.st).rgb;
z = texture2D(s2_D, tcoordVC.st).r;
float ALL = 0.; // sum of all weights
vec3 RES = vec3(0.); // sum of all contributions
int hN = N/2; // filter half width
vec2 coordi = vec2(0.,0.);
vec3 Ci;
float zi;
float dist;
float dz;
float Fi,Gi;
int c,d;
for(c=-hN;c<hN+1;c++)
{
for(d=-hN;d<hN+1;d++)
{
coordi = vec2(float(c)*SX,float(d)*SY);
Ci = texture2D(s2_I, tcoordVC.st+coordi).rgb;
zi = texture2D(s2_D, tcoordVC.st+coordi).r;
dist = clamp( float(c*c+d*d)/float(hN*hN) , 0., 1. );
dz = (z-zi)*(z-zi);
Fi = exp(-dist*dist/(2.* sigma*sigma));
Gi = exp(-dz*dz/(2.* sigmaz*sigmaz));
RES += Ci * Fi * Gi;
ALL += Fi * Gi;
}
}
RES /= ALL;
gl_FragData[0] = vec4( RES , z );
}
/*=========================================================================
Program: VTK
Module: vtkEDLComposeFS.glsl
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
/*----------------------------------------------------------------------
Acknowledgement:
This algorithm is the result of joint work by Electricité de France,
CNRS, Collège de France and Université J. Fourier as part of the
Ph.D. thesis of Christian BOUCHENY.
------------------------------------------------------------------------*/
//////////////////////////////////////////////////////////////////////////
//
//
// EyeDome Lighting - Compositing - Simplified version for use in VTK\n
//
// C.B. - 3 feb. 2009
//
//////////////////////////////////////////////////////////////////////////
// The following line handle system declarations such a
// default precisions, or defining precisions to null
//VTK::System::Dec
// the output of this shader
//VTK::Output::Dec
varying vec2 tcoordVC;
/**************************************************/
uniform sampler2D s2_S1; // fine scale
uniform sampler2D s2_S2; // larger medium scale
uniform sampler2D s2_C; // scene color image
/**************************************************/
void main (void)
{
vec4 shade1 = texture2D(s2_S1,tcoordVC.st);
vec4 shade2 = texture2D(s2_S2,tcoordVC.st);
vec4 color = texture2D(s2_C,tcoordVC.st);
// if it is the background (ala depth > 0.99) just copy it
//if(shade1.a > 0.99)
// {
// gl_FragData[0] = vec4(shade1.rgb,1.) * color;
// }
//else
// {
float lum = mix(shade1.r,shade2.r,0.3);
gl_FragData[0] = vec4(color.rgb*lum, color.a);
// }
gl_FragDepth = shade1.a; // write stored depth
}
/*=========================================================================
Program: VTK
Module: vtkEDLShadeFS.glsl
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
/*----------------------------------------------------------------------
Acknowledgement:
This algorithm is the result of joint work by Electricité de France,
CNRS, Collège de France and Université J. Fourier as part of the
Ph.D. thesis of Christian BOUCHENY.
------------------------------------------------------------------------*/
//////////////////////////////////////////////////////////////////////////
//
//
// EyeDome Lighting - Simplified version for use in VTK
// - oriented light
// - no focus
// - some uniforms transformed to local variables
//
// C.B. - 3 feb. 2009
//
// IN: Depth buffer of the scene
// r = recorded z, in [0:1]
// OUT: EDL shaded image
//
//////////////////////////////////////////////////////////////////////////
// The following line handle system declarations such a
// default precisions, or defining precisions to null
//VTK::System::Dec
// the output of this shader
//VTK::Output::Dec
varying vec2 tcoordVC;
/**************************************************/
uniform sampler2D s2_depth; // - Z Map
uniform float d; // [1.0 in full res - 2.0 at lower res]
//- Extension in image space, in pixels
uniform vec4 N[8]; //- Array of neighbours
// [No support for TabUniform in VTK
// --> constant array, hereafter]
uniform float F_scale; // [5.] - Shading amplification factor
uniform float SX; // - pixel horizontal step (image distance: 1/w)
uniform float SY; //- pixel vertical step (image distance: 1/h)
uniform float Znear; // near clipping plane
uniform float Zfar; // far clipping plane
uniform float SceneSize; // typical scene size, to scale the depth by.
uniform vec3 L; // [0.,0.,-1.] - Light direction [frontal]
/**************************************************/
/**************************************************/
int Nnb = 1; // nombre de voisins par rayon
float Zm = 0.; // minimal z in image
float ZM = 1.; // maximal z in image
float Z; // initial Z
vec3 WHITE3 = vec3(1.,1.,1.);
float t;
vec4 Zn[8]; // profondeurs des voisins
float D[8]; // ombrage genere par les voisins
vec4 tn, tnw, tw, tsw, ts, tse, te, tne;
float dn, dnw, dw, dsw, ds, dse, de, dne;
float S; // image step, corresponds to one pixel size
/**************************************************/
//////////////////////////////////////////////////////////////////////////
//
// Local shading functions
//
// Pseudo angle, avec S (distance pixel) valant l'unite
// zi elevation of current pixel
// zj elevation of its neighbour
// delta distance between the two
float angleP(float zi, float zj, float delta)
{
return max(0.,zj-zi) / (delta/S);
}
// zi elevation of current pixel
// zj elevation of its neighbour
// delta distance between the two
float obscurance(float zi, float zj, float delta)
{
return angleP(zi,zj,delta);
}
//
// Local shading functions
//
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Z transformation
//
float zflip(float z)
{
return 1. - z;
}
float zscale(float z)
{
return clamp((z-Zm)/(ZM-Zm),0.,1.);
}
// Inversion of OpenGL perspective projection
// (should be adapted for orthographic projection)
//
float ztransform(float z)
{
float Z;
Z = (z-0.5)*2.;
Z = -2.*Zfar*Znear/( (Zfar-Znear) * (Z-(Zfar+Znear)/(Zfar-Znear)) );
Z = (Z-Znear)/SceneSize;
return 1.-Z;
}
//
// Z transformation
//
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// NEIGHBORHOOD SHADING
//
void computeNeighbours8(float dist)
{
// Plan Lumiere-point
vec4 P = vec4( L.xyz , -dot(L.xyz,vec3(0.,0.,t)) );
// 0 at the back of the scene
int c;
vec2 V; // pixel voisin
float di = dist;
float Znp[8]; // profondeur des 8 voisins sur le plan
for(c=0; c<8;c++)
{
V = tcoordVC.st + di*vec2(SX,SY)*N[c].xy;
Zn[c].x = ztransform(texture2D(s2_depth,V).r);
// profondeur du voisin reel dans l'image
// VERSION qui ombre le fond
Znp[c] = dot( vec4(di*vec2(SX,SY)*N[c].xy, Zn[c].x, 1.0) , P );
}
dn = obscurance( 0., Znp[0] ,di*SX);
dnw = obscurance( 0., Znp[1],di*SX);
dw = obscurance( 0., Znp[2] ,di*SX);
dsw = obscurance( 0., Znp[3],di*SX);
ds = obscurance( 0., Znp[4] ,di*SX);
dse = obscurance( 0., Znp[5],di*SX);
de = obscurance( 0., Znp[6] ,di*SX);
dne = obscurance( 0., Znp[7],di*SX);
}
float computeObscurance(float F,float scale,float weight)
{
computeNeighbours8( scale );
float S = F;
float WE = weight;
S += dn * WE;
S += dnw * WE;
S += dw * WE;
S += dsw * WE;
S += ds * WE;
S += dse * WE;
S += de * WE;
S += dne * WE;
return S;
}
void ambientOcclusion()
{
float F = 0.;
float weight = 20.; // 2. * 3.14159;
F = computeObscurance(F,d,weight);
F = exp(-F_scale*F);
gl_FragData[0] = vec4(F,F,F,Z);
}
void main (void)
{
S = SX;
Z = texture2D(s2_depth, tcoordVC.st).r;
t = ztransform(Z);
ambientOcclusion();
}
/*=========================================================================
Program: ParaView
Module: vtkDepthImageProcessingPass.cxx
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
/*----------------------------------------------------------------------
Acknowledgement:
This algorithm is the result of joint work by Electricité de France,
CNRS, Collège de France and Université J. Fourier as part of the
Ph.D. thesis of Christian BOUCHENY.
------------------------------------------------------------------------*/
#include "vtkDepthImageProcessingPass.h"
#include "vtkObjectFactory.h"
#include <assert.h>
#include "vtkRenderState.h"
#include "vtkRenderer.h"
#include "vtkFrameBufferObject.h"
#include "vtkTextureObject.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkPNGWriter.h"
#include "vtkImageImport.h"
#include "vtkPixelBufferObject.h"
#include "vtkImageExtractComponents.h"
#include "vtkCamera.h"
#include "vtkMath.h"
vtkCxxSetObjectMacro(vtkDepthImageProcessingPass,DelegatePass,vtkRenderPass);
// ----------------------------------------------------------------------------
vtkDepthImageProcessingPass::vtkDepthImageProcessingPass()
{
this->DelegatePass = 0;
this->Width = 0;
this->Height = 0;
this->W = 0;
this->H = 0;
this->ExtraPixels = 0;
}
// ----------------------------------------------------------------------------
vtkDepthImageProcessingPass::~vtkDepthImageProcessingPass()
{
if(this->DelegatePass!=0)
{
this->DelegatePass->Delete();
this->DelegatePass=0;
}
}
// ----------------------------------------------------------------------------
void vtkDepthImageProcessingPass::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "DelegatePass:";
if(this->DelegatePass!=0)
{
this->DelegatePass->PrintSelf(os,indent);
}
else
{
os << "(none)" <<endl;
}
}
// ----------------------------------------------------------------------------
// Description:
// Render delegate with a image of different dimensions than the
// original one.
// \pre s_exists: s!=0
// \pre fbo_exists: fbo!=0
// \pre fbo_has_context: fbo->GetContext()!=0
// \pre target_exists: target!=0
// \pre target_has_context: target->GetContext()!=0
void vtkDepthImageProcessingPass::RenderDelegate(const vtkRenderState *s,
int width,
int height,
int newWidth,
int newHeight,
vtkFrameBufferObject *fbo,
vtkTextureObject *colortarget,
vtkTextureObject *depthtarget)
{
assert("pre: s_exists" && s!=0);
assert("pre: fbo_exists" && fbo!=0);
assert("pre: fbo_has_context" && fbo->GetContext()!=0);
assert("pre: colortarget_exists" && colortarget!=0);
assert("pre: colortarget_has_context" && colortarget->GetContext()!=0);
assert("pre: depthtarget_exists" && depthtarget!=0);
assert("pre: depthtarget_has_context" && depthtarget->GetContext()!=0);
vtkRenderer *r=s->GetRenderer();
vtkRenderState s2(r);
s2.SetPropArrayAndCount(s->GetPropArray(),s->GetPropArrayCount());
// Adapt camera to new window size
vtkCamera *savedCamera=r->GetActiveCamera();
savedCamera->Register(this);
vtkCamera *newCamera=vtkCamera::New();
newCamera->DeepCopy(savedCamera);
r->SetActiveCamera(newCamera);
if(newCamera->GetParallelProjection())
{
newCamera->SetParallelScale(
newCamera->GetParallelScale()*newHeight/static_cast<double>(height));
}
else
{
double large;
double small;
if(newCamera->GetUseHorizontalViewAngle())
{
large=newWidth;
small=width;
}
else
{
large=newHeight;
small=height</