To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.devOpen lugnet.cad.dev in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Development / 10094
10093  |  10095
Subject: 
Re: Rendering implementation details
Newsgroups: 
lugnet.cad.dev
Date: 
Tue, 25 Jan 2005 01:28:14 GMT
Viewed: 
2020 times
  
In lugnet.cad.dev, Mark Tarrabain wrote:
I was envisioning how an LDraw renderer would be implemented if it were
done with OpenGL, and I've arrived at some questions that I can't answer
for myself.

I'm particularly wondering about line type #5, the optional line.
According to the LDraw file format specification: "This draws a line
between the first two points, if the projections of the last two points
onto the screen are on the same side of an imaginary line through the
projections of the first two points onto the screen."   I understand
what this means, but I'm confused about certain details of
implementation that could, as near as I can see, be the cause of some
inefficiency.

For this line type, using OpenGL one thing I came up with was that one
would use gluProject on each vertex on both line segments to see where
they would fall on screen, examine the end points, and then decide
whether or not to draw them based on that, but I would imagine calling
gluProject 4 times for each optional line listed in a part definition
(especially since not all of them are necessarily even displayed!) would
adversely affect performance.   The only other way I could see it
working is to do _all_ the rendering in the application, and not rely on
something like opengl at all.  Again, I would imagine this to severely
impact performance.

Could anyone enlighten me as to how this could be done without making
serious compromises in efficiency?  Or am I completely out to lunch
about the performance impact of the concerns I've mentioned?

You're right about the performance hit.  We've discussed this issue
previously on lugnet, because quite a few of the renderers out there
use opengl (ldview, leocad, ldglite, Mac Brick Cad...)  Source code is
available for all of these if you want to take a look.

There are faster ways to do it but I don't think anyone has implemented
them in an ldraw renderer yet.  Search with google for "opengl" and
"cartoon rendering" or "magic halo" for the algorithms.  The basic idea
is to do something like this:

- draw back facing polygons of your model in wireframe with depth test
set to less or equal (glDepthTest(GL_LEQUAL)), no lighting, no texturing.

Then:

- draw front facing polygons solid, depth test less (glDepthTest(GL_LESS)),
lighting and texturing (if you want).  This covers all but the outer
edge lines.

You'll have to work out for yourself how this jives with transparent
bits.

Have fun,

Don



Message has 1 Reply:
  Re: Rendering implementation details
 
(...) I'm not 100% sure, but I believe most (if not all) of these outlining algorithms expect you to know the difference between the front faces and the back faces. It could be that they could be adopted for use when you don't have this information, (...) (20 years ago, 25-Jan-05, to lugnet.cad.dev)

Message is in Reply To:
  Rendering implementation details
 
I was envisioning how an LDraw renderer would be implemented if it were done with OpenGL, and I've arrived at some questions that I can't answer for myself. I'm particularly wondering about line type #5, the optional line. According to the LDraw (...) (20 years ago, 24-Jan-05, to lugnet.cad.dev)

22 Messages in This Thread:







Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR