EJShim / emscripten-vtk-examples

1 stars 1 forks source link

Emscripten build 에서 SphereMapper 사용 시 에러 #3

Open EJShim opened 4 years ago

EJShim commented 4 years ago
SphereMapper.js:2392 vtkShaderProgram (0x587ca8): Links failed: FRAGMENT varying vertexVCGSOutput does not match any VERTEX varying

vtk.js shader 참고 필요

EJShim commented 4 years ago

SphereMapper 에서 사용하는 쉐이더 그대로 사용

    // Visualization vtkOpenGLPolyDataMapper
    #ifdef EMSCRIPTEN
    vtkSmartPointer<vtkOpenGLPolyDataMapper> mapper = vtkSmartPointer<vtkOpenGLPolyDataMapper>::New();

    #else
    vtkSmartPointer<vtkOpenGLPolyDataMapper> mapper = vtkSmartPointer<vtkOpenGLPolyDataMapper>::New();  
    #endif
    mapper->SetInputData(polydata);

    std::string vs = GetStringFromFile("resources/glsl/vtkPointGaussianVS.glsl");
    std::string gs = GetStringFromFile("resources/glsl/vtkSphereMapperGS.glsl");    
EJShim commented 4 years ago

js VS shader for sphereMapper :

2: #ifndef GL_ES
3: #define highp
4: #define mediump
5: #define lowp
6: #endif // GL_ES
7: #define attribute in
8: #define varying out
9:
10:
11: /*=========================================================================
12:
13:   Program:   Visualization Toolkit
14:   Module:    vtkSphereMapperVS.glsl
15:
16:   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
17:   All rights reserved.
18:   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
19:
20:      This software is distributed WITHOUT ANY WARRANTY; without even
21:      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22:      PURPOSE.  See the above copyright notice for more information.
23:
24: =========================================================================*/
25: // this shader implements imposters in OpenGL for Spheres
26:
27: attribute vec4 vertexMC;
28: attribute vec2 offsetMC;
29:
30: // optional normal declaration
31: //VTK::Normal::Dec
32:
33: // Texture coordinates
34: //VTK::TCoord::Dec
35:
36: uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
37:
38: // material property values
39: in vec4 scalarColor;
40: out vec4 vertexColorVSOutput;
41:
42: // clipping plane vars
43: //VTK::Clip::Dec
44:
45: // camera and actor matrix values
46: uniform mat4 VCDCMatrix;
47: uniform mat4 MCVCMatrix;
48:
49: varying vec4 vertexVCVSOutput;
50: varying float radiusVCVSOutput;
51: varying vec3 centerVCVSOutput;
52:
53: uniform int cameraParallel;
54:
55: void main()
56: {
57:   vertexColorVSOutput = scalarColor;
58:
59:   //VTK::Normal::Impl
60:
61:   //VTK::TCoord::Impl
62:
63:   //VTK::Clip::Impl
64:
65:   // compute the projected vertex position
66:   vertexVCVSOutput = MCVCMatrix * vertexMC;
67:   centerVCVSOutput = vertexVCVSOutput.xyz;
68:   radiusVCVSOutput = length(offsetMC)*0.5;
69:
70:   // make the triangle face the camera
71:   if (cameraParallel == 0)
72:     {
73:     vec3 dir = normalize(-vertexVCVSOutput.xyz);
74:     vec3 base2 = normalize(cross(dir,vec3(1.0,0.0,0.0)));
75:     vec3 base1 = cross(base2,dir);
76:     vertexVCVSOutput.xyz = vertexVCVSOutput.xyz + offsetMC.x*base1 + offsetMC.y*base2;
77:     }
78:   else
79:     {
80:     // add in the offset
81:     vertexVCVSOutput.xy = vertexVCVSOutput.xy + offsetMC;
82:     }
83:
84:   gl_Position = VCPCMatrix * vertexVCVSOutput;
85: }
EJShim commented 4 years ago

cxx VS shader for sphereMapper :

2: #ifndef GL_ES
3: #define highp
4: #define mediump
5: #define lowp
6: #endif // GL_ES
7: #define attribute in
8: #define varying out
9:
10:
11: /*=========================================================================
12:
13:   Program:   Visualization Toolkit
14:   Module:    vtkPointGaussianVS.glsl
15:
16:   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
17:   All rights reserved.
18:   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
19:
20:      This software is distributed WITHOUT ANY WARRANTY; without even
21:      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22:      PURPOSE.  See the above copyright notice for more information.
23:
24: =========================================================================*/
25: // this shader implements imposters in OpenGL for Spheres
26:
27: in vec4 vertexMC;
28: in float radiusMC;
29: out float radiusVCVSOutput;
30:
31: // optional normal declaration
32: //VTK::Normal::Dec
33:
34: // Texture coordinates
35: //VTK::TCoord::Dec
36:
37: // material property values
38: in vec4 scalarColor;
39: out vec4 vertexColorVSOutput;
40:
41: // clipping plane vars
42: //VTK::Clip::Dec
43:
44: // camera and actor matrix values
45: uniform mat4 VCDCMatrix;
46: uniform mat4 MCVCMatrix;
47:
48: // picking support
49: //VTK::Picking::De
50:
51: void main()
52: {
53:   vertexColorVSOutput = scalarColor;
54:
55:   //VTK::Normal::Impl
56:
57:   //VTK::TCoord::Impl
58: asdf
59:   //VTK::Clip::Impl
60:
61:   radiusVCVSOutput = radiusMC;
62:
63:   gl_Position = MCVCMatrix * vertexMC;
64:   //VTK::Picking::Impl
65: }