PDA

View Full Version : how control scaling with texture map


daredavil
01-24-2007, 06:47 AM
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

joconnell
01-24-2007, 10:37 AM
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/pflow/pflow__inherit_UV.htm

thatoneguy
01-25-2007, 09:29 PM
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.

thatoneguy
01-25-2007, 09:30 PM
From: http://forums.cgsociety.org/showthread.php?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
)

PsychoSilence
01-26-2007, 06:35 PM
nice script :)

i really should gamble around with it! :D

kind regards

anselm

daredavil
01-29-2007, 05:48 AM
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

daredavil
01-29-2007, 12:42 PM
hello

it's done ,
thank u all

can i take animated images sequence



cheer
nitesh

thatoneguy
01-29-2007, 04:33 PM
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!

daredavil
01-31-2007, 06:12 AM
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

mahmoudcg
02-07-2007, 03:51 PM
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?

mahmoudcg
02-07-2007, 04:24 PM
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

mahmoudcg
02-07-2007, 05:00 PM
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
)

mahmoudcg
02-07-2007, 05:04 PM
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

CGTalk Moderation
02-07-2007, 05:04 PM
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.