how control scaling with texture map

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2007
how control scaling with texture map

hi

i am trying to control particle scaling with texture(black/white)
map . but i dnt know how to go for it .

Is there any way to attach particle scaling with texture map

please help me.


thanks in advance


nitesh
 
  01 January 2007
It sounds like the type of thing you would need to script or use pf tools box 3 for. If you want to try scripting it, here's a tutorial from bobo that lets you set the colour of a particle based on a texture map - you should be able to modify this a bit so that it converts the brightness of the colour into a scale value instead - http://www.scriptspot.com/bobo/mxs5..._inherit_UV.htm
 
  01 January 2007
In of itself I think bobo's script is insufficient. It doesn't actually aquire the RGB value of the texture. It needs an additional step which I'm not sure how to do: Read off RGB values from texture file "Name" at UV coordinate U.V. I'm guessing GetPixel and some UV scaling?

It's frustrating that all the source isn't available for Position Object, to see how it's officially supported... or that there isn't just a node by default which can feed out a value.

Last edited by thatoneguy : 01 January 2007 at 12:08 AM.
 
  01 January 2007
From: http://forums.cgsociety.org/showthr...p?f=98&t=249841
By: Mahmoudcg
Based on: Two of Bobo's scripts.


 
-- Particle Scale Based on Surface RGB --
-- Script mostly by Bobo --
-- and mahmoudcg --
-- tweaked by thatoneguy -- 
 
-- To Use: --
-- Create PF Source with a Position Object, Speed by Surface and Shape Operator --
-- Place Script Operator under Speed by Surface --
-- Make sure the object you use has a UVW mapped image in the diffuse in the proper material channel.  -- 
 
on ChannelsUsed pCont do
 (
 pCont.usePosition = true
 pCont.useScale = true
 pCont.useSpeed = true
 )
on Init pCont do 
 (
 global mapchannel = 1 -- Map Channel
 global emitter  = $Teapot01 -- Object Name
 global scalerv = .5
 global bmpfile = emitter.material.diffusemap.bitmap
 global xfactor = bmpfile.width
 global yfactor = bmpfile.height
 )
on Proceed pCont do 
 (
 count = pcont.numParticles()

 for i in 1 to count do
 (
 pcont.particleIndex=i
 if (pcont.particleAge==0) do
  (
  pvel = pcont.particleSpeed
  pos = pcont.particlePosition + pvel
  pray = ray pos -pvel
  arr = intersectRayEx emitter pray
  if(arr != undefined) then
   (
   tf = meshop.getmapface emitter mapchannel arr[2]
   tv1= meshop.getmapvert emitter mapchannel tf.x
   tv2= meshop.getmapvert emitter mapchannel tf.y
   tv3= meshop.getmapvert emitter mapchannel tf.z
   tv = tv1*arr[3].x + tv2*arr[3].y + tv3*arr[3].z
   if(tv.x >1)then
	(
	tv.x = tv.x-1
	)
   else if(tv.x<0)then
	(
	tv.x = tv.x+1
	)
   if(tv.y >1)then
	(
	tv.y = tv.y-1
	)
   else if(tv.y<0)then
	(
	tv.y = tv.y+1
	)
   co=getpixels bmpfile [tv.x*xfactor,(1-tv.y)*yfactor] 1
   pcont.particlescale = (co[1].r/255)+ scalerv
   )
  else
   (
   )
  )
 ) 
 )
on Release pCont do 
 (
 close bmpfile
 )
 

Last edited by thatoneguy : 01 January 2007 at 12:46 AM.
 
  01 January 2007
nice script

i really should gamble around with it!

kind regards

anselm
 
  01 January 2007
thank u all for helping me
-----------------
i tried this script in my scene but it gives me error.
it might my mistake also beacause i neverever play around with script editor.

pls can u show me or set dummy file to understand hw to use this script


thanks
nitesh

Last edited by daredavil : 01 January 2007 at 12:31 PM.
 
  01 January 2007
hello

it's done ,
thank u all

can i take animated images sequence



cheer
nitesh

Last edited by daredavil : 01 January 2007 at 02:29 PM.
 
  01 January 2007
Sorry I don't have time to work on an animated version. But, if you change:
if (pcont.particleAge==0) do

to
if (pcont.particleAge!=-1) do

it should be animatable.

Personally I'm still having some problems where it stops working on frame 0 :| sometimes it works perfectly, sometimes it just breaks. I wouldn't trust this script too much.

Edit: I just did a test where I got it to work. No problem. Added a UVW unwrap modifier. No problem. Applied a "UVW mapping clear" modifier. Applied another "UVW unwrap modifier" and it broke.. didn't work at all. So I deleted all of the stuff on top of the last working state of the stack. And it was still broken. So I removed everything in the stack. Reapplied a planar UVW map. Still broken. Removed the particles, recreated the particles. Still broken.

It's like you can do something where eventually it's permanently broken and the only way to fix it is to start over from scratch. I'm guessing it's somehow screwing up the map vertexes. But.. it still displays properly.

Help!

Last edited by thatoneguy : 01 January 2007 at 06:34 PM.
 
  01 January 2007
yes , it causing problame with uvw unwrap,but working properly on standerd geomatory like plane, box.

when i apply same script to my unwrap model it stop working & shows same particle scaling all over the mesh.

i am using only single grayscale frame in diffuse to control scaling

pls help me





thanks
nitesh

Last edited by daredavil : 01 January 2007 at 09:37 AM.
 
  02 February 2007
Originally Posted by thatoneguy: Sorry I don't have time to work on an animated version. But, if you change:
if (pcont.particleAge==0) do

to
if (pcont.particleAge!=-1) do

it should be animatable.

Personally I'm still having some problems where it stops working on frame 0 :| sometimes it works perfectly, sometimes it just breaks. I wouldn't trust this script too much.

Edit: I just did a test where I got it to work. No problem. Added a UVW unwrap modifier. No problem. Applied a "UVW mapping clear" modifier. Applied another "UVW unwrap modifier" and it broke.. didn't work at all. So I deleted all of the stuff on top of the last working state of the stack. And it was still broken. So I removed everything in the stack. Reapplied a planar UVW map. Still broken. Removed the particles, recreated the particles. Still broken.

It's like you can do something where eventually it's permanently broken and the only way to fix it is to start over from scratch. I'm guessing it's somehow screwing up the map vertexes. But.. it still displays properly.

Help!


thats weird. i just repeated your steps and its working just fine
i'm using 3ds max 7, which version are you using?
__________________
www.mahmoudghali.com
http://twitter.com/m_ghali
Mahmoud Ghali
 
  02 February 2007
ok i found the error
when added, the uvw clear mod deallocates the map face array and the script causes a runtime error and is no more evaluated
on max 7 it is reevaluated when adding or removing new uvw modifiers so it just works when u setup your uvs. although it throws an error on adding the uvwclear mod
on max 8 it stops bein reevaluated no matter what. u have to go and evaluate the script operator manualy

i'll fix it and post
__________________
www.mahmoudghali.com
http://twitter.com/m_ghali
Mahmoud Ghali
 
  02 February 2007
now it worx fine, if no face map array exists the script operator does nothing, so it worx after a uvwclear mod
also cleaned it a bit


-- Particle Scale Based on Surface RGB --
-- Script mostly by Bobo --
-- and mahmoudcg --
-- tweaked by thatoneguy -- 
 
-- To Use: --
-- Create PF Source with a Position Object, Speed by Surface and Shape Operator --
-- Place Script Operator under Speed by Surface --
-- Make sure the object you use has a UVW mapped image in the diffuse in the proper material channel.  --

on ChannelsUsed pCont do
 (
	 pCont.usePosition = true
	 pCont.useScale = true
	 pCont.useSpeed = true
 )
on Init pCont do 
 (
	 global mapchannel = 1 -- Map Channel
	 global emitter  = $Box01 -- Object Name
	 global scalerv = .5
	 global bmpfile = emitter.material.diffusemap.bitmap
	 global xfactor = bmpfile.width
	 global yfactor = bmpfile.height
 )
on Proceed pCont do 
 (
	 count = pcont.numParticles()

	 for i in 1 to count do
	 (
		 pcont.particleIndex=i
		 if (pcont.particleAge==0) do
		  (
			  pvel = pcont.particleSpeed
			  pos = pcont.particlePosition + pvel
			  pray = ray pos -pvel
			  arr = intersectRayEx emitter pray
			  if(arr != undefined and meshop.getMapSupport emitter mapchannel) then
			   (
				   tf = meshop.getmapface emitter mapchannel arr[2]
				   tv1= meshop.getmapvert emitter mapchannel tf.x
				   tv2= meshop.getmapvert emitter mapchannel tf.y
				  tv3= meshop.getmapvert emitter mapchannel tf.z
				   tv = tv1*arr[3].x + tv2*arr[3].y + tv3*arr[3].z

				tv.x = mod (tv.x + 1) 1
				tv.y = mod (tv.y + 1) 1
	
				   co=getpixels bmpfile [tv.x*xfactor,(1-tv.y)*yfactor] 1
				   pcont.particlescale = (co[1].r/255)+ scalerv
			   )
		  )
	 ) 
 )
on Release pCont do 
 (
 close bmpfile
 )
__________________
www.mahmoudghali.com
http://twitter.com/m_ghali
Mahmoud Ghali
 
  02 February 2007
Originally Posted by daredavil: yes , it causing problame with uvw unwrap,but working properly on standerd geomatory like plane, box.

when i apply same script to my unwrap model it stop working & shows same particle scaling all over the mesh.

i am using only single grayscale frame in diffuse to control scaling

pls help me





thanks
nitesh


can you state your procedures in steps plz
__________________
www.mahmoudghali.com
http://twitter.com/m_ghali
Mahmoud Ghali
 
  02 February 2007
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:20 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.