Jump to content


Model silhouette


6 replies to this topic

#1 enigma

    Member

  • Members
  • PipPip
  • 58 posts

Posted 21 March 2008 - 04:28 PM

I must render the silhouette of an arbitrary 3D model.
The models are in OBJ format.
First I have follow this to read obj file:
http://cggmwww.csie..../2002/prog1.htm
It works, but only if in the file are stored vertex normals.
For example:

v -1.500976 13.063408 0.460043

vn -0.461797 0.858629 -0.222485

vt 0.000000 0.000000

But if the vertex normals are not stored in this manner, I'm not able to found a silhouette.
So, I have tried this code for read obj file:
http://www.gamedev.n...=12&gforum_id=0
(third post, objread.h).
Whit this code, vertex normal are manually generated.
It works, but with some problems, for example:
Posted Image
In this rendering, there are some wrong edges.
For me is because some normals are wrong. It's correct?
How can I solve this problem?
Thanks!!

#2 yakul

    Member

  • Members
  • PipPip
  • 55 posts

Posted 21 March 2008 - 05:03 PM

I am not sure what you are trying to do.
But if you want a fast outline rendering, you should take a look at this:
http://graphics.cs.b...dges/index.html

#3 enigma

    Member

  • Members
  • PipPip
  • 58 posts

Posted 29 March 2008 - 03:29 PM

Hi!
I've found and I tried to use this code:

void drawSilhouette(GLfloat r, GLfloat g, GLfloat b)

{

	glPolygonMode(GL_FRONT,GL_FILL);

	glDepthFunc(GL_LESS);

             glEnable(GL_CULL_FACE);


	glBegin(GL_TRIANGLES);

	glColor3f(0.0, 0.0,0.0);


	//Here I draw my model with GL_TRIANGLES


	glEnable(GL_BLEND);

	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);


	glColor3f(r, g, b);

	glLineWidth(1.0);

	glDepthFunc(GL_LEQUAL);

	glPolygonMode(GL_BACK, GL_LINE);

	glCullFace(GL_FRONT);


	//Here I draw my model with GL_TRIANGLES


	glDisable(GL_BLEND);

	

	glDepthFunc(GL_LESS);

	glCullFace(GL_BACK);

	glDisable(GL_CULL_FACE);

}

It works correctly, see for example this silhouette rendering of Utah Teapot:
Posted Image
But I've a problem if the model has a holes, see for example this rendering of a head:
Posted Image
How can I fix this problem?
In the other cases the method run correctly!
Thanks!

#4 Mattias Gustavsson

    Senior Member

  • Members
  • PipPipPipPip
  • 413 posts

Posted 29 March 2008 - 07:08 PM

well, easiest way would be to fix the model, so it no longer has any holes :-)
  • www.mattiasgustavsson.com - My blog and current projects
  • www.rivtind.com - My Fantasy world and isometric RPG engine
  • www.pixieuniversity.com - My Software 2D Game Engine

#5 starstutter

    Senior Member

  • Members
  • PipPipPipPip
  • 1039 posts

Posted 30 March 2008 - 05:38 AM

Mattias Gustavsson said:

well, easiest way would be to fix the model, so it no longer has any holes :-)

I hate to say it, but he's right. Your 3D models should never have holes in them.
(\__/)
(='.'=)
This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!

#6 enigma

    Member

  • Members
  • PipPip
  • 58 posts

Posted 01 April 2008 - 07:11 PM

starstutter said:

I hate to say it, but he's right. Your 3D models should never have holes in them.
Ok, no holes... :-)
Otherwise, in this case, I must use another method...
Thanks!

#7 Vilem Otte

    Valued Member

  • Members
  • PipPipPip
  • 185 posts

Posted 02 April 2008 - 06:07 PM

Well, you can render silhouettes with holes using pixel comparing and some value to compare when it's silhouette and when not, anyway it has to run as post processing effect in a pixel shader.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users