[PB 5.11] Where are the shadows?

Everything related to 3D programming
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

[PB 5.11] Where are the shadows?

Post 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
Last edited by Bananenfreak on Fri Jul 26, 2013 11:52 am, edited 1 time in total.
Image
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Where are the shadows?

Post by Comtois »

add this line

Code: Select all

EntityRenderMode(ground, 0)
Please correct my english
http://purebasic.developpez.com/
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Where are the shadows?

Post 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)
Image
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Where are the shadows?

Post 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
Image
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Where are the shadows?

Post 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
Please correct my english
http://purebasic.developpez.com/
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Where are the shadows?

Post 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.
Image
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Where are the shadows?

Post 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.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: [PB 5.11] Where are the shadows?

Post by Bananenfreak »

Fred posted: Fixed.

Not really... :-)

Did you test the other shadowtypes, too? Do they work correctly?
Image
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: [PB 5.11] Where are the shadows?

Post by Olby »

They all work, except the TextureAdditive gives really low resolution @ 4096.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: [PB 5.11] Where are the shadows?

Post 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?
Image
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: [PB 5.11] Where are the shadows?

Post 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.
Please correct my english
http://purebasic.developpez.com/
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: [PB 5.11] Where are the shadows?

Post by Bananenfreak »

Ok, i didn´t say anything ;)
Image
Post Reply