Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Apr 18, 2024 16:11

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 6 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: stencil shadows again ... (outlines)
BeitragVerfasst: Mi Apr 27, 2005 18:50 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
This week i started again on understanding shadow volumes. What went wrong in my previous attempt is that i never got the outline properly calculated. So i need to get that right first.

So what do i have. A list of indexes to vertexes and normals (the gl3ds format). index 1 2 3 make a face 4 5 6 make another face, etc. So from that i need to create an edge list. if i render poly lines using the edge list i should be able to render polygon shape representing the outline (Silhouette) of the mesh.

Looking at the wiki:
2 benachbarte Flächen vom Objekt, bei denen man untersuchen will ob ihre Zwischenkante zur Silhouette gehört.
Hopefully i can assume that faces are in order. If not how do i find out what faces are next to each other, comparing vertexes?

Die Position des Betrachters.
That is the light, or when i just want to render an outline, the camera position.

Die Position auf die der Betrachter sieht. (Intelligenterweise, dass Zentrum des Objekts dessen Silhouette man berechnen will.)
The coordinate where the mesh is rendered on screen (ps how bad is it when it is not right?)

The calculating part i can follow, but
Außerdem sollten Kanten die nur zu einem Polygon gehören ebenfalls zur Silhouette gezählt werden.
How do i detect that?

Thanks for your answers in advance.

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
BeitragVerfasst: Mi Apr 27, 2005 19:18 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
noeska hat geschrieben:
Looking at the wiki:
2 benachbarte Flächen vom Objekt, bei denen man untersuchen will ob ihre Zwischenkante zur Silhouette gehört.
Hopefully i can assume that faces are in order. If not how do i find out what faces are next to each other, comparing vertexes?


Yes. This seems to be the only method. Number your vertices and look if an face uses 2 vertices a other vertex uses, too.


noeska hat geschrieben:
Die Position des Betrachters.
That is the light, or when i just want to render an outline, the camera position.

Correct.

noeska hat geschrieben:
Die Position auf die der Betrachter sieht. (Intelligenterweise, dass Zentrum des Objekts dessen Silhouette man berechnen will.)
The coordinate where the mesh is rendered on screen (ps how bad is it when it is not right?)

You can assume this. But a better way would be to make 2 vectors. one for every vertex of an edge and then take an average vector. This is sure slower because you have to calculate the vector for every edge.

noeska hat geschrieben:
The calculating part i can follow, but
Außerdem sollten Kanten die nur zu einem Polygon gehören ebenfalls zur Silhouette gezählt werden.
How do i detect that?

Normal 3D Object have no such edges (because the are closed). But you can count again if two faces use the same edge (see question2)

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Apr 28, 2005 00:50 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Dez 28, 2002 11:13
Beiträge: 2244
It can be easier:

for each triangle facing away from the light:

1) Draw the original triangle with reversed vertex order.
2) Draw the extruded triangle.
3) for each edge 0..2
if edge hasn't neighbour triangle => Draw Extruded Edge
if edge has neighbour triangle
if neighbour triangle is facing toward the light => DrawExtruded Edge

It is not wrong to extrude always all three edges of all triangles and to ignore the silhouette. It is only slow. The silhoutte can be used as an optimization when two neighbour triangles are both extruded to avoid drawing the same triangle facing front and facing back and increasing and decreasing the value in the stencil buffer.

Instead of extruding on the CPU you can duplicate your vertex list and set w of all duplicated points to zero. A vertex program can use an infinite projection matrix to extrude all vertices with w=0 or project the point on a plane a the light's radius.

Pseudo Code:
Code:
  1.        
  2. for i:=0 to Length(Triangles)-1 do
  3. begin
  4.   if Plane_Dist(Triangles[i].Plane,LightPos) <0 then
  5.   begin
  6.     // 1)
  7.     glBegin(GL_TRIANGLES);
  8.     glVertex3fv(Triangles[i].Points[2]);
  9.     glVertex3fv(Triangles[i].Points[1]);
  10.     glVertex3fv(Triangles[i].Points[0]);
  11.     glEnd();
  12.     // 2)
  13.     glBegin(GL_TRIANGLES);
  14.     glVertex3fv(ExtrudePoint(Triangles[i].Points[0]));
  15.     glVertex3fv(ExtrudePoint(Triangles[i].Points[1]));
  16.     glVertex3fv(ExtrudePoint(Triangles[i].Points[2]));
  17.     glEnd();
  18.  
  19.     for j:=0 to 2 do
  20.     begin
  21.       edge_triangle := triangles[i].edge[j];
  22.       if (edge_triangle =-1) or (Plane_Dist(Triangles[edge_triangle].Plane,LightPos)>0) then
  23.       begin
  24.       glBegin(GL_TRIANGLE_STRIP);
  25.       glVertex3fv(Triangles[i].Points[j]);
  26.       glVertex3fv(Triangles[i].Points[(j+1) mod 3]);
  27.       glVertex3fv(ExtrudePoint(Triangles[i].Points[j]));
  28.       glVertex3fv(ExtrudePoint(Triangles[i].Points[(j+1) mod 3]));
  29.       glEnd();  
  30.       end;
  31.     end;    
  32.  
  33.   end;
  34. end;
  35.  


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Do Apr 28, 2005 15:01 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
What do you mean with "extrude" the triangle? :oops:

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Mai 08, 2005 10:39 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
on the inet i found: robust, geometry-independent shadow volumes by graham aldridge and eric woods. They seem not to construct an edge list. @Lars Middelnorf: is that the way you do it?

Anyway it does not seem to work for me. You can find my code at: http://www.noeska.com/downloads/dglmodel.zip

Most important are:
- gldraw in glapp.pas
- Tall3dsMesh.loadmsafromstream at //build up edges (gl3ds)
- the Tedge and Tface structures (gl3ds)
- T3dsmesh.rendershadow
- T3dsmesh.faceslight
- extendvertex

I am about to give up :cry:

EDIT:
this evening i decided to have another go. Now it works for some camera positions for some lightpositions. I think things go wrong when the camera is inside a shadow volume. For that case i believe i should 'reverse' the stencil rendering but then the results seem to be right when inside a shadow volume but not anymore when outside a shadow volume. :? I uploaded the result sofar at http://www.noeska.com/downloads/dglmodel2.zip .

PS do not use the gl3ds.pas inside the archive as only milkshape static mesh is working, the rest is broken.

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Mai 10, 2005 17:21 
Offline
Forenkatze
Benutzeravatar

Registriert: Mi Okt 22, 2003 18:30
Beiträge: 1944
Wohnort: Närnberch
Programmiersprache: Scala, Java, C*
At neHe is a Tutorial about doing Stencil Shadows. Delphi-Code is also available there.

_________________
"Für kein Tier wird so viel gearbeitet wie für die Katz'."


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 6 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 10 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.168s | 17 Queries | GZIP : On ]