Help Engine Shadow Devil.

Blitz3D Forums/Blitz3D Programming/Help Engine Shadow Devil.

Yue(Posted 2012) [#1]
;Include all the includes for the shadow system
Include "..\Includes\DevilShadowSystem.bb"

Include "..\Includes\ShadowVolumes.bb"

Include "..\Includes\UserInterface.bb"
.Init
;Setup graphics
Graphics3D 800, 600, 32, 0



SetBuffer BackBuffer()

;Camera
Cam = CreateCamera()
PositionEntity Cam, 0, 3, -8

;Init shadows with the player camera.
;Note: Before rendering all other cameras, like cubemapping cameras must be hidden!
InitShadows(Cam)

;Light
Light = CreateLight()
PositionEntity Light, 10, 10, 0
PointEntity Light, CreatePivot()
SetShadowLight(Light) ;a shadow light
;the second parameter(optional) decides about if this light is parallel

;Floor
c = CreateCube()
ScaleEntity c, 5, 1, 5
EntityColor c, 0, 0, 255
SetShadowMesh(c, False) ;shadow receiver(false = receiver)

;Caster
Caster = CreateCube()
PositionEntity Caster, 3, 3, 0
EntityColor Caster, 255, 0, 0
SetShadowMesh(Caster,True) ;shadow caster(false = caster)

;Main loop
While Not KeyHit(1)
	TurnEntity Caster, 1, .5, 1.5
	
	;Use Render() insted of RenderWorld()
	;Don't ever use RenderWorld. Not even in the cubemap rendering proccess!
	;Render(mode = 0, anim_tween#
	;mode 0 = shadows and all other stuff desabled.
	;mode 1 = shadows and all other stuff enabled.
	;mode 2 = debug mode; volumes visible only. (For advanced users only!)
	;anim_tween# is the animation step for UpdateWorld
	;=> UpodateWorld(anim_tween#)
	Render(1)
	
	;Replace the parameter at Render() to see the effect. (possible parameters : 0;1;2)
	
	Flip
Wend
FreeShadows() 
Goto Init


End


Hi, this is not working in full screen mode, The same applies to the engine Ashadow to implement volumetric shadows., any suggestions.

Last edited 2012


Yue(Posted 2012) [#2]
Error Now: =(

Include "..\Includes\DevilShadowSystem.bb"
Include "..\Includes\ShadowVolumes.bb"
Include "..\Includes\UserInterface.bb"
;Setup graphics
Graphics3D 800, 600, 32, 0
SetBuffer BackBuffer()

;Camera
Cam = CreateCamera()
PositionEntity Cam, 0, 3, -8

;Init shadows with the player camera.
;Note: Before rendering all other cameras, like cubemapping cameras must be hidden!
InitShadows(Cam)

;Light
Light = CreateLight()
PositionEntity Light, 10, 10, 0
PointEntity Light, CreatePivot()
SetShadowLight(Light) ;a shadow light
;the second parameter(optional) decides about if this light is parallel

;Floor
c = CreateCube()
ScaleEntity c, 5, 1, 5
EntityColor c, 0, 0, 255
SetShadowMesh(c, False,"puerco.shv") ;shadow receiver(false = receiver)

;Caster
Caster = CreateCube()
PositionEntity Caster, 3, 3, 0
EntityColor Caster, 255, 0, 0
SetShadowMesh(Caster,True) ;shadow caster(false = caster)

;Main loop
While Not KeyHit(1)
	TurnEntity Caster, 1, .5, 1.5
	
	Render(1)
	Flip
Wend


FreeShadows() 
EndGraphics 
End



bytecode77(Posted 2012) [#3]
The demo you sent me starts with the splash screen and creates a MAV. Could you send me some compileable source code so I can debug it?

Thanks.


Yue(Posted 2012) [#4]
Ok,This small example shows the change of screen resolution, mode 0. Without using the shadow engine Devil.

Be right back and put the code using Shadow Devil.

; ============================
;	Change Resolution Screen
; 	No Engine Shadow Devil
; ============================

Local Height%					; Height Screen.
Local Width%					; Widht Screen.
Local Camera%					; Camera.
Local Light%					; Light.
Local Cube%						; Cube.

Const  Key_Exit% = 1			; Key Exit.

Local Change%					; Change Resolution.


Height% = 600  					; Init Height.
Width%	= 800					; Init Width.
.Init						; New Resolution Screen.
; Init Graphics.
;==============================
Graphics3D Width%,Height,32,0 	               ; Screen full mode.
SetBuffer BackBuffer()			       ; Draw Back Buffer.


; Init Entity.
;==============================

Camera% = CreateCamera()		       ; Entity Camera.
Light%  = CreateLight()			       ; Entity Light.
Cube%	= CreateCube()			       ; Entity Cube.

PositionEntity Cube%,0,0,5		       ; Position Cube.



; Bucle
;===============================
Repeat 
	
	
	
	; Button Mouse Left.
	If MouseHit(1) = True 
		Width% 		= 1024
		Height% 	= 768
		Exit 
	End If 
	
	If KeyHit(Key_Exit) End 	; Exit to Windows.
	TurnEntity Cube%,0,1,0
	
	RenderWorld 
	
	Flip
Forever
FlushKeys()
EndGraphics
Goto Init						; Change Resolution UP

; Remember Full Screen mode.



Code Engine Shadow Devil.
 ============================
;	Change Resolution Screen
; 	Engine Shadow Devil Bug
; ============================


Include "..\Includes\DevilShadowSystem.bb"
Include "..\Includes\ShadowVolumes.bb"
Include "..\Includes\UserInterface.bb"


Local Height%					; Height Screen.
Local Width%					; Widht Screen.

Local Camera%					; Camera.
Local Light%					; Light.
Local Cube%						; Cube.
Local Terrain%					; Terrain.

Const  Key_Exit% = 1			; Key Exit.

Local Change%					; Change Resolution.


Height% = 600  					; Init Height.
Width%	= 800					; Init Width.
.Init							; New Resolution Screen.
; Init Graphics.
;==============================
Graphics3D Width%,Height,32,0 	; Screen full mode.
SetBuffer BackBuffer()			; Draw Back Buffer.


; Init Entity.
;==============================

Camera% = CreateCamera()		; Entity Camera.
Light%  = CreateLight()			; Entity Light.
Cube%	= CreateCube()			; Entity Cube.
Terrain%= CreatePlane()			; Terrain%

PositionEntity Cube%,0,0,5		; Position Cube.
PositionEntity Terrain%,0,-5,0  ; Position Terrain.
PositionEntity Light, 0, 10, 0  ; Position Ligh.

InitShadows(Camera%)			; Init Engine Shadow Devil.
SetShadowLight(Light%)    		; Init Light Sahdow.

RotateEntity Light%,90,0,0		; Rotate entity Light.
SetShadowMesh(Terrain%, False)  ; Receiver Terrain.
SetShadowMesh(Cube%,True)		; Caster entity Cube.

; Bucle
;===============================
Repeat 
	
	
	
	; Button Mouse Left.
	If MouseHit(1) = True 
		Width% 		= 1024
		Height% 	= 768
		Exit 
	End If 
	
	If KeyHit(Key_Exit) End 	; Exit to Windows.
	TurnEntity Cube%,0,1,0
	
	Render(1) 
	
	Flip
Forever
FreeShadows()
FlushKeys()
EndGraphics
Goto Init						; Change Resolution UP

; Remember Full Screen mode.



Error mode 0 in Graphics3D



Last edited 2012

Last edited 2012


bytecode77(Posted 2012) [#5]
It seems like I'm not able to compile it as Blitz3D doesn't work for me anymore. Well I haven't been using it for years either.

Call me stupid, but can someone explain me why Blitz3D keeps telling me that the function wasn't found even if I put my OWN DLL and decls files into the userlibs directory? I don't code in BB anymore so I might miss something, or is Blitz3D too old to run on my machine?

Btw: Do you really have 128 MB RAM?


Yasha(Posted 2012) [#6]
Blitz3D keeps telling me that the function wasn't found


Maybe a stupid question, but did you restart Blitz? As far as I know it searches for DLLs when the IDE starts up (if you run it from the default IDE and not a third-party editor), not when you hit compile.


bytecode77(Posted 2012) [#7]
Yes I did restart the IDE. I coded alot in BB about 6-7 years ago. Now I can't even compile the Devil Shadow System :D

@Yue: Could you send me the debug & release executables of the source-code above?


Yue(Posted 2012) [#8]
Well, first of all thank you for your help, and what's the question, unfortunately I live in the ass of the world and everything would have a better computer, but never mind, I live in the stone age, I guess that is the inequality of the planet earth where I live.

Already shipping codes.


Yue(Posted 2012) [#9]
Here code NoBug (No Engine Shadow Devil)
http://www.mediafire.com/?jjddfhw5wfkk73b

Here code (Engine Shadow Devil)
http://www.mediafire.com/?a5x5lelnj3x42v9


bytecode77(Posted 2012) [#10]
Bug.exe works perfectly. It is consuming about 30-60 MB RAM. When you only have 128 MB in total, I gues the solution is pretty obvious :)

http://www.amazon.com/s/ref=nb_sb_noss_1/183-1609383-5759612?url=search-alias%3Daps&field-keywords=16+gb+ddr3+ram&x=0&y=0
Pick your choise.


Yue(Posted 2012) [#11]



Total Ram.
Free Ram.


bytecode77(Posted 2012) [#12]
Ok, so RAM is not the Problem. I tested it on Windows 7 x64 and it crashes once I click and the resolution is changed. My guess is that this is a bug in the Devil Shadow System. Since I'm not developing on it anymore, I think you will have to find a work around like restarting the program. I'm sorry.


Yue(Posted 2012) [#13]


The worst part is that so does the lib Ashadow.

Last edited 2012


bytecode77(Posted 2012) [#14]
And the very evilest worst part is, that whole Blitz3D is dying, if not already dead! But this topic has been discussed like a million times.
I started programming in C# about 6-7 years ago. That was exactly the time when I stopped coding in Blitz. Once you get used to code in Visual Studio, you may never use the Blitz IDE again, or any other IDE! That's also why there are so few IDEs around for Blitz. Because once you learn a language which is capable to develop an IDE for Blitz3D, you stop caring for Blitz3D at all! Get it ;)
Well, I'm still proud of the success of the Devil-Engines as I was 15 years old when I coded them. Also I never planed anything like it. I will host them for download for as long as Blitz3D exists, but I will not code anything in Blitz again :(


bytecode77(Posted 2012) [#15]
One more thing: A good alternative to DSS and Ashadow is the Swift Shadow System. I own it and it is really great. You could buy it and give it a try!


Yue(Posted 2012) [#16]
=( I have no money I'm poor, I live in the ass of the world ...


RemiD(Posted 2012) [#17]
Yue, here is a code example using Devil Shadow System, that works on 2 computers with windows 7 home premium 64 bits, and on 1 computer with windows XP home SP2.

;Include all the includes for the shadow system
Include "Includes\DevilShadowSystem.bb"
Include "Includes\ShadowVolumes.bb"
Include "Includes\UserInterface.bb"

;Setups graphics
Graphics3D(800,600,32,2)
HidePointer()
SeedRnd(MilliSecs())

;Creates the Camera
Camera = CreateCamera()
PositionEntity(Camera,5.0,1.6,-3.0)
RotateEntity(Camera,0.0,0.0,0.0)

;Init shadows with the player camera.
;Note: Before rendering all other cameras, like cubemapping cameras must be hidden!
InitShadows(Camera)

;Creates the Light
Light = CreateLight(2)
LightRange(Light,1.0)
LightColor(Light,255,125,000)
PositionEntity(Light,1.0,1.25,1.0)
SetShadowLight(Light) ; a light that casts shadows
LightMarqueur = CreateCube()
ScaleMesh(LightMarqueur,0.1/2,0.1/2,0.1/2)
EntityColor(LightMarqueur,225,125,000)
EntityFX(LightMarqueur,1)
PositionEntity(LightMarqueur,EntityX(Light,True),EntityY(Light,True),EntityZ(Light,True))
EntityParent(LightMarqueur,Light,True)

AmbientLight(030,030,030)

GroundXPart = CreateMesh()
GroundXPartSurface = CreateSurface(GroundXPart)
AddVertex(GroundXPartSurface, 0.0, 0.0, 0.0, 0.000, 1.000 )
AddVertex(GroundXPartSurface, 0.0, 0.0, 1.0, 0.000, 0.000 )
AddVertex(GroundXPartSurface, 1.0, 0.0, 1.0, 1.000, 0.000 )
AddVertex(GroundXPartSurface, 1.0, 0.0, 0.0, 1.000, 1.000 )
AddTriangle(GroundXPartSurface,0,1,2)
AddTriangle(GroundXPartSurface,0,2,3)
UpdateNormals(GroundXPart)
EntityColor(GroundXPart,255,255,255)
PositionEntity(GroundXPart,0,0,0)

;Receiver
Ground = CreateMesh()
For X% = 0 To 9
 For Z% = 0 To 9
  GroundPart = CopyMesh(GroundXPart)		
  PositionMesh(GroundPart,X%,0.0,Z%)
  AddMesh(GroundPart,Ground)
  FreeEntity(GroundPart)
 Next
Next
FreeEntity(GroundXPart)
SetShadowMesh(Ground,False) ;shadow receiver (False = Receiver)
EntityColor(Ground,075,075,075)
PositionEntity(Ground,0,0,0)

;Casters
Torche = CreateMesh()
EntityColor(Torche,075,050,025)
PositionEntity(Torche,5.0,0.0,1.0)
TorchePart1 = CreateCylinder(8)
ScaleMesh(TorchePart1,0.05/2,0.95/2,0.05/2)
PositionMesh(TorchePart1,0.0,0.95/2,0.0)
AddMesh(TorchePart1,Torche)
FreeEntity(TorchePart1)
TorchePart2 = CreateCylinder(8)
ScaleMesh(TorchePart2,0.1/2,0.05/2,0.1/2)
PositionMesh(TorchePart2,0.0,0.95+0.05/2,0.0)
AddMesh(TorchePart2,Torche)
FreeEntity(TorchePart2)
SetShadowMesh(Torche,True) ;shadow caster (True = Caster)
PositionEntity(Light,5.0,1.25,1.0)
EntityParent(Light,Torche,True)

Crate = CreateCube()
ScaleMesh(Crate,1.0/2,1.0/2,1.0/2)
EntityColor(Crate,075,050,025)
PositionMesh(Crate,0.0,1.0/2,0.0)
PositionEntity(Crate,5.0,0.0,2.5)
RotateEntity(Crate,0.0,45.0,0.0)
SetShadowMesh(Crate,True) ;shadow caster (True = Caster)

Colonne1 = CreateCylinder(8)
ScaleMesh(Colonne1,0.25/2,3.0/2,0.25/2)
EntityColor(Colonne1,075,075,075)
PositionMesh(Colonne1,0.0,3.0/2,0.0)
PositionEntity(Colonne1,2.5,0.0,2.5)
SetShadowMesh(Colonne1,True) ;shadow caster (True = Caster)

Colonne2 = CreateCylinder(8)
ScaleMesh(Colonne2,0.25/2,3.0/2,0.25/2)
EntityColor(Colonne2,075,075,075)
PositionMesh(Colonne2,0.0,3.0/2,0.0)
PositionEntity(Colonne2,7.5,0.0,2.5)
SetShadowMesh(Colonne2,True) ;shadow caster (True = Caster)

Colonne3 = CreateCylinder(8)
ScaleMesh(Colonne3,0.25/2,3.0/2,0.25/2)
EntityColor(Colonne3,075,075,075)
PositionMesh(Colonne3,0.0,3.0/2,0.0)
PositionEntity(Colonne3,3.5,0.0,5.0)
SetShadowMesh(Colonne3,True) ;shadow caster (True = Caster)

Colonne4 = CreateCylinder(8)
ScaleMesh(Colonne4,0.25/2,3.0/2,0.25/2)
EntityColor(Colonne4,075,075,075)
PositionMesh(Colonne4,0.0,3.0/2,0.0)
PositionEntity(Colonne4,6.5,0.0,5.0)
SetShadowMesh(Colonne4,True) ;shadow caster (True = Caster)

;Main loop
Repeat
	
 Cls
	
 If KeyDown(17) = True
  MoveEntity(Camera,0.0,0.0,0.1)	
 EndIf
 If KeyDown(31) = True
  MoveEntity(Camera,0.0,0.0,-0.1)		
 EndIf
 If KeyDown(30) = True
  TurnEntity(Camera,0.0,1.0,0.0)	
 EndIf
 If KeyDown(32) = True
  TurnEntity(Camera,0.0,-1.0,0.0)		
 EndIf
	
 MoveEntity(Torche,0.0,0.0,0.1)
 TurnEntity(Torche,0.0,10.0,0.0)
	
 If(KeyDown(2)=True)
  Wireframe(True)
 Else
  Wireframe(False)
 EndIf	
	
 ;Use Render() insted of RenderWorld()
 ;Don't ever use RenderWorld. Not even in the cubemap rendering proccess!
 ;Render(mode = 0, anim_tween#
 ;mode 0 = shadows and all other stuff desabled.
 ;mode 1 = shadows and all other stuff enabled.
 ;mode 2 = debug mode; volumes visible only. (For advanced users only!)
 ;anim_tween# is the animation step for UpdateWorld
 ;=> UpodateWorld(anim_tween#)
 ;Replace the parameter at Render() to see the effect. (possible parameters : 0;1;2)
 Render(1)

 Flip(True)

Until(KeyDown(1)=True)

FreeShadows()

End


You need to have these dll and decls in the Blitz3d/userlibs directory :
DevilShadowSystem_B3D.dll
DevilShadowSystem_DX7.dll
DevilShadowSystem.decls