Results 1 to 10 of 10

Thread: How to combine GBuffers & Entities?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    How to combine GBuffers & Entities?

    Is there a possibility to use the functionality of GBuffers ( TBGL_GBufferDefineFromArray ) to blast the data directly into an entity (static) or is there a way if one could send or copy that GBuffer to a displaylist as first?

    Or can't i just create some virtual Entity upon the GBuffer?

    It's mostly about the speed and i want to use the entity-system.

    Passing all data at once is much faster then each vertex line by line.
    Also saving to binary would make sense then.

    Any ideas? Functionslot is no option here...

    Were it possible to add a native (fast) function to load *.obj-files into displayllist/entity? I have to admit, *.obj is not my first choice since they lack vertex-colors but they are widely common and since we don't have no own Entity-Format yet - probably because of slow loading-speed...
    Last edited by ReneMiner; 24-10-2014 at 12:17.
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Rene,

    this is custom GBufferEntity, which you can modify. Let me know...


    Petr
    Attached Files Attached Files
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    that seems to work.

    Now have something to play with
    Only bug - you forgot to change %eBox to %eGBuffer in the example when rotating - on first turn it crashed. But thats minor - i found it.
    I think there are missing some Forum-sections as beta-testing and support

  4. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    i played a little around- somehow i fear if i set up different fov/aspect the GBuffer-Entity is not affected by the setting as i know it from 3d-fonts - not tried out yet...

    But anyway I wrapped a little -all hidden at heap-memory, be surprised what's possible in thinBasic - and the code reads now like that:
    Uses "TBGL" 
    
    #INCLUDE "t_Entity.tBasicU"
    
    Begin Const
      ' -- Scene IDs
      %sScene  = 1
    End Const 
    
    Function TBMain()
      Local hWnd As DWord
      Local FrameRate As Double
      
      ' -- Create and show window
      hWnd = TBGL_CreateWindowEx("TBGL script - press ESC to quit",    _
                                 640, 480, 32,                         _
                                 %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX ) 
      
      TBGL_ShowWindow 
    
      ' -- Create scene
      TBGL_SceneCreate(%sScene)
    
      ' create entities from 0 - don't have even a real local variable
    
      Local Entity As t_Entity At 0
      
      SetAt( Entity, Entity.Create(%sScene, %TBGL_CAMERA) )
    
             Entity.SetPos(0, 10, 20)
             Entity.SetTargetPos( 0, 0, 0)  
      %hCamera = GetAt( Entity ) As DWord ' if want to store it...
      
      ' -- Create directional light, don't need its ptr...  
      SetAt( Entity, Entity.Create(%sScene, %TBGL_LIGHT, %TBGL_LIGHTTYPE_DIRECTIONAL) )
    
             Entity.SetPos(0, 25, 20) ' above camera
             Entity.SetTargetPos( 0, 0, 0)  
             Entity.SetParent( %hCamera )
      
      ' -- Define data for mesh   
      
      ' -- Vertices
      
      Dim VertexA(3) As TBGL_TVECTOR3F At HEAP_Alloc( 3 * SizeOf(TBGL_TVECTOR3F) )    
      
      VertexA(1).x = -2
      VertexA(1).y = -2
      VertexA(1).z = 0
      
      VertexA(2).x = 2
      VertexA(2).y = -2     
      VertexA(2).z = 0  
      
      VertexA(3).x = 0
      VertexA(3).y = 2
      VertexA(3).z = 0  
      
      ' -- Colors
      
      Dim ColorA(3) As TBGL_TRGB At HEAP_Alloc( 3 * SizeOf(TBGL_TRGB) )
      
      ColorA(1).r = 255
      ColorA(1).g = 128
      ColorA(1).b = 64
      
      ColorA(2).r = 0
      ColorA(2).g = 255
      ColorA(2).b = 0  
      
      ColorA(3).r = 0
      ColorA(3).g = 0
      ColorA(3).b = 255 
      
      ' -- Entity                     
    
      %hTriangle = Entity.Create(%sScene,             _
                                 %TBGL_GBufferStatic, _
                                 %TBGL_TRIANGLES,     _
                                 GetAt(VertexA),      _
                                 GetAt(ColorA)        )
    
      
      
      TBGL_ResetKeyState() 
      
      ' -- Main loop
      While TBGL_IsWindow(hWnd) 
        FrameRate = TBGL_GetFrameRate
    
        TBGL_ClearFrame 
    
          TBGL_SceneRender(%sScene)
          
        TBGL_DrawFrame 
    
        ' -- ESCAPE key to exit application
        If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While 
    
        If TBGL_GetWindowKeyState(hWnd, %VK_LEFT) Then
    
          SetAt( Entity, %hTriangle )
                 Entity.Turn( 0,-90/FrameRate, 0)
    
        ElseIf TBGL_GetWindowKeyState(hWnd, %VK_RIGHT) Then
    
          SetAt( Entity, %hTriangle )
                 Entity.Turn( 0, 90/FrameRate, 0)
    
        ElseIf TBGL_GetWindowKeyState(hWnd, %VK_UP) Then
    
          SetAt( Entity, %hCamera )
                 Entity.Move( 0, 16/FrameRate, 0 )
                 Entity.SetTarget( %hTriangle )  
    
        ElseIf TBGL_GetWindowKeyState(hWnd, %VK_DOWN) Then
    
          SetAt( Entity, %hCamera )
                 Entity.Move( 0, -16/FrameRate, 0 )
                 Entity.SetTarget( %hTriangle )  
    
        EndIf
    
      Wend 
    
      TBGL_DestroyWindow
    End Function
    
    just a raw sketch, the entity does not have a texture yet, neither is the DisplayList-creation done...

    As you probably see- it's all arranged to have a future Mesh-udt that's single entities (groups) can have different types of data.
    Attached Files Attached Files
    Last edited by ReneMiner; 28-10-2014 at 14:39.
    I think there are missing some Forum-sections as beta-testing and support

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    one more question:

    is it possible to retrieve the pointers of vertex-, color-, normal- and texel-array from a once setup-GBuffer again?
    Or do i have to save them to some variable?
    I think there are missing some Forum-sections as beta-testing and support

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Rene,

    I would recommend to store them to data of the GBufferEntity - it should be fast enough.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. The silence inside the fractal - GBuffers (how many may be used ?)
    By RobbeK in forum TBGL Scripts and Projects
    Replies: 35
    Last Post: 24-01-2014, 12:18
  2. Entities again...
    By ReneMiner in forum TBGL General
    Replies: 6
    Last Post: 17-05-2013, 10:59
  3. Preview: GBuffers for TBGL
    By Petr Schreiber in forum TBGL module by Petr Schreiber
    Replies: 11
    Last Post: 04-03-2010, 11:33
  4. Scenes and Entities
    By Intio in forum thinBasic General
    Replies: 2
    Last Post: 09-12-2008, 20:44
  5. Bone deformation and entities
    By Michael Hartlef in forum TBGL General
    Replies: 7
    Last Post: 16-02-2008, 02:16

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •