Texture instancing?

Discussions about SOFTIMAGEs© Interactive Creative Environment©
User avatar
Kerro Perro
Posts: 306
Joined: 20 Mar 2011, 00:01
Location: Leiden, the Netherlands

Texture instancing?

Post by Kerro Perro » 07 Apr 2012, 14:58

Hi guys i'm looking for a way to automate "texture bombing" along a grid, what i wan't seems pretty basic: get multiple textures that form a pattern randomly distributed along a grid (point could). Texture wise it would be derived from this technique: http://www.digitalartform.com/archives/ ... ze_in.html This works great for getting "greebled" maps but it has the drawback that it needs a set size for the surface and the set-up can't be automated. (you can make a few actions in PS to speed things up but it still requires a lot of setup to get a different pattern each time)

So what i would like to do is a 2d/texture version of this:
Capture.PNG
Its just some geometry of pipes that form a "maze" instanced on a grid point cloud, simple right? But i don't know how to do this with textures.. the closest thing i could find was this http://caffeineabuse.blogspot.com/2011/ ... g-ice.html - that would work if just set the sprites to emit on a grid but ideally i would like to able to bake the "mazes" on objects for further shading/texturing..

Now i saw Paul Smith working with textures in ICE http://vimeo.com/groups/ice/videos/33908339 but unfortunately i can only catch the merest glimpse of his ICE tree so i have no idea how he's doing it :-l

Can anybody tell me how to get textures "instanced"??

Btw i also tried to get this effect using Enhance XSI nodes in the render tree but no joy, if anybody has a non-ICE solution that would be great too!

Thanks in advance! (%)
You do not have the required permissions to view the files attached to this post.

User avatar
rray
Moderator
Posts: 1810
Joined: 26 Sep 2009, 13:51
Location: Bonn, Germany

Re: Texture instancing?

Post by rray » 07 Apr 2012, 15:43

I think what Paul does is, he creates a point cloud with Helge's "Pixel-particles" addon (which creates a particle for each texture pixel), and from these particles looks up closest particles in a second point cloud which consists of randomly distributed particles.

I assume he then samples a texture using a random rotation and offset. The key is that these two random values are unique to the looked-up particle, probably he simply plugged their IDs into the random seed value of the randomize nodes.

By setting that color on the pixel particles, the texture is being created "on thy fly".
(Just a guess!)
softimage resources section updated Sep 26th 2026

User avatar
Kerro Perro
Posts: 306
Joined: 20 Mar 2011, 00:01
Location: Leiden, the Netherlands

Re: Texture instancing?

Post by Kerro Perro » 07 Apr 2012, 17:35

Hmm okay so i'll try out the pixel particles addon - i see from the vimeo introduction that it can be used to bake textures based an particle info, i'm hoping that maybe if i combine that with the sprites method perhaps i can bake in many randomized textures placed evenly...

- i hope i'm not sounding really stupid here, i have no idea if that's a workable solution...

User avatar
Kerro Perro
Posts: 306
Joined: 20 Mar 2011, 00:01
Location: Leiden, the Netherlands

Re: Texture instancing?

Post by Kerro Perro » 07 Apr 2012, 17:50

PS: i found the addon on your site but do you know where i could get the sample scenes i see in the video? They would probably help me out ;)

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: Texture instancing?

Post by Hirazi Blue » 07 Apr 2012, 18:16

The Sample Scenes were only included with the very first incarnation of the plugin AFAIK (the one named "sixbirds_pixelparticles.2010_SP1_1.0.xsiaddon", but you'd still have to manually change some compounds to get them to work with the new version. I'll send you a PM with a download link...
;)
Stay safe, sane & healthy!

User avatar
rray
Moderator
Posts: 1810
Joined: 26 Sep 2009, 13:51
Location: Bonn, Germany

Re: Texture instancing?

Post by rray » 07 Apr 2012, 19:10

Second thoughts... using pixel particles for this is probably double overkill.

Probably easiest and also scriptable is using the "UV Mapping Per Face" addon.

If you put all your textures in 1 big tiled image, you could modify the script so that it doesn't assign the whole 0,0-1,1 range to each face but a random smaller tile.
softimage resources section updated Sep 26th 2026

User avatar
Kerro Perro
Posts: 306
Joined: 20 Mar 2011, 00:01
Location: Leiden, the Netherlands

Re: Texture instancing?

Post by Kerro Perro » 07 Apr 2012, 19:48

Ai that sounds very sensible but where i can work a little with ICE and look at an ICE tree to see how it works i don't know any python at all... Looking at the script i have no idea where it's asigning the texture space...

I have to think about this... not sure what would be more hassle: doing it in a roundabout ICE way or taking a crash course in pyhon...

EDIT: what am i saying? I'll keep trying in ICE because i really don't know any python. Too bad though :(
Last edited by Kerro Perro on 07 Apr 2012, 19:55, edited 1 time in total.

User avatar
rray
Moderator
Posts: 1810
Joined: 26 Sep 2009, 13:51
Location: Bonn, Germany

Re: Texture instancing?

Post by rray » 07 Apr 2012, 19:55

simplest solution follows :D
edit ntiles in top area.. use 3.0 for 9 tiles, 4.0 for 16 tiles etc...

(* script is a documentation sample that Piotrek Marczak made into a working script, I only did the scrambling part)

Code: Select all

from win32com.client import constants as c
import random
x = Application
sel = x.Selection
true = 1
false = 0
ntiles = 5.0
null = None

def FindUVCluster(in_obj, in_Name):
	oClusters = in_obj.ActivePrimitive.Geometry.Clusters.Filter("Sample")
	for oCluster in oClusters:
		oProps = oCluster.Properties.Filter("uvspace")
		for oProp in oProps:
			if (oProp.Name == in_Name):
				return oProp
	print "Cluster not found"
	return null
	
def SetUVsPerFace(in_obj, in_uvprop):
	oProgressBar = XSIUIToolkit.ProgressBar
	oUVElements = in_uvprop.Elements
	oCluster = in_uvprop.Parent
	count = oUVElements.Count
	tup = oUVElements.Array
	#tuple to list - wtf...
	elArray = [1-tup[j][i] for i in range(len(tup[0])) for j in range(len(tup))]
	#zeroout uvs
	for i in range(len(elArray)):
		elArray[i] = 0  
	
	oFacets = in_obj.ActivePrimitive.Geometry.Facets
	#progressbar init
	oProgressBar.Maximum = oFacets.Count
	oProgressBar.Step = 1
	oProgressBar.Caption = "Creating UVs"
	oProgressBar.CancelEnabled = true
	oProgressBar.Visible = true
	for ofacet in oFacets:    
		oSamples = ofacet.Samples
		cntSamples = oSamples.Count
		sample0cidx = oCluster.FindIndex(oSamples(0).Index)
		sample1cidx = oCluster.FindIndex(oSamples(1).Index)
		sample2cidx = oCluster.FindIndex(oSamples(2).Index)	
		XOFF = random.randint(1,ntiles)/ntiles
		YOFF = random.randint(1,ntiles)/ntiles
		elArray[sample0cidx*3] = XOFF - 1.0/ntiles
		elArray[sample0cidx*3+1] = YOFF - 1.0/ntiles
		elArray[sample1cidx*3] = XOFF
		elArray[sample1cidx*3+1] = YOFF - 1.0/ntiles
		elArray[sample2cidx*3] = XOFF
		elArray[sample2cidx*3+1] = YOFF
		if (cntSamples >=4):
			sample3cidx = oCluster.FindIndex(oSamples(2).Index)
			elArray[oSamples(3).Index*3] = XOFF - 1.0/ntiles
			elArray[oSamples(3).Index*3+1] = YOFF
		oProgressBar.Increment()
		if oProgressBar.CancelPressed == true:
			break
	oUVElements.Array = elArray
	oProgressBar.Visible = false
	return true
	
#main
for s in sel:
	
	if s.type != "polymsh": 
		print "Select poly mesh"
	else:
		oGeo = s.Activeprimitive.Geometry
		prjName = "PerFaceUVs"
		print "Setting Uvs on " + s.FullName
		rtn = x.CreateProjection(s.FullName, "", "","", prjName,true)
		cluster = FindUVCluster(s, rtn[1])
		SetUVsPerFace(s, cluster)
	
softimage resources section updated Sep 26th 2026

User avatar
Kerro Perro
Posts: 306
Joined: 20 Mar 2011, 00:01
Location: Leiden, the Netherlands

Re: Texture instancing?

Post by Kerro Perro » 07 Apr 2012, 19:57

Haha wow that was insanely fast! Ignore my edit i made on my last comment i guess! ;)

User avatar
rray
Moderator
Posts: 1810
Joined: 26 Sep 2009, 13:51
Location: Bonn, Germany

Re: Texture instancing?

Post by rray » 07 Apr 2012, 20:00

If you want random rotation for the tiles, do a subdivide polys on the grid - this will scramble the UVs.
softimage resources section updated Sep 26th 2026

User avatar
Kerro Perro
Posts: 306
Joined: 20 Mar 2011, 00:01
Location: Leiden, the Netherlands

Re: Texture instancing?

Post by Kerro Perro » 07 Apr 2012, 20:13

Dude that works perfectly!! You've just figured out something i've been struggling with for days! ^:)^ ^:)^ Thanks!!

User avatar
rray
Moderator
Posts: 1810
Joined: 26 Sep 2009, 13:51
Location: Bonn, Germany

Re: Texture instancing?

Post by rray » 07 Apr 2012, 21:29

hey great
you're welcome !


(btw to make a texture out of this, just create another flat projection on the grid and rendermap that.)
softimage resources section updated Sep 26th 2026

Pooby
Posts: 501
Joined: 27 Aug 2010, 20:25

Re: Texture instancing?

Post by Pooby » 07 Apr 2012, 22:02

Just for the record, Rray was pretty spot on with the detective work on my texture instancing method.
I keep meaning to do a tutorial on it.

User avatar
Kerro Perro
Posts: 306
Joined: 20 Mar 2011, 00:01
Location: Leiden, the Netherlands

Re: Texture instancing?

Post by Kerro Perro » 07 Apr 2012, 22:07

Ah you must be Paul! Recovered from the sniffles? ;)