Original Post
The math is beyond me right now, can anyone point me towards a working c function?
// Cubic smoothing, yields C1 continuous curve from 0..1float cubic(float r) { return r*r*(3.0-2.0*r); }float2 cubic(float2 r) { return r*r*(3.0-2.0*r); }float3 cubic(float3 r) { return r*r*(3.0-2.0*r); }float4 cubic(float4 r) { return r*r*(3.0-2.0*r); }float4 bicubic(sampler2D t, float2 coord) { int2 n = floor(coord); float2 r = fract(coord); float2 w = cubic(r); return lerp( lerp(tex2Dfetch(t, int2(n.x,n.y)), tex2Dfetch(t, int2(n.x+1,n.y)), w.x), lerp(tex2Dfetch(t, int2(n.x,n.y+1)), tex2Dfetch(t, int2(n.x+1,n.y+1)), w.x), w.y);Quote:
Original post by s_p_oneil
Cubic is the same as linear, but as you interpolate values in a line from 0 to 1, you apply a simple function to convert the line into a smooth curve. The cubic function in my Cg shaders looks like this:
Quote:
Original post by avocados
Oops, I meant bilinear interpolation doesn't work well. This project is not in a 3d API. I need to smoothly scale noise for some perlin noise in procedural textures.
Quote:
Original post by PolyVox
Don't want to drag this off topic as the OP seems to be looking for a CPU solution, but are you aware that in GPU Gems 2 there is an article (Chapter 20) on implementing cubic filtering in terms of linear filters? You can get it for free on the NVidia website. Also you might find this interesting:
Quote:
Original post by s_p_oneil Quote:
Original post by PolyVox
Don't want to drag this off topic as the OP seems to be looking for a CPU solution, but are you aware that in GPU Gems 2 there is an article (Chapter 20) on implementing cubic filtering in terms of linear filters? You can get it for free on the NVidia website. Also you might find this interesting:
Thanks for the tip, but I wrote chapter 16 of that book. NVidia sent me 6 copies of it. ;-)
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more