Hello guys,
Just looking at 0.3 and it is fantastic!
Quick question regarding overlays/UI and how this looks/works in UPBGE? Can’t seems to find much info on it.
logic.addScene doesn’t seem to work.
Cheers
Hello guys,
Just looking at 0.3 and it is fantastic!
Quick question regarding overlays/UI and how this looks/works in UPBGE? Can’t seems to find much info on it.
logic.addScene doesn’t seem to work.
Cheers
My bad… here if anyone else is looking:
Just to revive this again, adding overlay collection just isn’t cutting it. Rendering is very glitchy, physics is static and doesn’t reflect the overlay and it sometimes adds doubles.
Is anyone aware of a good way of doing GUI in upbge 0.3? This is my biggest limiting factor with UPBGE currently.
well you can do it oldschool, just create a hud in the mainscene by parenting it all to the camera, and use some visibility toggles, or animations to slide it in and out of the view.
But also do remember 3.0 is not nearly as ready as people would, it’s an alpha, and will take atleast a year or more before it’s get’s good enough.
I just did a quick and dirt tuto here: https://www.youtube.com/watch?v=pG-nfn5xe5U (wait a bit to have HD version)
If someone understand it, feel free to do another better tuto.
Thanks guys, thats how I’ve been doing it. However this method means certain effects like bloom effect the UI aswell. I’m trying to work up a solution, will post if I get somehting working.
If you want to do more advanced UIs, you can use ImageRender and a GLSL 2D filter.
It requires a bit of bge knowledge.
import bpy, bge
from bge import texture
cont = bge.logic.getCurrentController() # on main camera
scene = bge.logic.getCurrentScene()
rendercam = scene.objects["rendercam"]
renderplane = scene.objects["renderplane"]
bge.overlayTex = texture.Texture(renderplane, 0, 0)
bge.overlayTex.source = texture.ImageRender(scene, rendercam)
def renderOverlay():
# Set rendercam as active cam
camBackup = scene.active_camera
scene.active_camera = rendercam
# Get HitObject in Overlay Camera space
overlayHitObject = cont.sensors["mouseover"].hitObject
if overlayHitObject is not None: #do something
# Disable not wanted effects before rendering overlay texture
bloomIntensityBackup = bpy.context.scene.eevee.bloom_intensity
bpy.context.scene.eevee.bloom_intensity = 0
# Render Overlay Camera to renderplane texture
bge.overlayTex.refresh(True)
# Restore main cam
scene.active_camera = camBackup
# Restore bloom
bpy.context.scene.eevee.bloom_intensity = bloomIntensityBackup
def sendUniformsTo2DFilters():
# Render overlay texture
renderOverlay()
# send uniforms to 2D filter to do the compositing between main render and overlay
filter = scene.filterManager.getFilter(0)
if filter is not None:
filter.setTexture(0, bge.overlayTex.bindId, "overlayTex")
###########################################################
The 2D filter:
uniform sampler2D bgl_RenderedTexture;
uniform sampler2D overlayTex;
in vec4 bgl_TexCoord;
out vec4 fragColor;
void main()
{
vec4 mainCol = texture(bgl_RenderedTexture, bgl_TexCoord.xy);
vec4 overlayCol = texture(overlayTex, bgl_TexCoord.xy);
//fragColor = (mainCol + overlayCol) / 2; //average between 2 colors
//fragColor = mix(mainColor, overlayCol, 0.8); // mix using a factor
//fragColor = something else
// if overlay texture is rendered with a transparent background:
if (overlayCol.a > 0.0) {
fragColor = overlayCol;
return;
}
fragColor = mainCol;
}
//////////////////////////////////////////////////////////////////////
EDIT: Not tested
Hmmm, that seems like what I want to do. May not have the capabilities to achieve it though.
Do you mind taking a look and seeing if I set it up correctly? Maybe an example? If this works it’ll be game changing for me.
IglGui.blend (789.8 KB)
I also remember this: https://github.com/Moguri/bgui
However a number of things in it appear to be deprecated, not sure how hard it would be to bring it up to date?
I did a test, but it is slow:
overlayImageRenderTest.blend (873.2 KB)
I’m not sure but maybe it is slow because when we modify a render setting, the depsgraph is notified to do an extra render pass. It means each frame, there would be the main bge render + the overlay render + extra render passes each time we change a render setting… Then even with a gtx 1080, I’m only at 48 fps in this file.
EDIT: To solve this issue, the render settings should not be modified at runtime and another way would have to be found without modifying these render options, like hiding some objects before overlay render pass or/and other things.
It seems Add Overlay Collection actuator is not working in version 0.30.0, when HUD collection is in another scene.
Just try moving HUD collection to another scene in the following file to see if it works.
Could this be a bug?
Seems to work for me:
I’d suggest upgrading to the latest UPBGE 0.33 experimental build based on Blender 3.33, as well as watch the shared tutorial from above:
You didn’t move HUD collection to another scene.
As per version 0.33 alpha, Add Overlay Collection still doesn’t work across scenes.
True. It only supports collections currently. If you wish to wish-list this feature, feel free to request it here over at the UPBGE Github: https://github.com/UPBGE/upbge/discussions
Upbge 3.3x now has BGUI support soon also in “use viewport render mode”
After that I want to try and get BGUI working in open xr