text: [{"Owner":"ZackMFleischman","Date":"2016-11-06T06:29:34Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tHi! \n_lt_/p_gt_\n\n_lt_p_gt_\n\tSo I_t_m ultimately trying to pick some meshes with textures that have transparency_co_ but when they overlap_co_ the transparent parts of the mesh still get picked.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tPlayground_dd_ _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1UCP5L_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1UCP5L_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\tIf you open up the console in the playground and click the 2 black circles in the center of the overlapping _qt_impact_qt_ textures_co_ you_t_ll notice that it always picks the 1st texture (although you_t_re clicking on 2 separate _qt_visible_qt_ textures if you take transparency into account). \n_lt_/p_gt_\n\n_lt_p_gt_\n\tI thought perhaps I could test to see if the texture color at the UV coordinates of the picked mesh is transparent_co_ and if it was_co_ I could temporarily mark that mesh as not pickable and pick again at the same location to get the mesh under it until I got something that isn_t_t transparent (and then restore the isPickable state of everything).\n_lt_/p_gt_\n\n_lt_p_gt_\n\tI still think that could work (although it seems terribly inefficient as I have to do several picks unnecessarily)_co_ but I frustratingly can_t_t actually find a good way to get the texture color given the texture and some UV indices (obtained through the pickedInfo). Am I just missing something obvious? Is there not simply an analogous textureObject.getTextureColorAtUV(u_co_ v) function? \n_lt_/p_gt_\n\n_lt_p_gt_\n\tI_t_m also open to other suggestions to get more accurate picking with transparency taken into account.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tThanks so much!\n_lt_/p_gt_\n\n_lt_p_gt_\n\tZack\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"NasimiAsl","Date":"2016-11-06T08:23:58Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tmesh.isPickable _eq_ true | false\n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#4SUQZ%230_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#4SUQZ#0_lt_/a_gt_ \n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#4SUQZ%231_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#4SUQZ#1_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ZackMFleischman","Date":"2016-11-06T17:54:21Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tI appreciate you taking some time @NasimiAsl but I_t_m not asking how to ignore a mesh that has transparency.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tFor clarity_co_ I_t_m asking 2 things_dd_\n_lt_/p_gt_\n\n_lt_p_gt_\n\t1.) How do you ignore ONLY the completely transparent part of a mesh when picking?\n_lt_/p_gt_\n\n_lt_p_gt_\n\t2.) How do you get the RGBA color of a texture given a specific UV coordinate into the texture?\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"NasimiAsl","Date":"2016-11-06T18:38:48Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/22522-zackmfleischman/?do_eq_hovercard_qt_ data-mentionid_eq__qt_22522_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/22522-zackmfleischman/_qt_ rel_eq__qt__qt__gt_@ZackMFleischman_lt_/a_gt_ you need GPU Picking system or just wanna read pixel from rendered Result?\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Pryme8","Date":"2016-11-06T18:44:21Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tI would think you would have to do a multiple pick loop_co_ where you check the alpha of the first picked meshs uv at that point and if its 0 then set that mesh to pickable false and do another pick at the same location.\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ZackMFleischman","Date":"2016-11-07T02:58:08Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/13038-nasimiasl/?do_eq_hovercard_qt_ data-mentionid_eq__qt_13038_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/13038-nasimiasl/_qt_ rel_eq__qt__qt__gt_@NasimiAsl_lt_/a_gt_ If a GPU Picking system would help I_t_m not opposed to it_co_ but I don_t_t know of one that exists or what that would entail. _lt_br /_gt_\n\tAs far as reading the pixel from the rendered result_co_ I_t_m referring to reading the color data from a Texture at a UV coordinate in the range (u_eq_[0_co_1]_co_ v_eq_[0_co_1]). Whether or not the texture is rendered is irrelevant. I want to know what it_t_s color is at certain coordinates. I_t_m surprised that I can_t_t just access a 2D array like this_dd_ textureObject.colorData_lt_span style_eq__qt_text-decoration_dd_underline_sm__qt__gt_[v]. _lt_/span_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/19199-pryme8/?do_eq_hovercard_qt_ data-mentionid_eq__qt_19199_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/19199-pryme8/_qt_ rel_eq__qt__qt__gt__lt_span style_eq__qt_text-decoration_dd_underline_sm__qt__gt_@Pryme8_lt_/span_gt__lt_/a_gt__lt_span style_eq__qt_text-decoration_dd_underline_sm__qt__gt_ Yes_co_ that is the algorithm I described above. I believe I could accomplish that if I were able to check the alpha at the meshes uv..._lt_strong_gt_BUT I don_t_t know HOW to check that alpha value_lt_/strong_gt_ (as I_t_ve mentioned a few times now). HOWEVER_co_ this algorithm seems terribly inefficient due to multiple picks on the order of the number of meshes the cast ray would intersect. I feel like there is a way to construct an algorithm that should only have to execute the picking process once_co_ and I_t_m open to any ideas people might have towards this. _lt_/span_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_span style_eq__qt_text-decoration_dd_underline_sm__qt__gt_Thanks again guys. _lt_/span_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_span style_eq__qt_text-decoration_dd_underline_sm__qt__gt_(ps_co_ no idea why this underlined everything but I can_t_t turn it off with an edit)_lt_/span_gt_\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"fenomas","Date":"2016-11-07T03:51:23Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/22522-zackmfleischman/?do_eq_hovercard_qt_ data-mentionid_eq__qt_22522_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/22522-zackmfleischman/_qt_ rel_eq__qt__qt__gt_@ZackMFleischman_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\tI don_t_t think browsers implement a way of reading a pixel color out of an image. I believe the only way is to create a canvas element (doesn_t_t have to be part of the DOM)_co_ draw the image into it_co_ and then read the pixel back out of the canvas. It would be costly to do this over and over_co_ but if you only need checks against a single texture you could draw the image once and read out of it cheaply when needed.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tAs for efficiency_co_ an algorithm is only inefficient if it does work that didn_t_t need to be done. If I follow you here_co_ you need to know where the pick hits a given mesh before you can determine whether that mesh should be ignored. So I_t_d expect that doing multiple picks is unavoidable.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Pryme8","Date":"2016-11-07T13:22:32Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tMultipicks are standard \n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Deltakosh","Date":"2016-11-09T00:43:18Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tHey\n_lt_/p_gt_\n\n_lt_p_gt_\n\t1.) How do you ignore ONLY the completely transparent part of a mesh when picking? You can define your own predicate to determine which meshes can be picked. You can either set mesh.isPickable _eq_ false for transparent mesh or use _lt_a href_eq__qt_https_dd_//github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L2906_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//github.com/BabylonJS/Babylon.js/blob/master/src/babylon.scene.ts#L2906_lt_/a_gt_ (When calling scene.pick(x_co_ y_co_ predicate))\n_lt_/p_gt_\n\n_lt_p_gt_\n\t2.) You first need to load your texture into an image object (DOM object). The using a canvas_co_ draw your picture inside it in order to get pixel colors (_lt_a href_eq__qt_https_dd_//dev.opera.com/articles/html5-canvas-basics/#pixelbasedmanipulation_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//dev.opera.com/articles/html5-canvas-basics/#pixelbasedmanipulation_lt_/a_gt_). Then with UV it is easy to get the RGBA of the pixel you want.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Pryme8","Date":"2016-11-09T02:30:18Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\t2) is where the butter is\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ZackMFleischman","Date":"2016-11-13T03:21:03Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/12925-fenomas/?do_eq_hovercard_qt_ data-mentionid_eq__qt_12925_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/12925-fenomas/_qt_ rel_eq__qt__qt__gt_@fenomas_lt_/a_gt_ _lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/4442-deltakosh/?do_eq_hovercard_qt_ data-mentionid_eq__qt_4442_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/4442-deltakosh/_qt_ rel_eq__qt__qt__gt_@Deltakosh_lt_/a_gt_ _lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/19199-pryme8/?do_eq_hovercard_qt_ data-mentionid_eq__qt_19199_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/19199-pryme8/_qt_ rel_eq__qt__qt__gt_@Pryme8_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\tThanks guys!\n_lt_/p_gt_\n\n_lt_p_gt_\n\tFor testing whether a part of an image is transparent I ended up doing as @fenomas and @Deltakosh said and did the following_dd_\n_lt_/p_gt_\n\n_lt_ol_gt__lt_li_gt_\n\t\tCreated an offscreen canvas element with a 2D context and draw the image to it.\n\t_lt_/li_gt_\n\t_lt_li_gt_\n\t\tGet the Image Data via `context.getImageData` and thus get access to the raw pixel data.\n\t_lt_/li_gt_\n_lt_/ol_gt__lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tFor only picking meshes when I_t_ve picked a non-transparent area of the mesh I did a pick loop as suggested_dd_\n_lt_/p_gt_\n\n_lt_ol_gt__lt_li_gt_\n\t\tPick with all meshes set to `isPickable`.\n\t_lt_/li_gt_\n\t_lt_li_gt_\n\t\tTest the UV coordinates of the texture of the pickedMesh to see if it_t_s transparent. (via `pickInfo.getTextureCoordinates`)\n\t_lt_/li_gt_\n\t_lt_li_gt_\n\t\tIf it_t_s transparent_co_ mark that mesh_t_s `isPickable` to false and recurse.\n\t_lt_/li_gt_\n\t_lt_li_gt_\n\t\tEventually we reach a mesh that isn_t_t transparent at the picked point_co_ or there is no mesh. We set `isPickable` back to true for all the ones we flipped and return that pickInfo.\n\t_lt_/li_gt_\n_lt_/ol_gt__lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tYou can see the results in the playground here_dd_ _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1UCP5L%235_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1UCP5L#5_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\tIf you click the image on the left_co_ the background will turn red.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tIf you click the image on the right_co_ the background will turn blue.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tIf you click the background (including in the middle of the images where it_t_s transparent!) the background will turn back to green.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tThanks again for your help. Big fan of this community.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Vousk-prod.","Date":"2016-11-14T18:35:10Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_blockquote class_eq__qt_ipsQuote_qt_ data-ipsquote_eq__qt__qt_ data-ipsquote-contentapp_eq__qt_forums_qt_ data-ipsquote-contentclass_eq__qt_forums_Topic_qt_ data-ipsquote-contentcommentid_eq__qt_150840_qt_ data-ipsquote-contentid_eq__qt_26224_qt_ data-ipsquote-contenttype_eq__qt_forums_qt_ data-ipsquote-timestamp_eq__qt_1479007263_qt_ data-ipsquote-userid_eq__qt_22522_qt_ data-ipsquote-username_eq__qt_ZackMFleischman_qt__gt_\n\t_lt_div class_eq__qt_ipsQuote_citation_qt__gt_\n\t\tOn 13/11/2016 at 4_dd_21 AM_co_ ZackMFleischman said_dd_\n\t_lt_/div_gt_\n\n\t_lt_div class_eq__qt_ipsQuote_contents_qt__gt_\n\t\t_lt_p_gt_\n\t\t\tYou can see the results in the playground here_dd_ _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1UCP5L%235_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1UCP5L#5_lt_/a_gt_\n\t\t_lt_/p_gt_\n\n\t\t_lt_p_gt_\n\t\t\tIf you click the image on the left_co_ the background will turn red.\n\t\t_lt_/p_gt_\n\n\t\t_lt_p_gt_\n\t\t\tIf you click the image on the right_co_ the background will turn blue.\n\t\t_lt_/p_gt_\n\n\t\t_lt_p_gt_\n\t\t\tIf you click the background (including in the middle of the images where it_t_s transparent!) the background will turn back to green.\n\t\t_lt_/p_gt_\n\t_lt_/div_gt_\n_lt_/blockquote_gt_\n\n_lt_p_gt_\n\tHmm_co_ that_t_s strange_co_ it doesn_t_t fully work for me (Firefox).\n_lt_/p_gt_\n\n_lt_p_gt_\n\tIf I click the square or outside the square_co_ it turns green. But if I click the black drawing_co_ it turns usually red on the left and blue on the right_co_ but it also sometimes turns red on the right_co_ and blue on the left.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ZackMFleischman","Date":"2016-11-14T20:35:59Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/6528-vousk-prod/?do_eq_hovercard_qt_ data-mentionid_eq__qt_6528_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/6528-vousk-prod/_qt_ rel_eq__qt__qt__gt_@Vousk-prod._lt_/a_gt_ This is by design. The black drawing is actually 2 _qt_impact_qt_ images overlaid on each other. I chose it because it has transparency. \n_lt_/p_gt_\n\n_lt_p_gt_\n\tThinking back I probably should have chosen 2 different images but I was just hacking something up to demonstrate the point. If you click the image on the left it turns red_co_ if you click the image on the right it turns blue. This includes the parts of the images that overlap.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Vousk-prod.","Date":"2016-11-15T21:00:25Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tOh_co_ I see. I should have had a look at the code to get that _lt_img alt_eq__qt__dd_P_qt_ data-emoticon_eq__qt__qt_ height_eq__qt_20_qt_ src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_tongue.png_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/tongue@2x.png 2x_qt_ title_eq__qt__dd_P_qt_ width_eq__qt_20_qt_ /_gt__lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"}]