I AM NIGHTMARE PRODUCTION DIARY #16

We're getting close to the end now as today I start the process of animating the films final sequence. 213 shots to go before this thing is in the bag- 1,224 down- 213 to go-

I cut the films teaser trailer and are now rendering out the shots that are used in the trailer-

Once the renders are done which I'll guess will be sometime around the weekend- then I'll shine up a few other things and release the trailer along with some new stills etc-

The render PC that you all bought for me is a champ- going 24/7 eating through the renders with no problems at 4.5ghz

BUT thats not to say that there haven't been any difficulties 0_o

Since I jumped into animation so fast with a new workflow wherein I don't do any final renders until the whole film is animated I met with some new workflow problems which took MANY head exploding hours to resolve but I was able to resolve them after about 30 hours and two separate days of me pounding my head on the desk-

So I've animated 1,224 shots right- now I didn't many render tests of the characters and the sets I'm using- I did a couple and ASSUMED everything was fine- I was wrong 0_o

Problem #1: Without me realizing it several of the materials I was using in the sets had an old "dirt" shader in their diffusion channel- so when rendered the materials would flicker like crazy AND cause an error to popup upon scene launch in R13 which I'm doing the rendering in

Option#1: Open every shot and manually remove the shader from every material- that would be about 6 materials per shot in 1,224 shots- thats a lot of clicks and a lot of time

Option#2: Create a script that does it automatically- I'm no coder and am a copy paste hack at best when it comes to scripting in c4d- BUT after MANY hours of research and desperation I found a python script on cineversity I was able to modify after a nice guy on Cgsociety gave me the important piece of code- here is the Python script to remove the "Dirt" shader from a scene OR any shader you choose- all you need to know is its name and replace "Dirt" with its name
--------------------

import c4d, os

############################################################
# recursive function where we do stuff to the shaders
############################################################
def shadertree(shader):
    # Loop through the BaseList
    while(shader):
       
        # This is where you do stuff
        print shader.GetName()
        if shader.GetName()=="Dirt":
            shader.Remove()
        # If it's a bitmap, we'll look at the filename
        if shader.GetType() == c4d.Xbitmap:
            filename = shader[c4d.BITMAPSHADER_FILENAME]
            print filename
            # for instance we can set the filename to just the file part
            filename = os.path.basename(filename)
            shader[c4d.BITMAPSHADER_FILENAME] = filename
       
        # Check for child shaders & recurse
        if shader.GetDown(): shadertree(shader.GetDown())
        # Get the Next Shader
        shader = shader.GetNext()
       
############################################################
# main function
############################################################
def main():
    # Get the first material
    mat = doc.GetFirstMaterial()
    # Loop through materials
    while(mat):
        # Get the first shader
        # Note - this is a 4D list - you've gotta GetDown
        shd = mat.GetFirstShader()
        # Use our recursive function to parse the shader tree
        shadertree(shd)
        # Get the Next material
        mat = mat.GetNext()

if __name__=='__main__':
    main()

------------------------

So now all I do is open a shot and execute that script and the dirt shaders are dead!

Problem#2: This one was far more annoying and time consuming 0_o So after animating those 1,224 shots I noticed that most of the characters textures looked dull when doing test renders for the trailer- I use a Fresnel shader with a modified gradient and parameters in the materials Luminance, Transparency, and Reflection channels to get the look.

So I'd had all these characters animated and they each have about 8 materials applied and NONE of them had the Fresnel shaders in their material channels 0_o

Option#1: For all 1,224 shots I'll have to manually copy paste the correct Fresnel shader in every shader channel for every character 0_o I did this for the 22 shots used in the trailer and it SUCKED and if I had to do it for every shot we're talking hours and hours and thousands of clicks

Option#2: Create a script that does it automatically

I had copy/paste hacked together a coffee script to activate/deactivate material channels and change material parameters a month or so go when discovering a bunch of textures had the wrong parameters- so I had this script here to fix that

My script is much longer as I'm modifying 40-50 materials
-------------------

var mat = doc->GetFirstMaterial(); //Get The first Material
if(!mat)return; //Error handling if no materials exist
while(mat)
{
if(mat->GetName() == "Fran face") // Look for the name "Fran face"
{
mat->SetBit(BIT_ACTIVE); // Set it as active
mat#MATERIAL_LUMINANCE_BRIGHTNESS = .30;// set color to white
mat#MATERIAL_LUMINANCE_TEXTURESTRENGTH = .30;
}
if(mat->GetName() == "chest3") // Look for the name "chest3"
{
mat->SetBit(BIT_ACTIVE); // Set it as active
mat#MATERIAL_USE_LUMINANCE = TRUE;
mat#MATERIAL_LUMINANCE_BRIGHTNESS = .15;// set color to white
mat#MATERIAL_LUMINANCE_TEXTURESTRENGTH = .15;
mat#MATERIAL_LUMINANCE_TEXTUREMIXING = 3;
mat#MATERIAL_USE_TRANSPARENCY = TRUE;
mat#MATERIAL_TRANSPARENCY_BRIGHTNESS = .10;// set color to white
mat#MATERIAL_TRANSPARENCY_TEXTURESTRENGTH = .13;
mat#MATERIAL_TRANSPARENCY_TEXTUREMIXING = 3;
mat#MATERIAL_TRANSPARENCY_FRESNEL = FALSE;
mat#MATERIAL_TRANSPARENCY_EXITREFLECTIONS = FALSE;
mat#MATERIAL_USE_REFLECTION = TRUE;
mat#MATERIAL_REFLECTION_BRIGHTNESS = 1;// set color to white
mat#MATERIAL_REFLECTION_TEXTURESTRENGTH = .29;
mat#MATERIAL_REFLECTION_TEXTUREMIXING = 3;
mat#MATERIAL_REFLECTION_ADDITIVE = FALSE;
}
if(mat->GetName() == "blackwood") // Look for the name "blackwood"
{
mat->SetBit(BIT_ACTIVE); // Set it as active
mat#MATERIAL_USE_DIFFUSION = FALSE;
}
mat = mat->GetNext(); // Get the next material if name is not found
}
---------------------

So I already had that script- so yesterday I though since I could already locate, activate and modify a materials channel with this COFFEE script I should be able to add a Fresnel shader to the channel-

Well I grinded for 8 hours yesterday trying to do this in coffee when I found it thats its not possible in Coffee and I'd have to use Python- So I picked my brain up off the desk and went at it-

I was able to figure out how to add a Fresnel Shader to a desired channel in the first active or selected material pretty quickly but I couldn't get the search thing to work- so the script would search for specific materials by name and add channels to those-

I asked for help on CgSociety and this pretty c00L guy Niklas whipped up a python script up for me real quick- I sent him a paypal tip and exhaled ^_^

I modified the script a bit after actually starting to understand how to use the Python SDK a little bit and now it works exactly as I'd like it too- here is the script- again, my script is much longer as theres a ton of materials to change- this one has two examples- all you have to do is add your own names and copy paste the repetitive bits

------------

import c4d

gra = c4d.Gradient()
gra.InsertKnot(c4d.Vector(1.0), 1.0, 0.0)
gra.InsertKnot(c4d.Vector(0.0), 1.0, 0.3)
sha = c4d.BaseShader(c4d.Xfresnel)
sha[c4d.SLA_FRESNEL_GRADIENT] = gra

mat = doc.SearchMaterialInc('chest3')
mat.InsertShader(sha)
doc.AddUndo(c4d.UNDOTYPE_NEW, sha)
doc.AddUndo(c4d.UNDOTYPE_CHANGE_SMALL, mat)
mat[c4d.MATERIAL_LUMINANCE_SHADER] = sha
mat[c4d.MATERIAL_REFLECTION_SHADER] = sha
mat[c4d.MATERIAL_TRANSPARENCY_SHADER] = sha
mat.Message(c4d.MSG_UPDATE)
mat.Update(True, True)

gra = c4d.Gradient()
gra.InsertKnot(c4d.Vector(1.0), 1.0, 0.0)
gra.InsertKnot(c4d.Vector(0.0), 1.0, 0.3)
sha = c4d.BaseShader(c4d.Xfresnel)
sha[c4d.SLA_FRESNEL_GRADIENT] = gra

mat = doc.SearchMaterialInc('L THIGH')
mat.InsertShader(sha)
doc.AddUndo(c4d.UNDOTYPE_NEW, sha)
doc.AddUndo(c4d.UNDOTYPE_CHANGE_SMALL, mat)
mat[c4d.MATERIAL_LUMINANCE_SHADER] = sha
mat[c4d.MATERIAL_REFLECTION_SHADER] = sha
mat[c4d.MATERIAL_TRANSPARENCY_SHADER] = sha
mat.Message(c4d.MSG_UPDATE)
mat.Update(True, True)

c4d.EventAdd()
-------------------------

So now that I have those three scripts- prepping my 1,400 shots won't be a total nightmare ^_^ Its just CLICK CLICK CLICK!

I keep telling myself I'm going to stop and take the time to REALLY understand Python but I never do- so when I need it I'm still all DUH DUH- there's NO EXCUSE not to learn with awesome free resources like Code Academy but when I want to sit and learn programming then I'll start on a new screenplay or make music 0_o

I believe the animated filmmakers of tomorrow will be fluent in languages like Python and C as if the creative tools don't meet their needs they will just create their own- how awesome is that?! ^_^

Well yeah so I had my little struggles and battles with the code but I got it DONE so now I can just put my energy into storytelling and animation so I can make I AM NIGHTMARE is the best film I can make!

For now I'm going to prep the dialogue for lip sync for this final sequence and get to it!





Comments

  1. your determination and will power are amazing, m dot! Seeing how you solved these suicidal problems makes me want to learn Python. And thanks for sharing the code!

    ReplyDelete
  2. Im glad your making it through these hurdles. Cant wait for the teaser trailer.

    ReplyDelete
  3. if u wanna learn python, i found this dude's python tutorials to be super helpful

    its from the theNewBoston

    http://thenewboston.org/list.php?cat=36

    and he has another set of tutorials on writing gui apps too, it may not be in the context of c4d but it'll give ya the foundation you'd need for scripting

    also make a bunch of small coding projects that u can do, i found word matching games to be an easy 101 project for python
    hope this is helpful

    ReplyDelete
  4. I recently ran into a similar kind of problem...I was trying to get an expression to work in 3dsmax, racked my brain for hours, asked around on forums, people gave me long intricate detailed examples, but nothing worked. Then I finally just by accident figured out the issue, and it's like, holy shit man. It was so simple it made me wanna cry. So I cried for a bit, then got back to makin shit :p

    ReplyDelete

Post a Comment