Sometimes doing OpenGL render active viewport is a very fast way of rendering an animation, especially 2D animations, when no lighting or fancy shading is needed.
There is a problem where materials don’t update in the viewport, like switching textures or animating UV’s.
This little script helped me to fix that problem for both scrubbing through the timeline, and rendering/playblasting the viewport:
Tested in Blender v2.77. Just run it once after opening the .blend you are working on.
import bpy
mats = bpy.data.materials
def my_handler(scene):
for m in mats:
m.invert_z = False
bpy.app.handlers.frame_change_pre.append(my_handler)
It adds a custom handler that loops through all the materials and sets a material property so Blender thinks it needs an update. I just picked invert_z because it has that value by default, and it doesnt ruin anything else.
I hope this helps some other people out!
Edit: Thanks for the code wrapping tip MCHammond and proxe!
When I tried to enable the script, I could not get it to load. Any suggestions? Sammey, sorry about the mistakes in my posts. I was not sure what you meant by tab and was looking for some clarification. Is the quotation mark supposed to be in the script? I am not a code guy. Once the script is enabled what is the procedure with the addon? Thanks
Indeed, Sammey you need to encase the properly formatted text in CODE brackets or edit your post and click Go Advanced properly format the code, select it and click the # in the toolbar region of the editor.
Hi thanks a lot for the little script ! i didn’t have a chance to test it yet, but this is super useful !
Does it work with animated texture ? this has always been a problem in the viewport in blender for me…
Anyway i put together a little installable script (like any other addon) which put a texture icon in the down header of the 3d view. It’s an on off toggle for the forcing of materials update, i thought it could be great as an addon but you don’t need it all the time, and the handler can make performance decrease in playback… Feel free to modify it in any way !
and thanks again !
edit : i confirm, it works perfectly with video texture, i tested the script in 2.78 and 2.79 on mac so far, when playing (not going frame to frame with right or left arrow, when playback with shift A), it allows to update the video texture
glad to find this script after 1 year of existence !
Thank you! I’ve been looking for a solution to this problem FOREVER. It’s such a pain in the ass as an animator having to export OpenGL renders to After Effects and animate the transparency of layers just to get an idea of how your timings are going to work. Even more so when you have multiple object and layers and you have to work out how to stack you layers in 2d to get the effect you need. I seriously hope this gets addressed in 2.8 is a default feature of Eevee. Anyway this little script should save me HOURS of work on every project. So again thanks so much for sharing your knowledge in this thread
Hi ! This script is indeed SUPER useful.
Would it be possible to make it work also whenever a bone is moved? I am driving a Hue-Saturation node with a bone, and the viewport doesnt update unless I move frames, which is annoying. I have no idea how to modify your code to take the “bone moving” event in account. Can anyone help?
thanks !