I'm new to this shader world and just want to try something out. I want to do the following: In a specific radius around the mouse, the texture in the background should rotate 10 degrees. Mouse coordinates are full values, so to work with them I have to make them normal, so I can describe the exact location in the texture. But in some way it does not work right Rotation works but I get the color information slightly offset.
I think the problem is I am using cylinders to do this. Thanks. Change the full mouse into coordinate [0,1] in the range (required for texture sample) , You do not need the I wrote it in GLSL, but it would be easy for you to pass on the CPU before passing this uniform, because basically this is the CPU side Is aware of the resolution. normal (mouse) but I do not know how to do this right here's the shader:
Uniform sampling 2D Texx; Uniform VC2 mouse; Zero main () {vec2 pos = vec2 (gl_FragCoord.x, gl_FragCoord.y); If (distance (pause, mouse) <90.0) {vec2 p = gl_TexCoord [0] .st; Vec2m = normal (mouse); P.x = M.x + (Cos (Andean (10.0) * (Px - M.X) - Sin (Andean (10.0)) * (PI-MI)); PY = ME + (sin (radians (10.0) * (Px-MX) + cos (radians (10.0)) * (PI-MI)); Gl_FragColor = vec4 (0.0, ME, 0.0, 0.0); Gl_FragColor = texture2D (tex0, p); } And {gl_FragColor.rgb = texture2D (tex0, gl_TexCoord [0] .st) .rgb; Gl_FragColor.a = 1.0; }}
mShader.uniform ("mouse", vec2f (m.x, 682-m.y));
normalized function, you need a simple scale:
vec2 mouse_norm = vec2 (mx / screen.width, 1.0 - my / screen. Height)
Comments
Post a Comment