I’ve been getting familiar with compiling blender from source so I can give it a try in implementing an extra feature to the gamengine (actually I only need it in the gameplayer).
I’m trying to add an SDI output to a BlackMagic Decklink card from the gamengine, so I can use blender (gameengine) in a professional video environment.
The thing is I’m not a developer, so I might need some help from more experienced developers. So far I’ve already managed to implement one part of the code. It detects my card from within blender. Next I just need to copy the final rendered image to the cards framebuffer and tell it to display it trough the SDI video Output (all of those calls are available in the cards SDK and although I don’t yet understand it all, in time I will).
So my question is where in the code is the final image actually rendered (realtime)? Is there any documentation on how the rasterizer actually is organized, and what each file actually does? Is there a more experienced developer who could give a short (hopefully simple) explanation of the realtime rendering process? As side reading I’ve been trying to get familiar with OpenGL rendering process in general, and would also appreciate if someone could indicate me some good readings to get me started)
I’ve implemented most of the code to detect the card and initialize it in the Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp, but I’m quite sure that’s not the best place to have it… As I learn more I will clean up my mess.
thank you for your help, but your sugestion may be a little too slow for HD at 50 fps. I’m trying to shortcut the part of actually copying to file. Copying directly in opengl (maybe using Pixel Buffer Object) is actually much faster and can sustain the framerate required. Even more so because I’m going to use a lot of shaders to post process the final image (I must do antialiasing, lens distortion and probably some more fx to the final 1920x1080 scene)
Thanks
I 've been reading the files you suggested and I’m starting to get a bigger picture of it, and I now understand your first reply… I thought you were suggesting using python or PIL or something of the kind to retrieve the image, but now I’m actually looking at VideoTexture/ImageRender.cpp and actually it may be one way to get my video output… but won’t I bu duplicating an unnecessary render process by not using the actual render of the scene to the main viewport?
Thanks
After digging somemore in the source code I ran into the “screenshot” function of the gamengine at GamePlayer/common/GPC_Canvas.cpp. Maybe a little rewrite here will do most of what I need, since it outputs the whole screen into an image buffer… I would only need to replace the current PNG file output with the cards framebuffer.
In the blenderplayer there is no color space conversion or gamma correction, and it only writes png’s witch is really slow, but the card accepts RGBA8, and data is uncompressed, so that must not be a problem (hopefully).
Just wonder if its fast enough for HD Video at 50 fps… any aditional thoughts?
I’ve done it already. SDI video Output is working… and actually all in KX_KetsjiEngine.cpp as you sugested, where all rendering actually comes together, but now I have another question you may be able to help me with.
Rendering to SD PAL should actually be interlaced to get smother movement, so I may have to implement fields by rendering at 50 fps, interlacing and outputing to the card only every two frames (interlaced). My question is do you think this could be better implemented as as frag shader, or directly in C++, and if the latest, also in KX_KetsjiEngine.cpp, or is there any other place (maybe where interlacing for stereo takes place) where I should try to implement this?
Sorry for the late reply,
as stated in the previous post, the decklink output is now working.
Starting the game engine starts decklink sdi output of blender player window (if you start the game engine within the viewport it outputs the toolbars as well).
I’m using an older blender version (2.73) because of 32bit output (transparency of canvas). I have a working version on linux, and a nearly working version on windows (windows version does not support alpha transparency, but outputs video on the card).
I am now using a different aproach, using shared memory, to create two, or more, outputs from a single bge window, using one output with RGB and the other with ALPHA, called KEY (I acctually have a decklink quad card, but it also works with several cards).
Not blender related, but using this aproach allows me to create a third party application that overlays blenders 3D graphics on top of live video with no overhead on blender performance (not using blender videotexture)