Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I want to know how many times the texture repeats.
#1
Hello,
I am generating a mesh in Curvy Generator using Volume Mesh.

I would like to know how many repeats of the material texture I have assigned to the generated mesh.

[Image: light.dotup.org64565.png]

I know that the above would probably be about 6.5 repeats, but I am unable to calculate it properly.
The total length of the path is 240m, the total length of the shape is 19.14484m, and the texture is 512x512, but I don't know what I am missing in calculating 6.5 from this.

I have selected Scale V for Keep Aspect in the Volume Mesh material.
UV Scale is X=1,Y=1.

If you have any hints that might help us in our calculations, I would appreciate it if you could let me know.
(Aspect ratios used internally by Curvy Spline, etc)
Thank you in advance.

Edit:
Version is Curvy Splines 8.7.1.
The reason I am asking this question is because I am changing the mainTextureOffset of the material in a script to achieve UV scrolling.
I ask because I need to match the UV scrolling speed with the scrolling speed in Unity's 3D space, and this calculation is necessary in the process.
Reply
#2
Hi
The number of repeating with your setting should be equal to 240/19.14, which is roughly 12. I can't think of a reason for why you have only 6. The code responsible for those calculations is located at the SamplePointsMaterialGroupCollection.CalculateAspectCorrection method, in the ToolBuddy\Assets\Curvy\Scripts\CG\SamplePointsMaterialGroupCollection.cs file.
Feel free to send me your reproduction case so I can dive into it if needed.
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Thank you for your response.
I currently have the Scale for Shape Extrusion set to 10 for both XY, but when I change it, the number of textures changes, so I am wondering if this might be affecting it.
For now, I'll try trial and error based on that hint!
Reply
#4
(09-09-2023, 11:25 PM)yanke Wrote: Thank you for your response.
I currently have the Scale for Shape Extrusion set to 10 for both XY, but when I change it, the number of textures changes, so I am wondering if this might be affecting it.
For now, I'll try trial and error based on that hint!

The Volume Mesh module has a "Unscale U" setting. This allows you the U coordinate to compensate the scaling.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#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
#6
You are welcome.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


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: