I’m sure most of you have seen this post on Blender Nation:
In the video it mentions “Realtime Render with Blender Game Engine”
Anyone know what this means? Is he using a screen recording program, or is this something within Blender? I Just want to know how this game engine “render” process works?
Anyone?
“I think he use a screen recording program to record the video.”
Thats sorta what I thought… but you know… wouldn’t that be a killer feature for Blender? A way to record in real time (or not in real time)… from the viewport… whats happening when the game engine in enabled. I guess it could be a GLSL renderer-er?
I discovered a way to do it using a pretty simple python script I found online. Attach this as a Controller (with an Always sensor) to an object with a ‘counter’ property. Turn on “Enable All Frames” in the Game menu options to ensure smooth animation.
#(c) Mike Pan [mpan3.homeip.net]
import Rasterizer
cont = GameLogic.getCurrentController()
obj = cont.owner
sep = ""
num = str(obj['counter'])
filename = sep.join([num,".BMP"])
#Un-comemnt the following line will save a bitmap every frame to disk. SLOW!
#Rasterizer.makeScreenshot(filename)
obj['counter'] += 1
When the game engine is run, this script will save a sequence of images in the same directory as the .blend file. The images will be the same size as the game viewport (and will include the header if it’s visible; remember to turn it off!). As far as I know, it can only write .BMP files, so you’ll need additional software to turn the image sequence into a video.
That script won’t work - it’s for 2.49. It also shouldn’t work, as obj[‘counter’] is never initialized, and the screenshot making line is commented out.
EDIT: This one should work.
from bge import render as Rasterizer
from bge import logic as GameLogic
cont = GameLogic.getCurrentController()
obj = cont.owner
sep = ""
num = str(obj['counter'])
filename = sep.join([num,".BMP"])
if not 'counter' in obj:
obj['counter'] = 0
Rasterizer.makeScreenshot(filename)
obj['counter'] += 1
Real time rendering is pressing p. ALL games real time render: the lighting, shaders, shadows, textures. It’s all rendered so fast that it renders around 60 frames in one second! This is completely normal
Ooh, thanks SolarLune! I just upgraded to 2.59, and thanks to you I got the script to work again.
I added a few lines so that, by setting a few other properties, one can define where the files are saved (otherwise they seem to end up in the directory with Blender.exe).
from bge import render as Rasterizer
from bge import logic as GameLogic
cont = GameLogic.getCurrentController()
obj = cont.owner
if not 'counter' in obj:
obj['counter'] = 0
if not 'filename' in obj:
obj['filename'] = "frame"
if not 'filepath' in obj:
obj['filepath'] = "C:/"
num = str(obj['counter'])
num = num.rjust(4,"0")
filepath = obj['filepath'] + obj['filename'] + num + ".BMP"
Rasterizer.makeScreenshot(filepath)
print ("saved " + filepath)
obj['counter'] += 1
If you need a faster rendering, use jpeg extension. At full screen, it renders faster. I plan on using that for my cinematic projects, after my project is in alpha. You can make a 5min short in 20m, 10 of which are editing!
WOW! Works amazingly.
For anyone trying it out, click on the “Activate True Level triggering” button and then change the Frequency to 1 on the Always actuator that you’re using. (seems to make it smoother)
The thing I noticed though is that I tried changing .BMP in the script to .jpg and got .png files. I tried changing the default format in the Blender Render settings to jpg and it still spat out .png. Any one get this as well? I’m sure I’m doing something wrong.
Anyway… BRAVO! This is great.
M
I know OBS as external frame grabber / streamer, its Open-Source so it works everywhere also on my favourite FreeBSD and macOS BSD I thought maybe Blender itself has some better frame grabbing / streaming capabilities that would not dramatically impact game performance…
Recently I have definitely switched away from nVidia, being their loyal customer for almost 20 years (since first nVidia Riva TNT back in the VooDoo 3DFX days of first steps in Blender around 2000 ), because of their dramatic lack of support for Open-Source, binary blob only drivers, and poor access to open hight quality technical specifications… I have switched to AMD RADEON RX580 just because it supports OpenCL on my favourite FreeBSD and probably I will stick to that vendor
with amd: hit ctrl+shift+r and it starts recording your stuff
alt+r to show menu (change this combo in the driver, blender uses this combo to clear rotation data, and this wont work if driver uses the same combo)