- Home /
UV Deformation
I remember a way of deforming the UV of a texture in UDK using a normal map and I was wondering, can we do the same in Unity?
I've been trying to mess around with the shaders but everytime i try to add a multiply or an additive to a texture UV it just tells me to off, saying "*" is not valid there.
In the end, the effect that I'm looking for is distortion of the texture using a normal map and since it was pretty straight forward in UDK, I suppose one of you guys must have done this before!
Do you mean you want to apply distortion on the normal map or distort the origin texture based on a normal map?
Distort the origin texture based on a normal map, but I got it working in the end. I'd be curious to see other ways to do it though because my way was pretty much wierd and ungraceful.
Answer by drak8888 · Nov 22, 2013 at 05:18 PM
Well I got it working this way :
IN.uv_MainTex = IN.uv_MainTex + IN.uv_MainTex * (UnpackNormal(tex2D(_BumpMap , IN.uv_BumpMap)/2 + tex2D(_BumpMap2 , IN.uv_BumpMap2)/2)/50);
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
The /50 in the end simply reducing the distortion because it was way too strong.
Maybe its not the best way to do it but it works like a charm, mixing 2 bumps and distorting the texture. All I had to do after was slide both bumps with Javascript and I could make myself some pretty water even in Unity Free.
Your answer
Follow this Question
Related Questions
Buoyancy using shaders 2 Answers
Shaders do not work in build. 0 Answers
How to iterate a Shader Pass? 0 Answers
Best Workflow/Setup for Swapping Shaders based on Build Target 0 Answers