WorldShadows TextureAdditive help

Everything related to 3D programming
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

WorldShadows TextureAdditive help

Post by Samuel »

I can't get TextureAdditive to display any shadows. I know they can work because the Character demo has them and they work fine.
I'm thinking that I might have to do something extra with the texture, but that's just a guess.


Code: Select all

;*******************Press Escape To Exit**********************
#CameraSpeed=1
If InitEngine3D()
  InitSprite()
  InitKeyboard()
  InitMouse()


 OpenWindow(0, 0, 0, 1000, 800, "Texture Additive Test", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
 OpenWindowedScreen(WindowID(0), 0, 0, 1000, 800, 0, 0, 0)


Define.d KeyX, KeyY, MouseX, MouseY

    
    CreateTexture(0, 32, 32)
     StartDrawing(TextureOutput(0))
       Box(0, 0, 32, 32 ,RGB(150,150,150))
     StopDrawing()
    
    CreateMaterial(0, TextureID(0))
    
    CreateCube(0,50)
    CreatePlane(1, 1000, 1000, 10, 10, 10, 10)
    
    CreateEntity(0, MeshID(0), MaterialID(0),0,0,0)
    CreateEntity(1,MeshID(1),MaterialID(0), 0, -100, 0)
   
    CreateLight(0, RGB(0, 55, 155), 200, 400 , 1000)
    CreateCamera(0, 0, 0, 100, 100)
    ;CameraLocate(0, 0, 0, 400)
    MoveCamera(0,0,0,400,#PB_Absolute)
    
    WorldShadows(#PB_Shadow_TextureAdditive , 0, 0, 512)
    ;WorldShadows(#PB_Shadow_Additive , 0, 0)
    Repeat

      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      
      If ExamineKeyboard()
        
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
        
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf    
        
      EndIf
      

      RotateEntity(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape)

  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: WorldShadows TextureAdditive help

Post by Comtois »

add this line

Code: Select all

   EntityRenderMode(1,0)
Please correct my english
http://purebasic.developpez.com/
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: WorldShadows TextureAdditive help

Post by Samuel »

Thank you for the help Comtois. That took care of the problem.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: WorldShadows TextureAdditive help

Post by Olby »

Comtois wrote:add this line

Code: Select all

   EntityRenderMode(1,0)
Can you please explain what you did? 0 does not correspond to any of the accepted constants, so you just "switch off" extra rendering modes. But how come additive shadows work without #PB_Entity_CastShadow ?
Thanks.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: WorldShadows TextureAdditive help

Post by Comtois »

Here is a tutorial that explains this better than I ever could.

http://www.ogre3d.org/tikiwiki/Basic+Tu ... e_Supports

Extract :
Neat huh? There are two more things we need to do with our ground before we are finished with it. The first is to tell the SceneManager that we don't want it to cast shadows since it is what's being used for shadows to project on.

Code: Select all

entGround->setCastShadows(false);
Please correct my english
http://purebasic.developpez.com/
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: WorldShadows TextureAdditive help

Post by Olby »

Makes sense. Thanks!
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Post Reply