Posts

Showing posts with the label transform_tex

fragment/vertex shader - distorting UVs and the Grabpass

Two things shown here, with a bit of fiddling needed to make it actually work, which shouldn't be a problem if you've looked at all the other bits. In the appdata struct we're including the UVs now, with TEXCOORD0 attribute. In the v2f function, we use TRANSFORM_TEX(v.uv, _MainTex) to get our uv coordinates into screenspace. Once we have these values, we use the sin function to distort both the X&Y, or U & V!, multiplying the input by some properties we defined earlier. This is passed to the Frag shader, which displays "a" texture..  What I've not mentioned is the GrabPass -it essentially takes a snapshot of the framebuffer and stores it as a texture. The Transparent Queue tag stops it from going crazy & rendering into infinity (think of when you record a tv and feed the recording into the tv.. The GrabPass is defined as a sampler2D, which must be labelled as _GrabTexture- after that it can be used in a tex2D function as usual.  Shader "Dave/U...