0
\$\begingroup\$

I have done the following highlighting shader using GLSL. What I want to do is getting the mouse coordinates and "start" the highlighting from that point. is that possible ? What's the math or the idea behind doing that ? https://youtu.be/8etJho4agpg

\$\endgroup\$
1
\$\begingroup\$

In the vertex shader (or on the CPU) what you'll want to do is transform your screen space coordinate into an object space coordinate. Or you could use a ray trace, tracing a ray from the screen point out of the camera, so that it hits the geometry and returns that point in world space (which you can easily turn into object space in your vertex shader) see https://docs.unity3d.com/ScriptReference/Camera.ScreenPointToRay.html for what I mean (I know your not using unity but it explains it better). Once you have this point then in the fragment shader subtract (or add) this point to the vertex position/uv used to calculate the highlight and it should make it expand out from the mouse.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.