I’m trying to create a material that will keep the texture at a constant predefined size while repeating it. Often used in the prototyping phase, and very helpful to get a visual reference of the surrounding scale.
For issue №1 try the following code (note the use of sign(…)). I’m not sure whether this is the optimal way, but at least it will allow you to tackle the other two issues.
if (nor.x >= nor.y && nor.x >= nor.z) {
x = pos.z * scale.z * sign(-normal.x);
y = pos.y * scale.y;
}
if (nor.y >= nor.x && nor.y >= nor.z) {
x = pos.x * scale.x;
y = pos.z * scale.z * sign(-normal.y);
}
if (nor.z >= nor.x && nor.z >= nor.y) {
x = pos.x * scale.x * sign(normal.z);
y = pos.y * scale.y;
}
Thanks a lot @PavelBoytchev, that did the trick. BTW the Shader code is inspired by the solution you provided it this thread (should’ve mentioned it ) So double thanks
Note, that it is not good to use constants like 16, it is better to use renderer.getMaxAnisotropy(). In the code the texture is created before the renderer, that’s why I did not use the renderer to get the maximal anisotropy.
@Fennec with a little bit of tweaking it’s possible to include an “alpha map” with this…
I’m wondering is it possible this shader material can be an extension of MeshStandardMaterial so it’d also include all of MSM’s other channel properties ( roughness, metalness, AO, normal etc…)?
EDIT:
I’ll try add the same opacity “alpha map” to this version, i think it’d be handy…