SetRenderQueue question

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

SetRenderQueue question

Post by Samuel »

Can SetRenderQueue() work with objects that are a certain distance away from each other?

I looked at the PB example for it. The example worked well for choosing which one got displayed over the other, but the cubes were overlapping each other.
I tried moving one of the cubes 30 units in front of the other, but SetRenderQueue() no longer worked.

Looking through some OGRE documentation I thought this was possible, but maybe I've misunderstood how SetRenderQueue() works.

I'd greatly appreciate it if someone could explain how SetRenderQueue() works to me.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - SetRenderQueue
;
;    (c) 2013 - Fantaisie Software
;
; ------------------------------------------------------------
;

;Use [F5]/[F6]


#CameraSpeed = 1

#Camera    = 0
#Entity0   = 0
#Entity1   = 1
#Material0 = 0
#Material1 = 1
#Mesh      = 0
#Texture0  = 0
#Texture1  = 1

If InitEngine3D()
  
  Add3DArchive(#PB_Compiler_Home+"/Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home+"/Examples/3D/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
ExamineDesktops()
DesktopW=DesktopWidth(0)
DesktopH=DesktopHeight(0)

If OpenWindow(0, 0, 0, DesktopW, DesktopH, "Test")

  If OpenWindowedScreen(WindowID(0), 0, 0, DesktopW, DesktopH, 0, 0, 0)
    
    CreateMaterial(#Material0, LoadTexture(#Texture0, "clouds.jpg"))
    CreateMaterial(#Material1, LoadTexture(#Texture1, "Dirt.jpg"))        
    
    CreateCube(#Mesh, 20)
    CreateEntity(0, MeshID(#Mesh), MaterialID(#Material0),  0, 0, 0)
    CreateEntity(1, MeshID(#Mesh), MaterialID(#Material1), 0, 0, 30)    
          SetRenderQueue(EntityID(0), 0)
          SetRenderQueue(EntityID(1), 1)
    
    SkyBox("stevecube.jpg")
    
    CreateCamera(#Camera, 0, 0, 100, 100)
    MoveCamera(#Camera, 40, 0, 150, #PB_Absolute)
    
    Repeat
      Event=WaitWindowEvent()   
      If ExamineKeyboard()
        If KeyboardReleased(#PB_Key_F5)
          SetRenderQueue(EntityID(#Entity0), 1)
          SetRenderQueue(EntityID(#Entity1), 0)  
        ElseIf KeyboardReleased(#PB_Key_F6)
          SetRenderQueue(EntityID(#Entity0), 0)
          SetRenderQueue(EntityID(#Entity1), 1)  
        EndIf  
      EndIf
      
      RenderWorld()
      FlipBuffers()
    Until Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
  EndIf
EndIf  
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: SetRenderQueue question

Post by Comtois »

this function is missing (we'll add it for the next version):
setDepthCheckEnabled()

Sets whether or not this pass renders with depth-buffer checking on or not.

Remarks:
If depth-buffer checking is on, whenever a pixel is about to be written to the frame buffer the depth buffer is checked to see if the pixel is in front of all other pixels written at that point. If not, the pixel is not written.

If depth checking is off, pixels are written no matter what has been rendered before.
meanwhile you can try with a material's script
Please correct my english
http://purebasic.developpez.com/
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: SetRenderQueue question

Post by Comtois »

quick test using this material's script

Code: Select all

material Clouds
{
	technique
	{
		pass
		{
			depth_check off
			depth_write off
			texture_unit
			{
				texture clouds.jpg
	  		}


		}
	}
}

material Dirt
{
	technique
	{
		pass
		{
			depth_check on
			depth_write on
			texture_unit
			{
				texture Dirt.jpg
	  		}


		}
	}
}

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - SetRenderQueue
;
;    (c) 2013 - Fantaisie Software
;
; ------------------------------------------------------------
;

;Use [F5]/[F6]


#RENDER_QUEUE_BACKGROUND = 0
#RENDER_QUEUE_SKIES_EARLY = 5
#RENDER_QUEUE_1 = 10
#RENDER_QUEUE_2 = 20
#RENDER_QUEUE_WORLD_GEOMETRY_1 = 25
#RENDER_QUEUE_3 = 30
#RENDER_QUEUE_4 = 40
#RENDER_QUEUE_MAIN = 50
#RENDER_QUEUE_6 = 60
#RENDER_QUEUE_7 = 70
#RENDER_QUEUE_WORLD_GEOMETRY_2 = 75
#RENDER_QUEUE_8 = 80
#RENDER_QUEUE_9 = 90
#RENDER_QUEUE_SKIES_LATE = 95
#RENDER_QUEUE_OVERLAY = 100
#RENDER_QUEUE_MAX = 105


IncludeFile "Screen3DRequester.pb"

#CameraSpeed = 1

#Camera    = 0
#Entity0   = 0
#Entity1   = 1
#Material0 = 0
#Material1 = 1
#Mesh      = 0
#Texture0  = 0
#Texture1  = 1

If InitEngine3D()
  
  Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Scripts", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Packs/skybox.zip", #PB_3DArchive_Zip)
  Parse3DScripts()
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    
    GetScriptMaterial(#Material0, "Clouds")
    GetScriptMaterial(#Material1, "Dirt")    
    CreateCube(#Mesh, 20)
    CreateEntity(#Entity0, MeshID(#Mesh), MaterialID(#Material0),  5, 0, 40)
    CreateEntity(#Entity1, MeshID(#Mesh), MaterialID(#Material1), -5, 0, 0)    
    
    SkyBox("stevecube.jpg")
    
    CreateCamera(#Camera, 0, 0, 100, 100)
    MoveCamera(#Camera, 0, 40, 150, #PB_Absolute)
    
    Repeat
      Screen3DEvents()
      
      If ExamineKeyboard()
        If KeyboardReleased(#PB_Key_F5)
          SetRenderQueue(EntityID(#Entity0), #RENDER_QUEUE_OVERLAY)
          SetRenderQueue(EntityID(#Entity1), #RENDER_QUEUE_SKIES_EARLY)  
        ElseIf KeyboardReleased(#PB_Key_F6)
          SetRenderQueue(EntityID(#Entity0), #RENDER_QUEUE_SKIES_EARLY)
          SetRenderQueue(EntityID(#Entity1), #RENDER_QUEUE_OVERLAY)  
        EndIf  
      EndIf
      
      RenderWorld()
      Screen3DStats()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End
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: SetRenderQueue question

Post by Samuel »

Comtois wrote:this function is missing (we'll add it for the next version):
That would be great if it could be included later.

Also, thank you for the example. It should work for the time being.

Thanks again!
Post Reply