Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   Displacement based on an expression? (https://simplymaya.com/forum/showthread.php?t=8857)

Dann 09-11-2003 12:54 AM

Displacement based on an expression?
 
1 Attachment(s)
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?

Dann 12-11-2003 07:18 PM

Did I stump you all?

Alan 17-11-2003 02:01 PM

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.... :)

Dann 17-11-2003 11:08 PM

not sure I understand what you're saying?

Alan 01-12-2003 09:00 PM

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?

misterdi 03-12-2003 08:51 AM

1 Attachment(s)
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.

misterdi 03-12-2003 09:00 AM

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.


All times are GMT. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018