How i can get the mouse position in a shader program?

Hi.

I want modify the colors of one texture passed to shader program in fragment program, but i want that only change the colors of the area around the mouse position.

I dont know how pass the value of mouse position to my CG shader and how use this position into it.

Can anyone help me?

Thanks!

1 Answer

1

Check out this shader: X-ray/Cutout shader with mouse it uses the mouse position in it to create the x-ray effect. The unityproject file is also available there which you can use to understand the logic behind it.

He’s just setting the mouse position on the material of that object using Material.SetVector and then using it as input in the shader.

Thanks, I'm going to try it.