I’ve been experimenting with the RenderToTexture function and noticed it will only render the current scene’s world and will not render scenes below it (background scenes). Is there a way of having those visible in the final “render” on the RtoT layer?
Almost every question has been answered here, so maybe if you do a search in the forum first, can save you a little bit time
It’s a shame you deleted that post, because it progresses the thread nicely. You mentioned that you’ve tried what was in that thread and it failed… let us know what you tried and where did it go wrong.
If you let us know in advance what you’ve tried, then it saves us a lot of effort replying. Explaining an entire technique is a lot of work, but debugging why an existing technique failed can often be a 30sec reply.
I tried using the script in my blend file by attaching a python controller to the video texture in the top-most layer, but it doesn’t really seem to be working for me. I get an error for “import mathutils” and “import common”…
Do I need to replace anything in the script itself with the names of the cameras/scenes? Also if I use the python module controller, whic “def” do I use (i.e. script.init, or script.main etc) Sorry I am not well versed in coding but I am trying.
mathutils doesn’t come with Python by default, but it does come in my current version of Blender (2.59)(PC). What version of Blender are you using?
I am using UPBGE 0.2.4 (old bullet branch) and blender 2.79 on Windows
I would start by looking to see if UPBGE comes with pip installed. If so, you should be able to run the following command to download and install mathutils:
pip install mathutils
If it doesn’t come with pip, then unfortunately I don’t know enough about UPBGE to advise further. @BluePrintRandom was answering a GIT issue regarding including pip in UPBGE, so he will probably know more about it. He might be able to tell you why UPBGE doesn’t come with mathutils too
Not sure on that one, sorry. I grew up without defining a main function and just putting my code straight into the script. If you’ve got an example blend to copy then just do whatever they did. If you’re still getting errors after solving the library issue then we can take look at it.
This is the script I’ve been using for RenderToTexture:
import bge from bge import render render.setMipmapping(render.RAS_MIPMAP_NONE) controller = bge.logic.getCurrentController() owner = controller.owner cameraName = owner['cam'] materialName = owner['material'] scene = bge.logic.getCurrentScene() camera = scene.cameras[cameraName] materialId = bge.texture.materialID(owner, "MA" + materialName) renderToTexture = bge.texture.Texture(owner, materialId) owner["RenderToTexture"] = renderToTexture source = bge.texture.ImageRender(scene, camera) source.capsize = [320, 240] scale = True renderToTexture.source = source
for the line scene = bge.logic.getCurrentScene() would there be a way to change that so “scene” refers to the current scene as well as scenes below it? Instead of CurrentScene is there a way to call a list of all scenes being shown?