I’ve recently started working with the Game Engine as a means for prototyping & demoing GUIs on a small USB-attached color display. I’ve written a python script that upon starting it procures a section of shared memory for frames of pixels to be placed, after which the script then streams those frames to the USB-attached display.
Inside my .blend file I’ve written another script that repeatedly captures the view of an Inactive Camera, and returns a list of pixel values. Those values are then placed in the shared memory that the non-Blender program procured, and they are then forwarded to the USB display.
While I’ve managed to get everything running, now that I’m starting to include file/image textures in what is displayed “in game”, the shadeless image textures are appearing “dim”/“dark” in comparison to how they should look. They look fine in the viewfinder, and when I run the BGE with the GLSL shading - but not with the Multitexture shading. Additionally I’ve streamed the textures directly to the screen with my non-blender python script, and they too look as bright as they should be. So somewhere between importing the textures into blender and when the pixels are dumped to the shared memory, something is dimming the textures.
As noted switching to GLSL shading appears to fix the color dimness issue. However my current Blender python code cannot capture the Inactive Camera’s view - details to follow shortly.
With that said, I’m looking for a solution that will allow me to in realtime capture a (not dimmed) Inactive Camera’s view so the pixel values can be shuttled out to the external program. From where I stand this could potentially be done through resolving the Multitexture Shading issue, or migrating to GLSL shading and updating my python code to work appropriately with the different Shading. But I don’t discount that there could be other ways as well.
I’m hoping this will be a simple problem for someone that’s been working with the BGE for longer than I have.
If you’ve read this far, thank you for taking the time to read through all this
Python Code Snippets:
import bge import numpy as np from bge import texture scene = bge.logic.getCurrentScene() controller = bge.logic.getCurrentController() own = controller.owner 12 if 'texReady' not in own: 13 cam = scene.objects['NOT ACTIVE CAMERA'] 14 matID = bge.texture.materialID(own, 'MARTT') 15 renderToTexture = bge.texture.Texture(own, matID) 16 renderToTexture.source = bge.texture.ImageRender(scene,cam) 17 renderToTexture.source.capsize = (128, 128) 18 renderToTexture.source.flip = True 19 own["RenderToTexture"] = renderToTexture 20 own['texReady'] = True
then if the texture is established:
own["RenderToTexture"].refresh(True) imageData = np.asarray(texture.imageToArray(own["RenderToTexture"].source), dtype=np.uint8)
If I run this with Multitexture Shading, then it works dimmed, but otherwise without issue.
But if I switch to GLSL I get this:
Blender Game Engine Started Python script error - object 'Plane', controller 'Python': Traceback (most recent call last): File "InitAndTransfer.py", line 15, in <module> RuntimeError: Texture material is not available Blender Game Engine Finished