Shadow volume

Blitz3D Forums/Blitz3D Programming/Shadow volume

DareDevil(Posted 2006) [#1]
This demo is created for simulate the volume shadow

shipment the code in order to test it and hoping that you can help me to improve it
hello

excuse for the my english

http://digilander.libero.it/enzo_light/shw.zip




GfK(Posted 2006) [#2]
Where to start....

1. You're referencing several include files which the rest of us don't have. [edit] I found one of them hidden in the above 'mess'. See point 3 below.

2. You're loading models and textures that the rest of us don't have.

3. Your code is not indented and is nigh on impossible to read. At LEAST put it in code tags.

People simply cannot be bothered messing about getting your code to run. Post a downloadable demo with EXE/ZIP file, and possibly a screenshot as well, and you might get people interested.


Grey Alien(Posted 2006) [#3]
or better still codebox tags.


IPete2(Posted 2006) [#4]
Vincenzo,

Use "[code] ...your code goes here... [\code]" to show your code - Oh but ignore the " ".

IPete2.


Grey Alien(Posted 2006) [#5]
or codebox, it's much better for lots of long code.


DareDevil(Posted 2006) [#6]
Ok!!!

Bye


GfK(Posted 2006) [#7]
Ran the EXE - Memory Access Violation.

Your code gives the same error at "WritePixelFast X,Y,0", in Function ShadowVolumeCreateImage()


DareDevil(Posted 2006) [#8]
?


bytecode77(Posted 2006) [#9]
you have got the same problem as i have...did u read my thread about stencil shadow volumes?
if not, this would be helpful at all :)


DareDevil(Posted 2006) [#10]
i ha a simulate stencil buffer :D
this is a very slow speed :(
help me for speed up

bye


bytecode77(Posted 2006) [#11]
yes, i will check the code out when i come back from my holiday trip in a few days...


DareDevil(Posted 2006) [#12]
i have changed the code function ShadowVolumeCreate3$ for speed up, imcrements 16 milliseconds

bye

post a new code




bytecode77(Posted 2006) [#13]
ok, i can help you(i have got the same problem as you!)

if you help me to find the function in that code which creates the volume and isolate it, i can help you to create a good stencil shadow system!

so where is the function which creates the volume?

edit: i found some things about the volume, but it is to slow for a real shadow system, and i can't really isolate the function from the rest(from the rubbish)


DareDevil(Posted 2006) [#14]
the function for create volume is the last function posted ShadowVolumeCreate3$(...)

this function is composed the 2 section

1° section:

acquire vertex transformed, selected vertex front side light, and defined edge triangle


2° section:

discard edge equal and create volume object other adge

the funtion is indipendent to the system

i have a idea.... InitShadow this function acquire vertex object first and precessed vertex(in the memory) post for volume, this system increment speed 2 - 10%

the very problem is generate ShadowVolumeCreateImage this funcion create slow speed for 2 read pixel(back and front face object volume) and 1 write pixel, this function simulate stencil

congratulation!! the your system render is very good speed

excuse for the my english

Thank's for all bye


bytecode77(Posted 2006) [#15]
but why is this thingy so slowly?
i think it is thew volume create function which is so slowly... so i cannot use it for my system sry :(


DareDevil(Posted 2006) [#16]
?

test the your system disabled the creation volume or system simulate stencil


bytecode77(Posted 2006) [#17]
ok, i found the function which lames all down, now i'm making a system out of this... if it works(IF IT WORKS) i will send it to u :)

edit: your source is 1200 lines large. i'm modifying it, and now it's only 250 lines long, how could this be?? - half of ypur code is rubish!


DareDevil(Posted 2006) [#18]
i send a link new version simplex

;)

i have divide common and shadow

digilander.libero.it/enzo_light/shw01.zip


bytecode77(Posted 2006) [#19]
there is nothing changed, but i'll try to make the best of both :)


DareDevil(Posted 2006) [#20]
i search the new alghoritm for generate silhouette bye


bytecode77(Posted 2006) [#21]
i have modifyed you one up to this:

Graphics3D 1024, 768, 32, 2
SetBuffer BackBuffer()

;Globs
Global sh_v1.Point3D, sh_v2.Point3D, sh_v3.Point3D, sh_nv1.Point3D, sh_nv2.Point3D, sh_nv3.Point3D, sh_vect1.Point3D, sh_vect2.Point3D, sh_vect3.Point3D, sh_light.Point3D, sh_lenght.Point3D, sh_normal.Point3D, sh_NCamera.Point3D
Global VolumeMesh, VolumeSurface
Dim Edge.Edge(65000)

;Camera
Cam = CreateCamera()

;Shadows
InitShadows()

;Floor
c = CreateCube()
ScaleEntity c, 10, 1, 10
PositionEntity c, 0, -5, 10
EntityColor c, 0, 255, 0

;Caster
Cube = CreateSphere()
PositionEntity Cube, -1.5, 0, 10
Cube2 = CreateCube()
PositionEntity Cube2, 1.5, 0, 10

;Light
Light = CreateLight()
PositionEntity Light, 0, 5, 10

While Not KeyHit(1)
	ms = ms + 1
	PointEntity Light, Cube
	TurnEntity Cube, 1, .5, 1.5
	TurnEntity Cube2, 1, .5, 1.5
	ResetShadowVolume()
	ShadowVolume(Cube, Light)
	ShadowVolume(Cube2, Light)
	RenderWorld
	Flip
Wend
FreeShadows()
End








;Types
Type Point3D
	Field x#, y#, z#
End Type
Type Edge
	Field Surf, Triangle
	Field Point0.Point3D, Point1.Point3D, Ray0.Point3D, Ray1.Point3D
End Type

Function InitShadows()
;Volume mesh
VolumeMesh = CreateMesh()
VolumeSurface = CreateSurface(VolumeMesh)
EntityAlpha VolumeMesh, .5
EntityColor VolumeMesh, 255, 0, 0
EntityFX VolumeMesh, 17
;Edges
For a = 0 To 65000
	Edge.Edge(a) = New Edge
	Edge(a)\Point0.Point3D = New Point3D
	Edge(a)\Point1.Point3D = New Point3D
	Edge(a)\Ray0.Point3D = New Point3D
	Edge(a)\Ray1.Point3D = New Point3D
Next
;Points
sh_v1.Point3D = New Point3D
sh_v2.Point3D = New Point3D
sh_v3.Point3D = New Point3D
sh_nv1.Point3D = New Point3D
sh_nv2.Point3D = New Point3D
sh_nv3.Point3D = New Point3D
sh_vect1.Point3D = New Point3D
sh_vect2.Point3D = New Point3D
sh_vect3.Point3D = New Point3D
sh_light.Point3D = New Point3D
sh_lenght.Point3D = New Point3D
sh_normal.Point3D = New Point3D
sh_NCamera.Point3D = New Point3D
End Function

Function FreeShadows()
If VolumeMesh Then FreeEntity VolumeMesh
Delete Each Point3D
Delete Each Edge
End Function

Function V3_Inc.Point3D(val1.Point3D, val2.Point3D)
val1\x = val1\x + val2\x
val1\y = val1\y + val2\y
val1\z = val1\z + val2\z
Return val1
End Function

Function V3_Dec.Point3D(val1.Point3D, val2.Point3D, val3.Point3D)
val3\x = val1\x - val2\x
val3\y = val1\y - val2\y
val3\z = val1\z - val2\z
End Function

Function V3_Mul.Point3D(val1.Point3D, val2.Point3D)
val1\x = val1\x * val2\x
val1\y = val1\y * val2\y
val1\z = val1\z * val2\z
Return val1
End Function

Function V3_Copy(a.Point3D, b.Point3D)
a\x# = b\x#
a\y# = b\y#
a\z# = b\z#
End Function

Function V3_Normalize(val.Point3D)
do# = 1.0 / Float(Sqr(val\x ^ 2 + val\y ^ 2 + val\z ^ 2))
val\x = val\x * do
val\y = val\y * do
val\z = val\z * do
End Function

Function V3_CheckVertex(a.Point3D, b.Point3D)
If a\x = b\x And a\y = b\y And a\z = b\z Then Return True Else Return False
End Function

Function ResetShadowVolume()
ClearSurface VolumeSurface
End Function

Function ShadowVolume(model, Light)
sh_light\x = EntityX(Light)
sh_light\y = EntityY(Light)
sh_light\z = EntityZ(Light)
sh_lenght\x = 1000
sh_lenght\y = 1000
sh_lenght\z = 1000
Norm.Point3D = New Point3D
MidPoint.Point3D = New Point3D
NormLight.Point3D = New Point3D
For n = 1 To CountSurfaces(model)
	surf = GetSurface(model, n)
	dwNumFaces = CountTriangles(surf) - 1
	For v = 0 To dwNumFaces
		vert0 = TriangleVertex(surf, v, 0)
		vert1 = TriangleVertex(surf, v, 1)
		vert2 = TriangleVertex(surf, v, 2)
		TFormPoint VertexX(surf, vert0), VertexY(surf, vert0), VertexZ(surf, vert0), model, 0
		sh_v1\x = TFormedX()
		sh_v1\y = TFormedY()
		sh_v1\z = TFormedZ()
		TFormPoint VertexX(surf, vert1), VertexY(surf, vert1), VertexZ(surf, vert1), model, 0
		sh_v2\x = TFormedX()
		sh_v2\y = TFormedY()
		sh_v2\z = TFormedZ()
		TFormPoint VertexX(surf, vert2), VertexY(surf, vert2), VertexZ(surf, vert2), model, 0
		sh_v3\x = TFormedX()
		sh_v3\y = TFormedY()
		sh_v3\z = TFormedZ()
		aa.Point3D = New Point3D
		bb.Point3D = New Point3D
		V3_Dec(sh_v3, sh_v2, aa.Point3D)
		V3_Dec(sh_v2, sh_v1, bb.Point3D)
		ax# = aa\y# * bb\z# - aa\z# * bb\y#
		ay# = aa\z# * bb\x# - aa\x# * bb\z#
		az# = aa\x# * bb\y# - aa\y# * bb\x#
		Norm\x# = ax#
		Norm\y# = ay#
		Norm\z# = az#
		Delete aa
		Delete bb
		MidPoint\x = (sh_v1\x# + sh_v2\x# + sh_v3\x) / 3
		MidPoint\y = (sh_v1\y# + sh_v2\y# + sh_v3\y) / 3
		MidPoint\z = (sh_v1\z# + sh_v2\z# + sh_v3\z) / 3
		V3_Dec(MidPoint, sh_light, NormLight)
		V3_Normalize(Norm)
		V3_Normalize(NormLight)
		Dot# = Norm\x# * NormLight\x# + Norm\y# * NormLight\y# + Norm\z# * NormLight\z#
		If Dot# => 0 And Dot# <= 1 Then
			ID_EdgeF.Edge = Edge(CNTFront)
			ID_EdgeF\Surf = surf
			ID_EdgeF\Triangle = v
			V3_Copy(ID_EdgeF\Point0, sh_v1)
			V3_Copy(ID_EdgeF\Point1, sh_v2)
			CNTFront = CNTFront + 1
			ID_EdgeF.Edge = Edge(CNTFront)
			ID_EdgeF\Surf = surf
			ID_EdgeF\Triangle = v
			V3_Copy(ID_EdgeF\Point0, sh_v2)
			V3_Copy(ID_EdgeF\Point1, sh_v3)
			CNTFront = CNTFront + 1
			ID_EdgeF.Edge = Edge(CNTFront)
			ID_EdgeF\Surf = surf
			ID_EdgeF\Triangle = v
			V3_Copy(ID_EdgeF\Point0, sh_v3)
			V3_Copy(ID_EdgeF\Point1, sh_v1)
			CNTFront = CNTFront + 1
		EndIf
	Next
Next
cntUguali = 0
cntDiverse = 0
For a = 0 To CNTFront
	If Edge(a)\surf > 0 Then
		Diverso = True
		MemB = 0
		ID_EdgeFA.Edge = Edge(a)
		ID_P0.Point3d = ID_EdgeFA\Point0
		ID_P1.Point3d = ID_EdgeFA\Point1
		For b = a + 1 To CNTFront
			ID_EdgeFB.Edge = Edge(b)
			If Edge(b)\surf > 0 Then
				check1 = V3_CheckVertex(ID_P0, ID_EdgeFB\Point0)
				check2 = V3_CheckVertex(ID_P1, ID_EdgeFB\Point1)
				If check1 And check2 Then
					MemB = b
					cntUguali = cntUguali + 1
					ID_EdgeFA\surf = 0
					ID_EdgeFB\surf = 0
					Diverso = False
					Exit
				Else
					check1 = V3_CheckVertex(ID_P0, ID_EdgeFB\Point1)
					check2 = V3_CheckVertex(ID_P1, ID_EdgeFB\Point0)
					If check1 And check2 Then
						MemB = b
						cntUguali = cntUguali + 1
						ID_EdgeFA\surf = 0
						ID_EdgeFB\surf = 0
						Diverso = False
						Exit
					EndIf
				EndIf
			EndIf
		Next
		If Diverso Then
			cntDiverse = cntDiverse + 1
			V3_Dec(ID_P0, sh_light, ID_EdgeFA\Ray0)
			V3_Normalize(ID_EdgeFA\Ray0)
			ID_EdgeFA\Ray0 = V3_Inc(V3_Mul(ID_EdgeFA\Ray0, sh_lenght), ID_P0)
			V3_Dec(ID_P1, sh_light, ID_EdgeFA\Ray1)
			V3_Normalize(ID_EdgeFA\Ray1)
			ID_EdgeFA\Ray1 = V3_Inc(V3_Mul(ID_EdgeFA\Ray1, sh_lenght), ID_P1)
			va = AddVertex(VolumeSurface, ID_P0\x, ID_P0\y, ID_P0\z)
			vb = AddVertex(VolumeSurface, ID_EdgeFA\Ray1\x, ID_EdgeFA\Ray1\y, ID_EdgeFA\Ray1\z)
			AddTriangle(VolumeSurface, va, AddVertex(VolumeSurface, ID_EdgeFA\Ray0\x, ID_EdgeFA\Ray0\y, ID_EdgeFA\Ray0\z), vb)
			AddTriangle(VolumeSurface, va, vb, AddVertex(VolumeSurface, ID_P1\x, ID_P1\y, ID_P1\z))
			ID_EdgeFA\surf = 0
			Edge(MemB)\surf = 0
		EndIf
	EndIf
Next
Delete Norm.Point3D
Delete MidPoint.Point3D
Delete NormLight.Point3D
End Function



Stevie G(Posted 2006) [#22]
Devils Child .. now that looks like it's supposed to .. Nice work :) You could get more raw speed by not calling your vector functions in the shadowvolume routine. Also, you create and delete Norm / MidPoint/ NormLight many times - just make them global and don't delete them so that they can be reused. Also in the normalize routine .. it's quicker to use x*x than using x^2.

I may have a play around and see if I can be speeded up.

So what's the next step?

Stevie


DareDevil(Posted 2006) [#23]
I Devils Child

the your system not have change result, the problem is generate silhouette, i have a solution, have a studi the system for fast silhouette this methods is based for adjacent triangle and a 1 for next (not nested)for generate sil.. I am creating this


bye


DareDevil(Posted 2006) [#24]
I all
this is a link for new systems generate silouette for blitz,
is not complete and optimized for my time is little, in order to complete servants the management fines object in sketched part

the new optimize are "simulate stencil buffer" is very slow

test this software

http://digilander.libero.it/enzo_light/shw03.zip

bye


bytecode77(Posted 2006) [#25]
is the createvolume function of shw03.zip faster than the old one?


DareDevil(Posted 2006) [#26]
very very fast!!!

i have create a new system for blitz Edge to edge remember?

if disable simulate stencil buffer and verify the difference

the include is changed

:)


bytecode77(Posted 2006) [#27]
there is a little bug... if i create a cylinder or a cone, the program crashes...


DareDevil(Posted 2006) [#28]
ok lock the program thanks
bye


DareDevil(Posted 2006) [#29]
The Bug is resolved

post the code
Bye :)




bytecode77(Posted 2006) [#30]
the volume of the cylinder looks a little bit strange...


Stevie G(Posted 2006) [#31]
I'd imagine that cylinders and cones may look strange as they use 2 surfaces unlike spheres and cubes. For shadow volume creation you need to combine these surfaces into one. I have a simple function which does this if you want it?

Stevie


bytecode77(Posted 2006) [#32]
yes, please :)


Stevie G(Posted 2006) [#33]
Function MESHsingle( Mesh )

	Copy = CreateMesh()
	ns = CreateSurface( Copy )
	For su = 1 To CountSurfaces( Mesh )
		s = GetSurface( Mesh , su )
		For t = 0 To CountTriangles( s ) - 1
			v0 = TriangleVertex( s, t, 0 )
			v1 = TriangleVertex( s, t, 1 )
			v2 = TriangleVertex( s, t, 2 )
			Nv0 = AddVertex( ns , VertexX( s , v0 ) , VertexY( s, v0 ) , VertexZ( s, v0 ) )
			Nv1 = AddVertex( ns , VertexX( s , v1 ) , VertexY( s, v1 ) , VertexZ( s, v1 ) )
			Nv2 = AddVertex( ns , VertexX( s , v2 ) , VertexY( s, v2 ) , VertexZ( s, v2 ) )
			AddTriangle ns , Nv0 , Nv1 , Nv2
		Next
	Next
	FreeEntity mesh
	Return Copy

End Function	


Useage ....

MyCylinder = MESHsingle( createcylinder() )

You may need to retain the normals but this should be easy to implement.

Stevie


big10p(Posted 2006) [#34]
I *think* CopyMesh attemps to combine surfaces.


Stevie G(Posted 2006) [#35]
Doh .. so it does ... Copymesh combines surfaces which share the same brush so logically this works just fine .... why I never thought of that is beyond me ;)

So function becomes ..


Function MESHsingle( Mesh )

 copy = copymesh( Mesh )
 freeentity Mesh
 return copy

end function




bytecode77(Posted 2006) [#36]
dare devil:
with the code of you i cannot make 2 entitys casting a volume!!! there is a bug...

edit: ok, but another issue is, that if i take a sphere with 32 segments, the initobject() takes half a minute!? what's about that? can we make it work without long initialization times?


DareDevil(Posted 2006) [#37]
i have write a new update for the software,
1° optimize pre load mesh
2° resolved problem object multi surface
3° i ha create a new function simulate stencil 2 fast speed

and ......

the inizialize mesh required 5 seconds in released version.

The new link a version is:

http://digilander.libero.it/enzo_light/shw06.zip

for multi object i not have write "for Obj=each..." for test this software.

bye


bytecode77(Posted 2006) [#38]
ok, i will check it out:

ps: look what i have made out of your libary:
http://www.blitzbasic.com/gallery/view_pic.php?id=1336&gallery=&page=1

when it's ready it will be FREE*


DareDevil(Posted 2006) [#39]
i have look program the different speed is very lot
8 millisecs in the my new systems, and 100 millisecs in the old method from used you.

bye


bytecode77(Posted 2006) [#40]
well, i see...
but...can we make the initobject() time fast AND the shadowvolume() time fast? when we could do this, this would be the best...


DareDevil(Posted 2006) [#41]
the init object pre elaborate mesh, not function in real time the IntObject is a system the elaborate edge.

the phase 1 is complete ( the bug for 2 object is not resolved generate over face 2 cube )

the Phase 2 is Multi Light Zone, is the system based the lenght light ray all object present in the ray generate volume shadow ;)

PS:
(in the new demo the system is settings a 256 size texture and not 128)


ok bye


DareDevil(Posted 2006) [#42]
Hi all

post the new update file shadow, i have finished face 1 and start the new section OPTIMIZE InitObject

bye

size texture 512






bytecode77(Posted 2006) [#43]
ok, when the initobject() works fast, i will intergrate this code into my stencil shadow system and you'll be the first who will know it :)

cya


bytecode77(Posted 2006) [#44]
look what i have done with your shadow code:
http://patrick-sch.de/bleibdafuerimmer/StencilShadowSystem.zip


DareDevil(Posted 2006) [#45]
Good !! the system is good :)

bye


t3K|Mac(Posted 2006) [#46]
hm, i get a "too many parameters" error at SetRenderState()


Stevie G(Posted 2006) [#47]
t3kMac ..I take it your using at least v1.88?

It works fine here ... a few clitches and some slowdown on demo 4. I still don't think it's fast enough for in-game use though :( Max FPS I got on the swwift demo was 60fps but that's without game logic / physics etc.. Your beethoven mesh is nowhere near the same polys as he was pushing.

Nice work none the less!!

It seems that the shadowvolume creation is still the bottleneck ... if only some smart guy could create a .dll for the volume building then you'd be cooking on gas :)

Stevie


bytecode77(Posted 2006) [#48]
yes, a volume dll would be revolutionary, because everybody could create his own shadow system, then remember: 90% of the work of a stencil shadow system is the shadow volume! the rest is as easy as clean up his ass :)


t3K|Mac(Posted 2006) [#49]
@stevieg: t3kMac ..I take it your using at least v1.88?

i am using blitz 1.96 and hmm don't know the version of dx7test.dll (mine is 77.824 Bytes) maybe i have an old one or old decals... can you send me yours please?


Stevie G(Posted 2006) [#50]
@ t3kMac ...

I just used the ones which came with the zip download and popped them into the uselibs directory and it worked fine.

Stevie


Ross C(Posted 2006) [#51]
Now, get cracking on self shadowing :P Good work guys :o)


jfk EO-11110(Posted 2006) [#52]
self shadowing should be simple. You only have to add the caster mesh to the list of the receiver surfaces.

One thing that is surely more a candidate for headache is the animated vertices problem. And after all we want to use shadows with characters, right?
Adding a pivot to every vertex is also very slow. Additionally there are weighted vertices, so this wouldn't work.

Somebody was working on a DLL that was capable of determinating the true vertex coords of animated meshes. Not sure what's going on there.

Anyway, good work!


t3K|Mac(Posted 2006) [#53]
@stevie: this dx7 dll looks way older than mine. now i have 3 different dx7.dlls. which one is the best?

dx7test.dll
DirectX7.dll
vardx7.dll

little chaos is coming up...


bytecode77(Posted 2006) [#54]
directx7.dll is the same as dx7test.dll
the name has just changed and i deleted the not-needed functions...

ps: daredevil, how is your progress?


DareDevil(Posted 2006) [#55]
the my proces is good i have found a litle bug in the initobject, this bug have effect in the load object that contain object null.

aptend a new version, what completed this you join the my system your.

ok!! bye ;)


t3K|Mac(Posted 2006) [#56]
thanks for the clear up.


DareDevil(Posted 2006) [#57]
I have integred your stencil buffer in the my systems is fast !!!

:)


bytecode77(Posted 2006) [#58]
GOOD!
a software stencil buffer is not very useful in games...


DareDevil(Posted 2006) [#59]
this is a link

http://digilander.libero.it/enzo_light/shw08.zip

lock software, the time systems is not correct o stencil buffer hardware has a slow speed

is fast the software simulate end not hardware?


bye


bytecode77(Posted 2006) [#60]
hey, thats not bad...man thats good! :)
yes, sure the hardware stencil buffer is faster... but there is a little bug...don't mid, i'll fix it soon!
the initobject() takes half a minute in the first sample, and there are >only< 2 spehres with 32 segments... quite to slowly for a real stencil shadow system ;)

have you got any idea what we could do?

edit: i noticed that you are better in creating volumes, and i am better in making it work with hardware, multilights and so on..

what about, that we could make s shadow system together? then we would be a team for this system! ok?
if you have icq or msn, you could give me your icq/msn number and we could chat a lil bit...


DareDevil(Posted 2006) [#61]
i'm not use icq :(

i have create the system silouette for permit a the new programmers the use software complet and simple that blitzbasic3d.

i'm ex programmer professional i have programmed wing commander prophecy for GBA and one part R-Type III by www.raylight.it studios Naples Italy.

http://www.mobygames.com/developer/sheet/view/developerId,166785/

The team for shadow? yes!!!

the my old team hobby is Eye&Light the link:

http://digilander.libero.it/eyeandlight/index.htm

bye


bytecode77(Posted 2006) [#62]
well, on www.icq.com you can download icq, then you must create an account and in my signature is my icq number, so you can easily find me :)

edit: here is OUR worklog :)
http://www.blitzbasic.com/logs/userlog.php?user=8270&log=660


bytecode77(Posted 2006) [#63]
i have played arround with shw08 for a few hours and i heve noticed that if you set the m4 mesh as a shadow caster, the shadow of that mesh looks anyhow...strange...


DareDevil(Posted 2006) [#64]
Good !!

i programmed the silouette in c++ for fast result and return the all


?????

bye


bytecode77(Posted 2006) [#65]
in c++? well... you may can make a volume dll for blitz, that would be the best :)


DareDevil(Posted 2006) [#66]
i have test the limits blitz, is view no screen the problem slow stencil, i have correct common type for max speed, and abjust your stencil sistem, lock gemedev site.

The new update:

digilander.libero.it/enzo_light/shw09.zip


Stevie G(Posted 2006) [#67]
You've got a major memory leak somewhere ... my system ran out of virtual memory after about 5 mins of running the shw example. Was a bugger to close it down.

Looks nice though .. assume the low res version is software stencils?

Stevie


bytecode77(Posted 2006) [#68]
how about making a solution in c++, and making a blitz dll? this would be the fastest solution EVER!


DareDevil(Posted 2006) [#69]
Ok new update:D silhouette fast speed up 10% resolved bug in common and general optimizzation .

Test this version

bye all

http://digilander.libero.it/enzo_light/shw10.zip


bytecode77(Posted 2006) [#70]
i have checked out the shw10 and there is a critical bug:



i don't know how this strip accures...the object has got only one surface. with the m4 model you see those strips, too!


DareDevil(Posted 2006) [#71]
I know this bug, but it has not been never resolved!!
perhaps the error is caused gives of connected the well faces not caused from the export
this bug I have an idea of like resolving it, I will insert a
tolerance on you concern to us
I have increased of an other 10% the performances of the silouette but it I have not still Posted perhaps why I succeed in 1/2 the speed


bytecode77(Posted 2006) [#72]
news: i have checked out the tfp libary from marksibly for tformpoint() commands on animated b3d meshes.
but there are too much bugs, so i cannot use it...

how is your progress?


JoshK(Posted 2006) [#73]
I got those strips when my quad faces were oriented backwards.

Test a third vertex along either of the triangles that make up the edge. Use the orientation of that vertex relative to the plane equation created by the quad to test which direction the quad should face.


Tom(Posted 2006) [#74]
Geometry is at fault here, not your code!

The strip is because the mesh is not a closed mesh. Shadow volumes must be completely closed, or consist of groups of closed meshes.

See...


The red and green lines show where an edge is exposed. Idealy, the 'top lip' red edge and the 'mouth cavity' blue edge should be spanned with polys. similarly, the green line should be joint to the lower mouth cavity inside :)


JoshK(Posted 2006) [#75]
Another tip:

When you are building the mesh edges, do NOT look for triangles that share vertices. You may have two different vertices in the same position, because of normals or texture mapping. Instead, look for triangles that share vertices that have an identical position. Compare the absolute value of the difference between each component of the vertex positions, and consider them the same if they less than a very small precision value, like 0.001:

Function VerticesMatch(surf,a,b)
If Abs(VertexX(surf,a)-VertexX(surf,b))<0.001
If Abs(VertexY(surf,a)-VertexY(surf,b))<0.001
If Abs(VertexZ(surf,a)-VertexZ(surf,b))<0.001
Return True
Endif
Endif
Endif
End Function


DareDevil(Posted 2006) [#76]
Ok!! for you the new update :D

the bug face is not resolved is the problem is object :(

ok pleace test the new version and check with others object


the new step is carmak sistem and multi light range

digilander.libero.it/enzo_light/shw11.zip

equation plane intersect rect?

bye


bytecode77(Posted 2006) [#77]
here is the new dll for the stencil buffer:
http://www.blitzbasic.com/Community/posts.php?topic=59699

use this instead of mine, because this one is better^^


DareDevil(Posted 2006) [#78]
the new version "shadowinclude", i have a problem for procedure tom for robust shadow pleace help me!!! :(
i have optmized other than for fast silhouette

the time render is very slow



Tom(Posted 2006) [#79]
Please use forum tags for pasting code! :)

Look for code/codebox
http://www.blitzbasic.com/faq/faq_entry.php?id=2


DareDevil(Posted 2006) [#80]
ok thanks for link

you help me!!


bytecode77(Posted 2006) [#81]
progress??


DareDevil(Posted 2006) [#82]
yes in the old code posted i have insert multy light system :)

this is a progress!!

no speed up addizional :( stencil buffer in not very speed for 5 render execute

if you have a idea for speed software or new alghoritm this is your house :D


new update for code stencil:

;=======================
; Creazione immagine ombra
; Fast2 ?
Function ShadowVolumeStenciBuffer_orig(ShowVol)
	EntityColor SHWSpriteFront, 5, 5, 5
	EntityAlpha SHWSpriteFront, 0.3
	;===>
	;SetBuffer  TextureBuffer(ShwTex1)
	;Cls 
	SetBuffer BackBuffer()
	;======================================================================
	;PASS 1
	;===>
	;Render object modal standard
	;===>
	HideEntity SHWSpriteFront
	;colour buffer OFF
	SetRenderState(Direct3DDevice7, D3DRS_CULLMODE, D3DCULL_CCW)
	;SetRenderState( Direct3DDevice7, D3DRS_ALPHABLENDENABLE, True );
	;SetRenderState( Direct3DDevice7, D3DRS_SRCBLEND, D3DBLEND_ONE );
	;SetRenderState( Direct3DDevice7, D3DRS_DESTBLEND, D3DBLEND_ONE );
	;lighting ON
	SetRenderState( Direct3DDevice7, D3DRS_AMBIENT, AMB_LIGHT );



DareDevil(Posted 2006) [#83]
this is a last update :( i not have orther idea

link:

http://digilander.libero.it/enzo_light/shw13.zip


bye :(


bytecode77(Posted 2006) [#84]
i will check it out when i get back from school...
cya


DareDevil(Posted 2006) [#85]
you is a student?

i have 29 years

what old are you?


bytecode77(Posted 2006) [#86]
i am 14 years old, but a good coder...


bytecode77(Posted 2006) [#87]
i have seen your work, but the bug with the faces isn't resolved yet :(...

some of the edge faces are casting wrong...

so they should be flipped...


DareDevil(Posted 2006) [#88]
this bug is in the init object, if you change in the sphere 32 o over "The bug show" ;)

the check vertex have a bug ?!?!

what is a bug?

what are I?

what sale live?

pleace help me for resolved bug!

all for one!! one for all :D


jfk EO-11110(Posted 2006) [#89]
I'd like to thank you guys again, I think you pushed stencil shadows to its limits for Blitz3D on an open source base.

Maybe the sooner or later somebody will add a fast volume creation.

Thanks!


Stevie G(Posted 2006) [#90]
Yeah, well done guys ... great work and alot of effort which is much appreciated. A damn shame it's not fast enough to use on a grander scale.

Hopefully if BRL can respond to Tom's renderworld() feature request and we'll all have super fast shadows soon!!

Stevie


DareDevil(Posted 2006) [#91]
i have search the bug for create object the time for resolved and is ok!!


bytecode77(Posted 2006) [#92]
sry, i do NOT understand your english...
please come to icq, download icq and post your icq numbere here!
´cya


DareDevil(Posted 2006) [#93]
ok the my number icq is 249548841


bytecode77(Posted 2006) [#94]
ok, thx :)