canvas.glsl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /* clang-format off */
  2. [vertex]
  3. layout(location = 0) in highp vec2 vertex;
  4. /* clang-format on */
  5. layout(location = 3) in vec4 color_attrib;
  6. #ifdef USE_SKELETON
  7. layout(location = 6) in uvec4 bone_indices; // attrib:6
  8. layout(location = 7) in vec4 bone_weights; // attrib:7
  9. #endif
  10. #ifdef USE_TEXTURE_RECT
  11. uniform vec4 dst_rect;
  12. uniform vec4 src_rect;
  13. #else
  14. #ifdef USE_INSTANCING
  15. layout(location = 8) in highp vec4 instance_xform0;
  16. layout(location = 9) in highp vec4 instance_xform1;
  17. layout(location = 10) in highp vec4 instance_xform2;
  18. layout(location = 11) in lowp vec4 instance_color;
  19. #ifdef USE_INSTANCE_CUSTOM
  20. layout(location = 12) in highp vec4 instance_custom_data;
  21. #endif
  22. #endif
  23. layout(location = 4) in highp vec2 uv_attrib;
  24. // skeleton
  25. #endif
  26. uniform highp vec2 color_texpixel_size;
  27. layout(std140) uniform CanvasItemData { //ubo:0
  28. highp mat4 projection_matrix;
  29. highp float time;
  30. };
  31. uniform highp mat4 modelview_matrix;
  32. uniform highp mat4 extra_matrix;
  33. out highp vec2 uv_interp;
  34. out mediump vec4 color_interp;
  35. #ifdef USE_NINEPATCH
  36. out highp vec2 pixel_size_interp;
  37. #endif
  38. #ifdef USE_SKELETON
  39. uniform mediump sampler2D skeleton_texture; // texunit:-1
  40. uniform highp mat4 skeleton_transform;
  41. uniform highp mat4 skeleton_transform_inverse;
  42. #endif
  43. #ifdef USE_LIGHTING
  44. layout(std140) uniform LightData { //ubo:1
  45. // light matrices
  46. highp mat4 light_matrix;
  47. highp mat4 light_local_matrix;
  48. highp mat4 shadow_matrix;
  49. highp vec4 light_color;
  50. highp vec4 light_shadow_color;
  51. highp vec2 light_pos;
  52. highp float shadowpixel_size;
  53. highp float shadow_gradient;
  54. highp float light_height;
  55. highp float light_outside_alpha;
  56. highp float shadow_distance_mult;
  57. };
  58. out vec4 light_uv_interp;
  59. out vec2 transformed_light_uv;
  60. out vec4 local_rot;
  61. #ifdef USE_SHADOWS
  62. out highp vec2 pos;
  63. #endif
  64. const bool at_light_pass = true;
  65. #else
  66. const bool at_light_pass = false;
  67. #endif
  68. #if defined(USE_MATERIAL)
  69. /* clang-format off */
  70. layout(std140) uniform UniformData { //ubo:2
  71. MATERIAL_UNIFORMS
  72. };
  73. /* clang-format on */
  74. #endif
  75. /* clang-format off */
  76. VERTEX_SHADER_GLOBALS
  77. /* clang-format on */
  78. void main() {
  79. vec4 color = color_attrib;
  80. #ifdef USE_INSTANCING
  81. mat4 extra_matrix_instance = extra_matrix * transpose(mat4(instance_xform0, instance_xform1, instance_xform2, vec4(0.0, 0.0, 0.0, 1.0)));
  82. color *= instance_color;
  83. vec4 instance_custom = instance_custom_data;
  84. #else
  85. mat4 extra_matrix_instance = extra_matrix;
  86. vec4 instance_custom = vec4(0.0);
  87. #endif
  88. #ifdef USE_TEXTURE_RECT
  89. if (dst_rect.z < 0.0) { // Transpose is encoded as negative dst_rect.z
  90. uv_interp = src_rect.xy + abs(src_rect.zw) * vertex.yx;
  91. } else {
  92. uv_interp = src_rect.xy + abs(src_rect.zw) * vertex;
  93. }
  94. highp vec4 outvec = vec4(dst_rect.xy + abs(dst_rect.zw) * mix(vertex, vec2(1.0, 1.0) - vertex, lessThan(src_rect.zw, vec2(0.0, 0.0))), 0.0, 1.0);
  95. #else
  96. uv_interp = uv_attrib;
  97. highp vec4 outvec = vec4(vertex, 0.0, 1.0);
  98. #endif
  99. #ifdef USE_PARTICLES
  100. //scale by texture size
  101. outvec.xy /= color_texpixel_size;
  102. #endif
  103. #define extra_matrix extra_matrix_instance
  104. //for compatibility with the fragment shader we need to use uv here
  105. vec2 uv = uv_interp;
  106. {
  107. /* clang-format off */
  108. VERTEX_SHADER_CODE
  109. /* clang-format on */
  110. }
  111. uv_interp = uv;
  112. #ifdef USE_NINEPATCH
  113. pixel_size_interp = abs(dst_rect.zw) * vertex;
  114. #endif
  115. #if !defined(SKIP_TRANSFORM_USED)
  116. outvec = extra_matrix * outvec;
  117. outvec = modelview_matrix * outvec;
  118. #endif
  119. #undef extra_matrix
  120. color_interp = color;
  121. #ifdef USE_PIXEL_SNAP
  122. outvec.xy = floor(outvec + 0.5).xy;
  123. // precision issue on some hardware creates artifacts within texture
  124. // offset uv by a small amount to avoid
  125. uv_interp += 1e-5;
  126. #endif
  127. #ifdef USE_SKELETON
  128. if (bone_weights != vec4(0.0)) { //must be a valid bone
  129. //skeleton transform
  130. ivec4 bone_indicesi = ivec4(bone_indices);
  131. ivec2 tex_ofs = ivec2(bone_indicesi.x % 256, (bone_indicesi.x / 256) * 2);
  132. highp mat2x4 m;
  133. m = mat2x4(
  134. texelFetch(skeleton_texture, tex_ofs, 0),
  135. texelFetch(skeleton_texture, tex_ofs + ivec2(0, 1), 0)) *
  136. bone_weights.x;
  137. tex_ofs = ivec2(bone_indicesi.y % 256, (bone_indicesi.y / 256) * 2);
  138. m += mat2x4(
  139. texelFetch(skeleton_texture, tex_ofs, 0),
  140. texelFetch(skeleton_texture, tex_ofs + ivec2(0, 1), 0)) *
  141. bone_weights.y;
  142. tex_ofs = ivec2(bone_indicesi.z % 256, (bone_indicesi.z / 256) * 2);
  143. m += mat2x4(
  144. texelFetch(skeleton_texture, tex_ofs, 0),
  145. texelFetch(skeleton_texture, tex_ofs + ivec2(0, 1), 0)) *
  146. bone_weights.z;
  147. tex_ofs = ivec2(bone_indicesi.w % 256, (bone_indicesi.w / 256) * 2);
  148. m += mat2x4(
  149. texelFetch(skeleton_texture, tex_ofs, 0),
  150. texelFetch(skeleton_texture, tex_ofs + ivec2(0, 1), 0)) *
  151. bone_weights.w;
  152. mat4 bone_matrix = skeleton_transform * transpose(mat4(m[0], m[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0))) * skeleton_transform_inverse;
  153. outvec = bone_matrix * outvec;
  154. }
  155. #endif
  156. gl_Position = projection_matrix * outvec;
  157. #ifdef USE_LIGHTING
  158. light_uv_interp.xy = (light_matrix * outvec).xy;
  159. light_uv_interp.zw = (light_local_matrix * outvec).xy;
  160. mat3 inverse_light_matrix = mat3(inverse(light_matrix));
  161. inverse_light_matrix[0] = normalize(inverse_light_matrix[0]);
  162. inverse_light_matrix[1] = normalize(inverse_light_matrix[1]);
  163. inverse_light_matrix[2] = normalize(inverse_light_matrix[2]);
  164. transformed_light_uv = (inverse_light_matrix * vec3(light_uv_interp.zw, 0.0)).xy; //for normal mapping
  165. #ifdef USE_SHADOWS
  166. pos = outvec.xy;
  167. #endif
  168. local_rot.xy = normalize((modelview_matrix * (extra_matrix_instance * vec4(1.0, 0.0, 0.0, 0.0))).xy);
  169. local_rot.zw = normalize((modelview_matrix * (extra_matrix_instance * vec4(0.0, 1.0, 0.0, 0.0))).xy);
  170. #ifdef USE_TEXTURE_RECT
  171. local_rot.xy *= sign(src_rect.z);
  172. local_rot.zw *= sign(src_rect.w);
  173. #endif
  174. #endif
  175. }
  176. /* clang-format off */
  177. [fragment]
  178. uniform mediump sampler2D color_texture; // texunit:0
  179. /* clang-format on */
  180. uniform highp vec2 color_texpixel_size;
  181. uniform mediump sampler2D normal_texture; // texunit:1
  182. in highp vec2 uv_interp;
  183. in mediump vec4 color_interp;
  184. #if defined(SCREEN_TEXTURE_USED)
  185. uniform sampler2D screen_texture; // texunit:-3
  186. #endif
  187. #if defined(SCREEN_UV_USED)
  188. uniform vec2 screen_pixel_size;
  189. #endif
  190. layout(std140) uniform CanvasItemData {
  191. highp mat4 projection_matrix;
  192. highp float time;
  193. };
  194. #ifdef USE_LIGHTING
  195. layout(std140) uniform LightData {
  196. highp mat4 light_matrix;
  197. highp mat4 light_local_matrix;
  198. highp mat4 shadow_matrix;
  199. highp vec4 light_color;
  200. highp vec4 light_shadow_color;
  201. highp vec2 light_pos;
  202. highp float shadowpixel_size;
  203. highp float shadow_gradient;
  204. highp float light_height;
  205. highp float light_outside_alpha;
  206. highp float shadow_distance_mult;
  207. };
  208. uniform lowp sampler2D light_texture; // texunit:-1
  209. in vec4 light_uv_interp;
  210. in vec2 transformed_light_uv;
  211. in vec4 local_rot;
  212. #ifdef USE_SHADOWS
  213. uniform highp sampler2D shadow_texture; // texunit:-2
  214. in highp vec2 pos;
  215. #endif
  216. const bool at_light_pass = true;
  217. #else
  218. const bool at_light_pass = false;
  219. #endif
  220. uniform mediump vec4 final_modulate;
  221. layout(location = 0) out mediump vec4 frag_color;
  222. #if defined(USE_MATERIAL)
  223. /* clang-format off */
  224. layout(std140) uniform UniformData {
  225. MATERIAL_UNIFORMS
  226. };
  227. /* clang-format on */
  228. #endif
  229. /* clang-format off */
  230. FRAGMENT_SHADER_GLOBALS
  231. /* clang-format on */
  232. void light_compute(
  233. inout vec4 light,
  234. inout vec2 light_vec,
  235. inout float light_height,
  236. inout vec4 light_color,
  237. vec2 light_uv,
  238. inout vec4 shadow_color,
  239. vec3 normal,
  240. vec2 uv,
  241. #if defined(SCREEN_UV_USED)
  242. vec2 screen_uv,
  243. #endif
  244. vec4 color) {
  245. #if defined(USE_LIGHT_SHADER_CODE)
  246. /* clang-format off */
  247. LIGHT_SHADER_CODE
  248. /* clang-format on */
  249. #endif
  250. }
  251. #ifdef USE_TEXTURE_RECT
  252. uniform vec4 dst_rect;
  253. uniform vec4 src_rect;
  254. uniform bool clip_rect_uv;
  255. #ifdef USE_NINEPATCH
  256. in highp vec2 pixel_size_interp;
  257. uniform int np_repeat_v;
  258. uniform int np_repeat_h;
  259. uniform bool np_draw_center;
  260. // left top right bottom in pixel coordinates
  261. uniform vec4 np_margins;
  262. float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, float margin_begin, float margin_end, int np_repeat, inout int draw_center) {
  263. float tex_size = 1.0 / tex_pixel_size;
  264. if (pixel < margin_begin) {
  265. return pixel * tex_pixel_size;
  266. } else if (pixel >= draw_size - margin_end) {
  267. return (tex_size - (draw_size - pixel)) * tex_pixel_size;
  268. } else {
  269. if (!np_draw_center) {
  270. draw_center--;
  271. }
  272. if (np_repeat == 0) { //stretch
  273. //convert to ratio
  274. float ratio = (pixel - margin_begin) / (draw_size - margin_begin - margin_end);
  275. //scale to source texture
  276. return (margin_begin + ratio * (tex_size - margin_begin - margin_end)) * tex_pixel_size;
  277. } else if (np_repeat == 1) { //tile
  278. //convert to ratio
  279. float ofs = mod((pixel - margin_begin), tex_size - margin_begin - margin_end);
  280. //scale to source texture
  281. return (margin_begin + ofs) * tex_pixel_size;
  282. } else if (np_repeat == 2) { //tile fit
  283. //convert to ratio
  284. float src_area = draw_size - margin_begin - margin_end;
  285. float dst_area = tex_size - margin_begin - margin_end;
  286. float scale = max(1.0, floor(src_area / max(dst_area, 0.0000001) + 0.5));
  287. //convert to ratio
  288. float ratio = (pixel - margin_begin) / src_area;
  289. ratio = mod(ratio * scale, 1.0);
  290. return (margin_begin + ratio * dst_area) * tex_pixel_size;
  291. }
  292. }
  293. }
  294. #endif
  295. #endif
  296. uniform bool use_default_normal;
  297. void main() {
  298. vec4 color = color_interp;
  299. vec2 uv = uv_interp;
  300. #ifdef USE_TEXTURE_RECT
  301. #ifdef USE_NINEPATCH
  302. int draw_center = 2;
  303. uv = vec2(
  304. map_ninepatch_axis(pixel_size_interp.x, abs(dst_rect.z), color_texpixel_size.x, np_margins.x, np_margins.z, np_repeat_h, draw_center),
  305. map_ninepatch_axis(pixel_size_interp.y, abs(dst_rect.w), color_texpixel_size.y, np_margins.y, np_margins.w, np_repeat_v, draw_center));
  306. if (draw_center == 0) {
  307. color.a = 0.0;
  308. }
  309. uv = uv * src_rect.zw + src_rect.xy; //apply region if needed
  310. #endif
  311. if (clip_rect_uv) {
  312. uv = clamp(uv, src_rect.xy, src_rect.xy + abs(src_rect.zw));
  313. }
  314. #endif
  315. #if !defined(COLOR_USED)
  316. //default behavior, texture by color
  317. #ifdef USE_DISTANCE_FIELD
  318. const float smoothing = 1.0 / 32.0;
  319. float distance = textureLod(color_texture, uv, 0.0).a;
  320. color.a = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance) * color.a;
  321. #else
  322. color *= texture(color_texture, uv);
  323. #endif
  324. #endif
  325. vec3 normal;
  326. #if defined(NORMAL_USED)
  327. bool normal_used = true;
  328. #else
  329. bool normal_used = false;
  330. #endif
  331. if (use_default_normal) {
  332. normal.xy = textureLod(normal_texture, uv, 0.0).xy * 2.0 - 1.0;
  333. normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
  334. normal_used = true;
  335. } else {
  336. normal = vec3(0.0, 0.0, 1.0);
  337. }
  338. #if defined(SCREEN_UV_USED)
  339. vec2 screen_uv = gl_FragCoord.xy * screen_pixel_size;
  340. #endif
  341. {
  342. float normal_depth = 1.0;
  343. #if defined(NORMALMAP_USED)
  344. vec3 normal_map = vec3(0.0, 0.0, 1.0);
  345. normal_used = true;
  346. #endif
  347. /* clang-format off */
  348. FRAGMENT_SHADER_CODE
  349. /* clang-format on */
  350. #if defined(NORMALMAP_USED)
  351. normal = mix(vec3(0.0, 0.0, 1.0), normal_map * vec3(2.0, -2.0, 1.0) - vec3(1.0, -1.0, 0.0), normal_depth);
  352. #endif
  353. }
  354. #ifdef DEBUG_ENCODED_32
  355. highp float enc32 = dot(color, highp vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0));
  356. color = vec4(vec3(enc32), 1.0);
  357. #endif
  358. color *= final_modulate;
  359. #ifdef USE_LIGHTING
  360. vec2 light_vec = transformed_light_uv;
  361. if (normal_used) {
  362. normal.xy = mat2(local_rot.xy, local_rot.zw) * normal.xy;
  363. }
  364. float att = 1.0;
  365. vec2 light_uv = light_uv_interp.xy;
  366. vec4 light = texture(light_texture, light_uv);
  367. if (any(lessThan(light_uv_interp.xy, vec2(0.0, 0.0))) || any(greaterThanEqual(light_uv_interp.xy, vec2(1.0, 1.0)))) {
  368. color.a *= light_outside_alpha; //invisible
  369. } else {
  370. float real_light_height = light_height;
  371. vec4 real_light_color = light_color;
  372. vec4 real_light_shadow_color = light_shadow_color;
  373. #if defined(USE_LIGHT_SHADER_CODE)
  374. //light is written by the light shader
  375. light_compute(
  376. light,
  377. light_vec,
  378. real_light_height,
  379. real_light_color,
  380. light_uv,
  381. real_light_shadow_color,
  382. normal,
  383. uv,
  384. #if defined(SCREEN_UV_USED)
  385. screen_uv,
  386. #endif
  387. color);
  388. #endif
  389. light *= real_light_color;
  390. if (normal_used) {
  391. vec3 light_normal = normalize(vec3(light_vec, -real_light_height));
  392. light *= max(dot(-light_normal, normal), 0.0);
  393. }
  394. color *= light;
  395. #ifdef USE_SHADOWS
  396. // Reset light_vec to compute shadows, the shadow map is created from the light origin, so it only
  397. // makes sense to compute shadows from there.
  398. light_vec = light_uv_interp.zw;
  399. float angle_to_light = -atan(light_vec.x, light_vec.y);
  400. float PI = 3.14159265358979323846264;
  401. /*int i = int(mod(floor((angle_to_light+7.0*PI/6.0)/(4.0*PI/6.0))+1.0, 3.0)); // +1 pq os indices estao em ordem 2,0,1 nos arrays
  402. float ang*/
  403. float su, sz;
  404. float abs_angle = abs(angle_to_light);
  405. vec2 point;
  406. float sh;
  407. if (abs_angle < 45.0 * PI / 180.0) {
  408. point = light_vec;
  409. sh = 0.0 + (1.0 / 8.0);
  410. } else if (abs_angle > 135.0 * PI / 180.0) {
  411. point = -light_vec;
  412. sh = 0.5 + (1.0 / 8.0);
  413. } else if (angle_to_light > 0.0) {
  414. point = vec2(light_vec.y, -light_vec.x);
  415. sh = 0.25 + (1.0 / 8.0);
  416. } else {
  417. point = vec2(-light_vec.y, light_vec.x);
  418. sh = 0.75 + (1.0 / 8.0);
  419. }
  420. highp vec4 s = shadow_matrix * vec4(point, 0.0, 1.0);
  421. s.xyz /= s.w;
  422. su = s.x * 0.5 + 0.5;
  423. sz = s.z * 0.5 + 0.5;
  424. //sz=lightlength(light_vec);
  425. highp float shadow_attenuation = 0.0;
  426. #ifdef USE_RGBA_SHADOWS
  427. #define SHADOW_DEPTH(m_tex, m_uv) dot(texture((m_tex), (m_uv)), vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0))
  428. #else
  429. #define SHADOW_DEPTH(m_tex, m_uv) (texture((m_tex), (m_uv)).r)
  430. #endif
  431. #ifdef SHADOW_USE_GRADIENT
  432. #define SHADOW_TEST(m_ofs) \
  433. { \
  434. highp float sd = SHADOW_DEPTH(shadow_texture, vec2(m_ofs, sh)); \
  435. shadow_attenuation += 1.0 - smoothstep(sd, sd + shadow_gradient, sz); \
  436. }
  437. #else
  438. #define SHADOW_TEST(m_ofs) \
  439. { \
  440. highp float sd = SHADOW_DEPTH(shadow_texture, vec2(m_ofs, sh)); \
  441. shadow_attenuation += step(sz, sd); \
  442. }
  443. #endif
  444. #ifdef SHADOW_FILTER_NEAREST
  445. SHADOW_TEST(su);
  446. #endif
  447. #ifdef SHADOW_FILTER_PCF3
  448. SHADOW_TEST(su + shadowpixel_size);
  449. SHADOW_TEST(su);
  450. SHADOW_TEST(su - shadowpixel_size);
  451. shadow_attenuation /= 3.0;
  452. #endif
  453. #ifdef SHADOW_FILTER_PCF5
  454. SHADOW_TEST(su + shadowpixel_size * 2.0);
  455. SHADOW_TEST(su + shadowpixel_size);
  456. SHADOW_TEST(su);
  457. SHADOW_TEST(su - shadowpixel_size);
  458. SHADOW_TEST(su - shadowpixel_size * 2.0);
  459. shadow_attenuation /= 5.0;
  460. #endif
  461. #ifdef SHADOW_FILTER_PCF7
  462. SHADOW_TEST(su + shadowpixel_size * 3.0);
  463. SHADOW_TEST(su + shadowpixel_size * 2.0);
  464. SHADOW_TEST(su + shadowpixel_size);
  465. SHADOW_TEST(su);
  466. SHADOW_TEST(su - shadowpixel_size);
  467. SHADOW_TEST(su - shadowpixel_size * 2.0);
  468. SHADOW_TEST(su - shadowpixel_size * 3.0);
  469. shadow_attenuation /= 7.0;
  470. #endif
  471. #ifdef SHADOW_FILTER_PCF9
  472. SHADOW_TEST(su + shadowpixel_size * 4.0);
  473. SHADOW_TEST(su + shadowpixel_size * 3.0);
  474. SHADOW_TEST(su + shadowpixel_size * 2.0);
  475. SHADOW_TEST(su + shadowpixel_size);
  476. SHADOW_TEST(su);
  477. SHADOW_TEST(su - shadowpixel_size);
  478. SHADOW_TEST(su - shadowpixel_size * 2.0);
  479. SHADOW_TEST(su - shadowpixel_size * 3.0);
  480. SHADOW_TEST(su - shadowpixel_size * 4.0);
  481. shadow_attenuation /= 9.0;
  482. #endif
  483. #ifdef SHADOW_FILTER_PCF13
  484. SHADOW_TEST(su + shadowpixel_size * 6.0);
  485. SHADOW_TEST(su + shadowpixel_size * 5.0);
  486. SHADOW_TEST(su + shadowpixel_size * 4.0);
  487. SHADOW_TEST(su + shadowpixel_size * 3.0);
  488. SHADOW_TEST(su + shadowpixel_size * 2.0);
  489. SHADOW_TEST(su + shadowpixel_size);
  490. SHADOW_TEST(su);
  491. SHADOW_TEST(su - shadowpixel_size);
  492. SHADOW_TEST(su - shadowpixel_size * 2.0);
  493. SHADOW_TEST(su - shadowpixel_size * 3.0);
  494. SHADOW_TEST(su - shadowpixel_size * 4.0);
  495. SHADOW_TEST(su - shadowpixel_size * 5.0);
  496. SHADOW_TEST(su - shadowpixel_size * 6.0);
  497. shadow_attenuation /= 13.0;
  498. #endif
  499. //color *= shadow_attenuation;
  500. color = mix(real_light_shadow_color, color, shadow_attenuation);
  501. //use shadows
  502. #endif
  503. }
  504. //use lighting
  505. #endif
  506. //color.rgb *= color.a;
  507. frag_color = color;
  508. }