Hello everyone.
I wanna to make shader, that will be inflate texture in center.
Like a Spherize effect in Photoshop
Before:
After:
Unforunately all my attempts failed.
I would be very grateful if someone could help me with this
Hello everyone.
I wanna to make shader, that will be inflate texture in center.
Like a Spherize effect in Photoshop
Before:
After:
Unforunately all my attempts failed.
I would be very grateful if someone could help me with this
The simplest implementation of this is to simply shift the UV value towards center based on its distance from center UV range (0.5, 0.5).
Example:
// "Amount" is some Vector2 defined in your shader/material that allows you to control the X and Y expand directions
float uvDist = distance(UV, 0.5); //Get distance between UV and UV center (0.5,0.5)
uvDist = min(0.5, uvDist); //Clamp the distance to the radius of the UV range (0.5)
uvDist = uvDist * 2; // Multiply the dist by 2, scaling it from 0-0.5 to 0-1 range to use as scaling factor
uvDist = 1 - uvDist; //Flip our distance so the closer to center we are, the greater the scaling
float2 factor = uvDist * Amount; //Adjust the factor by our material property controlled amount.
factor = saturate(factor); //Clamp to 0-1 range to ensure our lerp() stays within A/B
float2 inflatedUV = lerp(UV, float2(0.5, 0.5), factor); //Shift our UV value towards center based on our factor intensity.