Posted By: jenGs
Copy part of a bitmap - 08/07/14 10:14
I need a simple postprocessing shader to copy a part of a bitmap. Note: The values in my example are all hardcoded for testing.
OK, this doesn't work right. The area copied is always too big. I don't get the problem.
Smoothstep should output 0.0 to 1.0 if ras is in the area the source should be copied to.
And so far it does that. it gives a perfect gradient at this position when multiplied with the color.
19.0 / 608.0 should give me the size of part of the source bitmap I want to copy (without offset for now) in 0.0 - 1.0 range.
fx * (...) should increase the area from 0 to the maximum.
Where is the error?
Code:
float inrange(in float2 values) { return values[0] > 0.0 && values[1] > 0.0 && values[0] < 1.0 && values[1] < 1.0; } float4 process_blit(in float2 vPos: VPOS): COLOR { float2 tex = (vPos.xy + 0.5) / vecViewPort.xy; float2 ras = (vPos.xy + 0.5); float4 color = 1; float fx = smoothstep(0.0, 19.0, ras.x); float fy = smoothstep(0.0, 22.0, ras.y); float px = fx * (19.0 / 608.0); // 608 is the width of the source bitmap float py = fy * (22.0 / 88.0); // 88 is the height of the source bitmap color = tex2D(smpSrc, float2(px, py)) * inrange(float2(fx, fy)); return color; }
OK, this doesn't work right. The area copied is always too big. I don't get the problem.
Smoothstep should output 0.0 to 1.0 if ras is in the area the source should be copied to.
And so far it does that. it gives a perfect gradient at this position when multiplied with the color.
19.0 / 608.0 should give me the size of part of the source bitmap I want to copy (without offset for now) in 0.0 - 1.0 range.
fx * (...) should increase the area from 0 to the maximum.
Where is the error?