Skip to content

Bind ramp to control Opencl values

If we want to use ramp spare parameter to control values within opencl, first lets add ramp inside bindings tab. I am going to name mine 'control_ramp'

ramp binding
For this demonstration, I am going to drive ramp with pixel position which we can obtain simply by @P. We have to remember that in COPs pixel position is bound between -1 and 1, therefore we will have to normalize values first
(@P.x+1)/2

Now, having values between 0-1, if we want to sample ramp, first we need to declare new bind as a ramp

#bind ramp control_ramp float3 val=0

next, we can use bound ramp name @control_ramp like a function that accepts sample position

@control_ramp( (@P.x+1)/2 )

And that's it! we now, can remap image X by ramp spare parameter!

OpenCL
#bind layer !&dst float4

#bind ramp control_ramp float3 val=0

@KERNEL
{
    float4 out = (float4)(@control_ramp( (@P.x+1)/2 ), 1.0f);
    @dst.set( out );
}

ramp binding