Jump to content

  • Log In with Google      Sign In   
  • Create Account


3D scaling using sine based on time


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 kbenderoth89   Members   -  Reputation: 123

Like
0Likes
Like

Posted 03 June 2012 - 02:39 AM

So I'm trying to make my teapot scale properly when testing my HLSL shader effect.

currently I have this:


float4x4 scale = {(sin(gTime)*sin(gTime)),0,0,0,
0,sin(gTime)*sin(gTime),0,0,
0,0,sin(gTime)*sin(gTime),0,
0,0,0,1};
where gTime is the time elapsed since the program started.
Basically what I want it to do is scale from about 0.5 of its original state to 1.0 (the original size) constantly.
you could probably guess that what I currently have scales it from 1.0 to 0.0
is also tried using the absolute value and, well, it partially works, only the full scaling takes about 4 seconds and it takes 3 seconds before it moves
can anyone help me scale it smoothly from half its size to its full size using sin, cos, or tan?

Sponsor:

#2 RulerOfNothing   Members   -  Reputation: 1151

Like
1Likes
Like

Posted 03 June 2012 - 02:48 AM

sin^2(t) varies from 0 to 1, so to get a scaling factor that varies between 0.5 and 1 you need to have the scaling factor equal to 0.5+0.5*sin^2(t).

#3 jjd   Crossbones+   -  Reputation: 2068

Like
1Likes
Like

Posted 03 June 2012 - 06:22 AM

Keep in mind that squaring the sine function also doubles its frequency, and there is no need to actually square the sine because you can rescale and shift the unmodified sine function using (3 + sin(t)) / 4 to get a range of values between 0.5 and 1.0.

-Josh

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet


#4 kbenderoth89   Members   -  Reputation: 123

Like
0Likes
Like

Posted 03 June 2012 - 12:10 PM

Awesome it works and scales properly! Thanks a ton!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS