Page 1 of 1

[PB 5.11] Where are the shadows?

Posted: Fri Jul 26, 2013 9:20 am
by Bananenfreak
Hiho,

here is a code. The code should display the issue that only one pair of shadows is working correct at the "same" time (Modulative and Additive or TexureAdditive). But in fact, I don´t see any shadow. What is the Problem with this code? I can´t see my issue...

Code: Select all

EnableExplicit

Define.i cube, light, cam, ground, cube_mesh, ground_mesh

InitEngine3D()
InitSprite()
InitKeyboard()

OpenScreen(1920, 1080, 32, "Test_0", #PB_Screen_SmartSynchronization)

cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(cam, 0, 20, 0, #PB_Absolute)
CameraLookAt(cam, 10, 0, 10)

;WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(0, 0, 0), 4096)

light = CreateLight(#PB_Any, RGB(255, 255, 255), 20, 10, 20, #PB_Light_Directional)
LightDirection(light, 0.4, -1, 0.2)
AmbientColor(RGB(85,85,85))

cube_mesh = CreateCube(#PB_Any, 2)
BuildMeshShadowVolume(cube_mesh)
cube = CreateEntity(#PB_Any, MeshID(cube_mesh), 0, 10, 1, 10)

ground_mesh = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
BuildMeshShadowVolume(ground_mesh)
ground = CreateEntity(#PB_Any, MeshID(ground_mesh), 0, 10, 0, 10)

Repeat
  ClearScreen(RGB(0, 0, 0))
  
  ExamineKeyboard()
  
  RenderWorld()
  FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)

End

Re: Where are the shadows?

Posted: Fri Jul 26, 2013 9:25 am
by Comtois
add this line

Code: Select all

EntityRenderMode(ground, 0)

Re: Where are the shadows?

Posted: Fri Jul 26, 2013 9:36 am
by Bananenfreak
In the german Wiki, there is a entry:
#PB_Entity_CastShadow : Das Entity wirft einen Schatten, wenn WorldShadows() aktiviert wurde (Standard)
The Entity casts by default shadows, because Worldshadows is Default on.
Is this a issue in the wiki or not updated?

The english documentation:
http://www.purebasic.com/documentation/ ... rmode.html

Try this line:

Code: Select all

Debug #PB_Entity_CastShadow
You will receive a 4. What is the constant called "0"? Time for #PB_Entity_RecieveShadow, huh?

Ehm, next Problem:
Why this isn´t working correctly?

Code: Select all

EntityRenderMode(ground, 0 | #PB_Entity_CastShadow)
EntityRenderMode(cube, 0 | #PB_Entity_CastShadow)

Re: Where are the shadows?

Posted: Fri Jul 26, 2013 9:52 am
by Bananenfreak
Why this code is working with "TextureAdditive" but not with the other shadowtypes?!

Code: Select all

EnableExplicit

Define.i cube, light, cam, ground, cube_mesh, ground_mesh

InitEngine3D()
InitSprite()
InitKeyboard()

OpenScreen(1920, 1080, 32, "Test_0", #PB_Screen_SmartSynchronization)

cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(cam, 0, 20, 0, #PB_Absolute)
CameraLookAt(cam, 10, 0, 10)

WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(0, 0, 0), 4096) ;Additive and Modulative don´t work!

light = CreateLight(#PB_Any, RGB(255, 255, 255), 20, 10, 20, #PB_Light_Point)
;LightDirection(light, 0.4, -1, 0.2)
AmbientColor(RGB(85,85,85))

cube_mesh = CreateCube(#PB_Any, 2)
cube = CreateEntity(#PB_Any, MeshID(cube_mesh), 0, 10, 1, 10)
EntityRenderMode(cube, #PB_Entity_CastShadow)

ground_mesh = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
ground = CreateEntity(#PB_Any, MeshID(ground_mesh), 0, 10, 0, 10)
EntityRenderMode(ground, 0);| #PB_Entity_CastShadow)

Repeat
  ClearScreen(RGB(0, 0, 0))
  
  ExamineKeyboard()
  
  RenderWorld()
  FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)

End

Re: Where are the shadows?

Posted: Fri Jul 26, 2013 10:49 am
by Comtois
Bananenfreak wrote:Why this code is working with "TextureAdditive" but not with the other shadowtypes?!
All work fine here, even with this constant that is not documented "#PB_Shadow_TextureModulative = 5"

just changed light position :

Code: Select all

EnableExplicit

Define.i cube, light, cam, ground, cube_mesh, ground_mesh

InitEngine3D()
InitSprite()
InitKeyboard()

OpenScreen(1920, 1080, 32, "Test_0", #PB_Screen_SmartSynchronization)

cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(cam, 0, 20, 0, #PB_Absolute)
CameraLookAt(cam, 10, 0, 10)

WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(0, 0, 0), 4096) ;Additive and Modulative don´t work!

light = CreateLight(#PB_Any, RGB(255, 255, 255), 220, 210, 220, #PB_Light_Point)
;LightDirection(light, 0.4, -1, 0.2)
AmbientColor(RGB(85,85,85))

cube_mesh = CreateCube(#PB_Any, 2)
cube = CreateEntity(#PB_Any, MeshID(cube_mesh), 0, 10, 1, 10)
EntityRenderMode(cube, #PB_Entity_CastShadow)

ground_mesh = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
ground = CreateEntity(#PB_Any, MeshID(ground_mesh), 0, 10, 0, 10)
EntityRenderMode(ground, 0)

Repeat
  ClearScreen(RGB(0, 0, 0))
 
  ExamineKeyboard()
 
  RenderWorld()
  FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)

End

Re: Where are the shadows?

Posted: Fri Jul 26, 2013 11:47 am
by Bananenfreak
Work fine? With PB 5.11 or 5.20 Beta? Fred fixed a few bugs with the Shadows... Here, on my PC, the TextureAdditive shadows are very low res and in case the other types don´t work.

Re: Where are the shadows?

Posted: Fri Jul 26, 2013 1:03 pm
by Olby
Bananenfreak wrote:Work fine? With PB 5.11 or 5.20 Beta? Fred fixed a few bugs with the Shadows... Here, on my PC, the TextureAdditive shadows are very low res and in case the other types don´t work.
With 5.20 beta 7 shadows are rendered in extremely low resolution.

Re: [PB 5.11] Where are the shadows?

Posted: Fri Jul 26, 2013 3:35 pm
by Bananenfreak
Fred posted: Fixed.

Not really... :-)

Did you test the other shadowtypes, too? Do they work correctly?

Re: [PB 5.11] Where are the shadows?

Posted: Fri Jul 26, 2013 4:40 pm
by Olby
They all work, except the TextureAdditive gives really low resolution @ 4096.

Re: [PB 5.11] Where are the shadows?

Posted: Sat Jul 27, 2013 8:45 am
by Bananenfreak
Hmm, why TextureAdditive doesn´t work proper? 4096 is in my mind a medium to high Resolution for shadows...
If the light is near the cube, the shadow is correct. But as much as the light is away from the cube, the more the shadow will be in low Resolution. Is this a bug?

Re: [PB 5.11] Where are the shadows?

Posted: Sat Jul 27, 2013 9:43 am
by Comtois
extract from ogre's doc
The other issue is with point lights. Because texture shadows require a render to texture in the direction of the light, omnidirectional lights (point lights) would require 6 renders to totally cover all the directions shadows might be cast. For this reason, Ogre primarily supports directional lights and spotlights for generating texture shadows; you can use point lights but they will only work if off-camera since they are essentially turned into a spotlight shining into your camera frustum for the purposes of texture shadows.

Re: [PB 5.11] Where are the shadows?

Posted: Sat Jul 27, 2013 12:03 pm
by Bananenfreak
Ok, i didn´t say anything ;)