11#include " vtkF3DPointSplatMapper.h"
22
3+ #if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
34#include " vtkF3DBitonicSort.h"
45#include " vtkF3DComputeDepthCS.h"
6+ #endif
57#include " vtkF3DRenderer.h"
68
79#include < vtkCamera.h>
@@ -62,6 +64,7 @@ class vtkF3DSplatMapperHelper : public vtkOpenGLPointGaussianMapperHelper
6264 vtkOpenGLHelper& cellBO, vtkRenderer* ren, vtkActor* actor) override ;
6365
6466private:
67+ #if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
6568 void SortSplats (vtkRenderer* ren);
6669
6770 vtkNew<vtkShader> DepthComputeShader;
@@ -72,6 +75,7 @@ class vtkF3DSplatMapperHelper : public vtkOpenGLPointGaussianMapperHelper
7275
7376 double DirectionThreshold = 0.999 ;
7477 double LastDirection[3 ] = { 0.0 , 0.0 , 0.0 };
78+ #endif
7579
7680 int MaxTextureSize = 0 ;
7781 vtkNew<vtkTextureObject> SphericalHarmonicsTexture;
@@ -84,11 +88,13 @@ vtkStandardNewMacro(vtkF3DSplatMapperHelper);
8488// ----------------------------------------------------------------------------
8589vtkF3DSplatMapperHelper::vtkF3DSplatMapperHelper ()
8690{
91+ #if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
8792 this ->DepthComputeShader ->SetType (vtkShader::Compute);
8893 this ->DepthComputeShader ->SetSource (vtkF3DComputeDepthCS);
8994 this ->DepthProgram ->SetComputeShader (this ->DepthComputeShader );
9095
9196 this ->Sorter ->Initialize (512 , VTK_FLOAT , VTK_UNSIGNED_INT );
97+ #endif
9298}
9399
94100// ----------------------------------------------------------------------------
@@ -105,9 +111,11 @@ void vtkF3DSplatMapperHelper::BuildBufferObjects(vtkRenderer* ren, vtkActor* act
105111
106112 vtkOpenGLPointGaussianMapperHelper::BuildBufferObjects (ren, act);
107113
114+ #if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
108115 // allocate a buffer of depths used for sorting splats
109116 this ->DepthBuffer ->Allocate (splatCount * sizeof (float ), vtkOpenGLBufferObject::ArrayBuffer,
110117 vtkOpenGLBufferObject::DynamicCopy);
118+ #endif
111119
112120 this ->SphericalHarmonicsDegree = 0 ;
113121
@@ -269,6 +277,7 @@ void vtkF3DSplatMapperHelper::SetCameraShaderParameters(
269277 this ->Superclass ::SetCameraShaderParameters (cellBO, ren, actor);
270278}
271279
280+ #if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
272281// ----------------------------------------------------------------------------
273282void vtkF3DSplatMapperHelper::SortSplats (vtkRenderer* ren)
274283{
@@ -319,18 +328,20 @@ void vtkF3DSplatMapperHelper::SortSplats(vtkRenderer* ren)
319328 }
320329 }
321330}
331+ #endif
322332
323333// ----------------------------------------------------------------------------
324334void vtkF3DSplatMapperHelper::RenderPieceDraw (vtkRenderer* ren, vtkActor* actor)
325335{
336+ #if !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
326337 const vtkF3DRenderer* renderer = vtkF3DRenderer::SafeDownCast (ren);
327338
328339 if (renderer->GetBlendingMode () == vtkF3DRenderer::BlendingMode::SORT &&
329- vtkShader::IsComputeShaderSupported () && actor->GetForceTranslucent ())
340+ vtkShader::IsComputeShaderSupported () && actor->HasTranslucentPolygonalGeometry ())
330341 {
331342 this ->SortSplats (ren);
332343 }
333-
344+ # endif
334345 vtkOpenGLPointGaussianMapperHelper::RenderPieceDraw (ren, actor);
335346}
336347
@@ -342,16 +353,19 @@ void vtkF3DSplatMapperHelper::ReplaceShaderColor(
342353 {
343354 std::string VSSource = shaders[vtkShader::Vertex]->GetSource ();
344355
345- vtkShaderProgram::Substitute (VSSource, " //VTK::Color::Dec" ,
346- " //VTK::Color::Dec\n\n "
347- " uniform sampler2DArray sphericalHarmonics;\n "
348- " uniform vec3 cameraDirection;\n "
349- " vec3 decode(ivec3 texelIndex)\n "
350- " {\n "
351- " vec3 texel = texelFetch(sphericalHarmonics, texelIndex, 0).rgb;\n "
352- " return texel * 2.0 - 1.0;\n "
353- " }\n\n " ,
354- false );
356+ if (this ->SphericalHarmonicsDegree > 0 )
357+ {
358+ vtkShaderProgram::Substitute (VSSource, " //VTK::Color::Dec" ,
359+ " //VTK::Color::Dec\n\n "
360+ " uniform sampler2DArray sphericalHarmonics;\n "
361+ " uniform vec3 cameraDirection;\n "
362+ " vec3 decode(ivec3 texelIndex)\n "
363+ " {\n "
364+ " vec3 texel = texelFetch(sphericalHarmonics, texelIndex, 0).rgb;\n "
365+ " return texel * 2.0 - 1.0;\n "
366+ " }\n\n " ,
367+ false );
368+ }
355369
356370 std::stringstream shStr;
357371 shStr << " //VTK::Color::Impl\n " ;
0 commit comments