-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPBGE: Use VBO and VAO for debug drawing.
Using VBO and VAO allow to render all the lines in one command and to render all the AABB and frustum using instancing in one command too. The usage of VBO request that all the structs for lines, aabbs, frustum and boxes use array instead of mathfu types to avoid SSE padding and alignement. Four shaders are introduced to help debug drawing using instancing. The first is just for drawing lines using a flat color, the second is for wire boxes, the third for solid boxes with in and out color and the fourth for 2d boxes. All the these geometry type use geometry instancing. For each type RAS_OpenGLDebugDraw allocate a VAO and multiples VBOs, they are stored into m_vbos and m_vaos and accessed thanks to enums. The VAO are initialized in RAS_OpenGlDebugDraw constructor pointing to the uninitialized VBOs, some VBOs as unit 3d and 2d box and IBOs are initialized in the same time. At each render step the VBO containing data about instancing or geometry are updated from the data list contained into RAS_DebugDraw. Then the render is procceed binding the VAO and calling the proper draw call. 2d boxes receive a special treatment. The boxes are rendered using a vertically inverted ortho matrix because the Y axis is from the top of the screen. All these modification ends in a significant speedup for debug drawing and makes the code easier to move to blender 2.8.
- Loading branch information
1 parent
cd9fa2b
commit a23e65c
Showing
18 changed files
with
474 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
in vec2 pos; | ||
in vec4 trans; | ||
in vec4 color; | ||
|
||
flat out vec4 finalColor; | ||
|
||
void main() | ||
{ | ||
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(pos * trans.zw + trans.xy, 0.0, 1.0); | ||
finalColor = color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
flat in vec4 finalColor; | ||
|
||
void main() | ||
{ | ||
gl_FragColor = finalColor; | ||
} |
10 changes: 10 additions & 0 deletions
10
source/blender/gpu/shaders/gpu_shader_flat_color_vert.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
in vec3 pos; | ||
in vec4 color; | ||
|
||
flat out vec4 finalColor; | ||
|
||
void main() | ||
{ | ||
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(pos, 1.0); | ||
finalColor = color; | ||
} |
11 changes: 11 additions & 0 deletions
11
source/blender/gpu/shaders/gpu_shader_frustum_line_vert.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
in vec3 pos; | ||
in mat4 mat; | ||
in vec4 color; | ||
|
||
flat out vec4 finalColor; | ||
|
||
void main() | ||
{ | ||
gl_Position = gl_ModelViewProjectionMatrix * mat * vec4(pos, 1.0); | ||
finalColor = color; | ||
} |
8 changes: 8 additions & 0 deletions
8
source/blender/gpu/shaders/gpu_shader_frustum_solid_frag.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
flat in vec4 insideFinalColor; | ||
flat in vec4 outsideFinalColor; | ||
out vec4 fragColor; | ||
|
||
void main() | ||
{ | ||
gl_FragColor = gl_FrontFacing ? insideFinalColor : outsideFinalColor; | ||
} |
14 changes: 14 additions & 0 deletions
14
source/blender/gpu/shaders/gpu_shader_frustum_solid_vert.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
in vec3 pos; | ||
in mat4 mat; | ||
in vec4 insideColor; | ||
in vec4 outsideColor; | ||
|
||
flat out vec4 insideFinalColor; | ||
flat out vec4 outsideFinalColor; | ||
|
||
void main() | ||
{ | ||
gl_Position = gl_ModelViewProjectionMatrix * mat * vec4(pos, 1.0); | ||
insideFinalColor = insideColor; | ||
outsideFinalColor = outsideColor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
a23e65c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @panzergame !
From this commit onwards I can't start the game engine. Blender simply closes, printing:
And standalone player stops responding. Windows 7 64 bit, MSVSC 2015 32 bit.
Any advice? Thanks.
And happy new year. ;)
a23e65c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
I got issues too but only with intel GPUs, I'm investigating on.