Shaders failure with a specific file
This file polyEx.vtk fails with the following :
Loading: /home/glow/Downloads/polyEx.vtk
Using default scalar array: my_scalars
Number of points: 8
Number of polygons: 6
Number of lines: 0
Number of vertices: 0
1 point data array(s):
my_scalars : float : [0, 7]
2 cell data array(s):
cell_scalars : int : [0, 5]
cell_normals : float : [-1, 1] [-1, 1] [-1, 1]
0 field data array(s):
Camera position is : 0.5, 0.5, 4.17367.
Camera focal point is : 0.5, 0.5, 0.5.
Camera view up is : 0, 1, 0.
Camera view angle is : 30.
Using grid unit square size = 0.1
Grid origin set to [0.5, 0, 0.5]
[0m[31m2020-05-19 13:54:22.819 ( 0.436s) [ 6E777780] vtkShaderProgram.cxx:452 ERR| vtkShaderProgram (0x55deeba0c940): 1: #version 150
2: #ifdef GL_ES
3: #ifdef GL_FRAGMENT_PRECISION_HIGH
4: precision highp float;
5: precision highp sampler2D;
6: precision highp sampler3D;
7: #else
8: precision mediump float;
9: precision mediump sampler2D;
10: precision mediump sampler3D;
11: #endif
12: #define texelFetchBuffer texelFetch
13: #define texture1D texture
14: #define texture2D texture
15: #define texture3D texture
16: #else // GL_ES
17: #define highp
18: #define mediump
19: #define lowp
20: #if __VERSION__ == 150
21: #define texelFetchBuffer texelFetch
22: #define texture1D texture
23: #define texture2D texture
24: #define texture3D texture
25: #endif
26: #endif // GL_ES
27: #define varying in
28:
29:
30: /*=========================================================================
31:
32: Program: Visualization Toolkit
33: Module: vtkPolyDataFS.glsl
34:
35: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
36: All rights reserved.
37: See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
38:
39: This software is distributed WITHOUT ANY WARRANTY; without even
40: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
41: PURPOSE. See the above copyright notice for more information.
42:
43: =========================================================================*/
44: // Template for the polydata mappers fragment shader
45:
46: uniform int PrimitiveIDOffset;
47:
48:
49:
50: // VC position of this fragment
51: in vec4 vertexVCVSOutput;
52:
53: // Camera prop
54: uniform int cameraParallel;
55:
56:
57: // optional color passed in from the vertex shader, vertexColor
58: uniform float ambientIntensity; // the material ambient
59: uniform float diffuseIntensity; // the material diffuse
60: uniform float opacityUniform; // the fragment opacity
61: uniform vec3 ambientColorUniform; // ambient color
62: uniform vec3 diffuseColorUniform; // diffuse color
63: uniform float specularIntensity; // the material specular intensity
64: uniform vec3 specularColorUniform; // intensity weighted color
65: uniform float specularPowerUniform;
66:
67:
68: // optional surface normal declaration
69: uniform mat3 normalMatrix;
70: uniform samplerBuffer textureN;
71:
72:
73: // extra lighting parameters
74: uniform vec3 lightColor0;
75: uniform vec3 lightDirectionVC0; // normalized
76: uniform vec3 lightColor1;
77: uniform vec3 lightDirectionVC1; // normalized
78: uniform vec3 lightColor2;
79: uniform vec3 lightDirectionVC2; // normalized
80: uniform vec3 lightColor3;
81: uniform vec3 lightDirectionVC3; // normalized
82: uniform vec3 lightColor4;
83: uniform vec3 lightDirectionVC4; // normalized
84:
85: uniform mat3 normalMatrix;
86: const float PI = 3.14159265359;
87: const float recPI = 0.31830988618;
88: uniform float metallicUniform;
89: uniform float roughnessUniform;
90: uniform vec3 emissiveFactorUniform;
91: uniform float aoStrengthUniform;
92: uniform vec3 edgeTintUniform;
93: float D_GGX(float NdH, float roughness)
94: {
95: float a = roughness * roughness;
96: float a2 = a * a;
97: float d = (NdH * a2 - NdH) * NdH + 1.0;
98: return a2 / (PI * d * d);
99: }
100: float V_SmithCorrelated(float NdV, float NdL, float roughness)
101: {
102: float a2 = roughness * roughness;
103: float ggxV = NdL * sqrt(a2 + NdV * (NdV - a2 * NdV));
104: float ggxL = NdV * sqrt(a2 + NdL * (NdL - a2 * NdL));
105: return 0.5 / (ggxV + ggxL);
106: }
107: vec3 F_Schlick(vec3 F0, vec3 F90, float HdV)
108: {
109: return F0 + (F90 - F0) * pow(1.0 - HdV, 5.0);
110: }
111: vec3 DiffuseLambert(vec3 albedo)
112: {
113: return albedo * recPI;
114: }
115:
116:
117: // Texture maps
118: uniform sampler2D colortexture;
119:
120:
121: // Texture coordinates
122: in vec2 tcoordVCVSOutput;
123:
124:
125: // picking support
126: //VTK::Picking::Dec
127:
128: // Depth Peeling Support
129: //VTK::DepthPeeling::Dec
130:
131: // clipping plane vars
132: //VTK::Clip::Dec
133:
134: // the output of this shader
135: out vec4 fragOutput0;
136:
137:
138: // Apple Bug
139: //VTK::PrimID::Dec
140:
141: // handle coincident offsets
142: //VTK::Coincident::Dec
143:
144: // Value raster
145: //VTK::ValuePass::Dec
146:
147: void main()
148: {
149: // VC position of this fragment. This should not branch/return/discard.
150: vec4 vertexVC = vertexVCVSOutput;
151:
152: // Place any calls that require uniform flow (e.g. dFdx) here.
153: vec3 fdx = dFdx(vertexVC.xyz);
154: vec3 fdy = dFdy(vertexVC.xyz);
155: //VTK::UniformFlow::Impl
156:
157:
158: // Set gl_FragDepth here (gl_FragCoord.z by default)
159: //VTK::Depth::Impl
160:
161: // Early depth peeling abort:
162: //VTK::DepthPeeling::PreColor
163:
164: // Apple Bug
165: //VTK::PrimID::Impl
166:
167: //VTK::Clip::Impl
168:
169: //VTK::ValuePass::Impl
170:
171: vec3 specularColor = specularIntensity * specularColorUniform;
172: float specularPower = specularPowerUniform;
173: vec4 texColor = texture(colortexture, tcoordVCVSOutput.st);
174: vec3 ambientColor = ambientIntensity * texColor.rgb;
175: vec3 diffuseColor = diffuseIntensity * texColor.rgb;
176: float opacity = opacityUniform * texColor.a;
177:
178: // Generate the normal if we are not passed in one
179: vec3 normalVCVSOutput =
180: texelFetchBuffer(textureN, gl_PrimitiveID + PrimitiveIDOffset).xyz;
181: normalVCVSOutput = normalize(normalMatrix * normalVCVSOutput);
182: if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }
183:
184:
185: vec3 albedo = pow(diffuseColor, vec3(2.2));
186: float roughness = roughnessUniform;
187: float metallic = metallicUniform;
188: float ao = 1.0;
189: vec3 emissiveColor = vec3(0.0);
190: vec3 N = normalVCVSOutput;
191: vec3 V = normalize(-vertexVC.xyz);
192: float NdV = clamp(dot(N, V), 1e-5, 1.0);
193: vec3 irradiance = vec3(0.0);
194: vec3 prefilteredColor = vec3(0.0);
195: vec2 brdf = vec2(0.0, 0.0);
196: vec3 Lo = vec3(0.0);
197: vec3 F0 = mix(vec3(0.04), albedo, metallic);
198: float f90 = clamp(dot(F0, vec3(50.0 * 0.33)), 0.0, 1.0);
199: vec3 F90 = mix(vec3(f90), edgeTintUniform, metallic);
200: vec3 L, H, radiance, F, specular, diffuse;
201: float NdL, NdH, HdV, distanceVC, attenuation, D, Vis;
202:
203: L = normalize(-lightDirectionVC0);
204: H = normalize(V + L);
205: NdL = clamp(dot(N, L), 1e-5, 1.0);
206: NdH = clamp(dot(N, H), 1e-5, 1.0);
207: HdV = clamp(dot(H, V), 1e-5, 1.0);
208: radiance = lightColor0;
209: D = D_GGX(NdH, roughness);
210: Vis = V_SmithCorrelated(NdV, NdL, roughness);
211: F = F_Schlick(F0, F90, HdV);
212: specular = D * Vis * F;
213: diffuse = (1.0 - metallic) * (1.0 - F) * DiffuseLambert(albedo);
214: Lo += (diffuse + specular) * radiance * NdL;
215: L = normalize(-lightDirectionVC1);
216: H = normalize(V + L);
217: NdL = clamp(dot(N, L), 1e-5, 1.0);
218: NdH = clamp(dot(N, H), 1e-5, 1.0);
219: HdV = clamp(dot(H, V), 1e-5, 1.0);
220: radiance = lightColor1;
221: D = D_GGX(NdH, roughness);
222: Vis = V_SmithCorrelated(NdV, NdL, roughness);
223: F = F_Schlick(F0, F90, HdV);
224: specular = D * Vis * F;
225: diffuse = (1.0 - metallic) * (1.0 - F) * DiffuseLambert(albedo);
226: Lo += (diffuse + specular) * radiance * NdL;
227: L = normalize(-lightDirectionVC2);
228: H = normalize(V + L);
229: NdL = clamp(dot(N, L), 1e-5, 1.0);
230: NdH = clamp(dot(N, H), 1e-5, 1.0);
231: HdV = clamp(dot(H, V), 1e-5, 1.0);
232: radiance = lightColor2;
233: D = D_GGX(NdH, roughness);
234: Vis = V_SmithCorrelated(NdV, NdL, roughness);
235: F = F_Schlick(F0, F90, HdV);
236: specular = D * Vis * F;
237: diffuse = (1.0 - metallic) * (1.0 - F) * DiffuseLambert(albedo);
238: Lo += (diffuse + specular) * radiance * NdL;
239: L = normalize(-lightDirectionVC3);
240: H = normalize(V + L);
241: NdL = clamp(dot(N, L), 1e-5, 1.0);
242: NdH = clamp(dot(N, H), 1e-5, 1.0);
243: HdV = clamp(dot(H, V), 1e-5, 1.0);
244: radiance = lightColor3;
245: D = D_GGX(NdH, roughness);
246: Vis = V_SmithCorrelated(NdV, NdL, roughness);
247: F = F_Schlick(F0, F90, HdV);
248: specular = D * Vis * F;
249: diffuse = (1.0 - metallic) * (1.0 - F) * DiffuseLambert(albedo);
250: Lo += (diffuse + specular) * radiance * NdL;
251: L = normalize(-lightDirectionVC4);
252: H = normalize(V + L);
253: NdL = clamp(dot(N, L), 1e-5, 1.0);
254: NdH = clamp(dot(N, H), 1e-5, 1.0);
255: HdV = clamp(dot(H, V), 1e-5, 1.0);
256: radiance = lightColor4;
257: D = D_GGX(NdH, roughness);
258: Vis = V_SmithCorrelated(NdV, NdL, roughness);
259: F = F_Schlick(F0, F90, HdV);
260: specular = D * Vis * F;
261: diffuse = (1.0 - metallic) * (1.0 - F) * DiffuseLambert(albedo);
262: Lo += (diffuse + specular) * radiance * NdL;
263: // In IBL, we assume that v=n, so the amount of light reflected is
264: // the reflectance F0
265: vec3 specularBrdf = F0 * brdf.r + F90 * brdf.g;
266: vec3 iblSpecular = prefilteredColor * specularBrdf;
267: vec3 iblDiffuse = (1.0 - F0) * (1.0 - metallic) * irradiance * albedo;
268: vec3 color = iblDiffuse + iblSpecular + Lo;
269: color = mix(color, color * ao, aoStrengthUniform);
270: color += emissiveColor;
271: color = pow(color, vec3(1.0/2.2));
272: fragOutput0 = vec4(color, opacity);
273: //VTK::Light::Impl
274:
275:
276:
277:
278:
279: if (fragOutput0.a <= 0.0)
280: {
281: discard;
282: }
283:
284: //VTK::DepthPeeling::Impl
285:
286: //VTK::Picking::Impl
287:
288: // handle coincident offsets
289: //VTK::Coincident::Impl
290: }
[0m
[0m[31m2020-05-19 13:54:22.820 ( 0.436s) [ 6E777780] vtkShaderProgram.cxx:453 ERR| vtkShaderProgram (0x55deeba0c940): 0(85) : error C1038: declaration of "normalMatrix" conflicts with previous declaration at 0(69)
[0m
bt:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff67ef1d7 in vtkOpenGLPolyDataMapper::UpdateShaders (this=0x555555db9ba0, cellBO=..., ren=0x5555557a8e50, actor=0x555555db7350) at /home/glow/work/vt k/vtkSecondary/vtk/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:2188
2188 if (newShader != cellBO.Program || cellBO.Program->GetMTime() > cellBO.AttributeUpdateTime)
(gdb) bt
#0 0x00007ffff67ef1d7 in vtkOpenGLPolyDataMapper::UpdateShaders (this=0x555555db9ba0, cellBO=..., ren=0x5555557a8e50, actor=0x555555db7350) at /home/glow/wor k/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:2188
#1 0x00007ffff67f2f4c in vtkOpenGLPolyDataMapper::RenderPieceDraw (this=0x555555db9ba0, ren=0x5555557a8e50, actor=0x555555db7350) at /home/glow/work/vtk/vtkS econdary/vtk/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:2900
#2 0x00007ffff67f3531 in vtkOpenGLPolyDataMapper::RenderPiece (this=0x555555db9ba0, ren=0x5555557a8e50, actor=0x555555db7350) at /home/glow/work/vtk/vtkSecon dary/vtk/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:3004
#3 0x00007ffff58e250d in vtkPolyDataMapper::Render (this=0x555555db9ba0, ren=0x5555557a8e50, act=0x555555db7350) at /home/glow/work/vtk/vtkSecondary/vtk/Rend ering/Core/vtkPolyDataMapper.cxx:65
#4 0x00007ffff675f5e5 in vtkOpenGLActor::Render (this=0x555555db7350, ren=0x5555557a8e50, mapper=0x555555db9ba0) at /home/glow/work/vtk/vtkSecondary/vtk/Rend ering/OpenGL2/vtkOpenGLActor.cxx:104
#5 0x00007ffff57c7cd4 in vtkActor::RenderOpaqueGeometry (this=0x555555db7350, vp=0x5555557a8e50) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/Core/vtkAc tor.cxx:229
#6 0x00007ffff58e757c in vtkProp::RenderFilteredOpaqueGeometry (this=0x555555db7350, v=0x5555557a8e50, requiredKeys=0x0) at /home/glow/work/vtk/vtkSecondary/ vtk/Rendering/Core/vtkProp.cxx:273
#7 0x00007ffff67341d7 in vtkDefaultPass::RenderFilteredOpaqueGeometry (this=0x55555630e890, s=0x7fffffffcd20) at /home/glow/work/vtk/vtkSecondary/vtk/Renderi ng/OpenGL2/vtkDefaultPass.cxx:85
#8 0x00007ffff675f062 in vtkOpaquePass::Render (this=0x55555630e890, s=0x7fffffffcd20) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkOpaquePas s.cxx:43
#9 0x00007ffff68bcdd7 in vtkSequencePass::Render (this=0x5555563656a0, s=0x7fffffffcd20) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkSequenc ePass.cxx:70
#10 0x00007ffff670cc21 in vtkCameraPass::Render (this=0x55555636b370, s=0x7fffffffcd20) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkCameraPas s.cxx:144
#11 0x00007ffff6734eea in vtkDepthImageProcessingPass::RenderDelegate (this=0x5555563072a0, s=0x7fffffffd0f0, width=956, height=1056, newWidth=956, newHeight= 1056, fbo=0x555555f58700, colortarget=0x555558a2b0e0, depthtarget=0x555555ed2ce0)
at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkDepthImageProcessingPass.cxx:130
#12 0x00007ffff674e1fd in vtkFramebufferPass::Render (this=0x5555563072a0, s=0x7fffffffd0f0) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkFram ebufferPass.cxx:144
#13 0x000055555567567b in vtkF3DRenderPass::Render (this=0x555559dab700, s=0x7fffffffd1b0) at /home/glow/work/f3d/f3d/src/vtkF3DRenderPass.cxx:206
#14 0x00007ffff675dbb3 in vtkImageProcessingPass::RenderDelegate (this=0x5555561e2cb0, s=0x7fffffffd620, width=956, height=1056, newWidth=956, newHeight=1056, fbo=0x555555f5d410, target=0x555556343fa0) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkImageProcessingPass.cxx:171
#15 0x00007ffff68e939c in vtkToneMappingPass::Render (this=0x5555561e2cb0, s=0x7fffffffd620) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkTone MappingPass.cxx:117
#16 0x00007ffff677664e in vtkOpenGLFXAAPass::Render (this=0x555558a2bda0, s=0x7fffffffd620) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkOpenG LFXAAPass.cxx:33
#17 0x00007ffff68294fd in vtkOpenGLRenderer::DeviceRender (this=0x5555557a8e50) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkOpenGLRenderer.cx x:246
#18 0x00007ffff591f390 in vtkRenderer::Render (this=0x5555557a8e50) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/Core/vtkRenderer.cxx:377
#19 0x000055555567dec6 in vtkF3DRenderer::Render (this=0x5555557a8e50) at /home/glow/work/f3d/f3d/src/vtkF3DRenderer.cxx:753
#20 0x00007ffff5934574 in vtkRendererCollection::Render (this=0x55555586fcb0) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/Core/vtkRendererCollection.cxx :51 DP
#21 0x00007ffff59028e6 in vtkRenderWindow::DoStereoRender (this=0x55555586f390) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/Core/vtkRenderWindow.cxx:337DP
#22 0x00007ffff59026bb in vtkRenderWindow::Render (this=0x55555586f390) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/Core/vtkRenderWindow.cxx:297 re
#23 0x00007ffff682670d in vtkOpenGLRenderWindow::Render (this=0x55555586f390) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkOpenGLRenderWindow. cxx:2057 ar
#24 0x00007ffff69057a8 in vtkXOpenGLRenderWindow::Render (this=0x55555586f390) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/OpenGL2/vtkXOpenGLRenderWindo64 w.cxx:1519
#25 0x00007ffff590b522 in vtkRenderWindowInteractor::Render (this=0x555555870c90) at /home/glow/work/vtk/vtkSecondary/vtk/Rendering/Core/vtkRenderWindowIntera ctor.cxx:182
#26 0x00007ffff7c45160 in vtkOrientationMarkerWidget::SetInteractive (this=0x555558a5e4a0, interact=0) at /home/glow/work/vtk/vtkSecondary/vtk/Interaction/Wid gets/vtkOrientationMarkerWidget.cxx:539
#27 0x00007ffff7c475e3 in vtkOrientationMarkerWidget::InteractiveOff (this=0x555558a5e4a0) at /home/glow/work/vtk/vtkSecondary/vtk/Interaction/Widgets/vtkOrie ntationMarkerWidget.h:114
#28 0x000055555567c3f1 in vtkF3DRenderer::ShowAxis (this=0x5555557a8e50, show=true) at /home/glow/work/f3d/f3d/src/vtkF3DRenderer.cxx:299
#29 0x000055555567dd6a in vtkF3DRenderer::ShowOptions (this=0x5555557a8e50) at /home/glow/work/f3d/f3d/src/vtkF3DRenderer.cxx:727
#30 0x000055555569533a in F3DLoader::LoadFile (this=0x7fffffffe840, load=0) at /home/glow/work/f3d/f3d/src/F3DLoader.cxx:274
#31 0x0000555555693fbf in F3DLoader::Start (this=0x7fffffffe840, argc=2, argv=0x7fffffffe988) at /home/glow/work/f3d/f3d/src/F3DLoader.cxx:91
#32 0x000055555565bb6d in main (argc=2, argv=0x7fffffffe988) at /home/glow/work/f3d/f3d/src/main.cxx:11
Edited by Mathieu Westphal (Kitware)