small refactoring
FyiurAmron opened this issue · comments
I know it's arguable, but honestly I think that refactoring those
pos.x = floor(frac((i.uv.x - 0.5 * _Thickness) * localScale) + _Thickness * localScale);
pos.y = floor(frac((i.uv.y - 0.5 * _Thickness) * localScale) + _Thickness * localScale);
// ...
pos.x = floor(frac((i.uv.x - 0.5 * _Thickness) * 10.0 * localScale) + _Thickness * 10.0 * localScale);
pos.y = floor(frac((i.uv.y - 0.5 * _Thickness) * 10.0 * localScale) + _Thickness * 10.0 * localScale);
into a util method along the lines of
float xform( float base, float scale ){
return floor(frac((base - 0.5 * _Thickness) * scale) + _Thickness * scale);
}
and then calling them like
pos.x = xform(i.uv.x, localScale);
pos.y = xform(i.uv.y, localScale);
// ...
pos.x = xform(i.uv.x, 10.0 * localScale);
pos.y = xform(i.uv.y, 10.0 * localScale);
would make the code cleaner, more readable and beginner-friendly.
(Obviously, I can do a PR if you prefer that instead of an issue ticket)
Hello @FyiurAmron, sure you can make a PR 👍
(make sure the formatting is uniform though, like spaces, bracket placement, etc..)
@ogxd you do have mixed styles there: both
v2f vert (appdata v)
{
and
float remap(float value, float from1, float to1, float from2, float to2) {
which code style would you prefer for new code?
Ah indeed, my bad. In this case any is fine.