If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
![]() |
|
|
#1 |
|
Member
Join Date: May 2002
Location: Adelaide, South Australia
Posts: 270
|
Hi all,
Am using a vertex shader for shadow volume extrusion and have hit a snag. When two vertices share a common position but not normal or texture coord, I create degenerate faces between them an this works fin for mist cases. the problem is that the vertex shader calculates whether to extrude the vertex or not based on the vertex normal and not the face normal, this can create areas where a vertex should be extruded away but is not since it's shared vertex normal is not pointing away from the light. Short of creating unique vertices for each face I cannot think od a solution to this. Any ideas?
__________________
---------------------------------------------------- That's Floopy not Floppy....... And it's Mr Floopy to you! ---------------------------------------------------- |
|
|
|
|
|
#2 | |
|
Irregular
Join Date: Feb 2002
Posts: 1,170
|
Quote:
Maybe you should tell why you want to calculate the volume with VS so you cat get an advice in the right direction. |
|
|
|
|
|
|
#3 | ||
|
Member
Join Date: May 2002
Location: Adelaide, South Australia
Posts: 270
|
Quote:
Quote:
It is quite robust if degenerate tri's are placed between every edge, however this should not be required in all cases. I am thinking that only certain edges that share non-unique verts need these degenerate tris between them. I guess it's a matter of what metric is required to determine which do and which don't
__________________
---------------------------------------------------- That's Floopy not Floppy....... And it's Mr Floopy to you! ---------------------------------------------------- |
||
|
|
|
|
|
#4 | |
|
Irregular
Join Date: Feb 2002
Posts: 1,170
|
Quote:
Well, the correct shadow volumes needs the side triangles, so this is only achievable the way you described it (creating unique vertices for each face). On the other hand the other solution might not be that bad - worth a try. It might depend on the surface complexity of the object. |
|
|
|
|
|
|
#5 |
|
Member
Join Date: May 2002
Location: Adelaide, South Australia
Posts: 270
|
Will give it a go. Will try based on a face to face angle factor. Probably worth a bit of extra shadow geometry.
__________________
---------------------------------------------------- That's Floopy not Floppy....... And it's Mr Floopy to you! ---------------------------------------------------- |
|
|
|
|
|
#6 |
|
Irregular
Join Date: Feb 2002
Posts: 1,170
|
My guess is that the most visible artifact would be "shadow popping", when a vertex turns from lit to non-lit the shape of the shadow casted on another surface might have a sudden change. Might be small if the angle between the neighbour faces is small.
This is the only way to do it when N-patches are enabled, but since N-patches make the mesh more smooth, it should lessen the popping effect. |
|
|
|
|
|
#7 | |
|
Member
Join Date: May 2002
Location: Adelaide, South Australia
Posts: 270
|
Quote:
Still biggest problem is as I described which can cause quite a few holes in the shadow (If you can have a hole in the absence of light I think a completely robust solution is probably not likely but considering the alternatives it still looks pretty impressive.
__________________
---------------------------------------------------- That's Floopy not Floppy....... And it's Mr Floopy to you! ---------------------------------------------------- |
|
|
|
|
|
|
#8 |
|
Moderator
Join Date: Feb 2002
Location: Taiwan
Posts: 2,348
|
I did some experiments a while ago to use vertex shader to mimic my CPU implementation of shadow volumes (which is quite robust). However, its overhead is too large (a quad for each edge). There are also some problems with vertex blending (it is quite troublesome to recompute the true normal of a triangle). I decided to keep using CPU to do everything including vertex blending and shadow volumes.
|
|
|
|
|
|
#9 |
|
Member
|
I am using an approach, based on the Robust Shadow Volumes doc, where I find silhouettes in software using a somewhat fast algorithm with no need for an edge structure, and then do the final extrusion calculation in hardware by for each vertex passing in a number, 0 or 1, telling whether or not this vertex should be extruded to infinity or not. I've been thinking about how to move more calculations to the shader but so far I've not been successful. I have no idea if this algorithm is fast since I've only used it on fairly simple test scenes, but making, extruding and drawing shadow volumes from a 10000-poly object in realtime is no problem on my athlon 1800.. maybe doesn't say very much..
Anyway, here's my optimized shader (not as readable as it used to be anymore Code:
; v0 = position
; v1 = extrudeAmount <- {0,1} (NOTE this is reversed, vertices you
; want to extrude should use 0, others 1)
;
; c0-3 = Transposed matrix
; c4 = Homogenous light position
;(Ax*Lw - Lx*Aw, Ay*Lw - Ly*Aw, Az*Lw-Lz*Aw, 0);
mul r1, v0, c4.wwww
mad r1, c4, -v0.wwww, r1
; lerp between v0,r1
add r2, v0, -r1
mad r0, r2, v1.xxxx, r1
; Transform position
m4x4 oPos, r0, c0
|
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Feb 2002
Posts: 2,020
|
ector. I'm curious how your silhouette extraction is done. I've read about some methods before, but many needed a special data structure. Do you have a link to the algorithm or did you develop it yourself?
Thanks. |
|
|
|
|
|
#11 |
|
Member
|
well, i'm actually using a completely rewritten version of the not very efficiently written algorithm Microsoft uses in the ShadowVolume sample in DX8SDK.. check out that sample for the algorithm.
Anyway it's basically: maintain a list of edges. go through all your triangles (since you need to do it anyway for capping). for each front-facing triangle, apart from adding it to your list of cap polys, call AddEdge(v0,v1); AddEdge(v1,v2); AddEdge(v2,v0); AddEdge is a function that takes an edge, and adds it to the edge list if it's not already there, OR REMOVES it from the list if it is! this will leave you with a list only containing silhouette edges. To remove an item from this list, take the last one in the list and put it where the old one was so you won't have to shift around so much data. I have made the observation that when you add a new edge, you only need to test for edges in the list going in the "opposite direction", if your mesh is correct. Maybe an algorithm with connectivity information would be slightly faster, but I really like the simplicity of this and not having to keep track of an edge structure for each mesh. |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Feb 2002
Posts: 2,020
|
Thanks for the explaination.
|
|
|
|
|
|
#13 |
|
Irregular
Join Date: Feb 2002
Posts: 1,170
|
Well, that algorithm can screw up on some meshes (you can count on artist to be innovative, and create such meshes!
Also I don't think that "removing from the list" is a particularly fast operation, as it involves searching. Keeping an edge buffer is actually moving this searching out of real time code. |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Feb 2002
Location: gjethus, Norway
Posts: 1,256
|
To avoid searching through the entire edge list for every time an edge needs to be added/removed, you could use a hash table to store the edges. Which should give you a rather dramatic speedup for large-polycount models. Although you will have to experiment a little to find a good (fast and sufficiently random) hash function.
|
|
|
|
|
|
#15 |
|
Regular
|
If you go to that much trouble not taking connectivity into acount becomes a bit silly ... can't beat O(1).
|
|
|
|
|
|
#16 |
|
Member
|
>Also I don't think that "removing from the list" is a particularly fast
>operation, as it involves searching. uhms.. see the note how I do it. it's very fast >To avoid searching through the entire edge list for every time an edge >needs to be added/removed, you could use a hash table to store the >edges. Which should give you a rather dramatic speedup for large->polycount models. Although you will have to experiment a little to find a >good (fast and sufficiently random) hash function. yeah, I've thought of this to and I'll do some research into it once this edge search becomes the bottleneck.. and for various reasons, I don't think it's the bottleneck right now. Besides, i'm shadowing a morphing 10 000 poly object in 60fps (on athlon 1800+ / GF2MX!).. so it's not THAT horribly slow I know that with more advanced scenes this is still not going to be fast enough, but i'll worry about that when that time comes... |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PowerVR families - shader capabilities | Megadrive1988 | 3D Architectures & Chips | 29 | 05-Aug-2005 00:43 |
| ImgTech launches programmable shader graphics for mobiles | marco | Press Releases | 0 | 29-Jul-2005 09:40 |
| nvidia GPU at 1 Ghz in ps3? | version | Console Technology | 36 | 02-May-2005 20:03 |
| Driver Heaven: The Project - Serious rendering issues | Jawed | 3D Hardware, Software & Output Devices | 45 | 06-Feb-2005 09:51 |
| 5700, 5600, 9600 'Pure' DX9 Performances | Dave Baumann | 3D Architectures & Chips | 72 | 31-Oct-2003 00:55 |