Blax Posted December 19, 2015 Share Posted December 19, 2015 Hi! I have small quest for bjs-jedi-knight's If we need get screen position of point in 3d we make something like this:gl_Position = worldViewProjection * vec4(vPosition, 1.0);but what we make do, if we need back operation (get 3d point), if we know screen coords and have 3d object geometry?In BABYLON here help Scene.pick() method, but how looks his analog in GLS? What algoritm?p.s. i can make Scene.pick and translate result in Shader, but it will not so fast, as computing in GLSL, i think.p.p.s. May the BJS-Force be with you Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted December 19, 2015 Share Posted December 19, 2015 hi screen coords and gl_FragCoord is your answer for example vertex shader ..varying vec3 pos; void main(void){ pos = position; ...} fragment shader varying vec3 pos; void main(void){ if(abs(mouse.x - gl_FragCoord.x )< 2. && abs(mouse.y - gl_FragCoord.y )< 2.){ // pos is mouse hit position } ...} this sample show coord (x:100.,y:100.) if you want have it this position in javascript side best way is pick http://www.babylonjs.com/cyos/#2JSUPD Quote Link to comment Share on other sites More sharing options...
Blax Posted December 19, 2015 Author Share Posted December 19, 2015 Thanks, but...hmm.... i reffered to Scene.pick only as example. I need this in vetex shader. gl_FragCoord present only in fragment shader. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted December 19, 2015 Share Posted December 19, 2015 yes becase just fragment called per pixel you pick pos and add in the uniforms so you have it in vertex Quote Link to comment Share on other sites More sharing options...
Blax Posted December 19, 2015 Author Share Posted December 19, 2015 Yes, i know ))I wrong put the quest, sorry I not need any pick, i need know coordinates (local 3d coordinates of mesh), where my mesh touch the screen frame. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted December 19, 2015 Share Posted December 19, 2015 it is useful task i think.let me think about that just for final you need compute mesh coordinate in vertex shader ? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted December 19, 2015 Share Posted December 19, 2015 it is possible (don't mean i can do it)with vertex shader need 2 camera worldViewProjection with different position it is very hard task for me now i think you need compute that before render or tell me why you need this Quote Link to comment Share on other sites More sharing options...
Blax Posted December 19, 2015 Author Share Posted December 19, 2015 I found more simple way (only for my case, when mesh is flat and fixed on y)Simple calc "screen" width from camera-to-target distance and cos of half camera.fov * screen aspect coefficient. Thank for help, when i think on correct problem decription, born solution. NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
Blax Posted December 19, 2015 Author Share Posted December 19, 2015 All month i fight for more or less realistic sea water Flat water on bath or lake is nice, but sea water is other. Good look get all posiible fps It afore tree trying for make something pretty and fast.If i can - show Thank for you GLSL advices! Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted December 19, 2015 Share Posted December 19, 2015 Blax, there is a waterMaterial in the materialLibrary, couldn't it be used for your purpose ? NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
Blax Posted December 21, 2015 Author Share Posted December 21, 2015 Blax, there is a waterMaterial in the materialLibrary, couldn't it be used for your purpose ? Hi, Vousk-prod, can you show "more or less realistic sea water" with waterMaterial? Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted December 21, 2015 Share Posted December 21, 2015 I don't know, I've never used it . For what I saw in the demo, it's water and waves, but not realistic sea or ocean, we're ok on that. But maybe by tweaking the params ? Oh BTW the demos here don't work anymore (black areas appear) : http://doc.babylonjs.com/extensions/Water Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted December 21, 2015 Share Posted December 21, 2015 Until now, the best water demo I saw is this one :http://madebyevan.com/webgl-water/Everything is perfect here. Excellent fluid simulation, nice caustic, clean realtime shadows, impressive ssao, beautiful ambient from inside water... well, a really really good demo on every asects. Quote Link to comment Share on other sites More sharing options...
Blax Posted December 22, 2015 Author Share Posted December 22, 2015 Until now, the best water demo I saw is this one :http://madebyevan.com/webgl-water/Everything is perfect here. Excellent fluid simulation, nice caustic, clean realtime shadows, impressive ssao, beautiful ambient from inside water... well, a really really good demo on every asects. Thank!yes, i see all this demos. This one is real pretty, but not my case (i need _sea_ water ).WaterMaterial is simple variant (where water is not first actor in scene).I need found faster and pretty solution. Dig, dig, and dig again Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.