How to repeat texture on faces?

Hello,

I've been working with textures in OCCT and came across an issue where, after calling the EnableRepeat function to enable loop sampling mode for textures, I still find that the UV parameters of the texture mapping are confined between 0 and 1. This limitation results in the texture being stretched instead of repeated.

As a workaround, I considered scaling the texture itself according to the actual size of the face. However, this approach requires a significant amount of additional calculations. I'm wondering if there's a way to set the behavior for generating rendering data so that the UV coordinates are equal to the actual geometric coordinates. This would allow me to scale the texture to a specific size and have it repeat on the Face accordingly.

Is there a more direct method or setting available in OCCT to achieve this without extensive additional computations?

gkv311 n's picture

AIS_Shape provides methods for adjusting UV coordinates generation like SetTextureRepeatUV(), SetTextureScaleUV and similar. Have you already tried using them (please share some sample/screenshots then)?

From your description it seems you have tried enabling texture repeating flag for texture sampling parameters which affects only rendering of already generated UV coordinates.

huangy10's picture

I've already tried these interfaces, but there's a problem: To avoid texture distortion, I need to pre-calculate the shape of the graphic when setting the UV Scale and accordingly compute the correct UV scaling ratio, which undoubtedly adds extra computational load. However, if I set the texture coordinates equal to the world coordinates, it can solve this problem to some extent (it's also necessary to project the world coordinates onto the plane where the Face is located).

For example, if I have a 1x1 texture map and the target Face size is 1x4, I need to obtain the size of the Face in advance and set the texture scaling to 1x4, otherwise the 1x1 texture will be stretched. But if I directly use the world coordinates as texture coordinates, meaning the texture coordinates are from (0, 0) to (1, 4), then the texture will not be stretched.