POV-Ray : Newsgroups : povray.advanced-users : Pixel position from 3D coordinates : Re: Pixel position from 3D coordinates Server Time
3 Jul 2024 04:33:25 EDT (-0400)
  Re: Pixel position from 3D coordinates  
From: Mark Weyer
Date: 24 Sep 2008 11:45:00
Message: <web.48da5f7e3cca20e6fddaa4670@news.povray.org>
> To generate the game piece graphics, I generate full-board images with subsets
> of pieces in situ on the board, but with the board set as no_image, and the
> background pixels transparent.  I can then load several of these full images
> into my game program, and manually select slices of them for a given piece.  I
> can have several game pieces in each image (as long as they have a
> non-overlapping rectangle bounding box.

Let me mention shadows.
When doing similar stuff, I often had the problem that, translated to your
situation, different game pieces cast shadows onto each other. This looks
bad, when in the actual play only the shadowed piece is present, not the
one casting the shadow. The same goes for reflections of pieces in shiny
parts of other pieces. So in any case I would recommend to render each
piece separately. Of course, pieces failing to cast shadows onto each other
when they should also looks unrealistic. But much less so.
Another issue with shadows is shadows of pieces cast onto the board. You
might want that. In which case, unfortunately, everything below becomes
more complicated. So for the moment I assume you do not need those.

Also, let me mention antialiasing.
If you want some, then you should not just render your pieces with the
board set to noimage. Instead, you should render twice, first the piece
and the board normally, then just the piece with all textures replaced
by white and a black background. Afterwards, you use the non-black parts
of the second image (due to AA, they will not be full-white, mind you)
as a mask for the first image.

> I also considered generating individual bounded images for the pieces (rendered
> at all the various positions).  This essentially amounts to crops of the images
> in option 1.  That options seems to only complicate everything below...  so I
> think the first option is better, but I'm open to suggestions.

What does it complicate? This is what I would suggest. Of course, it wastes
a bit of time. But very little: It wastes the time to parse a scene more
often and for povray to find out that some pixel is indeed transparent.

So, now you have for each piece at each position an image which consists
mainly of transparent pixels. Then use some postprocessing tool to crop
this to the minimal rectangle. Write this tool yourself, unless somebody
else suggests an existing one.
The important point is, that the tool should output, separately, the
coordinates of cropping it has used. Plug these into your game source
code. That's all.

  Mark Weyer


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.