[MPlayer-dev-eng] gl & distorted fisheye for dome projection

Johannes Gajdosik johannes.gajdosik at gmx.at
Mon Jul 3 23:57:42 CEST 2006


Hello,

> Please give the full output (maybe also use -v).

-v was very useful: The error message was directly leading me to the
fact that I must specify the full path to the fragment program.

Now the distortion works fine for me, I use the following fragment program:

-------------distort.fp-----------------
!!ARBfp1.0
# distort.fp, Author and Copyright Johannes Gajdosik, 2006
# Licensed under the GNU GPL v2
# Many thanks to the kind assistance of Reimar Döffinger.
# This program distorts the image according to an index-texture.
# The r/g-values of this texture give the x/y position that is used
# for lookup in the image texture.
# The b-value is used for brightness reduction: maximum value means no
# brightness reduction, 0 means reduction to black.
# The index texture is divided into an upper half and a lower half.
# The upper half gives the high-byte of the x/y/brightness values,
# the lower half gives the low-byte.
# (8 bit accuracy is not enough and leads to pixelization-effects)
# Usage: mplayer -vo gl:yuv=2:customprog=/full-path/distort.fp:customtex=/full-path/index.ppm

TEMP tmp, y, u, v, pos;
# lookup the position/brightness in the index texture
# at 2 positions in order to get 16bit accuracy instead of just 8

MUL tmp, fragment.texcoord[0], {1.0, 0.5, 1.0, 0};
TEX pos, tmp, texture[3], 2D;
ADD tmp, tmp, {0.0,0.5,0.0,0};
TEX tmp, tmp, texture[3], 2D;
MAD pos, tmp, {0.00390625,0.00390625,0.00390625, 0}, pos;
# maximum value must be 1.0:
MUL pos, pos, {0.99610894941,0.99610894941,0.99610894941, 0};

# now do the normal YUV -> RGB conversion for point at position pos,
# this part is derived from edgdetect.fp by Reimar Döffinger
TEX y, pos, texture[0], 2D;
MAD tmp, y, {1.164, 1.164, 1.164, 0}, {-0.87416, 0.53133, -1.08599, 0};
TEX u, pos, texture[1], 2D;
MAD tmp, u, {0, -0.391, 2.018, 0}, tmp;
TEX v, pos, texture[2], 2D;
MAD tmp, v, {1.596, -0.813, 0, 0}, tmp;
# scale by brightness = pos.zzzz
MUL result.color, pos.zzzz, tmp;
END
-------------end of distort.fp-----------------

I want to ask you of about the following points:

1) 8 bit accuracy for x/y-coordinate lookup is not enough,
but leads to block artefacts. I have made a workaround by
using the lower half of the index texture for another 8 bit of accuracy
(the lower byte). This works quite fine, but it requires,
that fragment.texcoord[0] points exactly to one pixel in the texture,
no interpolation. Then also pos will point exactly to 1 pixel in the
index-texture, which typically has size 1024x2048.


> >   # move brightness-adjusted res into result
> >   MUL result.color, brightness, res
> You can do that, though it needs 3 multiplications - doing before the
> conversion
> MUL yuv.r, yuv, trans_coor.bbbb;
> should do the same at the cost of only one multiplication.

2) I am not so sure about the cost of multiplication and swizzling.
In SSE(2) multiplication is done in parallel, so 4 multiplications
cost the same as just one multiplication. But swizzling for the destination
operand would require expensive masking and OR. Therefore I tried to avoid
swizzling in the destination operand.

Thanks again, I will try to use this technique for stellarium, too.
Together with render-to-texture it should give top performance and
high quality distortion.

Yours,
Johannes Gajdosik



More information about the MPlayer-dev-eng mailing list