Advertisement
Guest User

Untitled

a guest
Jun 10th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /////////////////////////////// Source file 0/////////////////////////////
  2. #version 330
  3.  
  4. /////////////////////////////// Source file 1/////////////////////////////
  5. #define GLES_OVER_GL
  6.  
  7. /////////////////////////////// Source file 2/////////////////////////////
  8.  
  9. /////////////////////////////// Source file 3/////////////////////////////
  10. #define USE_TEXTURE_RECT
  11.  
  12. /////////////////////////////// Source file 4/////////////////////////////
  13.  
  14. /////////////////////////////// Source file 5/////////////////////////////
  15.  
  16. /////////////////////////////// Source file 6/////////////////////////////
  17.  
  18. /////////////////////////////// Source file 7/////////////////////////////
  19.  
  20. /////////////////////////////// Source file 8/////////////////////////////
  21.  
  22. /////////////////////////////// Source file 9/////////////////////////////
  23.  
  24. /////////////////////////////// Source file 10/////////////////////////////
  25.  
  26. /////////////////////////////// Source file 11/////////////////////////////
  27.  
  28. /////////////////////////////// Source file 12/////////////////////////////
  29.  
  30. /////////////////////////////// Source file 13/////////////////////////////
  31.  
  32. /////////////////////////////// Source file 14/////////////////////////////
  33.  
  34. /////////////////////////////// Source file 15/////////////////////////////
  35.  
  36. /////////////////////////////// Source file 16/////////////////////////////
  37.  
  38. /////////////////////////////// Source file 17/////////////////////////////
  39.  
  40. /////////////////////////////// Source file 18/////////////////////////////
  41.  
  42. /////////////////////////////// Source file 19/////////////////////////////
  43.  
  44. /////////////////////////////// Source file 20/////////////////////////////
  45.  
  46. /////////////////////////////// Source file 21/////////////////////////////
  47. precision highp float;
  48.  
  49. /////////////////////////////// Source file 22/////////////////////////////
  50. precision highp int;
  51.  
  52. /////////////////////////////// Source file 23/////////////////////////////
  53.  
  54.  
  55. layout(location=0) in highp vec2 vertex;
  56. layout(location=3) in vec4 color_attrib;
  57.  
  58. #ifdef USE_SKELETON
  59. layout(location=6) in uvec4 bone_indices; // attrib:6
  60. layout(location=7) in vec4 bone_weights; // attrib:7
  61. #endif
  62.  
  63. #ifdef USE_TEXTURE_RECT
  64.  
  65. uniform vec4 dst_rect;
  66. uniform vec4 src_rect;
  67.  
  68. #else
  69.  
  70. #ifdef USE_INSTANCING
  71.  
  72. layout(location=8) in highp vec4 instance_xform0;
  73. layout(location=9) in highp vec4 instance_xform1;
  74. layout(location=10) in highp vec4 instance_xform2;
  75. layout(location=11) in lowp vec4 instance_color;
  76.  
  77. #ifdef USE_INSTANCE_CUSTOM
  78. layout(location=12) in highp vec4 instance_custom_data;
  79. #endif
  80.  
  81. #endif
  82.  
  83. layout(location=4) in highp vec2 uv_attrib;
  84.  
  85. //skeletn
  86. #endif
  87.  
  88. uniform highp vec2 color_texpixel_size;
  89.  
  90.  
  91. layout(std140) uniform CanvasItemData { //ubo:0
  92.  
  93.     highp mat4 projection_matrix;
  94.     highp float time;
  95. };
  96.  
  97. uniform highp mat4 modelview_matrix;
  98. uniform highp mat4 extra_matrix;
  99.  
  100.  
  101. out highp vec2 uv_interp;
  102. out mediump vec4 color_interp;
  103.  
  104. #ifdef USE_NINEPATCH
  105.  
  106. out highp vec2 pixel_size_interp;
  107. #endif
  108.  
  109.  
  110. #ifdef USE_SKELETON
  111. uniform mediump sampler2D skeleton_texture; // texunit:-1
  112. uniform highp mat4 skeleton_transform;
  113. uniform highp mat4 skeleton_transform_inverse;
  114. #endif
  115.  
  116. #ifdef USE_LIGHTING
  117.  
  118. layout(std140) uniform LightData { //ubo:1
  119.  
  120.     //light matrices
  121.     highp mat4 light_matrix;
  122.     highp mat4 light_local_matrix;
  123.     highp mat4 shadow_matrix;
  124.     highp vec4 light_color;
  125.     highp vec4 light_shadow_color;
  126.     highp vec2 light_pos;
  127.     highp float shadowpixel_size;
  128.     highp float shadow_gradient;
  129.     highp float light_height;
  130.     highp float light_outside_alpha;
  131.     highp float shadow_distance_mult;
  132. };
  133.  
  134.  
  135. out vec4 light_uv_interp;
  136.  
  137.  
  138. out vec4 local_rot;
  139.  
  140. #ifdef USE_SHADOWS
  141. out highp vec2 pos;
  142. #endif
  143.  
  144. const bool at_light_pass = true;
  145. #else
  146. const bool at_light_pass = false;
  147. #endif
  148.  
  149. #ifdef USE_PARTICLES
  150. uniform int h_frames;
  151. uniform int v_frames;
  152. #endif
  153.  
  154.  
  155. #if defined(USE_MATERIAL)
  156.  
  157. layout(std140) uniform UniformData { //ubo:2
  158.  
  159. /////////////////////////////// Source file 24/////////////////////////////
  160.  
  161.  
  162. };
  163.  
  164. #endif
  165.  
  166.  
  167. /////////////////////////////// Source file 25/////////////////////////////
  168.  
  169.  
  170. void main() {
  171.  
  172.     vec4 color = color_attrib;
  173.  
  174. #ifdef USE_INSTANCING
  175.     mat4 extra_matrix2 = extra_matrix * transpose(mat4(instance_xform0,instance_xform1,instance_xform2,vec4(0.0,0.0,0.0,1.0)));
  176.     color*=instance_color;
  177.     vec4 instance_custom = instance_custom_data;
  178.  
  179. #else
  180.     mat4 extra_matrix2 = extra_matrix;
  181.     vec4 instance_custom = vec4(0.0);
  182. #endif
  183.  
  184. #ifdef USE_TEXTURE_RECT
  185.  
  186.     if (dst_rect.z < 0.0) { // Transpose is encoded as negative dst_rect.z
  187.         uv_interp = src_rect.xy + abs(src_rect.zw) * vertex.yx;
  188.     } else {
  189.         uv_interp = src_rect.xy + abs(src_rect.zw) * vertex;
  190.     }
  191.     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);
  192.  
  193. #else
  194.     uv_interp = uv_attrib;
  195.     highp vec4 outvec = vec4(vertex,0.0,1.0);
  196. #endif
  197.  
  198.  
  199. #ifdef USE_PARTICLES
  200.     //scale by texture size
  201.     outvec.xy/=color_texpixel_size;
  202.  
  203.     //compute h and v frames and adjust UV interp for animation
  204.     int total_frames = h_frames * v_frames;
  205.     int frame = min(int(float(total_frames) *instance_custom.z),total_frames-1);
  206.     float frame_w = 1.0/float(h_frames);
  207.     float frame_h = 1.0/float(v_frames);
  208.     uv_interp.x = uv_interp.x * frame_w + frame_w * float(frame % h_frames);
  209.     uv_interp.y = uv_interp.y * frame_h + frame_h * float(frame / h_frames);
  210.  
  211. #endif
  212.  
  213.  
  214. #define extra_matrix extra_matrix2
  215.  
  216. {
  217.  
  218. /////////////////////////////// Source file 26/////////////////////////////
  219.  
  220.  
  221. }
  222.  
  223.  
  224. #ifdef USE_NINEPATCH
  225.  
  226.     pixel_size_interp=abs(dst_rect.zw) * vertex;
  227. #endif
  228.  
  229. #if !defined(SKIP_TRANSFORM_USED)
  230.     outvec = extra_matrix * outvec;
  231.     outvec = modelview_matrix * outvec;
  232. #endif
  233.  
  234. #undef extra_matrix
  235.  
  236.     color_interp = color;
  237.  
  238. #ifdef USE_PIXEL_SNAP
  239.  
  240.     outvec.xy=floor(outvec+0.5).xy;
  241. #endif
  242.  
  243.  
  244. #ifdef USE_SKELETON
  245.  
  246.     if (bone_weights!=vec4(0.0)){ //must be a valid bone
  247.         //skeleton transform
  248.  
  249.         ivec4 bone_indicesi = ivec4(bone_indices);
  250.  
  251.         ivec2 tex_ofs = ivec2( bone_indicesi.x%256, (bone_indicesi.x/256)*2 );
  252.  
  253.         highp mat2x4 m = mat2x4(
  254.             texelFetch(skeleton_texture,tex_ofs,0),
  255.             texelFetch(skeleton_texture,tex_ofs+ivec2(0,1),0)
  256.         ) * bone_weights.x;
  257.  
  258.         tex_ofs = ivec2( bone_indicesi.y%256, (bone_indicesi.y/256)*2 );
  259.  
  260.         m+= mat2x4(
  261.                     texelFetch(skeleton_texture,tex_ofs,0),
  262.                     texelFetch(skeleton_texture,tex_ofs+ivec2(0,1),0)
  263.                 ) * bone_weights.y;
  264.  
  265.         tex_ofs = ivec2( bone_indicesi.z%256, (bone_indicesi.z/256)*2 );
  266.  
  267.         m+= mat2x4(
  268.                     texelFetch(skeleton_texture,tex_ofs,0),
  269.                     texelFetch(skeleton_texture,tex_ofs+ivec2(0,1),0)
  270.                 ) * bone_weights.z;
  271.  
  272.  
  273.         tex_ofs = ivec2( bone_indicesi.w%256, (bone_indicesi.w/256)*2 );
  274.  
  275.         m+= mat2x4(
  276.                     texelFetch(skeleton_texture,tex_ofs,0),
  277.                     texelFetch(skeleton_texture,tex_ofs+ivec2(0,1),0)
  278.                 ) * bone_weights.w;
  279.  
  280.         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;
  281.  
  282.         outvec = bone_matrix * outvec;
  283.     }
  284.  
  285. #endif
  286.  
  287.     gl_Position = projection_matrix * outvec;
  288.  
  289. #ifdef USE_LIGHTING
  290.  
  291.     light_uv_interp.xy = (light_matrix * outvec).xy;
  292.     light_uv_interp.zw =(light_local_matrix * outvec).xy;
  293. #ifdef USE_SHADOWS
  294.     pos=outvec.xy;
  295. #endif
  296.  
  297.  
  298.     local_rot.xy=normalize( (modelview_matrix * ( extra_matrix * vec4(1.0,0.0,0.0,0.0) )).xy  );
  299.     local_rot.zw=normalize( (modelview_matrix * ( extra_matrix * vec4(0.0,1.0,0.0,0.0) )).xy  );
  300. #ifdef USE_TEXTURE_RECT
  301.     local_rot.xy*=sign(src_rect.z);
  302.     local_rot.zw*=sign(src_rect.w);
  303. #endif
  304.  
  305.  
  306.  
  307. #endif
  308.  
  309. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement