Jump to content
  • Advertisement
Sign in to follow this  
kbenderoth89

3D scaling using sine based on time

This topic is 2384 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!