Blender addon for making picture or video spots


#1

Worked out most of the painful details, here they are:
-Use the same camera and rendering setup as that used for making your cube-faces.
-Remember the direction your camera is facing when selecting a spot to animate. You have to put ‘NORTH’, ‘SOUTH’, etc in the spot setup.
-Once you’ve set up your animation, check the ‘border’ option, but don’t check the ‘crop’ option (yet).
-Hit Shift-B and draw the region you want to spot. Here’s the hard part. You only have visual control for selecting the region, but it needs to be in dimensions that are codec friendly. Not sure what those are, but so far any even-number seems to work.
-Render one frame. In the render output window, click-drag with the mouse to locate the exact x,y location of the upper left corner of your spot image. Remember those values for your script later. Also note the full-size render vertical resolution for later. (ie 2048 usually)
The fun part:
-Now check the ‘crop’ button and render one image. Hit ‘N’ in the render window to view the properties palette. It will have the image dimensions. If it’s not as even-numbered, you will have to draw the frame again. Yeah, this SUCKS!!! I zoom the frame as much as possible, then redraw the frame over the previous one overlapping exactly the upper left corner but adjust the right and bottom edges as needed. Render one frame again, check the size again, iterate until happy or you smash your keyboard into smithereens. (what the hell is a ‘smithereen’ anyway. Nigec? Another brit word?)
-For the render output, if you are doing any video post-process, select AVI Codec. This will containerize but not compress your frames. If this is matching your final Blender face textures as-is, then select the Theora preset.
-Set your animation output path directly to the Video sub-directory of your Dagon project.
-Uncheck ‘extensions’ or blender inserts the frame numbers in the filename for some stupid reason. Name your file, and you have to put in the extension, ogv. (unless you are going with AVI, then use that extension.)
-Hit Animate. You are done in Blender.
-In your script, when attaching your video to a spot, use your coordinates you noted earlier. The Y value must be reversed, hence the face resolution:

spot = node:addSpot( Spot(NORTH, {x, 2048-y}, {auto = true, loop = true}) spot:attach(VIDEO, "minimovie.ogg")


I say, this would be extremely staight-forward if it weren’t for the region hassle. That would be a ridiculously easy python script to write and could scarf up all the other little steps as well into one neat little panel. Hint hint …:slight_smile:


#2

smithereens; is pretty much as it sounds in context, ie smash into little pieces.

Thanks this is really useful, actually i was turning to Blender today as I was going to try animated textures which do work rendered in thea, I have a tv I wanted to add some sort of looping image… problem is the first node the TV is on two faces, I’m not sure if it’ll sync correctly
Also still get the colour banding so i need to figure out why it happens befor I animate anything, hopefully its just the sampling is to low

I don’t know any python at all, I was thinking of a basic room script editor, it seems really trick on what to have


#3

I worked this out today for Blender, nothing fancy, but I plan on fleshing it out more.
It’s a script, not an addon, so you have open it up in the text editor then hit the ‘Run Script’ button. Since you need to access it while modeling and rendering, I suggest creating a new little window somewhere in your main work screen with the script open, just enough to read the header bad and see the Run Script button.
Here’s the steps:
-Setup just like you are going to render a cube face, looking through the camera to whatever direction you want your animation at.
-Click ‘Border’ option in the render panel.
-Draw your border. The script will adjust it to proper dimensions.
-Set your filepath in the Render panels. Make sure you type the extension .ogv
-Turn on the console from the main menu, Help section, 'Toggle System Console’
The script takes care of everything else, just hit the Run Script button.
The script will:
-Select the proper file type (theora movie)
-Correct the selection region if necessary. (will only adjust by at most one pixel in x and y)
-Print the correct values for the script coordinates and the movie resolution in the Console window.
-Force the ‘crop’ option on.
-Turn off the ‘extensions’ option. (or the filename will have junk stuff in it :? )
-Render the animation.
-Put the ‘extensions’ option and output file-type back to what they used to be.
-Reprints the spot location and size data (because all the render messages scroll the console)

Although I’ve written a few very simple python scripts in Blender for general file manipulation, this is my first attempt at using Python to actually do something with Blender itself. And I’m so glad I did, now spots are easy to do, mostly.

To use, open a text editing window in Blender, create a new empty file, then paste this in. Save it somewhere as well. Name doesn’t matter, although it doesn’t hurt to end it with .py

Remaining peeves:
-The console is a pain, it can’t be a window so you have to jam things around to read it while working in Blender. I’m still trying to find a better place to print out the info.
-You have to have the script window open in your creative zone. Needs a hotkey or placement into it’s own panel.

[code]
#start - get access to render settings of current scene
myren = bpy.data.scenes[bpy.context.scene.name].render
backup = myren

#adjust the borders to pixels and the width/height to even-numbers
rx = myren.resolution_x
ry = myren.resolution_y

#adjust left and bottom edges to pixel
left_x = 2*int((((myren.border_min_x)rx)+.5)/2)/rx
bottom_y = 2
int((((myren.border_min_y)*ry)+.5)/2)/ry
myren.border_min_x = left_x
myren.border_min_y = bottom_y

#adjust right and top edges to even-numbered pixel
spot_x = 2*int((((myren.border_max_x-left_x)rx)+.5)/2)/rx
spot_y = 2
int((((myren.border_max_y-bottom_y)*ry)+.5)/2)/ry
myren.border_max_x = left_x+spot_x
myren.border_max_y = bottom_y+spot_y

#adjust for inverted Dagon/Blender origin
script_x = int(left_xrx)
script_y = int(ry-((bottom_y+spot_y)ry))
spot_w = int(spot_x
rx)
spot_h = int(spot_y
ry)

#display adjusted values
print(“nn_________________________”)
print(“spot coordinates: {”,script_x,",",script_y,"}")
print(“spot dimensions: [”,spot_w,",",spot_h,"]")

#ensure images are being cropped
myren.use_crop_to_border = True

#set render file stuff, after backing it up
bu_ufe = myren.use_file_extension
bu_ff = myren.image_settings.file_format

myren.use_file_extension = False
myren.image_settings.file_format = “THEORA”

#render it out!
bpy.ops.render.render(animation=True)

#return settings to the original values
myren.use_file_extension = bu_ufe
myren.image_settings.file_format = bu_ff

#display adjusted values again
print(“nn_________________________”)
print(“spot coordinates: {”,script_x,",",script_y,"}")
print(“spot dimensions: [”,spot_w,",",spot_h,"]")[/code]


#4

[quote="“Nigec”"]… problem is the first node the TV is on two faces, I’m not sure if it’ll sync correctly
…[/quote]
I believe there might be a ‘sync’ option for videos? Good if so, can’t always have your animations not span two or more node faces.
Gads, it’s 4 am. :?


#5

ARRGGGH, just realized/remembered we need to use 2048 x2048 or spots don’t locate right, its maybe why I get the banding too, I was rendering small ie 1024x1024 as its just tests… worth a reminder if nothing else :slight_smile:

4am? you mean there’s two? I only ever see the other one :stuck_out_tongue:


#6

Nice, shadowphile! I have the same problems with Vue. I have to render the entire cube side and then crop to video. I’ll have to ask on the python forums at e-on to see if they have any solutions.


#7

figured I’d be updating this, so time to start versioning. Nothing fancy, just a way to keep track.
This version does the same as before but I still hate using the Console. So I’ve used the Stamp feature in the Render properties panel.
-Run it same as before but ensure the Render Result image is visible in the Image Editor, AND the Stamp sub-panel is expanded so you can read it.
-Unfortunately, when rendering to a video file, the Render Result window won’t update; I will be hunting for how to change that.
-When the animation is done, I do one final render of the first frame with text overlay that says “Dagon Spot: { x,y}” where x and y are the script positions. Nicer than the Console, which you now can keep closed. (although it’s a must for errors and tracking your render progress)
-Even better, if you leave the Stamp panel open, you will see in the Note section “{x,y}”, which is provided so you can directly cut and paste it into your code, yeah!

gotchas:
-It’s hard to write a public script in Blender while knowing people may have it set up for other projects. Almost impossible to guess what assumptions to make. So this isn’t a very robust script.
-Careful with the execution. Don’t forget to update the filename or it may overwrite past renders.
-Don’t know what happens if you draw a box exactly bordering the camera view. Avoid it for now.
-This script isn’t friendly if you are using the Stamp feature for your own renders. The script turns it off completely for the animation render, then back on so you can copy the text. Any other fields in the Stamp panel are ignored for now, so turn them all off or they may overwhelm the final image render. (Spots tend to be small, so the Stamp info is relatively large looking.) If you run your own render afterwards, don’t forget to disable Stamp.
I tried to save the code to the wiki, but that was a mess! So for now it stays here.

Dagon Make Video Spot for Blender - Version 1.0

#Dagon Make Video Spot for Blender - Version 1.0
#start - get access to render settings of current scene
myren = bpy.data.scenes[bpy.context.scene.name].render
backup = myren

#adjust the borders to pixels and the width/height to even-numbers
rx = myren.resolution_x
ry = myren.resolution_y

#adjust left and bottom edges to pixel
left_x = 2*int((((myren.border_min_x)*rx)+.5)/2)/rx
bottom_y = 2*int((((myren.border_min_y)*ry)+.5)/2)/ry
myren.border_min_x = left_x
myren.border_min_y = bottom_y

#adjust right and top edges to even-numbered pixel
spot_x = 2*int((((myren.border_max_x-left_x)*rx)+.5)/2)/rx
spot_y = 2*int((((myren.border_max_y-bottom_y)*ry)+.5)/2)/ry
myren.border_max_x = left_x+spot_x
myren.border_max_y = bottom_y+spot_y

#adjust for inverted Dagon/Blender origin
script_x = int(left_x*rx)
script_y = int(ry-((bottom_y+spot_y)*ry))
spot_w = int(spot_x*rx)
spot_h = int(spot_y*ry)

#display adjusted values
print("nn_________________________")
print("spot coordinates: {",script_x,",",script_y,"}")
print("spot dimensions: [",spot_w,",",spot_h,"]")

#ensure images are being cropped
myren.use_crop_to_border = True

#set render file stuff, after backing it up
bu_ufe = myren.use_file_extension
bu_ff = myren.image_settings.file_format 

myren.use_file_extension = False
myren.image_settings.file_format = "THEORA"
myren.use_stamp = False

#render it out!
bpy.ops.render.render(animation=True)

#return settings to the original values
myren.use_file_extension = bu_ufe
myren.image_settings.file_format = bu_ff

#display adjusted values again
print("nn_________________________")
print("spot coordinates: {",script_x,",",script_y,"}")
print("spot dimensions: [",spot_w,",",spot_h,"]")

#render final image with dimensions, put cut & paste data in Stamp Note field
myren.use_stamp = True
myren.use_stamp_note = True
myren.stamp_note_text = "Dagon Spot:{"+ str(script_x)+","+str(script_y)+"}"
bpy.ops.render.render(animation=False)
myren.stamp_note_text = "{"+str(script_x)+","+str(script_y)+"}"

#8

shadowphile, for entering the code in the wiki, cut and paste it into your edit, then try just putting four spaces in front of the first line and test it out. You don’t seem to need the double apostrophes that the buttons on the tool bar adds, go figure.

If only the first line shows up as code, add four spaces at the front of each line of the code. If the lines won’t wrap, try adding two spaces and hit enter at the end of each line.

I had to try all of these to get the code to show as code in my wiki post. :? >:(


#9

Good advice Imari, that worked. It’s all finished on this page:
https://github.com/Senscape/Dagon/wiki/Creating-Video-Spots-in-Blender


#10

Huston I have a problem!
OK, animation isn’t my thing so I thought I’d go simple, rendered a simple scene with a windmill turning, I rendered out my node then spent hours it seems trying to match up the colour of the video to the north image and failed
The video always comes out darker, i tested a frame against the face and the colour matches perfectly. in game:
[attachment=0:2bra4b9t]Image1.jpg[/attachment:2bra4b9t]

First tries was with Flash, then I went with Blender and still it looks darker…

I thought at first it was a irridance cache issue, but like I said the images match up

I was kinda smug because I can set the crop region manually easily in Thea, but my smugness was soon stapped out when it about 5 pixels out lol



#11

I’ve haven’t encountered that yet, Nige. Thus far the animations that I’ve added in have all been on the slides – like the doors opening and such.

Argh. If you have the alpha channel, you might try compositing the windmill itself over the cube face and then recropping. I wish that I had a better suggestion.


#12

First of all, are you doing this in Blender, cause this thread is for that script only! (stomp and curse) :stuck_out_tongue:

Anyway, I can see your problem but I don’t know your pipeline. You say you compare frames and it looks fine. Is it from Blender or Thea? You are rendering your spot as frames then compiling them into an OGV file? I’m not sure if this is correct, please clarify… If it is correct, what are you compiling them with?


#13

Been slaving all day, need to stop. But here’s my own ‘teaser’ for the Blender plugin. I SO love building my own tools. I’m thinking this might turn into a catch-all for other Dagon stuff.
Blender is an awesome platform for this kind of stuff, cross-platform, free to everybody, fires up instantly, tons of built-in tools already and fully capable of acting as a general Python IDE for OS and other apps.
Anyway, here’s the sneak peak:


#14

the sequence was edited in Blender, I figured if someone else had the same issue we could find the problem, but I’ll just do what Imari said and render the prop animation on its own, see if that works. sorry if its in the wrong place

really nice looking plugin, is this for Blender 2.63? (or whatever the most recent is)
Its great fun making scripts and a nice change from the modeling and what not :slight_smile:


#15

I get an error at line 3:

found bundled python: C:blender252.63python th config file: C:blender252.63scriptsaddonsrender_theaTheaConfig.txt th config file: C:UsersnigeAppDataRoamingBlender FoundationBlender2.63s criptsaddonsrender_theaTheaConfig.txt os.name: nt dataPath: C:ProgramDataThea Render locations file: C:ProgramDataThea RenderLocationslocations.txt locations found Traceback (most recent call last): File "Text", line 3, in <module> NameError: name 'bpy' is not defined


#16

nigec, you’re being cryptic. Is this the console output for blender 2.63 starting up? This output doesn’t look familiar, especially those words followed by a colon. There isn’t even a Text in line 3.
I also see blender 25, but you are pointing to 2.63 scripts. 2.5 era in blender was very unstable API, always changing.
don’t forget that you have to ‘import bpy’ or nothing will recognize it.

Yes, I’m using the official release 2.63a.


#17

I’ve always installed Blender from zip files and reuse the Blender 2.5 directory thats all.

I’ll re read the instructions my heads all over the place at the moment so I suspect I was doing selective reading again :oops: , I’m not a Blender user, I install Thea to see if it works and abuse some of its cool stuff like the fluid sim, compositor and smoke

[code]found bundled python: C:blender252.63python

read blend: C:UsersnigeDesktopromuntitled.blend
Traceback (most recent call last):
File “C:UsersnigeDesktopromuntitled.blendText.py”, line 3, in
NameError: name ‘bpy’ is not defined
[/code]
Actually its doing something weird, Text.py is my script, but the path is showing its in a directory C:UsersnigeDesktopromuntitled.blendText.py
infact its located: C:UsersnigeDesktoprom


#18

I’ve finished version 1.0 of Dagon Make Spots. Its a full-on addon now, no playing around with a script.
It creates and dumps images or video directly to their respective folders and gives you a snippet for your code. While it’s rendering you can paste the snippet into your script and when rendering is done you can immediately start Dagon. Should be very useful to Blender-heads. And a big learning curve for me. It’s not perfect, but it’s still kinda spiffy.
You can find it on the wiki: https://github.com/Senscape/Dagon/wiki/Creating-Spot-Videos-and-Images-with-Blender


#19

It seems to conflict with Thea, it unloads the addon and you can no longer tick the check box for Thea :o
I’ll try a fresh download Blender and not install the Thea addon, there’s sh*t loads added and my head isn’t in for digging around trying to remove them manually, downloading is a lot quicker.

Looks really promising mate, now do a C4D, Vue one :smiley:


#20

ok got it and with Thea, well they don’t fight anymore lol. The region render option wasn’t added so all it does is crop the image and index’s from 0,0, I put in a request for it to added but i’ll be a few weeks