0
$\begingroup$

I'm following these instructions https://blender.stackexchange.com/a/75652 (paragraph "Setting drivers"), and also the video linked here https://blender.stackexchange.com/a/5384 video: https://vimeo.com/40389198, to understand how to implement a driver Texture Panner.

I added a driver to a Mapping node translateY property by going to Datablock->Objects->Cube->Material Slots->Material.001->Material->Material.001->Node Tree->Nodes->Mapping->Location->Y, selecting Y and pressing D (note: right-clicking the property->Add Driver yields different results).

The expression of the driver sets the Mapping translateY to frame_current * 0.05.

The Debug value is ok and if I render the animation it works as expected.
However the viewport doesn't update the value for preview while scrolling frames.

Is there a workaround to preview it (with scripting maybe?) ?

Edit 1:

  • Reloaded the file which had an incorrect texture

This is the code snippet I used in 2.8 experimental. Since the drivers UI part hasn't been implemented yet, drivers can only be accessed with Python. It works in Cycles but not Eevee as of May 2018.

For an approach which works in 2.79 check D. Skarn's answer.

import bpy

mydriver = bpy.data.objects["Cube"].material_slots["Material.001"].material.node_tree.nodes["Mapping"].driver_add('translation',1)

scn = bpy.data.scenes["Scene"]

def getframe_fn():
 return scn.frame_current

bpy.app.driver_namespace["getframe"] = getframe_fn
mydriver.driver.expression = 'getframe()*0.05'  

Thank you all for the help!

$\endgroup$
  • $\begingroup$ Unfortunately, the 3d viewport does not support real time material changes, in 2.8 you will with eevee because that's real time rendering. I had deal with this problem myself and is very annoying, there's nothing you can do but wait for eevee to come out, sorry about that $\endgroup$ – user55023 Jun 11 '18 at 6:02
  • $\begingroup$ @Zophiekat I've tried running a little script in 2.8 to add the driver (since the UI doesn't show them yet in the version I downloaded a month ago) and... Wow!! It works! I'm posting the code in a while for those who want to see...Thank you sincerely! . $\endgroup$ – Ice-man Jun 11 '18 at 18:15
0
$\begingroup$

This is how I solved it in my addon. I made a property on materials specifying if I want to update that one live.

from bpy.app.handlers import persistent

@persistent
def live_update_materials(dummy):
    for mat in bpy.data.materials:
        if mat.wow_m2_material.LiveUpdate:
            mat.invert_z = mat.invert_z

bpy.app.handlers.frame_change_pre.append(live_update_materials)

This will reduce the animation playback FPS in the viewport, since the shader will be recompiled on every frame change. But it lets you preview the changes live and is not decreasing the FPS hard to on good hardware.

$\endgroup$
  • $\begingroup$ Tested just now, it works in 2.79b! Thank you very much! So setting any material attribute triggers the update? Hmm, I didn't think of that... $\endgroup$ – Ice-man Jun 11 '18 at 19:58
  • $\begingroup$ Yes, it does, I still recommend making a live update property like I did for the materials that are not animated that saves you some FPS. $\endgroup$ – D. Skarn Jun 11 '18 at 20:06
  • $\begingroup$ I see, that's better... By the way I've accepted your answer now! $\endgroup$ – Ice-man Jun 11 '18 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.