Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I want to know how many times the texture repeats.
#5
Thanks again for your advice regarding "Unscale U."
I followed the code a bit.
I am happy to report that I was able to find the number of texture iterations with the following code.

Code:
public static float GetTextureRepeatCountV(out Material mat)
{
    BuildVolumeMesh volumeMesh = VolumeMesh;

    // Get the Material being set
    mat = volumeMesh.GetMaterial(0);

    // Get UV Scale
    CGMaterialSettingsEx matSetting = volumeMesh.MaterialSettings[0];
    Vector2 uvScale = matSetting.UVScale;

    // Obtain the vertical aspect ratio of the texture
    CGVMesh vMesh = (CGVMesh)volumeMesh.OutVMesh.Data[0];
    float aspectCorrectionV = vMesh.UVs[vMesh.UVs.Count - 1].y;

    return mat.mainTextureScale.y * (uvScale.y * aspectCorrectionV);
}


I'm a little aggressive in asking for "aspectCorrectionV," but that probably won't be a problem.
I have also confirmed that UV scrolling is possible using the above code.

Code:
public static void ScrollV()
{
    // Get the number of V iterations of the texture
    float textureRepeatCountV = GetTextureRepeatCountV(out Material mat);

    // UV scrolling
    mat.mainTextureOffset = new Vector2(0, -ScrollTf * textureRepeatCountV);
}


I confirmed that the speeds also match those of other objects in 3D space.
The "ScrollTf" is a value between 0.0 and 1.0. In reality, I am running the code with a few more tweaks.

Anyway, this is what I wanted to do.
Thanks for the great support!
Reply


Messages In This Thread
RE: I want to know how many times the texture repeats. - by yanke - 09-17-2023, 08:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is it possible to create a road texture at runtime? artsung 1 4 01-30-2024, 09:30 AM
Last Post: _Aka_
  Some times mesh distortion. mammuoils1 5 3,759 12-24-2019, 05:40 PM
Last Post: _Aka_
  How to properly set UV for extruded spline texture Pixel Flipper 3 3,110 09-05-2019, 11:55 AM
Last Post: _Aka_
Brick texture painting wont work well m_mov_sia3 1 3,879 04-28-2015, 01:12 PM
Last Post: Jake

Forum Jump: