Skip to content

Creating Spot Videos and Images with Blender

shadowphile edited this page Apr 14, 2013 · 21 revisions

This is a Blender (tested on ver 2.63-2.66) add-on to help create mini-videos.

panel in Blender

What this script does

This script cuts out a mini-region of the camera's viewport and saves it as a video or image directly compatible for attaching to a Dagon spot. It should be understood that to 'animate' a section of a node's background graphics, an overlayed video needs to come from the exact same rendering step, and placed in the correct location with respect to the face texture, or the video will not blend into the background properly. Blender has an ideal tool for this, the 'border' render command ('Ctrl-B'). The mouse is used to draw a frame within the camera viewport that defines a smaller region that can be rendered only.

The intended workflow

  1. Use Blender to render out your face texture for a node.
  2. Set the camera to facing whichever face texture you want to capture a spot.
  3. Animate some element of your scene visible in the camera.
  4. Use this script to clip out the sub-region of the animated portion and save it for use in Dagon.

Detailed work-flow, step-by-step

  • A node-face-texture scene should be ready to render.
  • The animation frame-range and frame-rate have been set in the Render Properties->Dimensions sub-panel. 24 fps is a good default.
  • The Image Window is open to 'Render Result'. Desirable but is not necessary.
  • There are three boxes in the panel.
  • 1. Set Options
    Dagon Project: set this folder to the location of your Dagon executable.
    Note that you MUST have the standard /Resources/Images and /Resources/Video subfolders.
    Filename: Set the filename for your spot, no extension.
    Note that you MUST use characters compatible with your OS.
    Overwrite?: Checkbox to prevent overwriting files. Doesn't seem to work right now, always overwrites.
    output: Select the filetype of interest. There are four options.
    THEORA - Video compatible with the Dagon engine.
    UNCOMPRESSED AVI - Video with uncompressed frames, intended for post-processing and conversion to Theora elsewhere.
    TGA and PNG - Single image formats for Targa and PNG files respectively. Selecting these will only render a single image.
  • 2. Draw Region
    Click the button and the 3D Viewport camera will move to the active camera that should be aligned with one of your node cube-face renders.
    With the mouse in the 3D view, hit 'Ctrl-B' and draw the region of your sub-image with the mouse.
    If all you want is the coordinates for some reason, hit the button again and the Dagon Snippet field lower down will update. (right now I can't make it a live update)
  • 3. Render and Save
    By now this section should be un-ghosted. It will remain ghosted until all the above steps have been performed.
    Click Render and Save
    • Single images will save to the /Resources/Images folder
    • Videos will save to the /Resources/Video folder
    • The button will stay depressed until the render is finished. You cannot abort right now. You can monitor your render progress more closely if you toggle the system console open from the Help menu.
    • When the render is finished, a snapshot reference image with Dagon info is re-rendered (yeah, sorry) with overlayed information, ie direction, location, size.
      The image (jpeg) is displayed in the Render Result and also saved with the other file with the same name but '_ref' appended. Once your project is complete you can just delete all the reference files. For single images the ref image is the same except for overlayed info. For videos the single image will represent the frame that the Timeline cursor happened to be at when rendering started. This means you can choose which frame most clearly represents your video.
  • The last window, Dagon Snippet, can be cut & pasted directly into your Dagon code. Note that the position is based on the main render resolution settings in Blender, which should be the same as the node-face-texture the spot will overlay.
  • For the most part, all settings in Blender should remain unchanged as they are saved and restored after the spot operation.

Installation

To use, download from here and save into your scripts directory. This is my personal Dropbox. Actually, you can save it anywhere and use the 'Install Addon' button in User Preferences, but in the default scripts folder it will be automatically loaded when you start Blender.
Once it is loaded, open User Preferences, 'Addons' tab, ensure 'Community' button is highlighted. You will find it in the Render category. Enable the check-button next to the excited-man icon and the Panel will load up in the 3D Viewport, Tools region. You may have to scroll to see it.

Issues

  • THEORA video resolution must be in increments of 16 pixels. After the the region is drawn with the mouse, the right and bottom edges are rounded to the closest 16 pixels. You can see the change by clicking the button in Section 2 after drawing your box. Note that the POSITION is still accurate to one pixel, so the left and top edges will remain the same. If for some reason the right or bottom edge does not adjust to a satisfactory position, use Ctrl-B to redraw the box in a slightly different position. Eventually I will add controls to the panel to allow you to adjust the shown box without having to guess. I don't have control over the mouse-drawing with Python.
  • Saving to AVI doesn't respect the spot dimensions, pondering solution....
  • THEORA video doesn't seem to play back if one second or shorter. It may in Dagon but it doesn't in VLC.
  • The direction text in the snippet ('NORTH', etc) will say 'n/a' if the camera is not using standard directions for rendering node-face textures.
    These camera settings are:
    direction, then x,y,z values
    NORTH, 90,0,0
    EAST, 90,0,-90
    SOUTH, 90, 0, -180
    WEST, 90,0, 90
    UP, 180,0,0
    DOWN, 0,0,0