SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / Displacement based on an expression?
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 08-11-2003, 11:54 PM   #1
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Question Displacement based on an expression?

Does anyone know if it's possible to use an expression to control a displacement? Basically I'm trying to create a sine wave displacement, but I cannot use the Sine or Wave deformers because the displacment has to wrap around a sphere and those deformers only work linearly.

I started doing a displacment based on a ramp and got something that looks like the image below. Notice though that my waves are a bit too linear, and not round enough. So I thought I'd write a sine wave, but I can't seem to get it to work. My expression was

int $height = 10
int $freq = 4;

multiplyDivide1.input1Y = $height * sin( $freq * time );

While the object over time does move in a sine wave like function, it did not create waves like what I want.
Anyone have any thoughts on this one?
Attached Thumbnails
Click image for larger version

Name:	wave.jpg
Views:	89
Size:	15.7 KB
ID:	11467  
Dann is offline   Reply With Quote
Old 12-11-2003, 06:18 PM   #2
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Did I stump you all?
Dann is offline   Reply With Quote
Old 17-11-2003, 01:01 PM   #3
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

why dont you vary the frequency and the height variables (using noise or whatever) to adjust the linearity of the waves...? seems the most logical thing to do....
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 17-11-2003, 10:08 PM   #4
Dann
Registered User
 
Dann's Avatar
 
Join Date: Feb 2003
Location: Los Angeles
Posts: 695
Thanks: 0
Thanked 2 Times in 2 Posts
Default

not sure I understand what you're saying?
Dann is offline   Reply With Quote
Old 01-12-2003, 08:00 PM   #5
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

use some sort of a varying value to adjust the height of the waves so that you dont end up with all the waves at the same height. Isn't that what you wanted to do?
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 03-12-2003, 07:51 AM   #6
misterdi
Registered User
 
Join Date: Sep 2002
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
$height * sin( $freq * time )
I don't think "time" is appropriate in this case, as you said your object will be displaced with same amount of value in time, you won't get wave kind displacement.

I got an idea.

Basically I'm using the place2dTexture to drive the sine function.
I create 2 ramp texture, one is for the sine and the other one for envelope.

sine_ramp:
only a single entry, color white. Expression is hooked up in alphaGain.
Expression is:
Quote:
sine_ramp.alphaGain = sin(place2dTexture1.vCoord * 10.0 * 3.14);
The 3.14 value, my teacher said is approximately a PI constant. So in this case the total wave it's about 5 complete sine wave (1 cycle should be 2 * PI).

envelope_ramp:
3 entry, loc 0, 0.5, 1.0 : color black, white, black : interpolation smooth.
Outalpha from sine_ramp is mapped to alphaGain of envelope_ramp.
The usage of this envelope is to do ease in and ease out of sine_ramp.

Outalpha from this envelope_ramp is mapped to displacement of displacementShader, and as usual displacement from displacementShader is connected to the ShadingGroup displacement.

Create a simple NURBS plane (3 x 3) and apply the shader to it.
Render it and see whether you like it or not. You could adjust the color value in envelope_ramp to reduce the amplitude.

For animation, I think you need to tweak a bit the expression to introduce "time" back in expression. Maybe if you do
Quote:
sine_ramp.alphaGain = sin((place2dTexture1.vCoord + (time/50)) * 10.0 * 3.14);
you will get some animation of the wave.

This is just an idea, I don't know how it will work in your case.
Attached Thumbnails
Click image for larger version

Name:	scrshot.jpg
Views:	64
Size:	34.2 KB
ID:	11904  
misterdi is offline   Reply With Quote
Old 03-12-2003, 08:00 AM   #7
misterdi
Registered User
 
Join Date: Sep 2002
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually if you don't need an exact sine function you could do also using simple ramp for the sine with 3 entry black, white, black and set interpolation to smooth.

On the 2d placement, set V repeat to 5.

The rest could be the same, maybe you want to add more entry to the envelope so it has some variance to the envelope value maybe a U and V wave will have some interesting effect too.

Maybe I'm too lazy to setup ramp with so many entries, that's why I'm so useless.
misterdi is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

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

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.