Results 1 to 8 of 8

Thread: How to combine GBuffers & Entities?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    47
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    132

    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.
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,790
    Blog Entries
    3
    Rep Power
    693
    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 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    47
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    132
    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.
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  4. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    47
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    132
    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.
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    47
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    132
    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?
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,790
    Blog Entries
    3
    Rep Power
    693
    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 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  7. #7
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    47
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    132
    one more about this topic, help says for TBGL_GBufferCreate

    Syntax
    TBGL_GBufferCreate( gType, gDims )

    parameter-description for gType

    Use one of the following equates:
    %TBGL_POINTS
    %TBGL_LINES
    %TBGL_LINESTRIP
    %TBGL_LINELOOP
    %TBGL_TRIANGLES
    %TBGL_TRIANGLEFAN
    %TBGL_TRIANGLELOOP
    %TBGL_QUADS
    %TBGL_QUADSTRIP
    %TBGL_POLYGON
    this can not be correct.
    There is missing %TBGL_TRIANGLESTRIP while %TBGL_TRIANGLELOOP is not recognized as keyword by thinAir...

    however- it took me a while to find out what went wrong and how to solve it...
    Last edited by ReneMiner; 10-11-2014 at 09:38.
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  8. #8
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,790
    Blog Entries
    3
    Rep Power
    693
    Hi Rene,

    my apologies - nothing worse than bad docs, and now I fell into this category!
    I will fix it for next release!


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

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

Posting Permissions

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