POV-Ray : Newsgroups : povray.programming : OpenGL porting or support? : Re: OpenGL porting or support? Server Time
27 Sep 2024 19:40:35 EDT (-0400)
  Re: OpenGL porting or support?  
From: Patrick Elliott
Date: 28 Jun 2005 23:15:23
Message: <MPG.1d2bbffd61ab6af4989d97@news.povray.org>
In article <web.42c1137fc739b361d9bc26010@news.povray.org>, 
dra### [at] gmailcom says...
> hi...
> 
> is there any way to port POV to opengl?
> 
Or for a more complex explanation that Warps. No, because OpenGL only 
simulates raytracing using a) triangle meshes, not mathematical formula, 
b) its textures are pre-created, c) its reflection and other light 
features are mapped to objects, not generated by physical models and d) 
pretty much all of it is done using a painter type algorithm, which, 
instead of following a beam of light to see 'what' and 'if' it hit 
something, simply cuts away everything that shouldn't be 'visible' and 
ignores it. Item (d) is why you have to fake reflections, since OpenGL is 
incapable of determining 'if' let alone 'what', 'how many', or 'to what 
degree' light bounces of other objects, before being seen by the camera 
position.

Think of it this way. POVRay sets up a room, some lights and a camera, 
then snaps a photo. OpenGL and DirectX is a guy sitting in a room with an 
exacto knife, who splashes paint over several thousand sheets of paper, 
then uses the knife to 'cut out' every bit that isn't part of the final 
result, pastes them all on on top of the other, *then* takes a photo of 
the result. While this can 'look' very realistic, given a lot of patience 
and careful preparation, some things are impossible and you can't simply 
come back to the same room and stick a camera 'behind' the objects or 
move any lights. Doing so messes up any reflections or other 'effects' 
that have to be carefully 'adjusted' to still look right. I.e., you have 
to cut up entirely new bits, paint them all, then 'hope' you didn't mess 
something up which leaves the table top reflecting the floor, instead of 
the lamp over top of it and similar mistakes. Even OpenGL programs that 
'do' allow that do so by 'precalculating' where the reflections should 
be, then feeding a fake image of that reflection to the OpenGL system as 
a texture. I.e., it uses POVRay style calculations to figure out, "sort 
of", what it should look like, then glues the result to the wall, table, 
mirror, etc. that needs it.

POVRay is an complete machine show with an industrial lathe and a full 
employment of welders. OpenGL is a guy with a box of legos, a few tubes 
of paint and maybe some modelling clay to smooth the more obvious blocky 
bits. Its quite literally a complete impossibility to shoehorn POVRay 
into the later. Though, someone did work on a version that supported a 
'preview' system. It worked by taking the real math, manufacturing a 
bunch of approximate fakes, then showing a cheap imitation of the final 
result. I suspect it never worked too well, or for all objects. Some, 
like isosurfaces could take almost as long to produce a bad imitation, 
than to produce the real thing. This is why things like Moray, etc. that 
'do' use OpenGL, to give a rough idea of what the final result will be, 
don't even try to show some objects, but just stuff a big box, that is 
close to the estimated size expected, in their place.

-- 
void main () {

    call functional_code()
  else
    call crash_windows();
}


Post a reply to this message

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