random rotation texture tiles

General discussion about Indigo Materials - material requests, material developement, feedback, etc..
User avatar
CADMonkey
Posts: 22
Joined: Thu Sep 09, 2010 9:45 pm
Location: West Yorkshire

random rotation texture tiles

Post by CADMonkey » Tue Jan 08, 2013 11:35 pm

Is there a function in skindigo to randomly rotate a texture at point of render?

I'm working on a large tiled floor area. They use the same patterned tile throughout but they are laid with a random rotation.

I can aproxuimate the effect by ganging up several tiles in a texture image but when I do a high arial view you can see the repeat and the file is obviously just massive.

Is there a function to do this within Indigo? Is it a Shader function?

Also I assume truely random would be a bad idea? Would that mean the tiles could change orientation from render to render?

Below is a diagram of the effect I am looking to achieve: Tiles with any rotation just repeating across a floor
Attachments
random-rotation.png
random-rotation.png (3.68 KiB) Viewed 7239 times

User avatar
Zom-B
1st Place 100
Posts: 4700
Joined: Tue Jul 04, 2006 4:18 pm
Location: ´'`\_(ò_Ó)_/´'`
Contact:

Re: random rotation texture tiles

Post by Zom-B » Tue Jan 08, 2013 11:56 pm

Adding a functionality to define X textures to use from in the tiling and I'm happy too :)
polygonmanufaktur.de

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: random rotation texture tiles

Post by OnoSendai » Wed Jan 09, 2013 12:08 am

Should be pretty easy to do in ISL at least :)

StompinTom
Indigo 100
Posts: 1828
Joined: Mon Sep 04, 2006 3:33 pm

Re: random rotation texture tiles

Post by StompinTom » Wed Jan 09, 2013 12:22 am

OnoSendai wrote:Should be pretty easy to do in ISL at least :)
Ah that'd be amazing for tiles / floorboards / bricks. A kind of MultiTexture for Indigo.

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: random rotation texture tiles

Post by OnoSendai » Wed Jan 09, 2013 1:18 am

Here's a first crack at it.
Randomly selects from 3 textures, with a random orientation for each texture.

Shader looks like so (may have bugs!)

Code: Select all

 def rotate(real r, vec2 st) vec2:
              let 
                s = x(st)
                t = y(st)  
              in
                if(r < 0.5,
                  if(r < 0.25,
                      vec2(s, t),
                      vec2(t, -s)
                  ),
                  if(r < 0.75,
                    vec2(-s, -t),
                    vec2(-t, s)
                  )
                )
              
            def eval(vec3 pos) vec3 :
              let
                uv = getTexCoords(0)
                st = rotate(gridNoise(uv), uv)
                NUM_TEXTURES = 3
                tex_index = floorToInt(gridNoise(vec2(x(uv) + 45655.0, y(uv) + 3257.0)) * real(NUM_TEXTURES))
              in
                sample2DTextureVec3(tex_index, st)
Attachments
random_tiling_texture_test.pigs
(299.85 KiB) Downloaded 316 times
random_tiling_texture_test.jpg

User avatar
Zom-B
1st Place 100
Posts: 4700
Joined: Tue Jul 04, 2006 4:18 pm
Location: ´'`\_(ò_Ó)_/´'`
Contact:

Re: random rotation texture tiles

Post by Zom-B » Wed Jan 09, 2013 1:57 am

Damn that was quick :D

Will have a deeper look into it soon!
Thanks a lot Ono!!!
polygonmanufaktur.de

User avatar
CADMonkey
Posts: 22
Joined: Thu Sep 09, 2010 9:45 pm
Location: West Yorkshire

Re: random rotation texture tiles

Post by CADMonkey » Wed Jan 09, 2013 3:15 am

Amazing!

Thank you so Much

User avatar
snorky
Indigo 100
Posts: 331
Joined: Fri Apr 17, 2009 8:54 pm
Location: Parma, Italy

Re: random rotation texture tiles

Post by snorky » Wed Jan 09, 2013 3:48 am

:?: and mirroring function?

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: random rotation texture tiles

Post by OnoSendai » Wed Jan 09, 2013 6:37 am

snorky wrote::?: and mirroring function?
Mirroring is easy to add if needed.

StompinTom
Indigo 100
Posts: 1828
Joined: Mon Sep 04, 2006 3:33 pm

Re: random rotation texture tiles

Post by StompinTom » Wed Jan 09, 2013 12:24 pm

OnoSendai wrote:Here's a first crack at it.
Randomly selects from 3 textures, with a random orientation for each texture.

Shader looks like so (may have bugs!)

Code: Select all

 def rotate(real r, vec2 st) vec2:
              let 
                s = x(st)
                t = y(st)  
              in
                if(r < 0.5,
                  if(r < 0.25,
                      vec2(s, t),
                      vec2(t, -s)
                  ),
                  if(r < 0.75,
                    vec2(-s, -t),
                    vec2(-t, s)
                  )
                )
              
            def eval(vec3 pos) vec3 :
              let
                uv = getTexCoords(0)
                st = rotate(gridNoise(uv), uv)
                NUM_TEXTURES = 3
                tex_index = floorToInt(gridNoise(vec2(x(uv) + 45655.0, y(uv) + 3257.0)) * real(NUM_TEXTURES))
              in
                sample2DTextureVec3(tex_index, st)
Awesome!

User avatar
CADMonkey
Posts: 22
Joined: Thu Sep 09, 2010 9:45 pm
Location: West Yorkshire

Re: random rotation texture tiles

Post by CADMonkey » Thu Jan 10, 2013 6:23 am

Hi Folks...

Thanks so much what the ffort above... It does exactly what I would like to do.

However:


When I try to use the shader above I just get a black face... I assume its becuase it can't find the texures?


I'm using sketchup and relatively new to Indigo. Could someone give me a clue as how to apply several textures to a material please.
Attachments
screen.png

User avatar
Zom-B
1st Place 100
Posts: 4700
Joined: Tue Jul 04, 2006 4:18 pm
Location: ´'`\_(ò_Ó)_/´'`
Contact:

Re: random rotation texture tiles

Post by Zom-B » Thu Jan 10, 2013 6:41 am

The code above isn't the full shader to copy & paste that way!
There are also texture definitions inside the igs file.

best to open the pigs above in Indigo, pick the material and save it as a separate file to analyze it.
Afaik Exporters aren't capable of importing/exporting multiple textures atm!

Ono, is there a Exporter friendly way of defining the textures directly in the Shader?

Code: Select all

<scenedata>
	<material>
		<uid>5</uid>
		<name>mat1</name>
		<diffuse>
			<texture>
				<path>C:\Users\Zom-B\AppData\Local\Temp\indigo_temp_dir\indigo_temp_dir_1357756186\PACKED_1_ColorChecker_sRGB_from_Ref_lzw.tiff</path>
				<a>-0</a>
				<b>1</b>
				<c>-0</c>
				<uv_set_index>0</uv_set_index>
				<exponent>2.2</exponent>
				<tex_coord_generation>
					<uv>
						<matrix>1 0 0 1</matrix>
						<translation>0 -0</translation>
					</uv>
				</tex_coord_generation>
				<smooth>false</smooth>
			</texture>
			<texture>
				<path>C:\Users\Zom-B\AppData\Local\Temp\indigo_temp_dir\indigo_temp_dir_1357756186\PACKED_2_indigo_logo.png</path>
				<a>-0</a>
				<b>1</b>
				<c>-0</c>
				<uv_set_index>0</uv_set_index>
				<exponent>2.2</exponent>
				<tex_coord_generation>
					<uv>
						<matrix>1 0 0 1</matrix>
						<translation>0 -0</translation>
					</uv>
				</tex_coord_generation>
				<smooth>false</smooth>
			</texture>
			<texture>
				<path>C:\Users\Zom-B\AppData\Local\Temp\indigo_temp_dir\indigo_temp_dir_1357756186\PACKED_3_UV_mapper.jpg</path>
				<a>-0</a>
				<b>1</b>
				<c>-0</c>
				<uv_set_index>0</uv_set_index>
				<exponent>2.2</exponent>
				<tex_coord_generation>
					<uv>
						<matrix>1 0 0 1</matrix>
						<translation>0 -0</translation>
					</uv>
				</tex_coord_generation>
				<smooth>false</smooth>
			</texture>
			<albedo>
				<shader>
						<shader><![CDATA[  
            
            def rotate(real r, vec2 st) vec2:
              let 
                s = x(st)
                t = y(st)  
              in
                if(r < 0.5,
                  if(r < 0.25,
                      vec2(s, t),
                      vec2(t, -s)
                  ),
                  if(r < 0.75,
                    vec2(-s, -t),
                    vec2(-t, s)
                  )
                )
              
            def eval(vec3 pos) vec3 :
              let
                uv = getTexCoords(0)
                st = rotate(gridNoise(uv), uv)
                NUM_TEXTURES = 3
                tex_index = floorToInt(gridNoise(vec2(x(uv) + 45655.0, y(uv) + 3257.0)) * real(NUM_TEXTURES))
              in
                sample2DTextureVec3(tex_index, st)
            ]]></shader>
				</shader>
			</albedo>
			<random_triangle_colours>false</random_triangle_colours>
			<layer>0</layer>
		</diffuse>
	</material>
</scenedata>
polygonmanufaktur.de

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: random rotation texture tiles

Post by OnoSendai » Thu Jan 10, 2013 6:42 am

Zom-B wrote: Ono, is there a Exporter friendly way of defining the textures directly in the Shader?
Not currently.

User avatar
Zom-B
1st Place 100
Posts: 4700
Joined: Tue Jul 04, 2006 4:18 pm
Location: ´'`\_(ò_Ó)_/´'`
Contact:

Re: random rotation texture tiles

Post by Zom-B » Thu Jan 10, 2013 6:48 am

Setting some Variables that define maps and use them later on in the Shader would be useful.
Keeping stuff in the Shader would raise compatibility to Exporters, and ISL coding easier for n00bs like me ^^
polygonmanufaktur.de

User avatar
OnoSendai
Developer
Posts: 6241
Joined: Sat May 20, 2006 6:16 pm
Location: Wellington, NZ
Contact:

Re: random rotation texture tiles

Post by OnoSendai » Mon May 27, 2013 6:35 am

I uploaded a material using this random texture selection approach:
http://www.indigorenderer.com/materials/materials/1182

You can replace the textures used with your own textures to make it work for ceramic tiles etc..

Post Reply
17 posts

Who is online

Users browsing this forum: No registered users and 28 guests