./blender --debug Switching to fully guarded memory allocator. Blender 2.80 (sub 35) Build: 2018-12-04 00:28:28 Linux Release argv[0] = ./blender argv[1] = --debug read file /home/env/.config/blender/2.80/config/startup.blend Version 280 sub 35 date 2018-11-29 15:57 hash 26d5a3625ed Received X11 Error: error code: 8 request code: 154 minor code: 34 error text: BadMatch (invalid parameter attributes) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 8 request code: 154 minor code: 34 error text: BadMatch (invalid parameter attributes) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) Received X11 Error: error code: 2 request code: 154 minor code: 34 error text: BadValue (integer parameter out of range for operation) found bundled python: /home/env/blender_download/blender-2.80-1b6a394d862-linux-glibc224-x86_64/2.80/python GPUShader: compile error: ===== shader string 1 ==== 1 #version 330 ===== shader string 2 ==== 2 #extension GL_ARB_texture_query_lod: enable ===== shader string 3 ==== 3 #define GPU_NVIDIA ===== shader string 4 ==== 4 #define V3D_SHADING_OBJECT_OUTLINE 5 #define V3D_SHADING_SPECULAR_HIGHLIGHT 6 #define V3D_LIGHTING_STUDIO 7 #define NORMAL_VIEWPORT_PASS_ENABLED 8 #define WORKBENCH_ENCODE_NORMALS ===== shader string 5 ==== 9 struct LightData { 10 vec4 direction; 11 vec4 specular_color; 12 vec4 diffuse_color_wrap; /* rgb: diffuse col a: wrapped lighting factor */ 13 }; 14 15 struct WorldData { 16 vec4 background_color_low; 17 vec4 background_color_high; 18 vec4 object_outline_color; 19 vec4 shadow_direction_vs; 20 LightData lights[4]; 21 vec4 ambient_color; 22 int num_lights; 23 int matcap_orientation; 24 float background_alpha; 25 float curvature_ridge; 26 float curvature_valley; 27 int pad[3]; 28 }; 29 #define NO_OBJECT_ID uint(0) 30 #define EPSILON 0.00001 31 #define M_PI 3.14159265358979323846 32 33 #define CAVITY_BUFFER_RANGE 4.0 34 35 /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ 36 #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) 37 const vec4 dither_mat4x4[4] = vec4[4]( 38 vec4( P(0.0), P(8.0), P(2.0), P(10.0)), 39 vec4(P(12.0), P(4.0), P(14.0), P(6.0)), 40 vec4( P(3.0), P(11.0), P(1.0), P(9.0)), 41 vec4(P(15.0), P(7.0), P(13.0), P(5.0)) 42 ); 43 44 float bayer_dither_noise() { 45 ivec2 tx1 = ivec2(gl_FragCoord.xy) % 4; 46 ivec2 tx2 = ivec2(gl_FragCoord.xy) % 2; 47 return dither_mat4x4[tx1.x][tx1.y]; 48 } 49 50 #ifdef WORKBENCH_ENCODE_NORMALS 51 52 /* From http://aras-p.info/texts/CompactNormalStorage.html 53 * Using Method #4: Spheremap Transform */ 54 vec3 workbench_normal_decode(vec2 enc) 55 { 56 vec2 fenc = enc.xy * 4.0 - 2.0; 57 float f = dot(fenc, fenc); 58 float g = sqrt(1.0 - f / 4.0); 59 vec3 n; 60 n.xy = fenc*g; 61 n.z = 1 - f / 2; 62 return n; 63 } 64 65 /* From http://aras-p.info/texts/CompactNormalStorage.html 66 * Using Method #4: Spheremap Transform */ 67 vec2 workbench_normal_encode(vec3 n) 68 { 69 float p = sqrt(n.z * 8.0 + 8.0); 70 n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0); 71 return n.xy; 72 } 73 74 #else 75 /* Well just do nothing... */ 76 # define workbench_normal_encode(a) (a) 77 # define workbench_normal_decode(a) (a) 78 #endif /* WORKBENCH_ENCODE_NORMALS */ 79 80 /* Encoding into the alpha of a RGBA8 UNORM texture. */ 81 #define TARGET_BITCOUNT 8 82 #define METALLIC_BITS 3 /* Metallic channel is less important. */ 83 #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) 84 #define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS) 85 86 /* Encode 2 float into 1 with the desired precision. */ 87 float workbench_float_pair_encode(float v1, float v2) 88 { 89 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 90 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 91 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 92 int iv1 = int(v1 * float(v1_mask)); 93 int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS; 94 return float(iv1 | iv2) * (1.0 / float(total_mask)); 95 } 96 97 void workbench_float_pair_decode(float data, out float v1, out float v2) 98 { 99 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 100 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 101 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 102 int idata = int(data * float(total_mask)); 103 v1 = float(idata & v1_mask) * (1.0 / float(v1_mask)); 104 v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask)); 105 } 106 107 float calculate_transparent_weight(float z, float alpha) 108 { 109 #if 0 110 /* Eq 10 : Good for surfaces with varying opacity (like particles) */ 111 float a = min(1.0, alpha * 10.0) + 0.01; 112 float b = -gl_FragCoord.z * 0.95 + 1.0; 113 float w = a * a * a * 3e2 * b * b * b; 114 #else 115 /* Eq 7 put more emphasis on surfaces closer to the view. */ 116 // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ 117 // float w = 10.0 / (1e-5 + pow(abs(z) / 10.0, 3.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 8 */ 118 // float w = 10.0 / (1e-5 + pow(abs(z) / 200.0, 4.0)); /* Eq 9 */ 119 /* Same as eq 7, but optimized. */ 120 float a = abs(z) / 5.0; 121 float b = abs(z) / 200.0; 122 b *= b; 123 float w = 10.0 / ((1e-5 + a * a) + b * (b * b)); /* Eq 7 */ 124 #endif 125 return alpha * clamp(w, 1e-2, 3e2); 126 } 127 128 /* Special function only to be used with calculate_transparent_weight(). */ 129 float linear_zdepth(float depth, vec4 viewvecs[3], mat4 proj_mat) 130 { 131 if (proj_mat[3][3] == 0.0) { 132 float d = 2.0 * depth - 1.0; 133 return -proj_mat[3][2] / (d + proj_mat[2][2]); 134 } 135 else { 136 /* Return depth from near plane. */ 137 return depth * viewvecs[1].z; 138 } 139 } 140 141 vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat) 142 { 143 return (proj_mat[3][3] == 0.0) 144 ? normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz) 145 : vec3(0.0, 0.0, 1.0); 146 } 147 148 vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped) 149 { 150 /* Quick creation of an orthonormal basis */ 151 float a = 1.0 / (1.0 + I.z); 152 float b = -I.x * I.y * a; 153 vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x); 154 vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y); 155 vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N)); 156 if (flipped) { 157 matcap_uv.x = -matcap_uv.x; 158 } 159 return matcap_uv * 0.496 + 0.5; 160 } 161 uniform int object_id = 0; 162 163 uniform vec3 materialDiffuseColor; 164 uniform float materialMetallic; 165 uniform float materialRoughness; 166 167 #ifdef V3D_SHADING_TEXTURE_COLOR 168 uniform sampler2D image; 169 uniform float ImageTransparencyCutoff = 0.1; 170 171 #endif 172 173 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 174 in vec3 normal_viewport; 175 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 176 177 #ifdef V3D_SHADING_TEXTURE_COLOR 178 in vec2 uv_interp; 179 #endif /* V3D_SHADING_TEXTURE_COLOR */ 180 181 #ifdef HAIR_SHADER 182 flat in float hair_rand; 183 #endif 184 185 layout(location=0) out uint objectId; 186 layout(location=1) out vec4 materialData; 187 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 188 # ifdef WORKBENCH_ENCODE_NORMALS 189 layout(location=3) out vec2 normalViewport; 190 # else /* WORKBENCH_ENCODE_NORMALS */ 191 layout(location=3) out vec3 normalViewport; 192 # endif /* WORKBENCH_ENCODE_NORMALS */ 193 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 194 195 void main() 196 { 197 objectId = uint(object_id); 198 199 vec4 color_roughness; 200 #ifdef V3D_SHADING_TEXTURE_COLOR 201 color_roughness = texture(image, uv_interp); 202 if (color_roughness.a < ImageTransparencyCutoff) { 203 discard; 204 } 205 color_roughness.a = materialRoughness; 206 #else 207 color_roughness = vec4(materialDiffuseColor, materialRoughness); 208 #endif /* V3D_SHADING_TEXTURE_COLOR */ 209 210 #ifdef HAIR_SHADER 211 float hair_color_variation = hair_rand * 0.1; 212 color_roughness = clamp(color_roughness - hair_color_variation, 0.0, 1.0); 213 #endif 214 215 float metallic; 216 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT 217 # ifdef HAIR_SHADER 218 metallic = clamp(materialMetallic - hair_color_variation, 0.0, 1.0); 219 # else 220 metallic = materialMetallic; 221 # endif 222 #elif defined(V3D_LIGHTING_MATCAP) 223 /* Encode front facing in metallic channel. */ 224 metallic = float(gl_FrontFacing); 225 color_roughness.a = 0.0; 226 #endif 227 228 materialData.rgb = color_roughness.rgb; 229 materialData.a = workbench_float_pair_encode(color_roughness.a, metallic); 230 231 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 232 vec3 n = (gl_FrontFacing) ? normal_viewport : -normal_viewport; 233 n = normalize(n); 234 normalViewport = workbench_normal_encode(n); 235 #endif 236 } 0(89) : error C7011: implicit cast from "uint" to "int" 0(90) : error C7011: implicit cast from "uint" to "int" 0(91) : error C7011: implicit cast from "uint" to "int" 0(99) : error C7011: implicit cast from "uint" to "int" 0(100) : error C7011: implicit cast from "uint" to "int" 0(101) : error C7011: implicit cast from "uint" to "int" GPUShader: compile error: ===== shader string 1 ==== 1 #version 330 ===== shader string 2 ==== 2 #extension GL_ARB_texture_query_lod: enable ===== shader string 3 ==== 3 #define GPU_NVIDIA ===== shader string 4 ==== 4 #define V3D_SHADING_OBJECT_OUTLINE 5 #define V3D_SHADING_SPECULAR_HIGHLIGHT 6 #define V3D_LIGHTING_STUDIO 7 #define NORMAL_VIEWPORT_PASS_ENABLED 8 #define WORKBENCH_ENCODE_NORMALS ===== shader string 5 ==== 9 struct LightData { 10 vec4 direction; 11 vec4 specular_color; 12 vec4 diffuse_color_wrap; /* rgb: diffuse col a: wrapped lighting factor */ 13 }; 14 15 struct WorldData { 16 vec4 background_color_low; 17 vec4 background_color_high; 18 vec4 object_outline_color; 19 vec4 shadow_direction_vs; 20 LightData lights[4]; 21 vec4 ambient_color; 22 int num_lights; 23 int matcap_orientation; 24 float background_alpha; 25 float curvature_ridge; 26 float curvature_valley; 27 int pad[3]; 28 }; 29 #define NO_OBJECT_ID uint(0) 30 #define EPSILON 0.00001 31 #define M_PI 3.14159265358979323846 32 33 #define CAVITY_BUFFER_RANGE 4.0 34 35 /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ 36 #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) 37 const vec4 dither_mat4x4[4] = vec4[4]( 38 vec4( P(0.0), P(8.0), P(2.0), P(10.0)), 39 vec4(P(12.0), P(4.0), P(14.0), P(6.0)), 40 vec4( P(3.0), P(11.0), P(1.0), P(9.0)), 41 vec4(P(15.0), P(7.0), P(13.0), P(5.0)) 42 ); 43 44 float bayer_dither_noise() { 45 ivec2 tx1 = ivec2(gl_FragCoord.xy) % 4; 46 ivec2 tx2 = ivec2(gl_FragCoord.xy) % 2; 47 return dither_mat4x4[tx1.x][tx1.y]; 48 } 49 50 #ifdef WORKBENCH_ENCODE_NORMALS 51 52 /* From http://aras-p.info/texts/CompactNormalStorage.html 53 * Using Method #4: Spheremap Transform */ 54 vec3 workbench_normal_decode(vec2 enc) 55 { 56 vec2 fenc = enc.xy * 4.0 - 2.0; 57 float f = dot(fenc, fenc); 58 float g = sqrt(1.0 - f / 4.0); 59 vec3 n; 60 n.xy = fenc*g; 61 n.z = 1 - f / 2; 62 return n; 63 } 64 65 /* From http://aras-p.info/texts/CompactNormalStorage.html 66 * Using Method #4: Spheremap Transform */ 67 vec2 workbench_normal_encode(vec3 n) 68 { 69 float p = sqrt(n.z * 8.0 + 8.0); 70 n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0); 71 return n.xy; 72 } 73 74 #else 75 /* Well just do nothing... */ 76 # define workbench_normal_encode(a) (a) 77 # define workbench_normal_decode(a) (a) 78 #endif /* WORKBENCH_ENCODE_NORMALS */ 79 80 /* Encoding into the alpha of a RGBA8 UNORM texture. */ 81 #define TARGET_BITCOUNT 8 82 #define METALLIC_BITS 3 /* Metallic channel is less important. */ 83 #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) 84 #define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS) 85 86 /* Encode 2 float into 1 with the desired precision. */ 87 float workbench_float_pair_encode(float v1, float v2) 88 { 89 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 90 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 91 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 92 int iv1 = int(v1 * float(v1_mask)); 93 int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS; 94 return float(iv1 | iv2) * (1.0 / float(total_mask)); 95 } 96 97 void workbench_float_pair_decode(float data, out float v1, out float v2) 98 { 99 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 100 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 101 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 102 int idata = int(data * float(total_mask)); 103 v1 = float(idata & v1_mask) * (1.0 / float(v1_mask)); 104 v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask)); 105 } 106 107 float calculate_transparent_weight(float z, float alpha) 108 { 109 #if 0 110 /* Eq 10 : Good for surfaces with varying opacity (like particles) */ 111 float a = min(1.0, alpha * 10.0) + 0.01; 112 float b = -gl_FragCoord.z * 0.95 + 1.0; 113 float w = a * a * a * 3e2 * b * b * b; 114 #else 115 /* Eq 7 put more emphasis on surfaces closer to the view. */ 116 // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ 117 // float w = 10.0 / (1e-5 + pow(abs(z) / 10.0, 3.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 8 */ 118 // float w = 10.0 / (1e-5 + pow(abs(z) / 200.0, 4.0)); /* Eq 9 */ 119 /* Same as eq 7, but optimized. */ 120 float a = abs(z) / 5.0; 121 float b = abs(z) / 200.0; 122 b *= b; 123 float w = 10.0 / ((1e-5 + a * a) + b * (b * b)); /* Eq 7 */ 124 #endif 125 return alpha * clamp(w, 1e-2, 3e2); 126 } 127 128 /* Special function only to be used with calculate_transparent_weight(). */ 129 float linear_zdepth(float depth, vec4 viewvecs[3], mat4 proj_mat) 130 { 131 if (proj_mat[3][3] == 0.0) { 132 float d = 2.0 * depth - 1.0; 133 return -proj_mat[3][2] / (d + proj_mat[2][2]); 134 } 135 else { 136 /* Return depth from near plane. */ 137 return depth * viewvecs[1].z; 138 } 139 } 140 141 vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat) 142 { 143 return (proj_mat[3][3] == 0.0) 144 ? normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz) 145 : vec3(0.0, 0.0, 1.0); 146 } 147 148 vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped) 149 { 150 /* Quick creation of an orthonormal basis */ 151 float a = 1.0 / (1.0 + I.z); 152 float b = -I.x * I.y * a; 153 vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x); 154 vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y); 155 vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N)); 156 if (flipped) { 157 matcap_uv.x = -matcap_uv.x; 158 } 159 return matcap_uv * 0.496 + 0.5; 160 } 161 vec3 background_color(WorldData world_data, float y) { 162 return mix(world_data.background_color_low, world_data.background_color_high, y).xyz + bayer_dither_noise(); 163 } 164 165 /* [Drobot2014a] Low Level Optimizations for GCN */ 166 vec4 fast_rcp(vec4 v) 167 { 168 return intBitsToFloat(0x7eef370b - floatBitsToInt(v)); 169 } 170 171 vec3 brdf_approx(vec3 spec_color, float roughness, float NV) 172 { 173 /* Treat anything below 2% as shadowing. 174 * (in other words, makes it possible to completely disable 175 * specular on a material by setting specular color to black). */ 176 float shadowing = clamp(50.0 * spec_color.g, 0.0, 1.0); 177 /* Very rough own approx. We don't need it to be correct, just fast. 178 * Just simulate fresnel effect with roughness attenuation. */ 179 float fresnel = exp2(-8.35 * NV) * (1.0 - roughness); 180 return mix(spec_color, vec3(1.0), fresnel) * shadowing; 181 } 182 183 void prep_specular( 184 vec3 L, vec3 I, vec3 N, vec3 R, 185 out float NL, out float wrapped_NL, out float spec_angle) 186 { 187 wrapped_NL = dot(L, R); 188 vec3 half_dir = normalize(L + I); 189 spec_angle = clamp(dot(half_dir, N), 0.0, 1.0); 190 NL = clamp(dot(L, N), 0.0, 1.0); 191 } 192 193 /* Normalized Blinn shading */ 194 vec4 blinn_specular(vec4 shininess, vec4 spec_angle, vec4 NL) 195 { 196 /* Pi is already divided in the lamp power. 197 * normalization_factor = (shininess + 8.0) / (8.0 * M_PI) */ 198 vec4 normalization_factor = shininess * 0.125 + 1.0; 199 vec4 spec_light = pow(spec_angle, shininess) * NL * normalization_factor; 200 201 return spec_light; 202 } 203 204 /* NL need to be unclamped. w in [0..1] range. */ 205 vec4 wrapped_lighting(vec4 NL, vec4 w) 206 { 207 vec4 w_1 = w + 1.0; 208 vec4 denom = fast_rcp(w_1 * w_1); 209 return clamp((NL + w) * denom, 0.0, 1.0); 210 } 211 212 vec3 get_world_lighting( 213 WorldData world_data, 214 vec3 diffuse_color, vec3 specular_color, float roughness, 215 vec3 N, vec3 I) 216 { 217 vec3 specular_light = world_data.ambient_color.rgb; 218 vec3 diffuse_light = world_data.ambient_color.rgb; 219 vec4 wrap = vec4( 220 world_data.lights[0].diffuse_color_wrap.a, 221 world_data.lights[1].diffuse_color_wrap.a, 222 world_data.lights[2].diffuse_color_wrap.a, 223 world_data.lights[3].diffuse_color_wrap.a 224 ); 225 226 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT 227 /* Prepare Specular computation. Eval 4 lights at once. */ 228 vec3 R = -reflect(I, N); 229 vec4 spec_angle, spec_NL, wrap_NL; 230 prep_specular(world_data.lights[0].direction.xyz, I, N, R, spec_NL.x, wrap_NL.x, spec_angle.x); 231 prep_specular(world_data.lights[1].direction.xyz, I, N, R, spec_NL.y, wrap_NL.y, spec_angle.y); 232 prep_specular(world_data.lights[2].direction.xyz, I, N, R, spec_NL.z, wrap_NL.z, spec_angle.z); 233 prep_specular(world_data.lights[3].direction.xyz, I, N, R, spec_NL.w, wrap_NL.w, spec_angle.w); 234 235 vec4 gloss = vec4(1.0 - roughness); 236 /* Reduce gloss for smooth light. (simulate bigger light) */ 237 gloss *= 1.0 - wrap; 238 vec4 shininess = exp2(10.0 * gloss + 1.0); 239 240 vec4 spec_light = blinn_specular(shininess, spec_angle, spec_NL); 241 242 /* Simulate Env. light. */ 243 vec4 w = mix(wrap, vec4(1.0), roughness); 244 vec4 spec_env = wrapped_lighting(wrap_NL, w); 245 246 spec_light = mix(spec_light, spec_env, wrap * wrap); 247 248 /* Multiply result by lights specular colors. */ 249 specular_light += spec_light.x * world_data.lights[0].specular_color.rgb; 250 specular_light += spec_light.y * world_data.lights[1].specular_color.rgb; 251 specular_light += spec_light.z * world_data.lights[2].specular_color.rgb; 252 specular_light += spec_light.w * world_data.lights[3].specular_color.rgb; 253 254 float NV = clamp(dot(N, I), 0.0, 1.0); 255 specular_color = brdf_approx(specular_color, roughness, NV); 256 #endif 257 specular_light *= specular_color; 258 259 /* Prepare diffuse computation. Eval 4 lights at once. */ 260 vec4 diff_NL; 261 diff_NL.x = dot(world_data.lights[0].direction.xyz, N); 262 diff_NL.y = dot(world_data.lights[1].direction.xyz, N); 263 diff_NL.z = dot(world_data.lights[2].direction.xyz, N); 264 diff_NL.w = dot(world_data.lights[3].direction.xyz, N); 265 266 vec4 diff_light = wrapped_lighting(diff_NL, wrap); 267 268 /* Multiply result by lights diffuse colors. */ 269 diffuse_light += diff_light.x * world_data.lights[0].diffuse_color_wrap.rgb; 270 diffuse_light += diff_light.y * world_data.lights[1].diffuse_color_wrap.rgb; 271 diffuse_light += diff_light.z * world_data.lights[2].diffuse_color_wrap.rgb; 272 diffuse_light += diff_light.w * world_data.lights[3].diffuse_color_wrap.rgb; 273 274 /* Energy conservation with colored specular look strange. 275 * Limit this strangeness by using mono-chromatic specular intensity. */ 276 float spec_energy = dot(specular_color, vec3(0.33333)); 277 278 diffuse_light *= diffuse_color * (1.0 - spec_energy); 279 280 return diffuse_light + specular_light; 281 } 282 #define OBJECT_OUTLINE_OFFSET 1 283 284 float calculate_object_outline(usampler2D objectId, ivec2 texel, uint object_id) 285 { 286 uvec4 oid_offset = uvec4( 287 texelFetchOffset(objectId, texel, 0, ivec2(0, OBJECT_OUTLINE_OFFSET)).r, 288 texelFetchOffset(objectId, texel, 0, ivec2(0, -OBJECT_OUTLINE_OFFSET)).r, 289 texelFetchOffset(objectId, texel, 0, ivec2(-OBJECT_OUTLINE_OFFSET, 0)).r, 290 texelFetchOffset(objectId, texel, 0, ivec2( OBJECT_OUTLINE_OFFSET, 0)).r); 291 292 return dot(vec4(equal(uvec4(object_id), oid_offset)), vec4(0.25)); 293 } 294 out vec4 fragColor; 295 296 uniform mat4 ProjectionMatrix; 297 uniform mat4 ViewMatrixInverse; 298 299 uniform usampler2D objectId; 300 uniform sampler2D materialBuffer; 301 uniform sampler2D normalBuffer; 302 /* normalBuffer contains viewport normals */ 303 uniform sampler2D cavityBuffer; 304 uniform sampler2D matcapImage; 305 306 uniform vec2 invertedViewportSize; 307 uniform vec4 viewvecs[3]; 308 uniform float shadowMultiplier; 309 uniform float lightMultiplier; 310 uniform float shadowShift = 0.1; 311 uniform float shadowFocus = 1.0; 312 313 layout(std140) uniform world_block { 314 WorldData world_data; 315 }; 316 317 void main() 318 { 319 ivec2 texel = ivec2(gl_FragCoord.xy); 320 vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize; 321 322 vec4 material_data = texelFetch(materialBuffer, texel, 0); 323 vec3 base_color = material_data.rgb; 324 325 /* Do we need normals */ 326 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 327 vec3 normal_viewport = workbench_normal_decode(texelFetch(normalBuffer, texel, 0).rg); 328 #endif 329 330 vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix); 331 332 /* -------- SHADING --------- */ 333 #ifdef V3D_LIGHTING_FLAT 334 vec3 shaded_color = base_color; 335 336 #elif defined(V3D_LIGHTING_MATCAP) 337 /* When using matcaps, the material_data.a is the backface sign. */ 338 float flipped_nor = material_data.a; 339 normal_viewport = (flipped_nor > 0.0) ? normal_viewport : -normal_viewport; 340 bool flipped = world_data.matcap_orientation != 0; 341 vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped); 342 vec3 matcap = textureLod(matcapImage, matcap_uv, 0.0).rgb; 343 vec3 shaded_color = matcap * base_color; 344 345 #elif defined(V3D_LIGHTING_STUDIO) 346 347 # ifdef V3D_SHADING_SPECULAR_HIGHLIGHT 348 float roughness, metallic; 349 workbench_float_pair_decode(material_data.a, roughness, metallic); 350 vec3 specular_color = mix(vec3(0.05), base_color, metallic); 351 vec3 diffuse_color = mix(base_color, vec3(0.0), metallic); 352 # else 353 float roughness = 0.0; 354 vec3 specular_color = vec3(0.0); 355 vec3 diffuse_color = base_color; 356 # endif 357 358 vec3 shaded_color = get_world_lighting(world_data, 359 diffuse_color, specular_color, roughness, 360 normal_viewport, I_vs); 361 #endif 362 363 /* -------- POST EFFECTS --------- */ 364 #ifdef WB_CAVITY 365 /* Using UNORM texture so decompress the range */ 366 shaded_color *= texelFetch(cavityBuffer, texel, 0).r * CAVITY_BUFFER_RANGE; 367 #endif 368 369 #ifdef V3D_SHADING_SHADOW 370 float light_factor = -dot(normal_viewport, world_data.shadow_direction_vs.xyz); 371 float shadow_mix = smoothstep(shadowFocus, shadowShift, light_factor); 372 shaded_color *= mix(lightMultiplier, shadowMultiplier, shadow_mix); 373 #endif 374 375 #ifdef V3D_SHADING_OBJECT_OUTLINE 376 uint object_id = texelFetch(objectId, texel, 0).r; 377 float object_outline = calculate_object_outline(objectId, texel, object_id); 378 shaded_color = mix(world_data.object_outline_color.rgb, shaded_color, object_outline); 379 #endif 380 381 fragColor = vec4(shaded_color, 1.0); 382 } 0(89) : error C7011: implicit cast from "uint" to "int" 0(90) : error C7011: implicit cast from "uint" to "int" 0(91) : error C7011: implicit cast from "uint" to "int" 0(99) : error C7011: implicit cast from "uint" to "int" 0(100) : error C7011: implicit cast from "uint" to "int" 0(101) : error C7011: implicit cast from "uint" to "int" GPUShader: compile error: ===== shader string 1 ==== 1 #version 330 ===== shader string 2 ==== 2 #extension GL_ARB_texture_query_lod: enable ===== shader string 3 ==== 3 #define GPU_NVIDIA ===== shader string 4 ==== 4 #define V3D_SHADING_OBJECT_OUTLINE 5 #define V3D_SHADING_SPECULAR_HIGHLIGHT 6 #define V3D_LIGHTING_STUDIO 7 #define NORMAL_VIEWPORT_PASS_ENABLED 8 #define WORKBENCH_ENCODE_NORMALS 9 #define HAIR_SHADER ===== shader string 5 ==== 10 struct LightData { 11 vec4 direction; 12 vec4 specular_color; 13 vec4 diffuse_color_wrap; /* rgb: diffuse col a: wrapped lighting factor */ 14 }; 15 16 struct WorldData { 17 vec4 background_color_low; 18 vec4 background_color_high; 19 vec4 object_outline_color; 20 vec4 shadow_direction_vs; 21 LightData lights[4]; 22 vec4 ambient_color; 23 int num_lights; 24 int matcap_orientation; 25 float background_alpha; 26 float curvature_ridge; 27 float curvature_valley; 28 int pad[3]; 29 }; 30 #define NO_OBJECT_ID uint(0) 31 #define EPSILON 0.00001 32 #define M_PI 3.14159265358979323846 33 34 #define CAVITY_BUFFER_RANGE 4.0 35 36 /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ 37 #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) 38 const vec4 dither_mat4x4[4] = vec4[4]( 39 vec4( P(0.0), P(8.0), P(2.0), P(10.0)), 40 vec4(P(12.0), P(4.0), P(14.0), P(6.0)), 41 vec4( P(3.0), P(11.0), P(1.0), P(9.0)), 42 vec4(P(15.0), P(7.0), P(13.0), P(5.0)) 43 ); 44 45 float bayer_dither_noise() { 46 ivec2 tx1 = ivec2(gl_FragCoord.xy) % 4; 47 ivec2 tx2 = ivec2(gl_FragCoord.xy) % 2; 48 return dither_mat4x4[tx1.x][tx1.y]; 49 } 50 51 #ifdef WORKBENCH_ENCODE_NORMALS 52 53 /* From http://aras-p.info/texts/CompactNormalStorage.html 54 * Using Method #4: Spheremap Transform */ 55 vec3 workbench_normal_decode(vec2 enc) 56 { 57 vec2 fenc = enc.xy * 4.0 - 2.0; 58 float f = dot(fenc, fenc); 59 float g = sqrt(1.0 - f / 4.0); 60 vec3 n; 61 n.xy = fenc*g; 62 n.z = 1 - f / 2; 63 return n; 64 } 65 66 /* From http://aras-p.info/texts/CompactNormalStorage.html 67 * Using Method #4: Spheremap Transform */ 68 vec2 workbench_normal_encode(vec3 n) 69 { 70 float p = sqrt(n.z * 8.0 + 8.0); 71 n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0); 72 return n.xy; 73 } 74 75 #else 76 /* Well just do nothing... */ 77 # define workbench_normal_encode(a) (a) 78 # define workbench_normal_decode(a) (a) 79 #endif /* WORKBENCH_ENCODE_NORMALS */ 80 81 /* Encoding into the alpha of a RGBA8 UNORM texture. */ 82 #define TARGET_BITCOUNT 8 83 #define METALLIC_BITS 3 /* Metallic channel is less important. */ 84 #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) 85 #define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS) 86 87 /* Encode 2 float into 1 with the desired precision. */ 88 float workbench_float_pair_encode(float v1, float v2) 89 { 90 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 91 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 92 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 93 int iv1 = int(v1 * float(v1_mask)); 94 int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS; 95 return float(iv1 | iv2) * (1.0 / float(total_mask)); 96 } 97 98 void workbench_float_pair_decode(float data, out float v1, out float v2) 99 { 100 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 101 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 102 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 103 int idata = int(data * float(total_mask)); 104 v1 = float(idata & v1_mask) * (1.0 / float(v1_mask)); 105 v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask)); 106 } 107 108 float calculate_transparent_weight(float z, float alpha) 109 { 110 #if 0 111 /* Eq 10 : Good for surfaces with varying opacity (like particles) */ 112 float a = min(1.0, alpha * 10.0) + 0.01; 113 float b = -gl_FragCoord.z * 0.95 + 1.0; 114 float w = a * a * a * 3e2 * b * b * b; 115 #else 116 /* Eq 7 put more emphasis on surfaces closer to the view. */ 117 // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ 118 // float w = 10.0 / (1e-5 + pow(abs(z) / 10.0, 3.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 8 */ 119 // float w = 10.0 / (1e-5 + pow(abs(z) / 200.0, 4.0)); /* Eq 9 */ 120 /* Same as eq 7, but optimized. */ 121 float a = abs(z) / 5.0; 122 float b = abs(z) / 200.0; 123 b *= b; 124 float w = 10.0 / ((1e-5 + a * a) + b * (b * b)); /* Eq 7 */ 125 #endif 126 return alpha * clamp(w, 1e-2, 3e2); 127 } 128 129 /* Special function only to be used with calculate_transparent_weight(). */ 130 float linear_zdepth(float depth, vec4 viewvecs[3], mat4 proj_mat) 131 { 132 if (proj_mat[3][3] == 0.0) { 133 float d = 2.0 * depth - 1.0; 134 return -proj_mat[3][2] / (d + proj_mat[2][2]); 135 } 136 else { 137 /* Return depth from near plane. */ 138 return depth * viewvecs[1].z; 139 } 140 } 141 142 vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat) 143 { 144 return (proj_mat[3][3] == 0.0) 145 ? normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz) 146 : vec3(0.0, 0.0, 1.0); 147 } 148 149 vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped) 150 { 151 /* Quick creation of an orthonormal basis */ 152 float a = 1.0 / (1.0 + I.z); 153 float b = -I.x * I.y * a; 154 vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x); 155 vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y); 156 vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N)); 157 if (flipped) { 158 matcap_uv.x = -matcap_uv.x; 159 } 160 return matcap_uv * 0.496 + 0.5; 161 } 162 uniform int object_id = 0; 163 164 uniform vec3 materialDiffuseColor; 165 uniform float materialMetallic; 166 uniform float materialRoughness; 167 168 #ifdef V3D_SHADING_TEXTURE_COLOR 169 uniform sampler2D image; 170 uniform float ImageTransparencyCutoff = 0.1; 171 172 #endif 173 174 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 175 in vec3 normal_viewport; 176 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 177 178 #ifdef V3D_SHADING_TEXTURE_COLOR 179 in vec2 uv_interp; 180 #endif /* V3D_SHADING_TEXTURE_COLOR */ 181 182 #ifdef HAIR_SHADER 183 flat in float hair_rand; 184 #endif 185 186 layout(location=0) out uint objectId; 187 layout(location=1) out vec4 materialData; 188 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 189 # ifdef WORKBENCH_ENCODE_NORMALS 190 layout(location=3) out vec2 normalViewport; 191 # else /* WORKBENCH_ENCODE_NORMALS */ 192 layout(location=3) out vec3 normalViewport; 193 # endif /* WORKBENCH_ENCODE_NORMALS */ 194 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 195 196 void main() 197 { 198 objectId = uint(object_id); 199 200 vec4 color_roughness; 201 #ifdef V3D_SHADING_TEXTURE_COLOR 202 color_roughness = texture(image, uv_interp); 203 if (color_roughness.a < ImageTransparencyCutoff) { 204 discard; 205 } 206 color_roughness.a = materialRoughness; 207 #else 208 color_roughness = vec4(materialDiffuseColor, materialRoughness); 209 #endif /* V3D_SHADING_TEXTURE_COLOR */ 210 211 #ifdef HAIR_SHADER 212 float hair_color_variation = hair_rand * 0.1; 213 color_roughness = clamp(color_roughness - hair_color_variation, 0.0, 1.0); 214 #endif 215 216 float metallic; 217 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT 218 # ifdef HAIR_SHADER 219 metallic = clamp(materialMetallic - hair_color_variation, 0.0, 1.0); 220 # else 221 metallic = materialMetallic; 222 # endif 223 #elif defined(V3D_LIGHTING_MATCAP) 224 /* Encode front facing in metallic channel. */ 225 metallic = float(gl_FrontFacing); 226 color_roughness.a = 0.0; 227 #endif 228 229 materialData.rgb = color_roughness.rgb; 230 materialData.a = workbench_float_pair_encode(color_roughness.a, metallic); 231 232 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 233 vec3 n = (gl_FrontFacing) ? normal_viewport : -normal_viewport; 234 n = normalize(n); 235 normalViewport = workbench_normal_encode(n); 236 #endif 237 } 0(90) : error C7011: implicit cast from "uint" to "int" 0(91) : error C7011: implicit cast from "uint" to "int" 0(92) : error C7011: implicit cast from "uint" to "int" 0(100) : error C7011: implicit cast from "uint" to "int" 0(101) : error C7011: implicit cast from "uint" to "int" 0(102) : error C7011: implicit cast from "uint" to "int" GPUShader: compile error: ===== shader string 1 ==== 1 #version 330 ===== shader string 2 ==== 2 #extension GL_ARB_texture_query_lod: enable ===== shader string 3 ==== 3 #define GPU_NVIDIA ===== shader string 4 ==== 4 #define V3D_SHADING_OBJECT_OUTLINE 5 #define V3D_SHADING_SPECULAR_HIGHLIGHT 6 #define V3D_LIGHTING_STUDIO 7 #define NORMAL_VIEWPORT_PASS_ENABLED 8 #define V3D_SHADING_TEXTURE_COLOR 9 #define WORKBENCH_ENCODE_NORMALS ===== shader string 5 ==== 10 struct LightData { 11 vec4 direction; 12 vec4 specular_color; 13 vec4 diffuse_color_wrap; /* rgb: diffuse col a: wrapped lighting factor */ 14 }; 15 16 struct WorldData { 17 vec4 background_color_low; 18 vec4 background_color_high; 19 vec4 object_outline_color; 20 vec4 shadow_direction_vs; 21 LightData lights[4]; 22 vec4 ambient_color; 23 int num_lights; 24 int matcap_orientation; 25 float background_alpha; 26 float curvature_ridge; 27 float curvature_valley; 28 int pad[3]; 29 }; 30 #define NO_OBJECT_ID uint(0) 31 #define EPSILON 0.00001 32 #define M_PI 3.14159265358979323846 33 34 #define CAVITY_BUFFER_RANGE 4.0 35 36 /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ 37 #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) 38 const vec4 dither_mat4x4[4] = vec4[4]( 39 vec4( P(0.0), P(8.0), P(2.0), P(10.0)), 40 vec4(P(12.0), P(4.0), P(14.0), P(6.0)), 41 vec4( P(3.0), P(11.0), P(1.0), P(9.0)), 42 vec4(P(15.0), P(7.0), P(13.0), P(5.0)) 43 ); 44 45 float bayer_dither_noise() { 46 ivec2 tx1 = ivec2(gl_FragCoord.xy) % 4; 47 ivec2 tx2 = ivec2(gl_FragCoord.xy) % 2; 48 return dither_mat4x4[tx1.x][tx1.y]; 49 } 50 51 #ifdef WORKBENCH_ENCODE_NORMALS 52 53 /* From http://aras-p.info/texts/CompactNormalStorage.html 54 * Using Method #4: Spheremap Transform */ 55 vec3 workbench_normal_decode(vec2 enc) 56 { 57 vec2 fenc = enc.xy * 4.0 - 2.0; 58 float f = dot(fenc, fenc); 59 float g = sqrt(1.0 - f / 4.0); 60 vec3 n; 61 n.xy = fenc*g; 62 n.z = 1 - f / 2; 63 return n; 64 } 65 66 /* From http://aras-p.info/texts/CompactNormalStorage.html 67 * Using Method #4: Spheremap Transform */ 68 vec2 workbench_normal_encode(vec3 n) 69 { 70 float p = sqrt(n.z * 8.0 + 8.0); 71 n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0); 72 return n.xy; 73 } 74 75 #else 76 /* Well just do nothing... */ 77 # define workbench_normal_encode(a) (a) 78 # define workbench_normal_decode(a) (a) 79 #endif /* WORKBENCH_ENCODE_NORMALS */ 80 81 /* Encoding into the alpha of a RGBA8 UNORM texture. */ 82 #define TARGET_BITCOUNT 8 83 #define METALLIC_BITS 3 /* Metallic channel is less important. */ 84 #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) 85 #define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS) 86 87 /* Encode 2 float into 1 with the desired precision. */ 88 float workbench_float_pair_encode(float v1, float v2) 89 { 90 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 91 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 92 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 93 int iv1 = int(v1 * float(v1_mask)); 94 int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS; 95 return float(iv1 | iv2) * (1.0 / float(total_mask)); 96 } 97 98 void workbench_float_pair_decode(float data, out float v1, out float v2) 99 { 100 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 101 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 102 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 103 int idata = int(data * float(total_mask)); 104 v1 = float(idata & v1_mask) * (1.0 / float(v1_mask)); 105 v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask)); 106 } 107 108 float calculate_transparent_weight(float z, float alpha) 109 { 110 #if 0 111 /* Eq 10 : Good for surfaces with varying opacity (like particles) */ 112 float a = min(1.0, alpha * 10.0) + 0.01; 113 float b = -gl_FragCoord.z * 0.95 + 1.0; 114 float w = a * a * a * 3e2 * b * b * b; 115 #else 116 /* Eq 7 put more emphasis on surfaces closer to the view. */ 117 // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ 118 // float w = 10.0 / (1e-5 + pow(abs(z) / 10.0, 3.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 8 */ 119 // float w = 10.0 / (1e-5 + pow(abs(z) / 200.0, 4.0)); /* Eq 9 */ 120 /* Same as eq 7, but optimized. */ 121 float a = abs(z) / 5.0; 122 float b = abs(z) / 200.0; 123 b *= b; 124 float w = 10.0 / ((1e-5 + a * a) + b * (b * b)); /* Eq 7 */ 125 #endif 126 return alpha * clamp(w, 1e-2, 3e2); 127 } 128 129 /* Special function only to be used with calculate_transparent_weight(). */ 130 float linear_zdepth(float depth, vec4 viewvecs[3], mat4 proj_mat) 131 { 132 if (proj_mat[3][3] == 0.0) { 133 float d = 2.0 * depth - 1.0; 134 return -proj_mat[3][2] / (d + proj_mat[2][2]); 135 } 136 else { 137 /* Return depth from near plane. */ 138 return depth * viewvecs[1].z; 139 } 140 } 141 142 vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat) 143 { 144 return (proj_mat[3][3] == 0.0) 145 ? normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz) 146 : vec3(0.0, 0.0, 1.0); 147 } 148 149 vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped) 150 { 151 /* Quick creation of an orthonormal basis */ 152 float a = 1.0 / (1.0 + I.z); 153 float b = -I.x * I.y * a; 154 vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x); 155 vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y); 156 vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N)); 157 if (flipped) { 158 matcap_uv.x = -matcap_uv.x; 159 } 160 return matcap_uv * 0.496 + 0.5; 161 } 162 uniform int object_id = 0; 163 164 uniform vec3 materialDiffuseColor; 165 uniform float materialMetallic; 166 uniform float materialRoughness; 167 168 #ifdef V3D_SHADING_TEXTURE_COLOR 169 uniform sampler2D image; 170 uniform float ImageTransparencyCutoff = 0.1; 171 172 #endif 173 174 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 175 in vec3 normal_viewport; 176 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 177 178 #ifdef V3D_SHADING_TEXTURE_COLOR 179 in vec2 uv_interp; 180 #endif /* V3D_SHADING_TEXTURE_COLOR */ 181 182 #ifdef HAIR_SHADER 183 flat in float hair_rand; 184 #endif 185 186 layout(location=0) out uint objectId; 187 layout(location=1) out vec4 materialData; 188 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 189 # ifdef WORKBENCH_ENCODE_NORMALS 190 layout(location=3) out vec2 normalViewport; 191 # else /* WORKBENCH_ENCODE_NORMALS */ 192 layout(location=3) out vec3 normalViewport; 193 # endif /* WORKBENCH_ENCODE_NORMALS */ 194 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 195 196 void main() 197 { 198 objectId = uint(object_id); 199 200 vec4 color_roughness; 201 #ifdef V3D_SHADING_TEXTURE_COLOR 202 color_roughness = texture(image, uv_interp); 203 if (color_roughness.a < ImageTransparencyCutoff) { 204 discard; 205 } 206 color_roughness.a = materialRoughness; 207 #else 208 color_roughness = vec4(materialDiffuseColor, materialRoughness); 209 #endif /* V3D_SHADING_TEXTURE_COLOR */ 210 211 #ifdef HAIR_SHADER 212 float hair_color_variation = hair_rand * 0.1; 213 color_roughness = clamp(color_roughness - hair_color_variation, 0.0, 1.0); 214 #endif 215 216 float metallic; 217 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT 218 # ifdef HAIR_SHADER 219 metallic = clamp(materialMetallic - hair_color_variation, 0.0, 1.0); 220 # else 221 metallic = materialMetallic; 222 # endif 223 #elif defined(V3D_LIGHTING_MATCAP) 224 /* Encode front facing in metallic channel. */ 225 metallic = float(gl_FrontFacing); 226 color_roughness.a = 0.0; 227 #endif 228 229 materialData.rgb = color_roughness.rgb; 230 materialData.a = workbench_float_pair_encode(color_roughness.a, metallic); 231 232 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 233 vec3 n = (gl_FrontFacing) ? normal_viewport : -normal_viewport; 234 n = normalize(n); 235 normalViewport = workbench_normal_encode(n); 236 #endif 237 } 0(90) : error C7011: implicit cast from "uint" to "int" 0(91) : error C7011: implicit cast from "uint" to "int" 0(92) : error C7011: implicit cast from "uint" to "int" 0(100) : error C7011: implicit cast from "uint" to "int" 0(101) : error C7011: implicit cast from "uint" to "int" 0(102) : error C7011: implicit cast from "uint" to "int" GPUShader: compile error: ===== shader string 1 ==== 1 #version 330 ===== shader string 2 ==== 2 #extension GL_ARB_texture_query_lod: enable ===== shader string 3 ==== 3 #define GPU_NVIDIA ===== shader string 4 ==== 4 #define V3D_SHADING_OBJECT_OUTLINE 5 #define V3D_SHADING_SPECULAR_HIGHLIGHT 6 #define V3D_LIGHTING_STUDIO 7 #define NORMAL_VIEWPORT_PASS_ENABLED 8 #define V3D_SHADING_TEXTURE_COLOR 9 #define WORKBENCH_ENCODE_NORMALS 10 #define HAIR_SHADER ===== shader string 5 ==== 11 struct LightData { 12 vec4 direction; 13 vec4 specular_color; 14 vec4 diffuse_color_wrap; /* rgb: diffuse col a: wrapped lighting factor */ 15 }; 16 17 struct WorldData { 18 vec4 background_color_low; 19 vec4 background_color_high; 20 vec4 object_outline_color; 21 vec4 shadow_direction_vs; 22 LightData lights[4]; 23 vec4 ambient_color; 24 int num_lights; 25 int matcap_orientation; 26 float background_alpha; 27 float curvature_ridge; 28 float curvature_valley; 29 int pad[3]; 30 }; 31 #define NO_OBJECT_ID uint(0) 32 #define EPSILON 0.00001 33 #define M_PI 3.14159265358979323846 34 35 #define CAVITY_BUFFER_RANGE 4.0 36 37 /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ 38 #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) 39 const vec4 dither_mat4x4[4] = vec4[4]( 40 vec4( P(0.0), P(8.0), P(2.0), P(10.0)), 41 vec4(P(12.0), P(4.0), P(14.0), P(6.0)), 42 vec4( P(3.0), P(11.0), P(1.0), P(9.0)), 43 vec4(P(15.0), P(7.0), P(13.0), P(5.0)) 44 ); 45 46 float bayer_dither_noise() { 47 ivec2 tx1 = ivec2(gl_FragCoord.xy) % 4; 48 ivec2 tx2 = ivec2(gl_FragCoord.xy) % 2; 49 return dither_mat4x4[tx1.x][tx1.y]; 50 } 51 52 #ifdef WORKBENCH_ENCODE_NORMALS 53 54 /* From http://aras-p.info/texts/CompactNormalStorage.html 55 * Using Method #4: Spheremap Transform */ 56 vec3 workbench_normal_decode(vec2 enc) 57 { 58 vec2 fenc = enc.xy * 4.0 - 2.0; 59 float f = dot(fenc, fenc); 60 float g = sqrt(1.0 - f / 4.0); 61 vec3 n; 62 n.xy = fenc*g; 63 n.z = 1 - f / 2; 64 return n; 65 } 66 67 /* From http://aras-p.info/texts/CompactNormalStorage.html 68 * Using Method #4: Spheremap Transform */ 69 vec2 workbench_normal_encode(vec3 n) 70 { 71 float p = sqrt(n.z * 8.0 + 8.0); 72 n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0); 73 return n.xy; 74 } 75 76 #else 77 /* Well just do nothing... */ 78 # define workbench_normal_encode(a) (a) 79 # define workbench_normal_decode(a) (a) 80 #endif /* WORKBENCH_ENCODE_NORMALS */ 81 82 /* Encoding into the alpha of a RGBA8 UNORM texture. */ 83 #define TARGET_BITCOUNT 8 84 #define METALLIC_BITS 3 /* Metallic channel is less important. */ 85 #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) 86 #define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS) 87 88 /* Encode 2 float into 1 with the desired precision. */ 89 float workbench_float_pair_encode(float v1, float v2) 90 { 91 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 92 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 93 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 94 int iv1 = int(v1 * float(v1_mask)); 95 int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS; 96 return float(iv1 | iv2) * (1.0 / float(total_mask)); 97 } 98 99 void workbench_float_pair_decode(float data, out float v1, out float v2) 100 { 101 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 102 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 103 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 104 int idata = int(data * float(total_mask)); 105 v1 = float(idata & v1_mask) * (1.0 / float(v1_mask)); 106 v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask)); 107 } 108 109 float calculate_transparent_weight(float z, float alpha) 110 { 111 #if 0 112 /* Eq 10 : Good for surfaces with varying opacity (like particles) */ 113 float a = min(1.0, alpha * 10.0) + 0.01; 114 float b = -gl_FragCoord.z * 0.95 + 1.0; 115 float w = a * a * a * 3e2 * b * b * b; 116 #else 117 /* Eq 7 put more emphasis on surfaces closer to the view. */ 118 // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ 119 // float w = 10.0 / (1e-5 + pow(abs(z) / 10.0, 3.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 8 */ 120 // float w = 10.0 / (1e-5 + pow(abs(z) / 200.0, 4.0)); /* Eq 9 */ 121 /* Same as eq 7, but optimized. */ 122 float a = abs(z) / 5.0; 123 float b = abs(z) / 200.0; 124 b *= b; 125 float w = 10.0 / ((1e-5 + a * a) + b * (b * b)); /* Eq 7 */ 126 #endif 127 return alpha * clamp(w, 1e-2, 3e2); 128 } 129 130 /* Special function only to be used with calculate_transparent_weight(). */ 131 float linear_zdepth(float depth, vec4 viewvecs[3], mat4 proj_mat) 132 { 133 if (proj_mat[3][3] == 0.0) { 134 float d = 2.0 * depth - 1.0; 135 return -proj_mat[3][2] / (d + proj_mat[2][2]); 136 } 137 else { 138 /* Return depth from near plane. */ 139 return depth * viewvecs[1].z; 140 } 141 } 142 143 vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat) 144 { 145 return (proj_mat[3][3] == 0.0) 146 ? normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz) 147 : vec3(0.0, 0.0, 1.0); 148 } 149 150 vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped) 151 { 152 /* Quick creation of an orthonormal basis */ 153 float a = 1.0 / (1.0 + I.z); 154 float b = -I.x * I.y * a; 155 vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x); 156 vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y); 157 vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N)); 158 if (flipped) { 159 matcap_uv.x = -matcap_uv.x; 160 } 161 return matcap_uv * 0.496 + 0.5; 162 } 163 uniform int object_id = 0; 164 165 uniform vec3 materialDiffuseColor; 166 uniform float materialMetallic; 167 uniform float materialRoughness; 168 169 #ifdef V3D_SHADING_TEXTURE_COLOR 170 uniform sampler2D image; 171 uniform float ImageTransparencyCutoff = 0.1; 172 173 #endif 174 175 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 176 in vec3 normal_viewport; 177 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 178 179 #ifdef V3D_SHADING_TEXTURE_COLOR 180 in vec2 uv_interp; 181 #endif /* V3D_SHADING_TEXTURE_COLOR */ 182 183 #ifdef HAIR_SHADER 184 flat in float hair_rand; 185 #endif 186 187 layout(location=0) out uint objectId; 188 layout(location=1) out vec4 materialData; 189 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 190 # ifdef WORKBENCH_ENCODE_NORMALS 191 layout(location=3) out vec2 normalViewport; 192 # else /* WORKBENCH_ENCODE_NORMALS */ 193 layout(location=3) out vec3 normalViewport; 194 # endif /* WORKBENCH_ENCODE_NORMALS */ 195 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */ 196 197 void main() 198 { 199 objectId = uint(object_id); 200 201 vec4 color_roughness; 202 #ifdef V3D_SHADING_TEXTURE_COLOR 203 color_roughness = texture(image, uv_interp); 204 if (color_roughness.a < ImageTransparencyCutoff) { 205 discard; 206 } 207 color_roughness.a = materialRoughness; 208 #else 209 color_roughness = vec4(materialDiffuseColor, materialRoughness); 210 #endif /* V3D_SHADING_TEXTURE_COLOR */ 211 212 #ifdef HAIR_SHADER 213 float hair_color_variation = hair_rand * 0.1; 214 color_roughness = clamp(color_roughness - hair_color_variation, 0.0, 1.0); 215 #endif 216 217 float metallic; 218 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT 219 # ifdef HAIR_SHADER 220 metallic = clamp(materialMetallic - hair_color_variation, 0.0, 1.0); 221 # else 222 metallic = materialMetallic; 223 # endif 224 #elif defined(V3D_LIGHTING_MATCAP) 225 /* Encode front facing in metallic channel. */ 226 metallic = float(gl_FrontFacing); 227 color_roughness.a = 0.0; 228 #endif 229 230 materialData.rgb = color_roughness.rgb; 231 materialData.a = workbench_float_pair_encode(color_roughness.a, metallic); 232 233 #ifdef NORMAL_VIEWPORT_PASS_ENABLED 234 vec3 n = (gl_FrontFacing) ? normal_viewport : -normal_viewport; 235 n = normalize(n); 236 normalViewport = workbench_normal_encode(n); 237 #endif 238 } 0(91) : error C7011: implicit cast from "uint" to "int" 0(92) : error C7011: implicit cast from "uint" to "int" 0(93) : error C7011: implicit cast from "uint" to "int" 0(101) : error C7011: implicit cast from "uint" to "int" 0(102) : error C7011: implicit cast from "uint" to "int" 0(103) : error C7011: implicit cast from "uint" to "int" GPUShader: compile error: ===== shader string 1 ==== 1 #version 330 ===== shader string 2 ==== 2 #extension GL_ARB_texture_query_lod: enable ===== shader string 3 ==== 3 #define GPU_NVIDIA ===== shader string 4 ==== 4 #define V3D_SHADING_OBJECT_OUTLINE ===== shader string 5 ==== 5 struct LightData { 6 vec4 direction; 7 vec4 specular_color; 8 vec4 diffuse_color_wrap; /* rgb: diffuse col a: wrapped lighting factor */ 9 }; 10 11 struct WorldData { 12 vec4 background_color_low; 13 vec4 background_color_high; 14 vec4 object_outline_color; 15 vec4 shadow_direction_vs; 16 LightData lights[4]; 17 vec4 ambient_color; 18 int num_lights; 19 int matcap_orientation; 20 float background_alpha; 21 float curvature_ridge; 22 float curvature_valley; 23 int pad[3]; 24 }; 25 #define NO_OBJECT_ID uint(0) 26 #define EPSILON 0.00001 27 #define M_PI 3.14159265358979323846 28 29 #define CAVITY_BUFFER_RANGE 4.0 30 31 /* 4x4 bayer matrix prepared for 8bit UNORM precision error. */ 32 #define P(x) (((x + 0.5) * (1.0 / 16.0) - 0.5) * (1.0 / 255.0)) 33 const vec4 dither_mat4x4[4] = vec4[4]( 34 vec4( P(0.0), P(8.0), P(2.0), P(10.0)), 35 vec4(P(12.0), P(4.0), P(14.0), P(6.0)), 36 vec4( P(3.0), P(11.0), P(1.0), P(9.0)), 37 vec4(P(15.0), P(7.0), P(13.0), P(5.0)) 38 ); 39 40 float bayer_dither_noise() { 41 ivec2 tx1 = ivec2(gl_FragCoord.xy) % 4; 42 ivec2 tx2 = ivec2(gl_FragCoord.xy) % 2; 43 return dither_mat4x4[tx1.x][tx1.y]; 44 } 45 46 #ifdef WORKBENCH_ENCODE_NORMALS 47 48 /* From http://aras-p.info/texts/CompactNormalStorage.html 49 * Using Method #4: Spheremap Transform */ 50 vec3 workbench_normal_decode(vec2 enc) 51 { 52 vec2 fenc = enc.xy * 4.0 - 2.0; 53 float f = dot(fenc, fenc); 54 float g = sqrt(1.0 - f / 4.0); 55 vec3 n; 56 n.xy = fenc*g; 57 n.z = 1 - f / 2; 58 return n; 59 } 60 61 /* From http://aras-p.info/texts/CompactNormalStorage.html 62 * Using Method #4: Spheremap Transform */ 63 vec2 workbench_normal_encode(vec3 n) 64 { 65 float p = sqrt(n.z * 8.0 + 8.0); 66 n.xy = clamp(n.xy / p + 0.5, 0.0, 1.0); 67 return n.xy; 68 } 69 70 #else 71 /* Well just do nothing... */ 72 # define workbench_normal_encode(a) (a) 73 # define workbench_normal_decode(a) (a) 74 #endif /* WORKBENCH_ENCODE_NORMALS */ 75 76 /* Encoding into the alpha of a RGBA8 UNORM texture. */ 77 #define TARGET_BITCOUNT 8 78 #define METALLIC_BITS 3 /* Metallic channel is less important. */ 79 #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) 80 #define TOTAL_BITS (METALLIC_BITS + ROUGHNESS_BITS) 81 82 /* Encode 2 float into 1 with the desired precision. */ 83 float workbench_float_pair_encode(float v1, float v2) 84 { 85 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 86 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 87 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 88 int iv1 = int(v1 * float(v1_mask)); 89 int iv2 = int(v2 * float(v2_mask)) << ROUGHNESS_BITS; 90 return float(iv1 | iv2) * (1.0 / float(total_mask)); 91 } 92 93 void workbench_float_pair_decode(float data, out float v1, out float v2) 94 { 95 const int total_mask = ~(0xFFFFFFFF << TOTAL_BITS); 96 const int v1_mask = ~(0xFFFFFFFF << ROUGHNESS_BITS); 97 const int v2_mask = ~(0xFFFFFFFF << METALLIC_BITS); 98 int idata = int(data * float(total_mask)); 99 v1 = float(idata & v1_mask) * (1.0 / float(v1_mask)); 100 v2 = float(idata >> ROUGHNESS_BITS) * (1.0 / float(v2_mask)); 101 } 102 103 float calculate_transparent_weight(float z, float alpha) 104 { 105 #if 0 106 /* Eq 10 : Good for surfaces with varying opacity (like particles) */ 107 float a = min(1.0, alpha * 10.0) + 0.01; 108 float b = -gl_FragCoord.z * 0.95 + 1.0; 109 float w = a * a * a * 3e2 * b * b * b; 110 #else 111 /* Eq 7 put more emphasis on surfaces closer to the view. */ 112 // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ 113 // float w = 10.0 / (1e-5 + pow(abs(z) / 10.0, 3.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 8 */ 114 // float w = 10.0 / (1e-5 + pow(abs(z) / 200.0, 4.0)); /* Eq 9 */ 115 /* Same as eq 7, but optimized. */ 116 float a = abs(z) / 5.0; 117 float b = abs(z) / 200.0; 118 b *= b; 119 float w = 10.0 / ((1e-5 + a * a) + b * (b * b)); /* Eq 7 */ 120 #endif 121 return alpha * clamp(w, 1e-2, 3e2); 122 } 123 124 /* Special function only to be used with calculate_transparent_weight(). */ 125 float linear_zdepth(float depth, vec4 viewvecs[3], mat4 proj_mat) 126 { 127 if (proj_mat[3][3] == 0.0) { 128 float d = 2.0 * depth - 1.0; 129 return -proj_mat[3][2] / (d + proj_mat[2][2]); 130 } 131 else { 132 /* Return depth from near plane. */ 133 return depth * viewvecs[1].z; 134 } 135 } 136 137 vec3 view_vector_from_screen_uv(vec2 uv, vec4 viewvecs[3], mat4 proj_mat) 138 { 139 return (proj_mat[3][3] == 0.0) 140 ? normalize(viewvecs[0].xyz + vec3(uv, 0.0) * viewvecs[1].xyz) 141 : vec3(0.0, 0.0, 1.0); 142 } 143 144 vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped) 145 { 146 /* Quick creation of an orthonormal basis */ 147 float a = 1.0 / (1.0 + I.z); 148 float b = -I.x * I.y * a; 149 vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x); 150 vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y); 151 vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N)); 152 if (flipped) { 153 matcap_uv.x = -matcap_uv.x; 154 } 155 return matcap_uv * 0.496 + 0.5; 156 } 157 vec3 background_color(WorldData world_data, float y) { 158 return mix(world_data.background_color_low, world_data.background_color_high, y).xyz + bayer_dither_noise(); 159 } 160 #define OBJECT_OUTLINE_OFFSET 1 161 162 float calculate_object_outline(usampler2D objectId, ivec2 texel, uint object_id) 163 { 164 uvec4 oid_offset = uvec4( 165 texelFetchOffset(objectId, texel, 0, ivec2(0, OBJECT_OUTLINE_OFFSET)).r, 166 texelFetchOffset(objectId, texel, 0, ivec2(0, -OBJECT_OUTLINE_OFFSET)).r, 167 texelFetchOffset(objectId, texel, 0, ivec2(-OBJECT_OUTLINE_OFFSET, 0)).r, 168 texelFetchOffset(objectId, texel, 0, ivec2( OBJECT_OUTLINE_OFFSET, 0)).r); 169 170 return dot(vec4(equal(uvec4(object_id), oid_offset)), vec4(0.25)); 171 } 172 173 uniform usampler2D objectId; 174 175 uniform vec2 invertedViewportSize; 176 177 out vec4 fragColor; 178 179 layout(std140) uniform world_block { 180 WorldData world_data; 181 }; 182 183 void main() 184 { 185 vec2 uv_viewport = gl_FragCoord.xy * invertedViewportSize; 186 vec3 background = background_color(world_data, uv_viewport.y); 187 188 #ifndef V3D_SHADING_OBJECT_OUTLINE 189 190 fragColor = vec4(background, world_data.background_alpha); 191 192 #else /* !V3D_SHADING_OBJECT_OUTLINE */ 193 194 ivec2 texel = ivec2(gl_FragCoord.xy); 195 uint object_id = texelFetch(objectId, texel, 0).r; 196 float object_outline = calculate_object_outline(objectId, texel, object_id); 197 198 if (object_outline == 0.0) { 199 fragColor = vec4(background, world_data.background_alpha); 200 } 201 else { 202 /* Do correct alpha blending. */ 203 vec4 background_color = vec4(background, 1.0) * world_data.background_alpha; 204 vec4 outline_color = vec4(world_data.object_outline_color.rgb, 1.0); 205 fragColor = mix(outline_color, background_color, object_outline); 206 fragColor = vec4(fragColor.rgb / max(1e-8, fragColor.a), fragColor.a); 207 } 208 209 #endif /* !V3D_SHADING_OBJECT_OUTLINE */ 210 } 0(85) : error C7011: implicit cast from "uint" to "int" 0(86) : error C7011: implicit cast from "uint" to "int" 0(87) : error C7011: implicit cast from "uint" to "int" 0(95) : error C7011: implicit cast from "uint" to "int" 0(96) : error C7011: implicit cast from "uint" to "int" 0(97) : error C7011: implicit cast from "uint" to "int"