WorldShadows, material scrolling and blending issue

All bugs related to the 3D engine
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

WorldShadows, material scrolling and blending issue

Post by DK_PETER »

All versions: (5.44 and up - x86/x64)

Code: Select all

;Example - please check line 157

If InitEngine3D(#PB_Engine3D_AverageFPS) = 0 Or InitSprite() = 0 Or InitKeyboard() = 0
  End
EndIf

#SpritePos = 0
#SpriteStat = 1
#Relspeed = 0.93 ;Entity scroll speed

Structure _object
  id.i
  ma.i
  ms.i
  tx.i
EndStructure

Structure _Movement
  zoom.f
  rx.f
  rz.f
  relX.f
  relZ.f
EndStructure
Global mo._Movement

Declare.i Status()
Declare.i DrawScene()
Declare.i DrawObjects()

Global cam.i, ret.i, pl._object, lg.i, Quit.i = #False
Global NewList o._object()

mo\zoom = 200

ExamineDesktops()
OpenWindow(0, 0, 0, DesktopWidth(0), DesktopHeight(0), "Simple 'Isometric' illusion using Ogre3D", #PB_Window_BorderLess)
OpenWindowedScreen(WindowID(0), 0, 0, DesktopWidth(0), DesktopHeight(0))
Add3DArchive(".", #PB_3DArchive_FileSystem)
WorldShadows(#PB_Shadow_Additive)
lg = CreateLight(#PB_Any, $FF0000, -100, 200, -200)
cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(cam, 0, mo\zoom, 0)
RotateCamera(cam, -50, 45, 0)

ret = DrawScene()
ret = DrawObjects()

Repeat
  
  Repeat
    ev = WindowEvent()
  Until ev = 0
  
  ExamineKeyboard()
  
  If KeyboardPushed(#PB_Key_Escape)
    Quit = #True
  EndIf
  
  If KeyboardPushed(#PB_Key_Left)
    mo\relX + 0.001
    mo\rx = #Relspeed
  ElseIf KeyboardPushed(#PB_Key_Right)
    mo\relX - 0.001
    mo\rx = -#Relspeed
  Else
    mo\rx = 0
  EndIf
  
  If KeyboardPushed(#PB_Key_Up)
    mo\RelZ + 0.001
    mo\rz = #Relspeed
  ElseIf KeyboardPushed(#PB_Key_Down)
    mo\RelZ - 0.001
    mo\rz = -#Relspeed
  Else
    mo\rz = 0
  EndIf
  
  If KeyboardPushed(#PB_Key_Add)
    If mo\zoom - 0.4 > 100
      mo\zoom - 0.4
    Else
      mo\zoom = 100
    EndIf
  ElseIf KeyboardPushed(#PB_Key_Subtract)
    If mo\zoom + 0.4 < 200
      mo\zoom + 0.4
    Else
      mo\zoom = 200
    EndIf
  EndIf
  MoveCamera(cam, 0, mo\zoom, 0, #PB_Absolute)
  ScrollMaterial(pl\ma, mo\relX, mo\RelZ, #PB_Material_Fixed)
  
  ForEach o()
    If EntityX(o()\id)  > 500
      MoveEntity(o()\id, -500, EntityY(o()\id), EntityZ(o()\id), #PB_Absolute)
    ElseIf EntityX(o()\id) < -500
      MoveEntity(o()\id, 500, EntityY(o()\id), EntityZ(o()\id), #PB_Absolute)
    EndIf
    If EntityZ(o()\id)  > 500
      MoveEntity(o()\id, EntityX(o()\id), EntityY(o()\id), -500, #PB_Absolute)
    ElseIf EntityZ(o()\id) < -500
      MoveEntity(o()\id, EntityX(o()\id), EntityY(o()\id), 500, #PB_Absolute)
    EndIf
    MoveEntity(o()\id, mo\rx, 0, mo\rz, #PB_Relative)
  Next 
  
  RenderWorld()
  
  ret = Status()
  DisplayTransparentSprite(#SpritePos, 0, 0)
  DisplayTransparentSprite(#SpriteStat, 0, ScreenHeight()-30)
  FlipBuffers()
Until Quit = #True

Procedure.i DrawObjects()
  Protected  sc.i, c.i, x.f = -500, z.f = -500
  ;just place some cubes at some location using different sizes
  While x < 500
    While z < 500
      AddElement(o())
      sc = Random(60, 30)
      o()\ms = CreateCube(#PB_Any, 0.5)
      o()\id = CreateEntity(#PB_Any, MeshID(o()\ms), #PB_Material_None)
      ScaleEntity(o()\id, Random(100, 30), sc, Random(100, 30))
      MoveEntity(o()\id, x, sc/2, z, #PB_Absolute)
      z + 100
    Wend      
    x + 100
    z = -500
  Wend
  ProcedureReturn #True
EndProcedure

Procedure.i DrawScene()
  Protected x.i, y.i
  pl\ms = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
  CompilerIf #PB_Compiler_Version >= 550
    pl\tx = CreateTexture(#PB_Any, 512, 512, "Boxey")
  CompilerElse
    pl\tx = CreateTexture(#PB_Any, 512, 512)
  CompilerEndIf
  StartDrawing(TextureOutput(pl\tx))
  Box(0, 0, 512, 512, $52554F)
  For x = 0 To 512 Step 64
    For y = 0 To 512 Step 64
      Box(x, y, 32, 32, $9D989F)
      LineXY(x - 16, y, x - 16, y + 32, $FFFFFF)
      LineXY(x, y - 16, x + 32, y - 16, $FFFFFF)
    Next y
  Next x
  StopDrawing()
  pl\ma = CreateMaterial(#PB_Any, TextureID(pl\tx))
  MaterialBlendingMode(pl\ma, #PB_Material_Add)                   ;<---- Rem this and shadows returns - but material scrolling stops.
  MaterialFilteringMode(pl\ma, #PB_Material_Trilinear)
  pl\id = CreateEntity(#PB_Any, MeshID(pl\ms), MaterialID(pl\ma), 0, 0, 0)
  ScaleEntity(pl\id, 50, 0, 50)
  EntityRenderMode(pl\id, 0)
  ProcedureReturn #True
EndProcedure

Procedure.i Status()
  If IsSprite(#SpritePos) = 0: CreateSprite(#SpritePos, 400, 20) : TransparentSpriteColor(#SpritePos, $0) :  EndIf
  If IsSprite(#SpriteStat) = 0 : CreateSprite(#SpriteStat, 200, 20)  : TransparentSpriteColor(#SpriteStat, $0) : EndIf
  StartDrawing(SpriteOutput(#SpritePos))
  Box(0, 0, 400, 20, $0)
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(0, 0, "   scrollX: " + StrF(mo\relX,3) + " - ScrollZ: " + StrF(mo\RelZ,3), $FFFF57)
  StopDrawing()
  ;---------------------------------
  StartDrawing(SpriteOutput(#SpriteStat))
  Box(0, 0, 200, 20, $0)
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(0, 0, "   Fps: " + StrF(Engine3DStatus(#PB_Engine3D_AverageFPS), 2), $FFFF57)
  StopDrawing()
  ProcedureReturn #True
EndProcedure
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Saboteur
Enthusiast
Enthusiast
Posts: 271
Joined: Fri Apr 25, 2003 7:09 pm
Location: (Madrid) Spain
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by Saboteur »

I don't see material scrolling in any moment. In Mac OSX.
[:: PB Registered ::]

Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by DK_PETER »

Saboteur wrote:I don't see material scrolling in any moment. In Mac OSX.
? Use arrow keys to move entities and material..
+ and - to zoom
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
Saboteur
Enthusiast
Enthusiast
Posts: 271
Joined: Fri Apr 25, 2003 7:09 pm
Location: (Madrid) Spain
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by Saboteur »

Ok, I see.
Material don't scrolling, but if you use WorldShadows(#PB_Shadow_Modulative) the scroll works again.
I don't know if the 3d engine works very well, I have many problems with shadows, and terrains and distances.
[:: PB Registered ::]

Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by DK_PETER »

@Saboteur

True...Using WorldShadows(#PB_Shadow_Modulative) makes the scrolling continue but shadows are only partially rendered.
Try the other types and you'll see scrolling, noscrolling, shadows, partially shadows and no shadows..
Everything seems to collide with the MaterialBlendingMode() at line 157.

In general, I truly like the PB's 3D Ogre implementation. Granted, it has som quirkiness, but mostly you can 'circumvent'
or script your way out of some situations. I believe the team will continue to enhance it gradually over time - so there's always
something new to look forward to. Furthermore, the continued implementation makes PB even stronger.
This is just another small bump, which the team will deal with, eventually.

Thanks for showing interest. :wink:
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
Psychophanta
Addict
Addict
Posts: 4975
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by Psychophanta »

Saboteur wrote:Ok, I see.
Material don't scrolling, but if you use WorldShadows(#PB_Shadow_Modulative) the scroll works again.
I don't know if the 3d engine works very well, I have many problems with shadows, and terrains and distances.
Does ScrollMaterial() with #PB_Material_Fixed flag work really?
I don't get this command to work.

Also, shadows has problems, tested with several VGAs in windows XP, 7, 8.1 and 10.
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: WorldShadows, material scrolling and blending issue

Post by Dude »

Saboteur wrote:I don't know if the 3d engine works very well
Here's an example game that may change your mind:

viewtopic.php?f=14&t=71095

:shock:
User avatar
Psychophanta
Addict
Addict
Posts: 4975
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by Psychophanta »

Dude wrote:
Saboteur wrote:I don't know if the 3d engine works very well
Here's an example game that may change your mind:

viewtopic.php?f=14&t=71095

:shock:
That topic shows the engine works well, but not "very well" :wink:
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: WorldShadows, material scrolling and blending issue

Post by Dude »

Psychophanta wrote:That topic shows the engine works well, but not "very well" :wink:
I disagree. I'd say it shows it "extremely well", based on what can be achieved with it.
User avatar
Psychophanta
Addict
Addict
Posts: 4975
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by Psychophanta »

The engine works. That is what demonstate the pointed demo.
But there is a large path for the PB 3D to be a right one.
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: WorldShadows, material scrolling and blending issue

Post by applePi »

@Psychophanta
Does ScrollMaterial() with #PB_Material_Fixed flag work really?
it works if we put ScrollMaterial inside the main Loop like this:

Code: Select all

InitEngine3D() : InitKeyboard() : InitSprite()

window = OpenWindow(#PB_Any,0,0,800,600,"Scrolling material")
OpenWindowedScreen(WindowID(window),0,0,800,600)
Add3DArchive(#PB_Compiler_Home + "Examples\3D\Data\Textures\", #PB_3DArchive_FileSystem)

Mesh = CreatePlane(#PB_Any, 2, 2, 1, 1, 1, 1)
Texture = LoadTexture(#PB_Any, "MRAMOR6X6.jpg")
Material = CreateMaterial(#PB_Any,TextureID(texture))
Sprite = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 0, 0, 0)
RotateEntity(Sprite, 90, 0, 0, #PB_Relative)

AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), 0, 0, 50)

;WorldShadows(#PB_Shadow_Additive) ; will change behaviour of scrollmaterial
;WorldShadows(#PB_Shadow_Modulative) ; works okay

Camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(Camera, 0, 0, 5)
CameraLookAt(camera, 0, 0, 0)

;ScrollMaterial(Material, 0.2, 0, #PB_Material_Animated)
Repeat
      Repeat   
        Event = WindowEvent()
        Until Event = 0
    
  ExamineKeyboard() 
    
   
  x.f+0.01: y.f+0.01
  ScrollMaterial(Material, x, y, #PB_Material_Fixed)
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) 
while ScrollMaterial with #PB_Material_Animated like this:
ScrollMaterial(Material, 0.2, 0, #PB_Material_Animated)
should be used outside the main loop, since it initiates the automatic scrolling by the specified x,y amounts
User avatar
Psychophanta
Addict
Addict
Posts: 4975
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Re: WorldShadows, material scrolling and blending issue

Post by Psychophanta »

I see applePi.
In fact it works like it should:

Code: Select all

InitEngine3D() : InitKeyboard() : InitSprite()
window = OpenWindow(#PB_Any,0,0,800,600,"Scrolling material")
OpenWindowedScreen(WindowID(window),0,0,800,600)
Add3DArchive(#PB_Compiler_Home + "Examples\3D\Data\Textures\", #PB_3DArchive_FileSystem)
Mesh = CreatePlane(#PB_Any, 2, 2, 1, 1, 1, 1)
Texture = LoadTexture(#PB_Any, "MRAMOR6X6.jpg")
Material = CreateMaterial(#PB_Any,TextureID(texture))
Sprite = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 0, 0, 0)
RotateEntity(Sprite, 90, 0, 0, #PB_Relative)
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), 0, 0, 50)
Camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(Camera, 0, 0, 5)
CameraLookAt(camera, 0, 0, 0)
ScrollMaterial(Material,0,0.2,#PB_Material_Fixed)
Repeat
      Repeat   
        Event = WindowEvent()
        Until Event = 0
     ExamineKeyboard()
  RenderWorld()
  FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
but not in my program. At the moment i've not located the issue , so I had to have a workaround.
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
Post Reply