Jump to content

ViewProjectMatrix, GLSL


Blax
 Share

Recommended Posts

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  :ph34r: 

Link to comment
Share on other sites

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

 

 

 

 

 

Link to comment
Share on other sites

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!
 

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...