Jump to content
  • Advertisement
Sign in to follow this  
giugio

interpolation

This topic is 2426 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

hello.
I have a set of lines in dx9 and for each lines i would create two rectangles:
1 rectangle up
2 rectangle down

each rectangle must have a growing interpolated color :
from the line to the up of rectangle 1, and from the line to the bottom of rectangle 2
I think of do this with a shader :
my idea is to create two triangles for each rectangle and set the color of the upper vertexes to ColorA and the color of bottom vertexes to ColorB
then set UV coords and ... in the pixel shader i have a value of UV interpolated for each fragment, i'm wrong?
but how i can change parameters for my interpolation?
like the velocity of grow of the colors to go on the upper or bottom vertexes?
there are other parameters for the behaviour of the interpolation?

i must create values from 0 to 1, i can use a black/white color for the interpolation?
in this mode can i have a list of gray?each with a number from 0 to 1?

How i can create this shader for render the colors interpolated values?
thanks.

ps.i use cg shader or hlsl shader

Share this post


Link to post
Share on other sites
Advertisement
The interpolation parameter is always linear. However, you can use linearly interpolated parameters as input to a pixel shader, which can then run any other function based on said parameters (including custom color ramps or easing).

A common old-school method of remapping color ranges is to use a 1d color texture (a ramp) from which you look up with an input color value. In modern hardware, just calculating the remap function on the fly is likely faster, since the arithmetic is not as big a bottleneck as it used to be (as compared to shared memory access).

If you need more basic help with writing shaders in general, there are tons of tutorials on the 'net for that. DX SDK is a good place to start, and you'll find the complete HLSL documentation there as well.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!