Is it possible to make it transparent behind the 3D models?
I'm wanting to have essentially Godot overlayed in my android app so I can add 3D objects above my android UI. Messing around with your gltf demo, I can't seem to make Godot's background transparent. I'm not familiar with Android development at all so maybe you know the solution.
I have enabled these Godot project settings for a transparent background (not sure if it makes a difference, but I've opened the Godot project in Godot 4.5 so these settings might work differently in 4.2):
display/window/per_pixel_transparencydisplay/window/size/transparentrendering/viewport/transparent_background
Running the Godot project from the editor, I correctly get a transparent background on Linux:
However, on Android the background shows as black (I've added an image behind the Godot fragment container so I should be able to see it if Godot's background is transparent):
I thought that potentially adding android:background="@android:color/transparent" to the Godot fragment container would fix the issue, but it didn't:
<FrameLayout
android:id="@+id/godot_fragment_container"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@android:color/transparent" />
Any ideas?
I believe this could be a bug in Godot, so I've made an issue there: https://github.com/godotengine/godot/issues/106703
@lonevox You're correct, that's a bug. You can use the following workaround in your code until the issue is fixed:
override fun onStart() {
super.onStart()
godotFragment?.view?.let {
Log.d("FHK", "Checking for Godot surface view")
for (view in it.allViews) {
if (view is SurfaceView) {
Log.d("FHK", "FHK - Found Godot surface view")
view.setZOrderOnTop(true)
view.holder.setFormat(PixelFormat.TRANSLUCENT)
break
}
}
}
}
The workaround retrieves the Godot's SurfaceView and updates its flags to allow for transparency.