Fastlibs - shadows don't work

Blitz3D Forums/Blitz3D Beginners Area/Fastlibs - shadows don't work

Cubed Inc.(Posted 2010) [#1]
I went on fastlibs.com and downloaded the free trial and I want to learn everything about it before I buy it. I ran into a problem. I tried to create some noise blur shadows(seen in crisis,GTAIV etc) and the shadows won't show up or work at all.
Heres my code.
;Lego Island Rescue;

Include "include\FastExt.bb"
Include "include\ShadowsSimple.bb"

Graphics3D 1280,600,32,1

InitExt
TextureAnisotropy
TextureLodBias

CreateShadow 1 ; <<<<< create shadows (with quality=1) and customize his characteristics
ShadowRange 70 ; <<<<< set shadow range (70x70)
ShadowTexture = ShadowTexture() ; <<<<< get first shadow texture (shadow map)

Noise = LoadTexture("media\bump_noise.png") ; <<<<< load noise texture and set BUMP blend
TextureBlend Noise, FE_BUMP
ScaleTexture Noise, 0.15, 0.15


FadeOutTexture = LoadTexture("media\fade.png", 59)
ShadowFade FadeOutTexture


Const GRAVITY#=-2.5

Global GlowAlpha# = 101.0
Global GlowDarkPasses = 2
Global GlowBlurPasses = 4
Global GlowBlurRadius# = 0.35
Global GlowQuality = 0
Global GlowColorRed = 255
Global GlowColorGreen = 255
Global GlowColorBlue = 255
Global GlowAlphaTexture = 0

Const TYPE_PLAYER=1,TYPE_TARGET=3,TYPE_WATER=3
Const TYPE_SCENERY=10,TYPE_TERRAIN=11

Collisions TYPE_PLAYER,TYPE_TERRAIN,2,2
Collisions TYPE_PLAYER,TYPE_SCENERY,2,2
Collisions TYPE_TARGET,TYPE_TERRAIN,2,3
Collisions TYPE_TARGET,TYPE_SCENERY,2,2

;Lego Island;
island=LoadMesh("media/tower.b3d")
islandtex=LoadTexture("media/Untitled2.png",256)
PositionEntity island,0,-150,60
ScaleEntity island,4,4,4
EntityFX island,0
EntityType island,TYPE_TERRAIN

;Lego Island2;
island2=LoadMesh("media/tower.b3d")
islandtex2=LoadTexture("media/Untitled2.png",256)
PositionEntity island2,0,-150,5360
ScaleEntity island2,4,4,4
EntityFX island2,0
EntityType island2,TYPE_TERRAIN

;player;
player=LoadAnimMesh ("racer.b3d")
PositionEntity player,0,100,40
ScaleEntity player,2,2,2
EntityShininess player,0
EntityType player,TYPE_PLAYER

;test (it's not going to work, I just know it)
m=CreateCube()
PositionEntity m,1200,100,90
ScaleEntity m,100,100,100
CreateShadowCaster m

;water;
water = CreatePlane ()
h20 = LoadTexture ("media/water_tex.jpg",256)
EntityTexture water,h20
ScaleTexture h20, 200, 200
EntityAlpha water, 0.4
PositionEntity water,0,-140,60
EntityType water,TYPE_TERRAIN
EntityTexture water, Noise, 0, 1 ; <<<<< place noise texture before shadow texture
EntityTexture water, ShadowTexture, 0, 2 ; <<<<< place shadow texture to receiver

;camera (AKA the player);
camera=CreateCamera(target)
PositionEntity camera,0,100,-50
MoveEntity camera,0,3,-50
EntityType camera,TYPE_TARGET

;light;
light=CreateLight()
LightColor light,255,60,0
PositionEntity light,0,100,40
ShadowLight light

;target;
target=CreatePivot( player )
MoveEntity Target,0,40,-200
RotateEntity Target,0,80,0
EntityRadius Target,100,100

;crosshair;
CH = LoadImage ("media/crosshair.bmp")
MaskImage CH, 255, 0, 255
MidHandle CH

;sky/fog/range;
sky=CreateSphere(100)
skytex=LoadTexture("media/sky_RT.jpg")
EntityTexture sky,skytex
ScaleEntity sky,9000,9000,9000
CameraFogMode camera,10
CameraFogColor camera,200, 220, 255
CameraRange camera, 1,50000
CameraFogRange camera,1,2500-10
CameraClsColor camera,200,220,255
FlipMesh sky

smooth=True
;move camera;
While Not KeyDown(1)
TurnEntity sky,0,.1,0

If CountCollisions(island)<> 0 Then
;my failed alignment code;
islandx=CollisionNX( island,1 )
islandy=CollisionNY( island,1 )
islandz=CollisionNZ( island,1 )
If smooth Then
AlignToVector player,islandx,islandy,islandz,2,0.1 ;last parameter = .1
AlignToVector camera,islandx,islandy,islandz,2
Else
AlignToVector player,islandx,islandy,islandz,2 ;last parameter ommited: Default=1 = no smooth
End If
Else
;if not colliding, then align to a vertical vector: 0,1,0
If smooth Then
AlignToVector player, 0, 1, 0, 2, 0.1
Else
AlignToVector player, 0, 1, 0, 2
End If
EndIf


TranslateEntity player,0,GRAVITY,0
TranslateEntity camera,0,GRAVITY,0

MoveEntity player,0,0,15

If KeyDown(208)
MoveEntity player,0,0,-15
EndIf
If KeyDown(203)
TurnEntity player,0,1,0
EndIf
If KeyDown(205)
TurnEntity player,0,-1,0
EndIf
If Not KeyDown(1)
dx#=EntityX( target,True )-EntityX( camera )
dy#=EntityY( target,True )-EntityY( camera )
dz#=EntityZ( target,True )-EntityZ( camera )
TranslateEntity camera,dx*.3,dy*.2,dz*.3
EndIf
PointEntity camera,player

UpdateWorld
UpdateShadows camera
RenderWorld
;attach crosshair;
x = (MouseX () - x) / 3 + x
y = (MouseY () - y) / 3 + y

DrawImage CH, x, y
CustomPostprocessGlow GlowAlpha, GlowDarkPasses, GlowBlurPasses, GlowBlurRadius, GlowQuality, GlowColorRed, GlowColorGreen, GlowColorBlue, GlowAlphaTexture
RenderPostprocess FE_GLOW

Flip
Wend
End

please help.


Oiduts Studios(Posted 2010) [#2]
First of all, you really need to use forum codes. I cant really find anything wrong with your code. Just making sure you know that you are putting shadows on the water and not the land. It would be much better if you could be more specific.


Cubed Inc.(Posted 2010) [#3]
well see, I created a cube called m, and I tried to make it so that it would cast a noise blur shadow, and I tried to make the water act as a plane( like in the noise blur example ) and have the cube's noise blur shadow cast onto it, but it did not work. I hope that more specific:)


Oiduts Studios(Posted 2010) [#4]
Well i just noticed that your cube is scaled to 100x100x100. There might be a problem because the shadow range is 70. When you are looking at a giant cube you are far away from it right? So you should shrink your level down a bit. Hope I'm right.


Cubed Inc.(Posted 2010) [#5]
sorry for not replying in a while. I figured out the problem. thanks for trying to help anyway.