Advertisement
Guest User

Untitled

a guest
May 20th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.13 KB | None | 0 0
  1. Playing Thrive 0.5.8.1
  2. Thrive is running. Log output:
  3. Process Started
  4. Godot Engine v3.4.4.stable.mono..3089e490a - https://godotengine.org
  5. OpenGL ES 3.0 Renderer: ATI Mobility Radeon HD 4200 Series
  6. OpenGL ES Batching: ON
  7. Mono: Log file is: 'C:/Users/Profile1/AppData/Roaming/Thrive/mono/mono_logs/2022-05-20_18.34.26_6820.log'
  8. This is Thrive version: 0.5.8.1
  9. Startup C# locale is: ru-RU Godot locale is: ru_RU
  10. user:// directory is: C:/Users/Profile1/AppData/Roaming/Thrive
  11. Game logs are written to: C:/Users/Profile1/AppData/Roaming/Thrive\logs latest log is 'log.txt'
  12. Doing delayed apply for some settings
  13. Set audio output device to: Default
  14. Set C# locale to: en Godot locale is: en
  15. No SteamClient class found, not initializing Steam
  16. Loaded registry for Compound with 11 items
  17. Loaded registry for MembraneType with 6 items
  18. Loaded registry for Background with 11 items
  19. Loaded registry for Biome with 11 items
  20. Loaded registry for BioProcess with 13 items
  21. Loaded registry for OrganelleDefinition with 23 items
  22. Loaded registry for MusicCategory with 6 items
  23. Loaded registry for HelpTexts with 5 items
  24. Loaded registry for NamedInputGroup with 6 items
  25. Loaded registry for Gallery with 3 items
  26. SimulationParameters loading ended
  27. SimulationParameters are good
  28. Loading mod Nodes into the scene tree
  29. Jukebox now playing from: Menu
  30. Jukebox: starting track: res://assets/sounds/main-menu-theme-1.ogg position: 0
  31. TaskExecutor started with parallel job count: 2
  32. Previous patch doesn't exist, despawning all entities.
  33. Applying patch (Tazermichen Volcanic Vent) settings
  34. Number of clouds in this patch = 8
  35. Registering new spawner: Name: ammonia density: 4E-05
  36. Registering new spawner: Name: glucose density: 2E-05
  37. Registering new spawner: Name: phosphates density: 4E-05
  38. Registering new spawner: Name: hydrogensulfide density: 4E-05
  39. oxygen spawn density is 0. It won't spawn
  40. carbondioxide spawn density is 0. It won't spawn
  41. nitrogen spawn density is 0. It won't spawn
  42. sunlight spawn density is 0. It won't spawn
  43. Number of chunks in this patch = 4
  44. Registering new spawner: Name: FLOATING_HAZARD density: 0.0001
  45. Registering new spawner: Name: SMALL_IRON_CHUNK density: 3E-05
  46. MARINE_SNOW spawn density is 0. It won't spawn
  47. Registering new spawner: Name: BIG_IRON_CHUNK density: 8E-05
  48. Number of species in this patch = 1
  49. Registering new spawner: Name: 1 density: 1.438849E-05
  50. Player Microbe spawned
  51. Jukebox now playing from: MicrobeStage
  52. 1 | #version 330
  53. 2 | #define GLES_OVER_GL
  54. 3 | #define MAX_LIGHT_DATA_STRUCTS 409
  55. 4 |
  56. 5 | #define MAX_FORWARD_LIGHTS 32
  57. 6 |
  58. 7 | #define MAX_REFLECTION_DATA_STRUCTS 455
  59. 8 |
  60. 9 | #define MAX_SKELETON_BONES 1365
  61. 10 |
  62. 11 | #define ENABLE_OCTAHEDRAL_COMPRESSION
  63. 12 | #define USE_LIGHT_DIRECTIONAL
  64. 13 | #define USE_FORWARD_LIGHTING
  65. 14 | #define USE_RADIANCE_MAP
  66. 15 | #define USE_RADIANCE_MAP_ARRAY
  67. 16 | #define SHADOW_MODE_PCF_5
  68. 17 | #define USE_SHADOW
  69. 18 | #define USE_LIGHTMAP_FILTER_BICUBIC
  70. 19 | #define LIGHT_DIRECTIONAL_SHADOW
  71. 20 | #define LIGHT_USE_PSSM4
  72. 21 | #define USE_MATERIAL
  73. 22 | #define ENABLE_UV_INTERP
  74. 23 | precision highp float;
  75. 24 | precision highp int;
  76. 25 |
  77. 26 |
  78. 27 | /* texture unit usage, N is max_texture_unity-N
  79. 28 |
  80. 29 | 1-skeleton
  81. 30 | 2-radiance
  82. 31 | 3-reflection_atlas
  83. 32 | 4-directional_shadow
  84. 33 | 5-shadow_atlas
  85. 34 | 6-decal_atlas
  86. 35 | 7-screen
  87. 36 | 8-depth
  88. 37 | 9-probe1
  89. 38 | 10-probe2
  90. 39 |
  91. 40 | */
  92. 41 |
  93. 42 | uniform highp mat4 world_transform;
  94. 43 | /* clang-format on */
  95. 44 |
  96. 45 | #define M_PI 3.14159265359
  97. 46 | #define SHADER_IS_SRGB false
  98. 47 |
  99. 48 | /* Varyings */
  100. 49 |
  101. 50 | #if defined(ENABLE_COLOR_INTERP)
  102. Output is too long, it was truncated! See the log file for full output.
  103.  
  104. 873 |
  105. 874 | splane.xy /= splane.z;
  106. 875 | splane.xy = splane.xy * 0.5 + 0.5;
  107. 876 |
  108. 877 | splane.xy = splane.xy * clamp_rect.zw + clamp_rect.xy;
  109. 878 | splane.xy = clamp(splane.xy, clamp_rect.xy, clamp_rect.xy + clamp_rect.zw);
  110. 879 |
  111. 880 | highp vec4 ambient_out;
  112. 881 | ambient_out.a = blend;
  113. 882 | ambient_out.rgb = textureLod(reflection_atlas, splane.xy, 5.0).rgb;
  114. 883 | ambient_out.rgb = mix(reflections[idx].ambient.rgb, ambient_out.rgb, reflections[idx].ambient.a);
  115. 884 | if (reflections[idx].params.z < 0.5) {
  116. 885 | ambient_out.rgb = mix(ambient, ambient_out.rgb, blend);
  117. 886 | }
  118. 887 |
  119. 888 | ambient_out.rgb *= ambient_out.a;
  120. 889 | ambient_accum += ambient_out;
  121. 890 | } else {
  122. 891 | highp vec4 ambient_out;
  123. 892 | ambient_out.a = blend;
  124. 893 | ambient_out.rgb = reflections[idx].ambient.rgb;
  125. 894 | if (reflections[idx].params.z < 0.5) {
  126. 895 | ambient_out.rgb = mix(ambient, ambient_out.rgb, blend);
  127. 896 | }
  128. 897 | ambient_out.rgb *= ambient_out.a;
  129. 898 | ambient_accum += ambient_out;
  130. 899 | }
  131. 900 | #endif
  132. 901 | }
  133. 902 |
  134. 903 | #ifdef USE_LIGHTMAP
  135. 904 | #ifdef USE_LIGHTMAP_LAYERED
  136. 905 | uniform mediump sampler2DArray lightmap; //texunit:-9
  137. 906 | uniform int lightmap_layer;
  138. 907 | #else
  139. 908 | uniform mediump sampler2D lightmap; //texunit:-9
  140. 909 | #endif
  141. 910 |
  142. 911 | uniform mediump float lightmap_energy;
  143. 912 |
  144. 913 | #ifdef USE_LIGHTMAP_FILTER_BICUBIC
  145. 914 | uniform vec2 lightmap_texture_size;
  146. 915 |
  147. 916 | // w0, w1, w2, and w3 are the four cubic B-spline basis functions
  148. 917 | float w0(float a) {
  149. 918 | return (1.0 / 6.0) * (a * (a * (-a + 3.0) - 3.0) + 1.0);
  150. 919 | }
  151. 920 |
  152. 921 | float w1(float a) {
  153. 922 | return (1.0 / 6.0) * (a * a * (3.0 * a - 6.0) + 4.0);
  154. 923 | }
  155. 924 |
  156. 925 | float w2(float a) {
  157. 926 | return (1.0 / 6.0) * (a * (a * (-3.0 * a + 3.0) + 3.0) + 1.0);
  158. 927 | }
  159. 928 |
  160. 929 | float w3(float a) {
  161. 930 | return (1.0 / 6.0) * (a * a * a);
  162. 931 | }
  163. 932 |
  164. 933 | // g0 and g1 are the two amplitude functions
  165. 934 | float g0(float a) {
  166. 935 | return w0(a) + w1(a);
  167. 936 | }
  168. 937 |
  169. 938 | float g1(float a) {
  170. 939 | return w2(a) + w3(a);
  171. 940 | }
  172. 941 |
  173. 942 | // h0 and h1 are the two offset functions
  174. 943 | float h0(float a) {
  175. 944 | return -1.0 + w1(a) / (w0(a) + w1(a));
  176. 945 | }
  177. 946 |
  178. 947 | float h1(float a) {
  179. 948 | return 1.0 + w3(a) / (w2(a) + w3(a));
  180. 949 | }
  181. 950 |
  182. 951 | vec4 texture_bicubic(sampler2D tex, vec2 uv) {
  183. 952 | vec2 texel_size = vec2(1.0) / lightmap_texture_size;
  184. 953 |
  185. 954 | uv = uv * lightmap_texture_size + vec2(0.5);
  186. 955 |
  187. 956 | vec2 iuv = floor(uv);
  188. 957 | vec2 fuv = fract(uv);
  189. 958 |
  190. 959 | float g0x = g0(fuv.x);
  191. 960 | float g1x = g1(fuv.x);
  192. 961 | float h0x = h0(fuv.x);
  193. 962 | float h1x = h1(fuv.x);
  194. 963 | float h0y = h0(fuv.y);
  195. 964 | float h1y = h1(fuv.y);
  196. 965 |
  197. 966 | vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - vec2(0.5)) * texel_size;
  198. 967 | vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - vec2(0.5)) * texel_size;
  199. 968 | vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - vec2(0.5)) * texel_size;
  200. 969 | vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - vec2(0.5)) * texel_size;
  201. 970 |
  202. 971 | return (g0(fuv.y) * (g0x * texture(tex, p0) + g1x * texture(tex, p1))) +
  203. 972 | (g1(fuv.y) * (g0x * texture(tex, p2) + g1x * texture(tex, p3)));
  204. 973 | }
  205. 974 |
  206. 975 | vec4 textureArray_bicubic(sampler2DArray tex, vec3 uv) {
  207. 976 | vec2 texel_size = vec2(1.0) / lightmap_texture_size;
  208. 977 |
  209. 978 | uv.xy = uv.xy * lightmap_texture_size + vec2(0.5);
  210. 979 |
  211. 980 | vec2 iuv = floor(uv.xy);
  212. 981 | vec2 fuv = fract(uv.xy);
  213. 982 |
  214. 983 | float g0x = g0(fuv.x);
  215. 984 | float g1x = g1(fuv.x);
  216. 985 | float h0x = h0(fuv.x);
  217. 986 | float h1x = h1(fuv.x);
  218. 987 | float h0y = h0(fuv.y);
  219. 988 | float h1y = h1(fuv.y);
  220. 989 |
  221. 990 | vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - vec2(0.5)) * texel_size;
  222. 991 | vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - vec2(0.5)) * texel_size;
  223. 992 | vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - vec2(0.5)) * texel_size;
  224. 993 | vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - vec2(0.5)) * texel_size;
  225. 994 |
  226. 995 | return (g0(fuv.y) * (g0x * texture(tex, vec3(p0, uv.z)) + g1x * texture(tex, vec3(p1, uv.z)))) +
  227. 996 | (g1(fuv.y) * (g0x * texture(tex, vec3(p2, uv.z)) + g1x * texture(tex, vec3(p3, uv.z))));
  228. 997 | }
  229. 998 |
  230. 999 | #define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture_bicubic(m_tex, m_uv)
  231. 1000 | #define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) textureArray_bicubic(m_tex, m_uv)
  232. 1001 |
  233. 1002 | #else //!USE_LIGHTMAP_FILTER_BICUBIC
  234. 1003 | #define LIGHTMAP_TEXTURE_SAMPLE(m_tex, m_uv) texture(m_tex, m_uv)
  235. 1004 | #define LIGHTMAP_TEXTURE_LAYERED_SAMPLE(m_tex, m_uv) texture(m_tex, m_uv)
  236. 1005 |
  237. 1006 | #endif //USE_LIGHTMAP_FILTER_BICUBIC
  238. 1007 | #endif
  239. 1008 |
  240. 1009 | #ifdef USE_LIGHTMAP_CAPTURE
  241. 1010 | uniform mediump vec4[12] lightmap_captures;
  242. 1011 | #endif
  243. 1012 |
  244. 1013 | #ifdef USE_GI_PROBES
  245. 1014 |
  246. 1015 | uniform mediump sampler3D gi_probe1; //texunit:-9
  247. 1016 | uniform highp mat4 gi_probe_xform1;
  248. 1017 | uniform highp vec3 gi_probe_bounds1;
  249. 1018 | uniform highp vec3 gi_probe_cell_size1;
  250. 1019 | uniform highp float gi_probe_multiplier1;
  251. 1020 | uniform highp float gi_probe_bias1;
  252. 1021 | uniform highp float gi_probe_normal_bias1;
  253. 1022 | uniform bool gi_probe_blend_ambient1;
  254. 1023 |
  255. 1024 | uniform mediump sampler3D gi_probe2; //texunit:-10
  256. 1025 | uniform highp mat4 gi_probe_xform2;
  257. 1026 | uniform highp vec3 gi_probe_bounds2;
  258. 1027 | uniform highp vec3 gi_probe_cell_size2;
  259. 1028 | uniform highp float gi_probe_multiplier2;
  260. 1029 | uniform highp float gi_probe_bias2;
  261. 1030 | uniform highp float gi_probe_normal_bias2;
  262. 1031 | uniform bool gi_probe2_enabled;
  263. 1032 | uniform bool gi_probe_blend_ambient2;
  264. 1033 |
  265. 1034 | vec3 voxel_cone_trace(mediump sampler3D probe, vec3 cell_size, vec3 pos, vec3 ambient, bool blend_ambient, vec3 direction, float tan_half_angle, float max_distance, float p_bias) {
  266. 1035 | float dist = p_bias; //1.0; //dot(direction,mix(vec3(-1.0),vec3(1.0),greaterThan(direction,vec3(0.0))))*2.0;
  267. 1036 | float alpha = 0.0;
  268. 1037 | vec3 color = vec3(0.0);
  269. 1038 |
  270. 1039 | while (dist < max_distance && alpha < 0.95) {
  271. 1040 | float diameter = max(1.0, 2.0 * tan_half_angle * dist);
  272. 1041 | vec4 scolor = textureLod(probe, (pos + dist * direction) * cell_size, log2(diameter));
  273. 1042 | float a = (1.0 - alpha);
  274. 1043 | color += scolor.rgb * a;
  275. 1044 | alpha += a * scolor.a;
  276. 1045 | dist += diameter * 0.5;
  277. 1046 | }
  278. 1047 |
  279. 1048 | if (blend_ambient) {
  280. 1049 | color.rgb = mix(ambient, color.rgb, min(1.0, alpha / 0.95));
  281. 1050 | }
  282. 1051 |
  283. 1052 | return color;
  284. 1053 | }
  285. 1054 |
  286. 1055 | void gi_probe_compute(mediump sampler3D probe, mat4 probe_xform, vec3 bounds, vec3 cell_size, vec3 pos, vec3 ambient, vec3 environment, bool blend_ambient, float multiplier, mat3 normal_mtx, vec3 ref_vec, float roughness, float p_bias, float p_normal_bias, inout vec4 out_spec, inout vec4 out_diff) {
  287. 1056 | vec3 probe_pos = (probe_xform * vec4(pos, 1.0)).xyz;
  288. 1057 | vec3 ref_pos = (probe_xform * vec4(pos + ref_vec, 1.0)).xyz;
  289. 1058 | ref_vec = normalize(ref_pos - probe_pos);
  290. 1059 |
  291. 1060 | probe_pos += (probe_xform * vec4(normal_mtx[2], 0.0)).xyz * p_normal_bias;
  292. 1061 |
  293. 1062 | /* out_diff.rgb = voxel_cone_trace(probe,cell_size,probe_pos,normalize((probe_xform * vec4(ref_vec,0.0)).xyz),0.0 ,100.0);
  294. 1063 | out_diff.a = 1.0;
  295. 1064 | return;*/
  296. 1065 | //out_diff = vec4(textureLod(probe,probe_pos*cell_size,3.0).rgb,1.0);
  297. 1066 | //return;
  298. 1067 |
  299. 1068 | //this causes corrupted pixels, i have no idea why..
  300. 1069 | if (any(bvec2(any(lessThan(probe_pos, vec3(0.0))), any(greaterThan(probe_pos, bounds))))) {
  301. 1070 | return;
  302. 1071 | }
  303. 1072 |
  304. 1073 | vec3 blendv = abs(probe_pos / bounds * 2.0 - 1.0);
  305. 1074 | float blend = clamp(1.0 - max(blendv.x, max(blendv.y, blendv.z)), 0.0, 1.0);
  306. 1075 | //float blend=1.0;
  307. 1076 |
  308. 1077 | float max_distance = length(bounds);
  309. 1078 |
  310. 1079 | //radiance
  311. 1080 | #ifdef VCT_QUALITY_HIGH
  312. 1081 |
  313. 1082 | #define MAX_CONE_DIRS 6
  314. 1083 | vec3 cone_dirs[MAX_CONE_DIRS] = vec3[](
  315. 1084 | vec3(0.0, 0.0, 1.0),
  316. 1085 | vec3(0.866025, 0.0, 0.5),
  317. 1086 | vec3(0.267617, 0.823639, 0.5),
  318. 1087 | vec3(-0.700629, 0.509037, 0.5),
  319. 1088 | vec3(-0.700629, -0.509037, 0.5),
  320. 1089 | vec3(0.267617, -0.823639, 0.5));
  321. 1090 |
  322. 1091 | float cone_weights[MAX_CONE_DIRS] = float[](0.25, 0.15, 0.15, 0.15, 0.15, 0.15);
  323. 1092 | float cone_angle_tan = 0.577;
  324. 1093 | float min_ref_tan = 0.0;
  325. 1094 | #else
  326. 1095 |
  327. 1096 | #define MAX_CONE_DIRS 4
  328. 1097 |
  329. 1098 | vec3 cone_dirs[MAX_CONE_DIRS] = vec3[](
  330. 1099 | vec3(0.707107, 0.0, 0.707107),
  331. 1100 | vec3(0.0, 0.707107, 0.707107),
  332. 1101 | vec3(-0.707107, 0.0, 0.707107),
  333. 1102 | vec3(0.0, -0.707107, 0.707107));
  334. 1103 |
  335. 1104 | float cone_weights[MAX_CONE_DIRS] = float[](0.25, 0.25, 0.25, 0.25);
  336. 1105 | float cone_angle_tan = 0.98269;
  337. 1106 | max_distance *= 0.5;
  338. 1107 | float min_ref_tan = 0.2;
  339. 1108 |
  340. 1109 | #endif
  341. 1110 | vec3 light = vec3(0.0);
  342. 1111 | for (int i = 0; i < MAX_CONE_DIRS; i++) {
  343. 1112 | vec3 dir = normalize((probe_xform * vec4(pos + normal_mtx * cone_dirs[i], 1.0)).xyz - probe_pos);
  344. 1113 | light += cone_weights[i] * voxel_cone_trace(probe, cell_size, probe_pos, ambient, blend_ambient, dir, cone_angle_tan, max_distance, p_bias);
  345. 1114 | }
  346. 1115 |
  347. 1116 | light *= multiplier;
  348. 1117 |
  349. 1118 | out_diff += vec4(light * blend, blend);
  350. 1119 |
  351. 1120 | //irradiance
  352. 1121 |
  353. 1122 | vec3 irr_light = voxel_cone_trace(probe, cell_size, probe_pos, environment, blend_ambient, ref_vec, max(min_ref_tan, tan(roughness * 0.5 * M_PI * 0.99)), max_distance, p_bias);
  354. 1123 |
  355. 1124 | irr_light *= multiplier;
  356. 1125 | //irr_light=vec3(0.0);
  357. 1126 |
  358. 1127 | out_spec += vec4(irr_light * blend, blend);
  359. 1128 | }
  360. 1129 |
  361. 1130 | void gi_probes_compute(vec3 pos, vec3 normal, float roughness, inout vec3 out_specular, inout vec3 out_ambient) {
  362. 1131 | roughness = roughness * roughness;
  363. 1132 |
  364. 1133 | vec3 ref_vec = normalize(reflect(normalize(pos), normal));
  365. 1134 |
  366. 1135 | //find arbitrary tangent and bitangent, then build a matrix
  367. 1136 | vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);
  368. 1137 | vec3 tangent = normalize(cross(v0, normal));
  369. 1138 | vec3 bitangent = normalize(cross(tangent, normal));
  370. 1139 | mat3 normal_mat = mat3(tangent, bitangent, normal);
  371. 1140 |
  372. 1141 | vec4 diff_accum = vec4(0.0);
  373. 1142 | vec4 spec_accum = vec4(0.0);
  374. 1143 |
  375. 1144 | vec3 ambient = out_ambient;
  376. 1145 | out_ambient = vec3(0.0);
  377. 1146 |
  378. 1147 | vec3 environment = out_specular;
  379. 1148 |
  380. 1149 | out_specular = vec3(0.0);
  381. 1150 |
  382. 1151 | gi_probe_compute(gi_probe1, gi_probe_xform1, gi_probe_bounds1, gi_probe_cell_size1, pos, ambient, environment, gi_probe_blend_ambient1, gi_probe_multiplier1, normal_mat, ref_vec, roughness, gi_probe_bias1, gi_probe_normal_bias1, spec_accum, diff_accum);
  383. 1152 |
  384. 1153 | if (gi_probe2_enabled) {
  385. 1154 | gi_probe_compute(gi_probe2, gi_probe_xform2, gi_probe_bounds2, gi_probe_cell_size2, pos, ambient, environment, gi_probe_blend_ambient2, gi_probe_multiplier2, normal_mat, ref_vec, roughness, gi_probe_bias2, gi_probe_normal_bias2, spec_accum, diff_accum);
  386. 1155 | }
  387. 1156 |
  388. 1157 | if (diff_accum.a > 0.0) {
  389. 1158 | diff_accum.rgb /= diff_accum.a;
  390. 1159 | }
  391. 1160 |
  392. 1161 | if (spec_accum.a > 0.0) {
  393. 1162 | spec_accum.rgb /= spec_accum.a;
  394. 1163 | }
  395. 1164 |
  396. 1165 | out_specular += spec_accum.rgb;
  397. 1166 | out_ambient += diff_accum.rgb;
  398. 1167 | }
  399. 1168 |
  400. 1169 | #endif
  401. 1170 |
  402. 1171 | void main() {
  403. 1172 | #ifdef RENDER_DEPTH_DUAL_PARABOLOID
  404. 1173 |
  405. 1174 | if (dp_clip > 0.0)
  406. 1175 | discard;
  407. 1176 | #endif
  408. 1177 |
  409. 1178 | //lay out everything, whathever is unused is optimized away anyway
  410. 1179 | highp vec3 vertex = vertex_interp;
  411. 1180 | vec3 view = -normalize(vertex_interp);
  412. 1181 | vec3 albedo = vec3(1.0);
  413. 1182 | vec3 transmission = vec3(0.0);
  414. 1183 | float metallic = 0.0;
  415. 1184 | float specular = 0.5;
  416. 1185 | vec3 emission = vec3(0.0);
  417. 1186 | float roughness = 1.0;
  418. 1187 | float rim = 0.0;
  419. 1188 | float rim_tint = 0.0;
  420. 1189 | float clearcoat = 0.0;
  421. 1190 | float clearcoat_gloss = 0.0;
  422. 1191 | float anisotropy = 0.0;
  423. 1192 | vec2 anisotropy_flow = vec2(1.0, 0.0);
  424. 1193 |
  425. 1194 | #if defined(ENABLE_AO)
  426. 1195 | float ao = 1.0;
  427. 1196 | float ao_light_affect = 0.0;
  428. 1197 | #endif
  429. 1198 |
  430. 1199 | float alpha = 1.0;
  431. 1200 |
  432. 1201 | #if defined(ALPHA_SCISSOR_USED)
  433. 1202 | float alpha_scissor = 0.5;
  434. 1203 | #endif
  435. 1204 |
  436. 1205 | #if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
  437. 1206 | vec3 binormal = normalize(binormal_interp);
  438. 1207 | vec3 tangent = normalize(tangent_interp);
  439. 1208 | #else
  440. 1209 | vec3 binormal = vec3(0.0);
  441. 1210 | vec3 tangent = vec3(0.0);
  442. 1211 | #endif
  443. 1212 | vec3 normal = normalize(normal_interp);
  444. 1213 |
  445. 1214 | #if defined(DO_SIDE_CHECK)
  446. 1215 | if (!gl_FrontFacing) {
  447. 1216 | normal = -normal;
  448. 1217 | }
  449. 1218 | #endif
  450. 1219 |
  451. 1220 | #if defined(ENABLE_UV_INTERP)
  452. 1221 | vec2 uv = uv_interp;
  453. 1222 | #endif
  454. 1223 |
  455. 1224 | #if defined(ENABLE_UV2_INTERP) || defined(USE_LIGHTMAP)
  456. 1225 | vec2 uv2 = uv2_interp;
  457. 1226 | #endif
  458. 1227 |
  459. 1228 | #if defined(ENABLE_COLOR_INTERP)
  460. 1229 | vec4 color = color_interp;
  461. 1230 | #endif
  462. 1231 |
  463. 1232 | #if defined(ENABLE_NORMALMAP)
  464. 1233 |
  465. 1234 | vec3 normalmap = vec3(0.5);
  466. 1235 | #endif
  467. 1236 |
  468. 1237 | float normaldepth = 1.0;
  469. 1238 |
  470. 1239 | #if defined(SCREEN_UV_USED)
  471. 1240 | vec2 screen_uv = gl_FragCoord.xy * screen_pixel_size;
  472. 1241 | #endif
  473. 1242 |
  474. 1243 | #if defined(ENABLE_SSS)
  475. 1244 | float sss_strength = 0.0;
  476. 1245 | #endif
  477. 1246 |
  478. 1247 | {
  479. 1248 | /* clang-format off */
  480. 1249 | {
  481. 1250 | vec4 m_albedo=texture(m_albedoTexture, uv_interp);
  482. 1251 | vec4 m_normalmap=texture(m_normalTexture, uv_interp);
  483. 1252 | vec3 m_normals=vec3(((m_normalmap.r*2.0)-1.0), ((m_normalmap.g*2.0)-1.0), ((m_normalmap.b*2.0)-1.0));
  484. 1253 | float m_y=m_normals.y;
  485. 1254 | m_normals.y=-m_normals.z;
  486. 1255 | m_normals.z=m_y;
  487. 1256 | vec4 m_damaged=texture(m_damagedTexture, uv_interp);
  488. 1257 | vec4 m_final=(((m_albedo*m_healthFraction)+(m_damaged*(1.0-m_healthFraction)))*m_tint);
  489. 1258 | vec4 m_dissolveTex=texture(m_dissolveTexture, uv_interp);
  490. 1259 | float m_cutoff=(dot(m_dissolveTex.rgb, vec3(0.3,0.3,0.3))-float((-0.8+clamp(m_dissolveValue, 0.0, 1.0))));
  491. 1260 | albedo=m_final.rgb;
  492. 1261 | normal=(camera_matrix*(world_transform*vec4(m_normals, 0.0))).xyz;
  493. 1262 | alpha=(round(m_cutoff)*m_final.a);
  494. 1263 | }
  495. 1264 |
  496. 1265 |
  497. 1266 | /* clang-format on */
  498. 1267 | }
  499. 1268 |
  500. 1269 | #if !defined(USE_SHADOW_TO_OPACITY)
  501. 1270 |
  502. 1271 | #if defined(ALPHA_SCISSOR_USED)
  503. 1272 | if (alpha < alpha_scissor) {
  504. 1273 | discard;
  505. 1274 | }
  506. 1275 | #endif // ALPHA_SCISSOR_USED
  507. 1276 |
  508. 1277 | #ifdef USE_OPAQUE_PREPASS
  509. 1278 |
  510. 1279 | if (alpha < opaque_prepass_threshold) {
  511. 1280 | discard;
  512. 1281 | }
  513. 1282 |
  514. 1283 | #endif // USE_OPAQUE_PREPASS
  515. 1284 |
  516. 1285 | #endif // !USE_SHADOW_TO_OPACITY
  517. 1286 |
  518. 1287 | #if defined(ENABLE_NORMALMAP)
  519. 1288 |
  520. 1289 | normalmap.xy = normalmap.xy * 2.0 - 1.0;
  521. 1290 | normalmap.z = sqrt(max(0.0, 1.0 - dot(normalmap.xy, normalmap.xy))); //always ignore Z, as it can be RG packed, Z may be pos/neg, etc.
  522. 1291 |
  523. 1292 | normal = normalize(mix(normal, tangent * normalmap.x + binormal * normalmap.y + normal * normalmap.z, normaldepth));
  524. 1293 |
  525. 1294 | #endif
  526. 1295 |
  527. 1296 | #if defined(LIGHT_USE_ANISOTROPY)
  528. 1297 |
  529. 1298 | if (anisotropy > 0.01) {
  530. 1299 | //rotation matrix
  531. 1300 | mat3 rot = mat3(tangent, binormal, normal);
  532. 1301 | //make local to space
  533. 1302 | tangent = normalize(rot * vec3(anisotropy_flow.x, anisotropy_flow.y, 0.0));
  534. 1303 | binormal = normalize(rot * vec3(-anisotropy_flow.y, anisotropy_flow.x, 0.0));
  535. 1304 | }
  536. 1305 |
  537. 1306 | #endif
  538. 1307 |
  539. 1308 | #ifdef ENABLE_CLIP_ALPHA
  540. 1309 | if (albedo.a < 0.99) {
  541. 1310 | //used for doublepass and shadowmapping
  542. 1311 | discard;
  543. 1312 | }
  544. 1313 | #endif
  545. 1314 |
  546. 1315 | /////////////////////// LIGHTING //////////////////////////////
  547. 1316 |
  548. 1317 | //apply energy conservation
  549. 1318 |
  550. 1319 | #ifdef USE_VERTEX_LIGHTING
  551. 1320 |
  552. 1321 | vec3 specular_light = specular_light_interp.rgb;
  553. 1322 | vec3 diffuse_light = diffuse_light_interp.rgb;
  554. 1323 | #else
  555. 1324 |
  556. 1325 | vec3 specular_light = vec3(0.0, 0.0, 0.0);
  557. 1326 | vec3 diffuse_light = vec3(0.0, 0.0, 0.0);
  558. 1327 |
  559. 1328 | #endif
  560. 1329 |
  561. 1330 | vec3 ambient_light;
  562. 1331 | vec3 env_reflection_light = vec3(0.0, 0.0, 0.0);
  563. 1332 |
  564. 1333 | vec3 eye_vec = view;
  565. 1334 |
  566. 1335 | // IBL precalculations
  567. 1336 | float ndotv = clamp(dot(normal, eye_vec), 0.0, 1.0);
  568. 1337 | vec3 f0 = F0(metallic, specular, albedo);
  569. 1338 | vec3 F = f0 + (max(vec3(1.0 - roughness), f0) - f0) * pow(1.0 - ndotv, 5.0);
  570. 1339 |
  571. 1340 | #ifdef USE_RADIANCE_MAP
  572. 1341 |
  573. 1342 | #ifdef AMBIENT_LIGHT_DISABLED
  574. 1343 | ambient_light = vec3(0.0, 0.0, 0.0);
  575. 1344 | #else
  576. 1345 | {
  577. 1346 | { //read radiance from dual paraboloid
  578. 1347 |
  579. 1348 | vec3 ref_vec = reflect(-eye_vec, normal);
  580. 1349 | float horizon = min(1.0 + dot(ref_vec, normal), 1.0);
  581. 1350 | ref_vec = normalize((radiance_inverse_xform * vec4(ref_vec, 0.0)).xyz);
  582. 1351 | vec3 radiance = textureDualParaboloid(radiance_map, ref_vec, roughness) * bg_energy;
  583. 1352 | env_reflection_light = radiance;
  584. 1353 | env_reflection_light *= horizon * horizon;
  585. 1354 | }
  586. 1355 | }
  587. 1356 | #ifndef USE_LIGHTMAP
  588. 1357 | {
  589. 1358 | vec3 norm = normal;
  590. 1359 | norm = normalize((radiance_inverse_xform * vec4(norm, 0.0)).xyz);
  591. 1360 | norm.xy /= 1.0 + abs(norm.z);
  592. 1361 | norm.xy = norm.xy * vec2(0.5, 0.25) + vec2(0.5, 0.25);
  593. 1362 | if (norm.z > 0.0001) {
  594. 1363 | norm.y = 0.5 - norm.y + 0.5;
  595. 1364 | }
  596. 1365 |
  597. 1366 | vec3 env_ambient = texture(irradiance_map, norm.xy).rgb * bg_energy;
  598. 1367 | env_ambient *= 1.0 - F;
  599. 1368 |
  600. 1369 | ambient_light = mix(ambient_light_color.rgb, env_ambient, radiance_ambient_contribution);
  601. 1370 | }
  602. 1371 | #endif
  603. 1372 | #endif //AMBIENT_LIGHT_DISABLED
  604. 1373 |
  605. 1374 | #else
  606. 1375 |
  607. 1376 | #ifdef AMBIENT_LIGHT_DISABLED
  608. 1377 | ambient_light = vec3(0.0, 0.0, 0.0);
  609. 1378 | #else
  610. 1379 | ambient_light = ambient_light_color.rgb;
  611. 1380 | env_reflection_light = bg_color.rgb * bg_energy;
  612. 1381 | #endif //AMBIENT_LIGHT_DISABLED
  613. 1382 |
  614. 1383 | #endif
  615. 1384 |
  616. 1385 | ambient_light *= ambient_energy;
  617. 1386 |
  618. 1387 | float specular_blob_intensity = 1.0;
  619. 1388 |
  620. 1389 | #if defined(SPECULAR_TOON)
  621. 1390 | specular_blob_intensity *= specular * 2.0;
  622. 1391 | #endif
  623. 1392 |
  624. 1393 | #ifdef USE_GI_PROBES
  625. 1394 | gi_probes_compute(vertex, normal, roughness, env_reflection_light, ambient_light);
  626. 1395 |
  627. 1396 | #endif
  628. 1397 |
  629. 1398 | #ifdef USE_LIGHTMAP
  630. 1399 | #ifdef USE_LIGHTMAP_LAYERED
  631. 1400 | ambient_light = LIGHTMAP_TEXTURE_LAYERED_SAMPLE(lightmap, vec3(uv2, float(lightmap_layer))).rgb * lightmap_energy;
  632. 1401 | #else
  633. 1402 | ambient_light = LIGHTMAP_TEXTURE_SAMPLE(lightmap, uv2).rgb * lightmap_energy;
  634. 1403 | #endif
  635. 1404 | #endif
  636. 1405 |
  637. 1406 | #ifdef USE_LIGHTMAP_CAPTURE
  638. 1407 | {
  639. 1408 | vec3 cone_dirs[12] = vec3[](
  640. 1409 | vec3(0.0, 0.0, 1.0),
  641. 1410 | vec3(0.866025, 0.0, 0.5),
  642. 1411 | vec3(0.267617, 0.823639, 0.5),
  643. 1412 | vec3(-0.700629, 0.509037, 0.5),
  644. 1413 | vec3(-0.700629, -0.509037, 0.5),
  645. 1414 | vec3(0.267617, -0.823639, 0.5),
  646. 1415 | vec3(0.0, 0.0, -1.0),
  647. 1416 | vec3(0.866025, 0.0, -0.5),
  648. 1417 | vec3(0.267617, 0.823639, -0.5),
  649. 1418 | vec3(-0.700629, 0.509037, -0.5),
  650. 1419 | vec3(-0.700629, -0.509037, -0.5),
  651. 1420 | vec3(0.267617, -0.823639, -0.5));
  652. 1421 |
  653. 1422 | vec3 local_normal = normalize(camera_matrix * vec4(normal, 0.0)).xyz;
  654. 1423 | vec4 captured = vec4(0.0);
  655. 1424 | float sum = 0.0;
  656. 1425 | for (int i = 0; i < 12; i++) {
  657. 1426 | float amount = max(0.0, dot(local_normal, cone_dirs[i])); //not correct, but creates a nice wrap around effect
  658. 1427 | captured += lightmap_captures[i] * amount;
  659. 1428 | sum += amount;
  660. 1429 | }
  661. 1430 |
  662. 1431 | captured /= sum;
  663. 1432 |
  664. 1433 | // Alpha channel is used to indicate if dynamic objects keep the environment lighting
  665. 1434 | if (lightmap_captures[0].a > 0.5) {
  666. 1435 | ambient_light += captured.rgb;
  667. 1436 | } else {
  668. 1437 | ambient_light = captured.rgb;
  669. 1438 | }
  670. 1439 | }
  671. 1440 | #endif
  672. 1441 |
  673. 1442 | #ifdef USE_FORWARD_LIGHTING
  674. 1443 |
  675. 1444 | highp vec4 reflection_accum = vec4(0.0, 0.0, 0.0, 0.0);
  676. 1445 | highp vec4 ambient_accum = vec4(0.0, 0.0, 0.0, 0.0);
  677. 1446 | for (int i = 0; i < reflection_count; i++) {
  678. 1447 | reflection_process(reflection_indices[i], vertex, normal, binormal, tangent, roughness, anisotropy, ambient_light, env_reflection_light, reflection_accum, ambient_accum);
  679. 1448 | }
  680. 1449 |
  681. 1450 | if (reflection_accum.a > 0.0) {
  682. 1451 | specular_light += reflection_accum.rgb / reflection_accum.a;
  683. 1452 | } else {
  684. 1453 | specular_light += env_reflection_light;
  685. 1454 | }
  686. 1455 | #if !defined(USE_LIGHTMAP) && !defined(USE_LIGHTMAP_CAPTURE)
  687. 1456 | if (ambient_accum.a > 0.0) {
  688. 1457 | ambient_light = ambient_accum.rgb / ambient_accum.a;
  689. 1458 | }
  690. 1459 | #endif
  691. 1460 | #endif
  692. 1461 |
  693. 1462 | {
  694. 1463 | #if defined(DIFFUSE_TOON)
  695. 1464 | //simplify for toon, as
  696. 1465 | specular_light *= specular * metallic * albedo * 2.0;
  697. 1466 | #else
  698. 1467 |
  699. 1468 | // scales the specular reflections, needs to be be computed before lighting happens,
  700. 1469 | // but after environment, GI, and reflection probes are added
  701. 1470 | // Environment brdf approximation (Lazarov 2013)
  702. 1471 | // see https://www.unrealengine.com/en-US/blog/physically-based-shading-on-mobile
  703. 1472 | const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);
  704. 1473 | const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);
  705. 1474 | vec4 r = roughness * c0 + c1;
  706. 1475 | float a004 = min(r.x * r.x, exp2(-9.28 * ndotv)) * r.x + r.y;
  707. 1476 | vec2 env = vec2(-1.04, 1.04) * a004 + r.zw;
  708. 1477 | specular_light *= env.x * F + env.y;
  709. 1478 | #endif
  710. 1479 | }
  711. 1480 |
  712. 1481 | #if defined(USE_LIGHT_DIRECTIONAL)
  713. 1482 |
  714. 1483 | vec3 light_attenuation = vec3(1.0);
  715. 1484 |
  716. 1485 | float depth_z = -vertex.z;
  717. 1486 | #ifdef LIGHT_DIRECTIONAL_SHADOW
  718. 1487 | #if !defined(SHADOWS_DISABLED)
  719. 1488 |
  720. 1489 | #ifdef LIGHT_USE_PSSM4
  721. 1490 | if (depth_z < shadow_split_offsets.w) {
  722. 1491 | #elif defined(LIGHT_USE_PSSM2)
  723. 1492 | if (depth_z < shadow_split_offsets.y) {
  724. 1493 | #else
  725. 1494 | if (depth_z < shadow_split_offsets.x) {
  726. 1495 | #endif //LIGHT_USE_PSSM4
  727. 1496 |
  728. 1497 | vec3 pssm_coord;
  729. 1498 | float pssm_fade = 0.0;
  730. 1499 |
  731. 1500 | #ifdef LIGHT_USE_PSSM_BLEND
  732. 1501 | float pssm_blend;
  733. 1502 | vec3 pssm_coord2;
  734. 1503 | bool use_blend = true;
  735. 1504 | #endif
  736. 1505 |
  737. 1506 | #ifdef LIGHT_USE_PSSM4
  738. 1507 |
  739. 1508 | if (depth_z < shadow_split_offsets.y) {
  740. 1509 | if (depth_z < shadow_split_offsets.x) {
  741. 1510 | highp vec4 splane = (shadow_matrix1 * vec4(vertex, 1.0));
  742. 1511 | pssm_coord = splane.xyz / splane.w;
  743. 1512 |
  744. 1513 | #if defined(LIGHT_USE_PSSM_BLEND)
  745. 1514 |
  746. 1515 | splane = (shadow_matrix2 * vec4(vertex, 1.0));
  747. 1516 | pssm_coord2 = splane.xyz / splane.w;
  748. 1517 | pssm_blend = smoothstep(0.0, shadow_split_offsets.x, depth_z);
  749. 1518 | #endif
  750. 1519 |
  751. 1520 | } else {
  752. 1521 | highp vec4 splane = (shadow_matrix2 * vec4(vertex, 1.0));
  753. 1522 | pssm_coord = splane.xyz / splane.w;
  754. 1523 |
  755. 1524 | #if defined(LIGHT_USE_PSSM_BLEND)
  756. 1525 | splane = (shadow_matrix3 * vec4(vertex, 1.0));
  757. 1526 | pssm_coord2 = splane.xyz / splane.w;
  758. 1527 | pssm_blend = smoothstep(shadow_split_offsets.x, shadow_split_offsets.y, depth_z);
  759. 1528 | #endif
  760. 1529 | }
  761. 1530 | } else {
  762. 1531 | if (depth_z < shadow_split_offsets.z) {
  763. 1532 | highp vec4 splane = (shadow_matrix3 * vec4(vertex, 1.0));
  764. 1533 | pssm_coord = splane.xyz / splane.w;
  765. 1534 |
  766. 1535 | #if defined(LIGHT_USE_PSSM_BLEND)
  767. 1536 | splane = (shadow_matrix4 * vec4(vertex, 1.0));
  768. 1537 | pssm_coord2 = splane.xyz / splane.w;
  769. 1538 | pssm_blend = smoothstep(shadow_split_offsets.y, shadow_split_offsets.z, depth_z);
  770. 1539 | #endif
  771. 1540 |
  772. 1541 | } else {
  773. 1542 | highp vec4 splane = (shadow_matrix4 * vec4(vertex, 1.0));
  774. 1543 | pssm_coord = splane.xyz / splane.w;
  775. 1544 | pssm_fade = smoothstep(shadow_split_offsets.z, shadow_split_offsets.w, depth_z);
  776. 1545 |
  777. 1546 | #if defined(LIGHT_USE_PSSM_BLEND)
  778. 1547 | use_blend = false;
  779. 1548 |
  780. 1549 | #endif
  781. 1550 | }
  782. 1551 | }
  783. 1552 |
  784. 1553 | #endif //LIGHT_USE_PSSM4
  785. 1554 |
  786. 1555 | #ifdef LIGHT_USE_PSSM2
  787. 1556 |
  788. 1557 | if (depth_z < shadow_split_offsets.x) {
  789. 1558 | highp vec4 splane = (shadow_matrix1 * vec4(vertex, 1.0));
  790. 1559 | pssm_coord = splane.xyz / splane.w;
  791. 1560 |
  792. 1561 | #if defined(LIGHT_USE_PSSM_BLEND)
  793. 1562 |
  794. 1563 | splane = (shadow_matrix2 * vec4(vertex, 1.0));
  795. 1564 | pssm_coord2 = splane.xyz / splane.w;
  796. 1565 | pssm_blend = smoothstep(0.0, shadow_split_offsets.x, depth_z);
  797. 1566 | #endif
  798. 1567 |
  799. 1568 | } else {
  800. 1569 | highp vec4 splane = (shadow_matrix2 * vec4(vertex, 1.0));
  801. 1570 | pssm_coord = splane.xyz / splane.w;
  802. 1571 | pssm_fade = smoothstep(shadow_split_offsets.x, shadow_split_offsets.y, depth_z);
  803. 1572 | #if defined(LIGHT_USE_PSSM_BLEND)
  804. 1573 | use_blend = false;
  805. 1574 |
  806. 1575 | #endif
  807. 1576 | }
  808. 1577 |
  809. 1578 | #endif //LIGHT_USE_PSSM2
  810. 1579 |
  811. 1580 | #if !defined(LIGHT_USE_PSSM4) && !defined(LIGHT_USE_PSSM2)
  812. 1581 | { //regular orthogonal
  813. 1582 | highp vec4 splane = (shadow_matrix1 * vec4(vertex, 1.0));
  814. 1583 | pssm_coord = splane.xyz / splane.w;
  815. 1584 | }
  816. 1585 | #endif
  817. 1586 |
  818. 1587 | //one one sample
  819. 1588 |
  820. 1589 | float shadow = sample_shadow(directional_shadow, directional_shadow_pixel_size, pssm_coord.xy, pssm_coord.z, light_clamp);
  821. 1590 |
  822. 1591 | #if defined(LIGHT_USE_PSSM_BLEND)
  823. 1592 |
  824. 1593 | if (use_blend) {
  825. 1594 | shadow = mix(shadow, sample_shadow(directional_shadow, directional_shadow_pixel_size, pssm_coord2.xy, pssm_coord2.z, light_clamp), pssm_blend);
  826. 1595 | }
  827. 1596 | #endif
  828. 1597 |
  829. 1598 | #ifdef USE_CONTACT_SHADOWS
  830. 1599 | if (shadow > 0.01 && shadow_color_contact.a > 0.0) {
  831. 1600 | float contact_shadow = contact_shadow_compute(vertex, -light_direction_attenuation.xyz, shadow_color_contact.a);
  832. 1601 | shadow = min(shadow, contact_shadow);
  833. 1602 | }
  834. 1603 | #endif
  835. 1604 | light_attenuation = mix(mix(shadow_color_contact.rgb, vec3(1.0), shadow), vec3(1.0), pssm_fade);
  836. 1605 | }
  837. 1606 |
  838. 1607 | #endif // !defined(SHADOWS_DISABLED)
  839. 1608 | #endif //LIGHT_DIRECTIONAL_SHADOW
  840. 1609 |
  841. 1610 | #ifdef USE_VERTEX_LIGHTING
  842. 1611 | diffuse_light *= mix(vec3(1.0), light_attenuation, diffuse_light_interp.a);
  843. 1612 | specular_light *= mix(vec3(1.0), light_attenuation, specular_light_interp.a);
  844. 1613 |
  845. 1614 | #else
  846. 1615 | light_compute(normal, -light_direction_attenuation.xyz, eye_vec, binormal, tangent, light_color_energy.rgb, light_attenuation, albedo, transmission, light_params.z * specular_blob_intensity, roughness, metallic, specular, rim, rim_tint, clearcoat, clearcoat_gloss, anisotropy, diffuse_light, specular_light, alpha);
  847. 1616 | #endif
  848. 1617 |
  849. 1618 | #endif //#USE_LIGHT_DIRECTIONAL
  850. 1619 |
  851. 1620 | #ifdef USE_VERTEX_LIGHTING
  852. 1621 | diffuse_light *= albedo;
  853. 1622 | #endif
  854. 1623 |
  855. 1624 | #ifdef USE_FORWARD_LIGHTING
  856. 1625 |
  857. 1626 | #ifndef USE_VERTEX_LIGHTING
  858. 1627 |
  859. 1628 | for (int i = 0; i < omni_light_count; i++) {
  860. 1629 | light_process_omni(omni_light_indices[i], vertex, eye_vec, normal, binormal, tangent, albedo, transmission, roughness, metallic, specular, rim, rim_tint, clearcoat, clearcoat_gloss, anisotropy, specular_blob_intensity, diffuse_light, specular_light, alpha);
  861. 1630 | }
  862. 1631 |
  863. 1632 | for (int i = 0; i < spot_light_count; i++) {
  864. 1633 | light_process_spot(spot_light_indices[i], vertex, eye_vec, normal, binormal, tangent, albedo, transmission, roughness, metallic, specular, rim, rim_tint, clearcoat, clearcoat_gloss, anisotropy, specular_blob_intensity, diffuse_light, specular_light, alpha);
  865. 1634 | }
  866. 1635 |
  867. 1636 | #endif //USE_VERTEX_LIGHTING
  868. 1637 |
  869. 1638 | #endif
  870. 1639 |
  871. 1640 | #ifdef USE_SHADOW_TO_OPACITY
  872. 1641 | alpha = min(alpha, clamp(length(ambient_light), 0.0, 1.0));
  873. 1642 |
  874. 1643 | #if defined(ALPHA_SCISSOR_USED)
  875. 1644 | if (alpha < alpha_scissor) {
  876. 1645 | discard;
  877. 1646 | }
  878. 1647 | #endif // ALPHA_SCISSOR_USED
  879. 1648 |
  880. 1649 | #ifdef USE_OPAQUE_PREPASS
  881. 1650 |
  882. 1651 | if (alpha < opaque_prepass_threshold) {
  883. 1652 | discard;
  884. 1653 | }
  885. 1654 |
  886. 1655 | #endif // USE_OPAQUE_PREPASS
  887. 1656 |
  888. 1657 | #endif // USE_SHADOW_TO_OPACITY
  889. 1658 |
  890. 1659 | #ifdef RENDER_DEPTH
  891. 1660 | //nothing happens, so a tree-ssa optimizer will result in no fragment shader :)
  892. 1661 | #else
  893. 1662 |
  894. 1663 | specular_light *= reflection_multiplier;
  895. 1664 | ambient_light *= albedo; //ambient must be multiplied by albedo at the end
  896. 1665 |
  897. 1666 | #if defined(ENABLE_AO)
  898. 1667 | ambient_light *= ao;
  899. 1668 | ao_light_affect = mix(1.0, ao, ao_light_affect);
  900. 1669 | specular_light *= ao_light_affect;
  901. 1670 | diffuse_light *= ao_light_affect;
  902. 1
  903. 671 | #endif
  904. 1672 |
  905. 1673 | // base color remapping
  906. 1674 | diffuse_light *= 1.0 - metallic; // TODO: avoid all diffuse and ambient light calculations when metallic == 1 up to this point
  907. 1675 | ambient_light *= 1.0 - metallic;
  908. 1676 |
  909. 1677 | if (fog_color_enabled.a > 0.5) {
  910. 1678 | float fog_amount = 0.0;
  911. 1679 |
  912. 1680 | #ifdef USE_LIGHT_DIRECTIONAL
  913. 1681 |
  914. 1682 | vec3 fog_color = mix(fog_color_enabled.rgb, fog_sun_color_amount.rgb, fog_sun_color_amount.a * pow(max(dot(normalize(vertex), -light_direction_attenuation.xyz), 0.0), 8.0));
  915. 1683 | #else
  916. 1684 |
  917. 1685 | vec3 fog_color = fog_color_enabled.rgb;
  918. 1686 | #endif
  919. 1687 |
  920. 1688 | //apply fog
  921. 1689 |
  922. 1690 | if (fog_depth_enabled) {
  923. 1691 | float fog_far = fog_depth_end > 0.0 ? fog_depth_end : z_far;
  924. 1692 |
  925. 1693 | float fog_z = smoothstep(fog_depth_begin, fog_far, length(vertex));
  926. 1694 |
  927. 1695 | fog_amount = pow(fog_z, fog_depth_curve) * fog_density;
  928. 1696 | if (fog_transmit_enabled) {
  929. 1697 | vec3 total_light = emission + ambient_light + specular_light + diffuse_light;
  930. 1698 | float transmit = pow(fog_z, fog_transmit_curve);
  931. 1699 | fog_color = mix(max(total_light, fog_color), fog_color, transmit);
  932. 1700 | }
  933. 1701 | }
  934. 1702 |
  935. 1703 | if (fog_height_enabled) {
  936. 1704 | float y = (camera_matrix * vec4(vertex, 1.0)).y;
  937. 1705 | fog_amount = max(fog_amount, pow(smoothstep(fog_height_min, fog_height_max, y), fog_height_curve));
  938. 1706 | }
  939. 1707 |
  940. 1708 | float rev_amount = 1.0 - fog_amount;
  941. 1709 |
  942. 1710 | emission = emission * rev_amount + fog_color * fog_amount;
  943. 1711 | ambient_light *= rev_amount;
  944. 1712 | specular_light *= rev_amount;
  945. 1713 | diffuse_light *= rev_amount;
  946. 1714 | }
  947. 1715 |
  948. 1716 | #ifdef USE_MULTIPLE_RENDER_TARGETS
  949. 1717 |
  950. 1718 | #ifdef SHADELESS
  951. 1719 | diffuse_buffer = vec4(albedo.rgb, 0.0);
  952. 1720 | specular_buffer = vec4(0.0);
  953. 1721 |
  954. 1722 | #else
  955. 1723 |
  956. 1724 | //approximate ambient scale for SSAO, since we will lack full ambient
  957. 1725 | float max_emission = max(emission.r, max(emission.g, emission.b));
  958. 1726 | float max_ambient = max(ambient_light.r, max(ambient_light.g, ambient_light.b));
  959. 1727 | float max_diffuse = max(diffuse_light.r, max(diffuse_light.g, diffuse_light.b));
  960. 1728 | float total_ambient = max_ambient + max_diffuse;
  961. 1729 | #ifdef USE_FORWARD_LIGHTING
  962. 1730 | total_ambient += max_emission;
  963. 1731 | #endif
  964. 1732 | float ambient_scale = (total_ambient > 0.0) ? (max_ambient + ambient_occlusion_affect_light * max_diffuse) / total_ambient : 0.0;
  965. 1733 |
  966. 1734 | #if defined(ENABLE_AO)
  967. 1735 | ambient_scale = mix(0.0, ambient_scale, ambient_occlusion_affect_ao_channel);
  968. 1736 | #endif
  969. 1737 | diffuse_buffer = vec4(diffuse_light + ambient_light, ambient_scale);
  970. 1738 | specular_buffer = vec4(specular_light, metallic);
  971. 1739 |
  972. 1740 | #ifdef USE_FORWARD_LIGHTING
  973. 1741 | diffuse_buffer.rgb += emission;
  974. 1742 | #endif
  975. 1743 | #endif //SHADELESS
  976. 1744 |
  977. 1745 | normal_mr_buffer = vec4(normalize(normal) * 0.5 + 0.5, roughness);
  978. 1746 |
  979. 1747 | #if defined(ENABLE_SSS)
  980. 1748 | sss_buffer = sss_strength;
  981. 1749 | #endif
  982. 1750 |
  983. 1751 | #else //USE_MULTIPLE_RENDER_TARGETS
  984. 1752 |
  985. 1753 | #ifdef SHADELESS
  986. 1754 | frag_color = vec4(albedo, alpha);
  987. 1755 | #else
  988. 1756 | frag_color = vec4(ambient_light + diffuse_light + specular_light, alpha);
  989. 1757 | #ifdef USE_FORWARD_LIGHTING
  990. 1758 | frag_color.rgb += emission;
  991. 1759 | #endif
  992. 1760 | #endif //SHADELESS
  993. 1761 |
  994. 1762 | #endif //USE_MULTIPLE_RENDER_TARGETS
  995. 1763 |
  996. 1764 | #endif //RENDER_DEPTH
  997. 1765 | }
  998. 1766 |
  999. Jukebox: starting track: res://assets/sounds/microbe-theme-6.ogg position: 0
  1000. Jukebox: starting track: res://assets/sounds/soundeffects/microbe-ambience2.ogg position: 0
  1001. 3.cpp:156) ERROR: SceneShaderGLES3: Program LINK FAILED: Fragment shader(s) failed to link, Vertex shader(s) linked. Fragment Shader not supported by HWWARNING: warning(#276) Symbol 'position_interp' usage doesn't match between two stages at: get_current_version (drivers/gles3/shader_gles3.cpp:478) ERROR: Method failed. Returning: nullptr at: get_current_version (drivers/gles3/shader_gles3.cpp:485) ERROR: Condition "!version" is true. Returned: false at: bind (drivers/gles3/shader_gles3.cpp:118) ERROR: Condition "!version" is true. Returned: -1 at: _get_uniform (drivers/gles3/shader_gles3.h:362) ERROR: Condition "!version" is true. Returned: -1 at: _get_uniform (drivers/gles3/shader_gles3.h:362) ERROR: Condition "!version" is true. Returned: -1 at: _get_uniform (drivers/gles3/shader_gles3.h:362) ERROR: Condition "!version" is true. Returned: -1 at: _get_uniform (drivers/gles3/shader_gles3.h:362)
  1002. child process exited with code 0
  1003. Thrive has exited normally (exit code 0).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement