I am writing a filter with OBS-Shaderfilter to remap an image/video. The filter creates its output by sampling a texture image and uses Red/Green values as new co-ordinates to sample the input). I've seen this called UV mapping or ST mapping.
It works OK with an 8 bit RG texture image, but then I am limited to 256x256 pixel sampling fidelity.
I cant get it to work for 16 bit RG colour texture image which would open up some powerful image / video transformations.
Is it possible to sample 16 bit RG values ?
--------------------------------------------------------------------
Below my filter code and texture creation method
- I want to sample remap_texture 16 bit RG values...
uniform texture2d remap_texture <string label = "remap_texture";>;
float4 mainImage(VertData v_in) : TARGET
{
float2 uvmap = remap_texture.Sample(textureSampler, v_in.uv);
return image.Sample(textureSampler, uvmap);
}
Test texture generation (identity or 1 to 1 mapping so expect output = input)
Generate an identity test texture 256x256 -> texture_8bit.png
ffmpeg -f lavfi -i nullsrc=size=256x256 -vf format=gray8,geq='X' -frames 1 -y xmap.pgm
ffmpeg -f lavfi -i nullsrc=size=256x256 -vf format=gray8,geq='Y' -frames 1 -y ymap.pgm
magick convert xmap.pgm ymap.pgm -background black -channel RG -combine texture_8bit.png
Generate an identity test texture 1080x1080 -> texture_16bit.png
ffmpeg -f lavfi -i nullsrc=size=1080x1080 -vf format=gray16,geq='X' -frames 1 -y xmap.pgm
ffmpeg -f lavfi -i nullsrc=size=1080x1080 -vf format=gray16,geq='Y' -frames 1 -y ymap.pgm
magick convert xmap.pgm ymap.pgm -background black -channel RG -combine texture_16bit.png
It works OK with an 8 bit RG texture image, but then I am limited to 256x256 pixel sampling fidelity.
I cant get it to work for 16 bit RG colour texture image which would open up some powerful image / video transformations.
Is it possible to sample 16 bit RG values ?
--------------------------------------------------------------------
Below my filter code and texture creation method
- I want to sample remap_texture 16 bit RG values...
uniform texture2d remap_texture <string label = "remap_texture";>;
float4 mainImage(VertData v_in) : TARGET
{
float2 uvmap = remap_texture.Sample(textureSampler, v_in.uv);
return image.Sample(textureSampler, uvmap);
}
Test texture generation (identity or 1 to 1 mapping so expect output = input)
Generate an identity test texture 256x256 -> texture_8bit.png
ffmpeg -f lavfi -i nullsrc=size=256x256 -vf format=gray8,geq='X' -frames 1 -y xmap.pgm
ffmpeg -f lavfi -i nullsrc=size=256x256 -vf format=gray8,geq='Y' -frames 1 -y ymap.pgm
magick convert xmap.pgm ymap.pgm -background black -channel RG -combine texture_8bit.png
Generate an identity test texture 1080x1080 -> texture_16bit.png
ffmpeg -f lavfi -i nullsrc=size=1080x1080 -vf format=gray16,geq='X' -frames 1 -y xmap.pgm
ffmpeg -f lavfi -i nullsrc=size=1080x1080 -vf format=gray16,geq='Y' -frames 1 -y ymap.pgm
magick convert xmap.pgm ymap.pgm -background black -channel RG -combine texture_16bit.png