We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

GDL
About building parametric objects with GDL.
SOLVED!

Random texture origin for FOR – TO – NEXT

jc4d
Expert

Hello,

 

I have a simple block using FOR – TO – NEXT to duplicate it, is there a way to add a random texture origin to each duplicated so there is no visible texture repetitions?

jc4d_0-1677498832649.png

 

Juan.

22 REPLIES 22
Lingwisyer
Guru

Is it rotated? It is a bit hard to see in your image as your texture size is significantly bigger than your board size...

 

Lingwisyer_0-1678152593873.png

Lingwisyer_1-1678152857678.png

 

 

VERT	0 + tile_fill_origin_x[iDis],	0 + tile_fill_origin_y[iDis],	0	!Origin
VERT	1 + tile_fill_origin_x[iDis],	0 + tile_fill_origin_y[iDis],	0	!X 
VERT	0 + tile_fill_origin_x[iDis],	1 + tile_fill_origin_y[iDis],	0	!Y 
VERT	0 + tile_fill_origin_x[iDis],	0 + tile_fill_origin_y[iDis],	1	!Z 
coor	2+1024,	-1,	-2,	-3,	-4 

 

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Yes, in my case the texture doesn't "follow" the board size. But the texture is not rotated.

Could it be that I'm approaching this whole thing in the wrong way? 🤔

 

This is my surface:

jc4d_0-1678165951248.png

 

3D script:

N1= CEIL(A /(RimaA+RimaV))

FOR H=1 TO N1
GOSUB 20
ADDx RimaV + RimaA
NEXT H


DEL TOP
END

20:
block RimaA, RimaB, B
RETURN

 

Juan

Solution

Try this ...

Just use your surface material.

I have only offset in the 'y' direction.

And maybe turn the 'random origin' off in your surface material (mine is off).

 

 

 

board_width = 0.100
board_gap = 0.010

N1= CEIL(A /(board_width+board_gap))

FOR H=1 TO N1
GOSUB 20
ADDx board_width + board_gap
NEXT H


DEL TOP
END

20:

MATERIAL "Timber_Pine - vertical"
block board_width, B, ZZYZX
texture_origin_y = RND(10)
GOSUB 100

RETURN


100: !!texture mapping

VERT 0,0+texture_origin_y,0 !Origin
VERT 1,0+texture_origin_y,0 !X direction
VERT 0,1+texture_origin_y,0 !Y direction
VERT 0,0+texture_origin_y,1 !Z direction
COOR 2+256,1,2,3,4
body -1

RETURN

 

 

 

 

BarryKelly_0-1678168757745.png

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Mind you, if you texture is big enough you may not even need the VERT/COOR gosub.

You can see here the repetition without VERT/COOR - not great but it is OK.

 

BarryKelly_1-1678169205875.png

 

BarryKelly_3-1678169391725.png

 

 

If you are using the VERT/COOR gosub, you are really just using the first edge of the material.

I guess you could add in a 'texture_origin_x' offset as well which I took out of my example.

Your texture only needs to be one board width if you do use it, but a bigger texture is fine because you can use it for other situations as well as in sheeting rather than boards.

 

Barry.

 

 

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
jc4d
Expert

Thank you, now I started understanding the logic (somehow 😅) . Some things are more difficult than expected,

 

Juan

In my case I'm using a texture that is meant for wood panels more than borads, so having an offset in x and in z it helped a lot to avoid any tiling in any direction.

The reason for all this is that those boards are going to be used as inner ceilings in open spaces that can cover up to 15m by 15m, and if you count that each board is 5cm wide, you can image how does it looks if there is no texture offset.

 

Juan

Hi Peter,

 

Can the seed range be used to randomise a material?

 

 

MATERIAL mat_array[int(rnd(SYMB_POS_X % mat_count)) + 1]

 

 

I was hoping to use it within a loop to randomly use between 1 and 5 random materials, but the RND does not change within the loop, only when the object is placed again...

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
Peter Baksa
Graphisoft
Graphisoft

COOR{3} expects that the texture axis coordinates are expressed in the space before moving the origin (unlike XFORM).

It is much simpler to let GDL do the transformations, and use the current coordinate system with COOR{3}:

add dx, dy, dz
rotz da
coor{3} 2, 4,
	0,0,0,
	1,0,0,
	0,1,0,
	0,0,1
del 2
body -1

Don't forget body -1 when modeling objects in a loop.

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Sorry, my mistake, I oversimpified the example. What worked for me is:

int(rnd(_seed * _rangemax) % _rangemax) + 1

Here seed should be a fractional number greater than one to always utilize the whole range.

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

 

Hi Peter,

 

MATERIAL mat_array[int(rnd(abs(SYMB_POS_X) * mat_count) % mat_count) + 1]

 

Is giving me a static number per instance of the object.

 

Lingwisyer_0-1679016652286.png

 

 

Ling.

 

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!