Commit b421b3f9 authored by Francois Bertel's avatar Francois Bertel

ENH:For some reason I forgot to move the shader code out of vtkOpenGLRenderer...

ENH:For some reason I forgot to move the shader code out of vtkOpenGLRenderer when I moved EncodeString from VolumeRendering to Utilities.
parent 29f2d199
......@@ -257,6 +257,29 @@ IF(VTK_USE_X)
SET( Kit_SRCS ${Kit_SRCS} vtkXRenderWindowInteractor.cxx)
ENDIF(VTK_USE_X)
# The set of source files to be encoded.
SET(glsl_files
vtkOpenGLRenderer_PeelingFS
)
# Create custom commands to encode each assembly file into a C string
# literal in a header file.
SET(glsl_h_files)
FOREACH(file ${glsl_files})
SET(src ${VTK_SOURCE_DIR}/Rendering/${file}.glsl)
SET(res ${VTK_BINARY_DIR}/Rendering/${file}.cxx)
SET(resh ${VTK_BINARY_DIR}/Rendering/${file}.h)
SET(glsl_h_files ${glsl_h_files} "${resh}")
ADD_CUSTOM_COMMAND(
OUTPUT ${res} ${resh}
DEPENDS ${src} vtkEncodeString
COMMAND ${VTK_ENCODESTRING_EXE}
ARGS ${res} ${src} ${file} --build-header VTK_RENDERING_EXPORT vtkSystemIncludes.h
)
SET(Kit_EXTRA_SRCS ${Kit_EXTRA_SRCS} ${res})
ENDFOREACH(file)
# OpenGL extensions stuff.
# Parse the extensions into vtkgl.h/vtkgl.cxx.
......@@ -457,7 +480,7 @@ ELSE (VTK_USE_MANGLED_MESA)
ENDIF(VTK_OPENGL_HAS_OSMESA AND OSMESA_LIBRARY)
ENDIF(VTK_USE_MANGLED_MESA)
SET(Kit_SRCS ${Kit_SRCS} ${KitOpenGL_SRCS})
SET(Kit_EXTRA_SRCS ${Kit_FT_SRCS})
SET(Kit_EXTRA_SRCS ${Kit_EXTRA_SRCS} ${Kit_FT_SRCS})
IF(VTK_USE_GL2PS)
SET(Kit_EXTRA_SRCS ${Kit_EXTRA_SRCS} ${Kit_GL2PS_SRCS})
......@@ -599,3 +622,9 @@ IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
COMPONENT Development
)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
IF(NOT CMAKE_CROSSCOMPILING)
# Add target dependency to ensure the vtkEncodeString is built before
# Rendering is.
ADD_DEPENDENCIES(vtk${KIT} vtkEncodeString)
ENDIF(NOT CMAKE_CROSSCOMPILING)
......@@ -43,7 +43,7 @@ public:
};
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkOpenGLRenderer, "1.90");
vtkCxxRevisionMacro(vtkOpenGLRenderer, "1.91");
vtkStandardNewMacro(vtkOpenGLRenderer);
#endif
......@@ -56,40 +56,7 @@ public:
vtkstd::list<GLuint> List;
};
const char *vtkOpenGLRenderer_PeelingFS=
// "#extension GL_ARB_texture_rectangle: enable\n"
"uniform sampler2DRectShadow shadowTex;\n"
"uniform sampler2DRectShadow opaqueShadowTex;\n"
"uniform float offsetX;\n"
"uniform float offsetY;\n"
"uniform int useTexture;\n"
"uniform sampler2D texture;\n"
"void main()\n"
"{\n"
"vec4 r0=gl_FragCoord;\n"
"r0.x=r0.x-offsetX;\n"
"r0.y=r0.y-offsetY;\n"
"float r1=shadow2DRect(opaqueShadowTex,r0.xyz).x;\n"
"r1=r1-0.5;\n"
"if(r1<0.0)\n"
"{\n"
" discard;\n"
"}\n"
"r0.x=shadow2DRect(shadowTex,r0.xyz).x;\n"
"r0.x=r0.x-0.5;\n"
"if(r0.x<0.0)\n"
"{\n"
" discard;\n"
"}\n"
"if(useTexture==1)\n"
"{\n"
" gl_FragColor=gl_Color*texture2D(texture,gl_TexCoord[0].xy);\n"
"}\n"
"else\n"
"{\n"
" gl_FragColor=gl_Color;\n"
"}\n"
"}\n";
extern const char *vtkOpenGLRenderer_PeelingFS;
vtkOpenGLRenderer::vtkOpenGLRenderer()
{
......
// ============================================================================
//
// Program: Visualization Toolkit
// Module: vtkOpenGLRenderer_PeelingFS.glsl
//
// 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.
//
// ============================================================================
//
// Fragment shader used by the depth peeling algorithm.
// #extension GL_ARB_texture_rectangle: enable
uniform sampler2DRectShadow shadowTex;
uniform sampler2DRectShadow opaqueShadowTex;
uniform float offsetX;
uniform float offsetY;
uniform int useTexture;
uniform sampler2D texture;
void main()
{
vec4 r0=gl_FragCoord;
r0.x=r0.x-offsetX;
r0.y=r0.y-offsetY;
float r1=shadow2DRect(opaqueShadowTex,r0.xyz).x;
r1=r1-0.5;
if(r1<0.0)
{
discard;
}
r0.x=shadow2DRect(shadowTex,r0.xyz).x;
r0.x=r0.x-0.5;
if(r0.x<0.0)
{
discard;
}
if(useTexture==1)
{
gl_FragColor=gl_Color*texture2D(texture,gl_TexCoord[0].xy);
}
else
{
gl_FragColor=gl_Color;
}
}
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