I am looking to run a Blender workload in Amazon Web Services (AWS). I am testing on a Windows Server image on a non-GPU compute resource. Instead of GPU I am attaching AWS Elastic Graphics to the instance. This provides OpenGL 4.3. This is working really well for another workload which uses Unity (in which case I need to force OpenGL mode).
When I open blender.exe (2.83), it immediately exits. Running it from the command line I am able to capture the following output, which indicates some sort of shader error on startup.
Edit: 2.79b launches just fine, so this seems to be a new bug introduced. We need to export to gltf so I'd like to be on the latest version.
I realize this may be an unusual case, but does anyone have any ideas on how I might get blender to run? Perhaps some command line settings? Thanks in advance!
C:\Program Files\Blender Foundation\Blender 2.83>blender
AL lib: (EE) ALCmmdevPlayback_open: Device init failed: 0x80070490
Warning: Could not find a matching GPU name. Things may not behave as expected.
Detected OpenGL configuration:
Vendor: Amazon Web Services, Inc.
Renderer: Amazon Elastic Graphics (eg1.medium)
found bundled python: C:\Program Files\Blender Foundation\Blender 2.83\2.83\python
GPUShader: compile error:
Vertex shader failed to compile with the following errors:
ERROR: 5:445: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:445: error(#102) #error: Builtin Name not supported
ERROR: 5:454: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:454: error(#102) #error: Builtin Name not supported
ERROR: 5:459: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:459: error(#102) #error: Builtin Name not supported
ERROR: 5:469: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:469: error(#102) #error: Builtin Name not supported
ERROR: error(#273) 8 compilation errors. No code generated
Error : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF7CA4E8774
Module : C:\Program Files\Blender Foundation\Blender 2.83\blender.exe
Here is out from using --debug-all in case that is helpful:
AL lib: (EE) ALCmmdevPlayback_open: Device init failed: 0x80070490
Switching to fully guarded memory allocator.
read file
Version 280 sub 39 date unknown hash unknown
DEG_relations_tag_update: Tagging relations for update.
DEG_relations_tag_update: Tagging relations for update.
DEG_relations_tag_update: Tagging relations for update.
DEG_relations_tag_update: Tagging relations for update.
DEG_relations_tag_update: Tagging relations for update.
graph_id_tag_update: id=SCScene flags=LEGACY_0 source=USER_EDIT
Warning: Could not find a matching GPU name. Things may not behave as expected.
Detected OpenGL configuration:
Vendor: Amazon Web Services, Inc.
Renderer: Amazon Elastic Graphics (eg1.medium)
ED_screen_refresh: set screen
[SCScene :: View Layer]: Removed 31 relations to no-op nodes
graph_id_tag_update: id=SCScene flags=TRANSFORM, GEOMETRY, SHADING, SELECT, BASE_FLAGS, POINT_CACHE, COPY_ON_WRITE, SEQUENCER_STRIPS, AUDIO_SEEK, AUDIO_FPS, AUDIO_VOLUME, AUDIO_MUTE, AUDIO_LISTENER, AUDIO, PARAMETERS source=RELATIONS
graph_id_tag_update: id=OBCube flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=MECube flags=LEGACY_0 source=RELATIONS
graph_id_tag_update: id=MECube flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=MAMaterial flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=OBLight flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=LALight flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=OBCamera flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=CACamera flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=GRMaster Collection flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=GRCollection flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=WOWorld flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=LSLineStyle flags=COPY_ON_WRITE source=RELATIONS
graph_id_tag_update: id=SCScene flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=OBCube flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=MECube flags=LEGACY_0 source=VISIBILITY
graph_id_tag_update: id=MECube flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=MAMaterial flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=OBLight flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=LALight flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=OBCamera flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=CACamera flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=GRMaster Collection flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=GRCollection flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=WOWorld flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=LSLineStyle flags=COPY_ON_WRITE source=VISIBILITY
Depsgraph built in 0.000456 seconds.
graph_id_tag_update: id=SCScene flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=OBCube flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=MECube flags=LEGACY_0 source=VISIBILITY
graph_id_tag_update: id=MECube flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=MAMaterial flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=OBLight flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=LALight flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=OBCamera flags=TRANSFORM, GEOMETRY, COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=CACamera flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=GRMaster Collection flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=GRCollection flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=WOWorld flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=NTShader Nodetree flags=COPY_ON_WRITE source=VISIBILITY
graph_id_tag_update: id=LSLineStyle flags=COPY_ON_WRITE source=VISIBILITY
[SCScene :: View Layer]: ... (output removed to save space)
I0723 23:12:13.248817 6420 blender_python.cpp:191] Debug flags initialized to:
CPU flags:
AVX2 : True
AVX : True
SSE4.1 : True
SSE3 : True
SSE2 : True
BVH layout : BVH8
Split : False
CUDA flags:
Adaptive Compile : False
OptiX flags:
CUDA streams : 1
OpenCL flags:
Device type : ALL
Debug : False
Memory limit : 0
Depsgraph updated in 0.000455 seconds.
Depsgraph evaluation FPS: -nan(ind)
found bundled python: C:\Program Files\Blender Foundation\Blender 2.83\2.83\python
FRS_set_context: context 0x000002ECFED695F8 scene 0x000002EC821785B8
GPUShader: compile error:
===== shader string 1 ====
1 #version 330
===== shader string 2 ====
2 #define GPU_VERTEX_SHADER
===== shader string 3 ====
3 #extension GL_ARB_texture_gather: enable
4 #define GPU_ARB_texture_gather
5 #extension GL_ARB_texture_query_lod: enable
6 #extension GL_ARB_texture_cube_map_array : enable
7 #define GPU_ARB_texture_cube_map_array
===== shader string 4 ====
8 #define GPU_ATI
9 #define OS_WIN
10 #define DFDX_SIGN 1.0
11 #define DFDY_SIGN 1.0
===== shader string 5 ====
12 #define blender_srgb_to_framebuffer_space(a) a
13 #define V3D_LIGHTING_STUDIO
14 #define WORKBENCH_ENCODE_NORMALS
15 #define OPAQUE_MATERIAL
===== shader string 6 ====
16 #define COMMON_VIEW_LIB
17 #define DRW_RESOURCE_CHUNK_LEN 512
18
19 /* keep in sync with DRWManager.view_data */
20 layout(std140) uniform viewBlock
21 {
22 /* Same order as DRWViewportMatrixType */
23 mat4 ViewProjectionMatrix;
24 mat4 ViewProjectionMatrixInverse;
25 mat4 ViewMatrix;
26 mat4 ViewMatrixInverse;
27 mat4 ProjectionMatrix;
28 mat4 ProjectionMatrixInverse;
29
30 vec4 clipPlanes[6];
31
32 /* TODO move it elsewhere. */
33 vec4 CameraTexCoFactors;
34 };
35
36 #ifdef world_clip_planes_calc_clip_distance
37 # undef world_clip_planes_calc_clip_distance
38 # define world_clip_planes_calc_clip_distance(p) \
39 _world_clip_planes_calc_clip_distance(p, clipPlanes)
40 #endif
41
42 #ifdef COMMON_GLOBALS_LIB
43 float mul_project_m4_v3_zfac(in vec3 co)
44 {
45 return pixelFac * ((ViewProjectionMatrix[0][3] * co.x) + (ViewProjectionMatrix[1][3] * co.y) +
46 (ViewProjectionMatrix[2][3] * co.z) + ViewProjectionMatrix[3][3]);
47 }
48 #endif
49
50 /* Not the right place but need to be common to all overlay's.
51 * TODO Split to an overlay lib. */
52 mat4 extract_matrix_packed_data(mat4 mat, out vec4 dataA, out vec4 dataB)
53 {
54 const float div = 1.0 / 255.0;
55 int a = int(mat[0][3]);
56 int b = int(mat[1][3]);
57 int c = int(mat[2][3]);
58 int d = int(mat[3][3]);
59 dataA = vec4(a & 0xFF, a >> 8, b & 0xFF, b >> 8) * div;
60 dataB = vec4(c & 0xFF, c >> 8, d & 0xFF, d >> 8) * div;
61 mat[0][3] = mat[1][3] = mat[2][3] = 0.0;
62 mat[3][3] = 1.0;
63 return mat;
64 }
65
66 /* Same here, Not the right place but need to be common to all overlay's.
67 * TODO Split to an overlay lib. */
68 /* edge_start and edge_pos needs to be in the range [0..sizeViewport]. */
69 vec4 pack_line_data(vec2 frag_co, vec2 edge_start, vec2 edge_pos)
70 {
71 vec2 edge = edge_start - edge_pos;
72 float len = length(edge);
73 if (len > 0.0) {
74 edge /= len;
75 vec2 perp = vec2(-edge.y, edge.x);
76 float dist = dot(perp, frag_co - edge_start);
77 /* Add 0.1 to diffenrentiate with cleared pixels. */
78 return vec4(perp * 0.5 + 0.5, dist * 0.25 + 0.5 + 0.1, 1.0);
79 }
80 else {
81 /* Default line if the origin is perfectly aligned with a pixel. */
82 return vec4(1.0, 0.0, 0.5 + 0.1, 1.0);
83 }
84 }
85
86 uniform int resourceChunk;
87
88 #ifdef GPU_VERTEX_SHADER
89 # ifdef GL_ARB_shader_draw_parameters
90 # define baseInstance gl_BaseInstanceARB
91 # else /* no ARB_shader_draw_parameters */
92 uniform int baseInstance;
93 # endif
94
95 # if defined(IN_PLACE_INSTANCES) || defined(INSTANCED_ATTR)
96 /* When drawing instances of an object at the same position. */
97 # define instanceId 0
98 # elif defined(GPU_DEPRECATED_AMD_DRIVER)
99 /* A driver bug make it so that when using an attribute with GL_INT_2_10_10_10_REV as format,
100 * the gl_InstanceID is incremented by the 2 bit component of the attribute.
101 * Ignore gl_InstanceID then. */
102 # define instanceId 0
103 # else
104 # define instanceId gl_InstanceID
105 # endif
106
107 # ifdef UNIFORM_RESOURCE_ID
108 /* This is in the case we want to do a special instance drawcall but still want to have the
109 * right resourceId and all the correct ubo datas. */
110 uniform int resourceId;
111 # define resource_id resourceId
112 # else
113 # define resource_id (baseInstance + instanceId)
114 # endif
115
116 /* Use this to declare and pass the value if
117 * the fragment shader uses the resource_id. */
118 # define RESOURCE_ID_VARYING flat out int resourceIDFrag;
119 # define RESOURCE_ID_VARYING_GEOM flat out int resourceIDGeom;
120 # define PASS_RESOURCE_ID resourceIDFrag = resource_id;
121 # define PASS_RESOURCE_ID_GEOM resourceIDGeom = resource_id;
122 #endif
123
124 /* If used in a fragment / geometry shader, we pass
125 * resource_id as varying. */
126 #ifdef GPU_GEOMETRY_SHADER
127 # define RESOURCE_ID_VARYING \
128 flat out int resourceIDFrag; \
129 flat in int resourceIDGeom[];
130
131 # define resource_id resourceIDGeom
132 # define PASS_RESOURCE_ID(i) resourceIDFrag = resource_id[i];
133 #endif
134
135 #ifdef GPU_FRAGMENT_SHADER
136 flat in int resourceIDFrag;
137 # define resource_id resourceIDFrag
138 #endif
139
140 /* Breaking this across multiple lines causes issues for some older GLSL compilers. */
141 /* clang-format off */
142 #if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) && !defined(INSTANCED_ATTR)
143 /* clang-format on */
144 struct ObjectMatrices {
145 mat4 drw_modelMatrix;
146 mat4 drw_modelMatrixInverse;
147 };
148
149 layout(std140) uniform modelBlock
150 {
151 ObjectMatrices drw_matrices[DRW_RESOURCE_CHUNK_LEN];
152 };
153
154 # define ModelMatrix (drw_matrices[resource_id].drw_modelMatrix)
155 # define ModelMatrixInverse (drw_matrices[resource_id].drw_modelMatrixInverse)
156
157 #else /* GPU_INTEL */
158 /* Intel GPU seems to suffer performance impact when the model matrix is in UBO storage.
159 * So for now we just force using the legacy path. */
160 /* Note that this is also a workaround of a problem on osx (amd or nvidia)
161 * and older amd driver on windows. */
162 uniform mat4 ModelMatrix;
163 uniform mat4 ModelMatrixInverse;
164 #endif
165
166 #define resource_handle (resourceChunk * DRW_RESOURCE_CHUNK_LEN + resource_id)
167
168 /** Transform shortcuts. */
169 /* Rule of thumb: Try to reuse world positions and normals because converting though viewspace
170 * will always be decomposed in at least 2 matrix operation. */
171
172 /**
173 * Some clarification:
174 * Usually Normal matrix is transpose(inverse(ViewMatrix * ModelMatrix))
175 *
176 * But since it is slow to multiply matrices we decompose it. Decomposing
177 * inversion and transposition both invert the product order leaving us with
178 * the same original order:
179 * transpose(ViewMatrixInverse) * transpose(ModelMatrixInverse)
180 *
181 * Knowing that the view matrix is orthogonal, the transpose is also the inverse.
182 * Note: This is only valid because we are only using the mat3 of the ViewMatrixInverse.
183 * ViewMatrix * transpose(ModelMatrixInverse)
184 **/
185 #define normal_object_to_view(n) (mat3(ViewMatrix) * (transpose(mat3(ModelMatrixInverse)) * n))
186 #define normal_object_to_world(n) (transpose(mat3(ModelMatrixInverse)) * n)
187 #define normal_world_to_object(n) (transpose(mat3(ModelMatrix)) * n)
188 #define normal_world_to_view(n) (mat3(ViewMatrix) * n)
189
190 #define point_object_to_ndc(p) (ViewProjectionMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0))
191 #define point_object_to_view(p) ((ViewMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0)).xyz)
192 #define point_object_to_world(p) ((ModelMatrix * vec4(p, 1.0)).xyz)
193 #define point_view_to_ndc(p) (ProjectionMatrix * vec4(p, 1.0))
194 #define point_view_to_object(p) ((ModelMatrixInverse * (ViewMatrixInverse * vec4(p, 1.0))).xyz)
195 #define point_view_to_world(p) ((ViewMatrixInverse * vec4(p, 1.0)).xyz)
196 #define point_world_to_ndc(p) (ViewProjectionMatrix * vec4(p, 1.0))
197 #define point_world_to_object(p) ((ModelMatrixInverse * vec4(p, 1.0)).xyz)
198 #define point_world_to_view(p) ((ViewMatrix * vec4(p, 1.0)).xyz)
199
200 /* Due to some shader compiler bug, we somewhat need to access gl_VertexID
201 * to make vertex shaders work. even if it's actually dead code. */
202 #ifdef GPU_INTEL
203 # define GPU_INTEL_VERTEX_SHADER_WORKAROUND gl_Position.x = float(gl_VertexID);
204 #else
205 # define GPU_INTEL_VERTEX_SHADER_WORKAROUND
206 #endif
207
208 #define DRW_BASE_SELECTED (1 << 1)
209 #define DRW_BASE_FROM_DUPLI (1 << 2)
210 #define DRW_BASE_FROM_SET (1 << 3)
211 #define DRW_BASE_ACTIVE (1 << 4)
212
213 #ifdef GPU_VERTEX_SHADER
214 # define IN_OUT out
215 #else
216 # define IN_OUT in
217 #endif
218
219 IN_OUT ShaderStageInterface
220 {
221 vec3 normal_interp;
222 vec3 color_interp;
223 float alpha_interp;
224 vec2 uv_interp;
225 #ifdef TRANSPARENT_MATERIAL
226 flat float roughness;
227 flat float metallic;
228 #else
229 flat float packed_rough_metal;
230 #endif
231 flat int object_id;
232 };
233
234 #define EPSILON 0.00001
235 #define M_PI 3.14159265358979323846
236
237 #define CAVITY_BUFFER_RANGE 4.0
238
239 #ifdef WORKBENCH_ENCODE_NORMALS
240
241 # define WB_Normal vec2
242
243 /* From http://aras-p.info/texts/CompactNormalStorage.html
244 * Using Method #4: Spheremap Transform */
245 vec3 workbench_normal_decode(vec4 enc)
246 {
247 vec2 fenc = enc.xy * 4.0 - 2.0;
248 float f = dot(fenc, fenc);
249 float g = sqrt(1.0 - f / 4.0);
250 vec3 n;
251 n.xy = fenc * g;
252 n.z = 1 - f / 2;
253 return n;
254 }
255
256 /* From http://aras-p.info/texts/CompactNormalStorage.html
257 * Using Method #4: Spheremap Transform */
258 WB_Normal workbench_normal_encode(bool front_face, vec3 n)
259 {
260 n = normalize(front_face ? n : -n);
261 float p = sqrt(n.z * 8.0 + 8.0);
262 n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0);
263 return n.xy;
264 }
265
266 #else
267 # define WB_Normal vec3
268 /* Well just do nothing... */
269 # define workbench_normal_encode(f, a) (a)
270 # define workbench_normal_decode(a) (a.xyz)
271 #endif /* WORKBENCH_ENCODE_NORMALS */
272
273 /* Encoding into the alpha of a RGBA16F texture. (10bit mantissa) */
274 #define TARGET_BITCOUNT 8u
275 #define METALLIC_BITS 3u /* Metallic channel is less important. */
276 #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS)
277
278 /* Encode 2 float into 1 with the desired precision. */
279 float workbench_float_pair_encode(float v1, float v2)
280 {
281 // const uint v1_mask = ~(0xFFFFFFFFu << ROUGHNESS_BITS);
282 // const uint v2_mask = ~(0xFFFFFFFFu << METALLIC_BITS);
283 /* Same as above because some compiler are dumb af. and think we use mediump int. */
284 const int v1_mask = 0x1F;
285 const int v2_mask = 0x7;
286 int iv1 = int(v1 * float(v1_mask));
287 int iv2 = int(v2 * float(v2_mask)) << int(ROUGHNESS_BITS);
288 return float(iv1 | iv2);
289 }
290
291 void workbench_float_pair_decode(float data, out float v1, out float v2)
292 {
293 // const uint v1_mask = ~(0xFFFFFFFFu << ROUGHNESS_BITS);
294 // const uint v2_mask = ~(0xFFFFFFFFu << METALLIC_BITS);
295 /* Same as above because some compiler are dumb af. and think we use mediump int. */
296 const int v1_mask = 0x1F;
297 const int v2_mask = 0x7;
298 int idata = int(data);
299 v1 = float(idata & v1_mask) * (1.0 / float(v1_mask));
300 v2 = float(idata >> int(ROUGHNESS_BITS)) * (1.0 / float(v2_mask));
301 }
302
303 vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat)
304 {
305 if (proj_mat[3][3] == 0.0) {
306 return normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz);
307 }
308 else {
309 return vec3(0.0, 0.0, 1.0);
310 }
311 }
312
313 vec3 view_position_from_depth(vec2 uvcoords, float depth, vec4 viewvecs[3], mat4 proj_mat)
314 {
315 if (proj_mat[3][3] == 0.0) {
316 /* Perspective */
317 float d = 2.0 * depth - 1.0;
318
319 float zview = -proj_mat[3][2] / (d + proj_mat[2][2]);
320
321 return zview * (viewvecs[0].xyz + vec3(uvcoords, 0.0) * viewvecs[1].xyz);
322 }
323 else {
324 /* Orthographic */
325 vec3 offset = vec3(uvcoords, depth);
326
327 return viewvecs[0].xyz + offset * viewvecs[1].xyz;
328 }
329 }
330
331 /* TODO(fclem) deduplicate code. */
332 bool node_tex_tile_lookup(inout vec3 co, sampler2DArray ima, sampler1DArray map)
333 {
334 vec2 tile_pos = floor(co.xy);
335
336 if (tile_pos.x < 0 || tile_pos.y < 0 || tile_pos.x >= 10)
337 return false;
338
339 float tile = 10.0 * tile_pos.y + tile_pos.x;
340 if (tile >= textureSize(map, 0).x)
341 return false;
342
343 /* Fetch tile information. */
344 float tile_layer = texelFetch(map, ivec2(tile, 0), 0).x;
345 if (tile_layer < 0.0)
346 return false;
347
348 vec4 tile_info = texelFetch(map, ivec2(tile, 1), 0);
349
350 co = vec3(((co.xy - tile_pos) * tile_info.zw) + tile_info.xy, tile_layer);
351 return true;
352 }
353
354 vec4 workbench_sample_texture(sampler2D image, vec2 coord, bool nearest_sampling)
355 {
356 /* TODO(fclem) We could do the same with sampler objects.
357 * But this is a quick workaround instead of messing with the GPUTexture itself. */
358 if (nearest_sampling) {
359 /* Use texelFetch for nearest_sampling to reduce glitches. See: T73726 */
360 vec2 tex_size = vec2(textureSize(image, 0).xy);
361 ivec2 uv = ivec2(floor(coord * tex_size) + 0.5);
362 return texelFetch(image, uv, 0);
363 }
364 else {
365 return texture(image, coord);
366 }
367 }
368
369 vec4 workbench_sample_texture_array(sampler2DArray tile_array,
370 sampler1DArray tile_data,
371 vec2 coord,
372 bool nearest_sampling)
373 {
374
375 vec3 uv = vec3(coord, 0);
376 if (!node_tex_tile_lookup(uv, tile_array, tile_data))
377 return vec4(1.0, 0.0, 1.0, 1.0);
378
379 /* TODO(fclem) We could do the same with sampler objects.
380 * But this is a quick workaround instead of messing with the GPUTexture itself. */
381 if (nearest_sampling) {
382 /* Use texelFetch for nearest_sampling to reduce glitches. See: T73726 */
383 vec3 tex_size = vec3(textureSize(tile_array, 0));
384 uv.xy = floor(uv.xy * tex_size.xy) + 0.5;
385 return texelFetch(tile_array, ivec3(uv), 0);
386 }
387 else {
388 return texture(tile_array, uv);
389 }
390 }
391
392 uniform sampler2DArray imageTileArray;
393 uniform sampler1DArray imageTileData;
394 uniform sampler2D imageTexture;
395
396 uniform float imageTransparencyCutoff = 0.1;
397 uniform bool imageNearest;
398 uniform bool imagePremult;
399
400 vec3 workbench_image_color(vec2 uvs)
401 {
402 #ifdef V3D_SHADING_TEXTURE_COLOR
403 # ifdef TEXTURE_IMAGE_ARRAY
404 vec4 color = workbench_sample_texture_array(imageTileArray, imageTileData, uvs, imageNearest);
405 # else
406 vec4 color = workbench_sample_texture(imageTexture, uvs, imageNearest);
407 # endif
408
409 /* Unpremultiply if stored multiplied, since straight alpha is expected by shaders. */
410 if (imagePremult && !(color.a == 0.0 || color.a == 1.0)) {
411 color.rgb /= color.a;
412 }
413
414 # ifdef GPU_FRAGMENT_SHADER
415 if (color.a < imageTransparencyCutoff) {
416 discard;
417 }
418 # endif
419
420 return color.rgb;
421 #else
422 return vec3(1.0);
423 #endif
424 }
425
426 layout(std140) uniform material_block
427 {
428 vec4 mat_data[4096];
429 };
430
431 /* If set to -1, the resource handle is used instead. */
432 uniform int materialIndex;
433
434 void workbench_material_data_get(
435 int handle, out vec3 color, out float alpha, out float roughness, out float metallic)
436 {
437 handle = (materialIndex != -1) ? materialIndex : handle;
438 vec4 data = mat_data[uint(handle) & 0xFFFu];
439 color = data.rgb;
440
441 uint encoded_data = floatBitsToUint(data.w);
442 alpha = float((encoded_data >> 16u) & 0xFFu) * (1.0 / 255.0);
443 roughness = float((encoded_data >> 8u) & 0xFFu) * (1.0 / 255.0);
444 metallic = float(encoded_data & 0xFFu) * (1.0 / 255.0);
445 }
446
447 #pragma BLENDER_REQUIRE(common_view_lib.glsl)
448 #pragma BLENDER_REQUIRE(workbench_shader_interface_lib.glsl)
449 #pragma BLENDER_REQUIRE(workbench_common_lib.glsl)
450 #pragma BLENDER_REQUIRE(workbench_material_lib.glsl)
451 #pragma BLENDER_REQUIRE(workbench_image_lib.glsl)
452
453 in vec3 pos;
454 in vec3 nor;
455 in vec4 ac; /* active color */
456 in vec2 au; /* active texture layer */
457
458 void main()
459 {
460 vec3 world_pos = point_object_to_world(pos);
461 gl_Position = point_world_to_ndc(world_pos);
462
463 #ifdef USE_WORLD_CLIP_PLANES
464 world_clip_planes_calc_clip_distance(world_pos);
465 #endif
466
467 uv_interp = au;
468
469 normal_interp = normalize(normal_object_to_view(nor));
470
471 #ifdef OPAQUE_MATERIAL
472 float metallic, roughness;
473 #endif
474 workbench_material_data_get(resource_handle, color_interp, alpha_interp, roughness, metallic);
475
476 if (materialIndex == 0) {
477 color_interp = ac.rgb;
478 }
479
480 #ifdef OPAQUE_MATERIAL
481 packed_rough_metal = workbench_float_pair_encode(roughness, metallic);
482 #endif
483
484 object_id = int((uint(resource_id) + 1u) & 0xFFu);
485 }
Vertex shader failed to compile with the following errors:
ERROR: 5:445: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:445: error(#102) #error: Builtin Name not supported
ERROR: 5:454: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:454: error(#102) #error: Builtin Name not supported
ERROR: 5:459: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:459: error(#102) #error: Builtin Name not supported
ERROR: 5:469: error(#438) Extension GL_ARB_shader_draw_parameters is requried' by gl_BaseInstanceARB'.
ERROR: 5:469: error(#102) #error: Builtin Name not supported
ERROR: error(#273) 8 compilation errors. No code generated
Error : EXCEPTION_ACCESS_VIOLATION
Address : 0x00007FF7CA4E8774
Module : C:\Program Files\Blender Foundation\Blender 2.83\blender.exe