How to precisely rotate object to align with 3D cursor via Python script? I would like to rotate my object, which is a simple rod, so it PRECISELY align with the 3D cursor.
Here are some images showing what I mean:

I wish it to be precise so I asked for the python script, but showing me how to calculate this is also very helpful.

Any help appreciated.

You can use the Vector.angle function to find the angle between an arbitrary axis vector (like the Z axis "up" vector), and the 3D cursor. This will provide you the angle you need to rotate your object to align it with the cursor in that specific axis.

import bpy
from mathutils import Vector

curloc  = bpy.context.scene.cursor_location # Cursor location
up      = Vector((0,0,1)) # Positive Z axis
right   = Vector((1,0,0)) # Positive X axis
forward = Vector((0,1,0)) # Positive Y axis

o = bpy.context.object    # Active object

# Calculate angle between up and cursor vectors and set as Y rotation
o.rotation_euler.y = up.angle( curloc )

Notice that in the example above I'm aligning the object with the cursor on the Y axis specifically. You can change this by replacing the axis letter on o.rotation_euler, to align with a different axis.


looking weird in rendermode In the picture you can see my model in the edit mode. In the render mode it is not looking the same. It got some weird other vertices lining up, and I don't want that it looks like this! What have I done wrong? please tell me. Thank you

You've done nothing wrong. The extra edges and faces you are seeing are caused by the rendering process. Graphics cards can only deal with triangles, thus everything is converted to triangles before rendering (not permanently though). There are some ways to make it less apparent though. First is to make sure your faces are as flat as possible. If the faces aren't flat along their normal there will always be some sort of edge visible due to the face being split int 2 triangles. The other option is to manually split any faces where it is very noticeable into triangles manually so that you have control over where the edge goes.

Depending on what you are trying to do, you may be able to render using the OpenGL render that blender has, which will render the viewport, and not triangulate the faces.. Doing so won't allow you to have the same amount of controls or options as using a render engine would, but for non realistic renders especially it can be quite useful.

One final thing to try is to use an edge split modifier or auto smooth the normals. Both of these will require your model shading to be set to smooth, and will render angles over a certain limit as sharp edges. Assuming your faces are all relatively flat you could probably find an angle that would render the faces flat and the edges sharp.


How to import PyQt into Blender? I have been trying to import PyQt into Blender following Has anyone hooked up PySide to Blender? in Windows. However I am unable to get it to work.

import sys
sys.path.append('C:/Users/apple/blenderqt/py/Lib/site-packages')
import bpy
from PyQt5.QtWidgets import (QApplication, QWidget, QToolTip,
    QPushButton)
from PyQt5.QtGui import QIcon, QFont

class Example(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):

        QToolTip.setFont(QFont('SanSerif', 10))

        self.setToolTip('This is a QWidget widget')

        btn = QPushButton('Button', self)
        btn.setToolTip('This is a QPushButton widget')
        btn.resize(btn.sizeHint())
        btn.move(50, 50)

        self.setGeometry(300, 300, 300, 220)
        self.setWindowTitle('Icon')
        self.setWindowIcon(QIcon('web.png'))

        self.show()

if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

I followed the same steps in the other question and PyQt works fine in the virtual environment but it does not work when I put it in the Blender project. What is the problem?

I have PyQt5 working from within Blender on Windows 10. There are likely multiple setup scenarios that are possible and you didn't provide any information on exactly what errors you are running in to, so I'll describe the setup that is working for me::

blender-2.76b-windows64.msi
PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x64.exe
python-3.4.4.amd64.msi  (probably not required)

In my case, I had already installed PyQt5 in to an existing python-3.4.4 installation. The PyQt5 installer does not support installing to multiple locations, but I suspect I could uninstall and then reinstall it into the {blender-install}/python directory.  What I did instead was create a text file named qt.conf inside of my {blender-install} directory with this content:

[Paths]
Prefix = C:/Dev/python-3.4/Lib/site-packages/PyQt5
Binaries = C:/Dev/python-3.4/Lib/site-packages/PyQt5

The PyQt5 installer usually puts a qt.conf file in the python-install folder for you with relative paths. (My python install folder was C:/Dev/python-3.4).

One technique I found useful for troubleshooting things was to run the blender.exe from a DOS command prompt.  At first when I tried launching a QApplication, blender and everything would immediately crash and there would be no error message. By running from the DOS command prompt, I was able to see the errors. (This is different from the console window within Blender which does not have the chance to show errors when Qt crashes Blender itself.)

With the above done, I was able to run your script above. However, because you called app.exec(), once the Qt window was shown Blender became completely unresponsive. Closing the Qt window then immediately exited blender.

It doesn't seem to be necessary to call app.exec(). I also thought it would be necessary to somehow start the Qt event loop, but that doesn't seem to be the case. This answer on StackOverflow might explain why: https://stackoverflow.com/questions/28060218/where-is-pyqt-event-loop-running

For my own test, I used this simple script:

import sys
sys.path.append('C:\\Dev\\python-3.4\\Lib\\site-packages')
import bpy

from PyQt5.QtCore import Qt
from PyQt5 import QtGui
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QGridLayout, QLabel, QLineEdit, QWidget, QPushButton

class TestWindow(QWidget):
    def __init__(self, parent=None):
        super(TestWindow, self).__init__(parent)

        mainLayout = QGridLayout()

        test1Label = QLabel("Test 1:")
        test1Line = QLineEdit()
        mainLayout.addWidget(test1Label, 0, 0)
        mainLayout.addWidget(test1Line, 0, 1)

        test2Label = QLabel("Test 2:")
        test2Line = QLineEdit()
        mainLayout.addWidget(test2Label, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(test2Line, 1, 1)

        button = QPushButton('Close', self)
        button.clicked.connect(self.handleButton)
        mainLayout.addWidget(button, 2, 0)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Qt Test in Blender")

    def handleButton(self):
        print("close clicked")
        app.beep()
        window.hide()
        # note that at this point, I think the Qt app
        # is technically still 'running'

try:
    app = QtWidgets.QApplication(sys.argv)
    window = TestWindow()
    window.show()

    # I was surprised to see that it wasn't necessary to
    # somehow start the Qt event loop.  Normally something like
    # app.exec() would need to be called, but that of course
    # would hang blender. I found some info on why
    # event loop likely works from within blender without
    # additional setup here:
    # https://stackoverflow.com/questions/28060218/where-is-pyqt-event-loop-running

except Exception as e:
    print ('error')
    print (e)

If the above does not help, consider posting more information about exactly what errors or response you are seeing.


Emission shader low resolution in Eevee I do the following:

I start a new project
I add a new material to the cube
I add emission volume

Then the emission appears with low resolution. If i add the material to a sphere, the emission appears cube-shaped.
How do I get a high resolution or a sphere-shaped emission?

Eeevee only supports box-shaped volumes. To increase the resolution bump up the tile size and samples in rendering/volumetrics.


Make Object Fall Over Correctly So I have a small shack made out of Legos in blender that I want to animate to fall over, the only issue is that the z rotation doesn't work as expected. Here is a explanation in pictures.

This First Picture just shows my little shack, all the legos making it there need to fall.

In this picture I thought that rotating around the z would help solve the issue, nope it moves the same way moving around the x does! I can make the brick sit where it is supposed to but when you play the animation do to all of the different axis movement it does a pirouette in mid-air, I just want it to fall flat.
Thanks for your Help!
EDIT: Here is a simplified blend, the walls fall in and then need to tip and fall over.

EDIT#2: That totally works for rotating the object in the correct manner, thanks Markus von Broady! But the issue is when I put a keyframe into the animation, this happens.

So its all good except for it swings out to the side in the animation! Do you know how to fix that?

On your second screenshot we can see the gizmo showing 3 axes:

The green Y axis is cut off and goes up/down (the letter is up, so the Y coordinate increases up and decreases down), X axis goes right/left (increases towards the right), and Z is in middle - because it goes towards you / away from you.
Rotating something around an axis is like pretending there's a real, physical axis going through that object, think of a wheel in a car and how it rotates around its axis. In other words, if you choose to rotate around a particular axis, every point of the object will remain within the same distance to the axis during the rotation.
  rotation around Z axis; all vertices stay at same distance (and in this case they share that distance which is the same as the radius of the black circle)
It seems you either want to rotate around the red X axis or green Y axis:

But since you want to make it flip over, with the lower end not moving, you need to move the axis of the object around which you rotate. All axes go through the origin point, so you move the X or Y axis by moving the origin point. Keep in mind the green and red lines in the viewport won't move, as they represent the X=0 and Y=0 in the world coordinate space, and not object coordinate space:

The effect is the same as if you moved the mesh (in Edit Mode) up to be above the XY axes (both local and world as in this case the origin is at 0;0;0 coordinates):

Keep in mind you don't actually have to modify the origin/mesh of the object. You can position your 3D cursor wherever you want and rotate using this cursor as Pivot Point, instead of Origin:

For a still image it doesn't really matter which technique you use, but for an animation you might run into different problems for each, so I recommend to try each of them and see which of those problems you like the most. Often you will use empties and parent your objects to them, for an additional control.


how to turn a square into a circle in 2.8 In blender 2.79 there was an ability "to circle", i believe, that took a series of vertices and made a circle with them. i am not finding that ability anywhere in 2.8, is it gone?

You're looking for To Sphere.
Go into Edit Mode, select the vertices you want to change, press Shift+Alt+S and move the mouse till you get the shape you want (or use the menu Mesh > Transform > To Sphere).

LMB  to confirm changes, RMB  to cancel.


My objects "exploaded" instead of playing the animation So I'm new to Blender and doing my first project.
This is the one I'm following: https://www.youtube.com/watch?v=bpvh-9H8S1g
But the Tear It Down part for me looked different. Instead of playing the animation my objects "exploaded", and when I have rewinded this is what I got:

And now I cant go back, with Alt+Z
ps:
this is the animation that I got

Is there a fix for this?
Even if not, I just want to know what happened, or what may have cased this.
Thanks.

As it says in the comments under your video:
You have ALL of your cubes in one place. The must not intersect. So you "forgot" to move your cubes like he did in the video.
To move your cube, select it, then tap G then you can move it with your mouse.
Or better, press G X -> then it only moves in x direction.
same with G Y or G Z.


Blender 2.82 - Object disappears and reappears when moving the cutter in boolean difference I am having a house plan with build up walls. I want to create a animation in which the walls disappear from top to bottom. While still cleaning up the geometry I tried already to cut the geometry in boolean with a big cube down. It works well in the first 10% of the geometry, then the object disappears. After shifting the cube more down the cut object reappears again and everything looks as it should be.
Any idea, what could cause the problem and how to solve. As mentioned, I am still cleaning the model up.
Thanks in advance for your input
JK

I subdivided the cube, but the result was the same. Being new in Blender I saw, when the object disappears while moving the cutter, some small areas marked in orange. I looked into the mesh there and found still some issues with vertices, which needed cleaning. Afterwards the Boolean worked fine throughout the whole movement.


Cannot find uv option in texture mapping in Blender 2.72 I want to add a world texture in Blender and choose its coordinate mapping to UV to create a particle system fade out effect when using an explosion modifier just as this dissolving tutorial does: https://www.youtube.com/watch?v=gD8qlNdEt6E. But when I tried to do this, I cannot find such an option (no "uv" in the option list):

Could anyone please tell me how I can do this? Appreciate for your kindly help~

This is correct, world has no vertices so it cannot have UVs.


How do I create repeating patterns with cycles' procedural textures Most people's question in this area is how to reduce repeating patterns, however I want to create them.

I'm creating 2d rendered tiles for my game, and I want to create procedural materials for my tiles that will seamlessly match. For that I need the cycles procedural textures to repeat on a predictable interval.

I've looked at similar threads, and they only deal with simple gradients, or images, not things like voronoi, musgrave, noise.
I haven't been able to figure out how to scale/manupilate with math, the procedural nodes to any degree of repetition.

You can use the math Modulo node on mapping vectors to create tilling for procedural textures:

To tile them seamlessly you need to flip tiles in X and Y axis:

For the Tilling X and Y nodes use values between 0 and 1. And to tile them in 3D just copy the setup into Z channel.

Why Mapping node does not add tilling to procedural textures:

Mapping node does adjust tilling for Image textures. This is because image has finite dimensions and repeats itself - the tilling is already "build-in". The Mapping node only zooms, translates and rotates this tilled image.

Since procedural textures are infinite, they have no borders and are not tilled. The Mapping node will just transform them but not tile them.

How and why the math nodes work:

Texture mapping does transform texture space to object space - you can visualize it like this:

This is for Generated mapping, other types will be mapped differently. Generated mapping will map the <0,1> interval to object bounding box. Therefore it stretches with scaling the mesh, but it does not rotate with mesh rotating (edit mode). It does rotate with object since generated mapping will be always aligned with object's local coords. To bind the texture to mesh UV mapping must be chosen and mesh unwrapped to tangent space.

When we split the mapping vectors into XYZ channels, we get access to each axis and can manipulate it:

Lets focus only on single channel (all apply the same principles). Now we output what we get (in the marked rectangle). This can be visualized with a graph function:

What we need for tilling though is this graph:

This is a graph of a modulo function (precisely modulo 0.33..) and will create 3 tiles on each axis. It is mapping the output to the same input locations repeatedly.

To have it tile seamlessly and flip every odd tile lower the graph of half the curve height and make the values absolute:

You get double the tiles naturally.

There are many effects you can do with this:

Texture pixelation with rounding node: How to pixelate a texture in Cycles?

Image blurring with noising the vectors: Motion blur on texture

Staggered mapping with rounding and offsetting: Staggered Texture Mapping

Etc..


Volume scatter makes the render image and render view entirely black I want to use fog in blender cycles, but I don't understand the mist thing (I am a beginner). I have seen a tutorial on YouTube about volume scatter, but when I apply it, the render view and the rendered image are nothing but black. Does anyone know how to fix this?

When you give your environment a Volume Scatter shader, you need to use a light source other than a Sun Lamp, like a Point Lamp or a Plane with an Emission shader. A Sun Lamp essentially lights a scene from an infinite distance away. The light has to go through an infinite amount of space before it reaches your objects in your scene, and so a Volume density of anything greater then 0 will completely block the Sun's rays, since the Sun is an infinite distance away. So you have to use a light source that has a definite location, like a Point Lamp, Spotlight, or Emission shader.

If you must use a Sun Lamp as your light source, instead of giving your whole environment a Volume Scatter shader, create a Cube or Sphere and give that a Volume Scatter, and just scale it up so it encompasses the visible area of your scene. That way a Sun Lamp can penetrate through the fog, since it only has a finite distance the light has to go through.


How to use flat color shading with anti-aliasing for multi-materials? I've been searching a while now for a solution to render out a flat colored map for masking out objects in photoshop.

I found this very helpfull topic:
https://blenderartists.org/forum/showthread.php?387255-Surface-ID-Pass-in-Blender

Is there a way to combine this technique so that objects with the same material/object will use the same color?

The main benefit from this technique is that it's anti-aliased which makes it more suitable for masking.

Each material can have it's own Pass Index set up in the Properties Window > Material > Settings > Pass Index

If you set them up correctly after rendering, using a Compositor you can use an ID Mask node to mask out each part of the image according to material.

It can be directly from the Render Layers node or from an Image node through a multi layer file format like EXR.

See the Blender Manual on how to

You an then use the compositor to extract one mask for each material and save it as an image.

This technique has the advantage that since it uses a black and white mask for each layer pass you can get full anti-aliasing for each mask, without running the risk of 'ID Collision' when the mixed anti-aliased colors match a different object from another pass.


Super Laggy when moving vertices, in edit mode, where it shouldn't be laggy I'm a new modeler here, and its been pretty smooth, until now. I have been working a Dodge Challenger for the past couple of weeks, with almost no speed bumps or anything. With subsurf, The total model adds up to 235k tris, 117k faces, and 123k verts. I upgraded my GeForce driver to 457.xx.  Didn't open blender until the next day. The next day, I tried to move a vertice in edit mode with sub surf set to 2. It was VERY slow. About 2 fps. For the record, it didn't do this before, so it's not my laptop. My laptop has a 2-core i5-7200U, with a 2gb GeForce 940mx, and 12 gb RAM.
I tested on two different computers, both having the same outcome. First, my dads laptop with a similar build. Super laggy when Trying to edit a vertice in edit mode with sub-surf. Then, our desktop, with an older i7, 6gb GeForce GTX1060, and 16 gb RAM. Same outcome.
I dont know what to do at this point. 250k tris shouldnt be laggy, but it is. Or , im stupid, and it should. I just remember editing the whole 200k face mesh with sub surf visible.
Also for the record, the model was made in 2.79x. Yes, I know. I opened it the most recent version, and it still  did it.
If yall can help, or just tell me it is what it is, id be happy.

I have found the issue. Its the shrink-wrap modifier I used for the side markers.


using XML in the Blender Game Engine i've been experimenting with the BGE and i'm a beginner programmer. I was wondering if their was a way to apply a texture to an object that could be read from an XML file, for the purpose of making a billboard with a changable display? if anyone could give me some help as where to start i'd appreciate it.

Parsing XML is very simple in Python3. You can use the built-in xml module for that.

To bind the data to a texture is slightly more complicated, but it can be done too using Blender Game Engine's videotexture module.


Fluid simulation not baking, no fluid input object in the scene I keep getting the no fluid input objects in the scene error every time I try to bake please help, I'm just trying to bake a simple text

I'm using blender 2.78c on windows 8.1

As @JtheNinja said above, you didn't set the simulation right.

The "text object" (it must be converted to mesh for this to work) must be set as "fluid", and another surrounding shape (usually a big cube) must be set as "domain", and then baked. As soon as you start baking, the big cube domain will become a fluid-like shape resembling your text:

Without any other setting, or obstacle, this will generate a fluid "text shaped" object that will suddenly splash onto the "ground" (ie: the domain bottom face):

With higher domain resolutions, the fluid-like shape will better fit the text shape, of course (here I used 120 with other standard default fluid settings)


How can I add Lens Flares/Halos? Is there an addon, or an easy way to add lens flare effects or light aberrations in Blender? I've been using Blender for a while now, and it's very time consuming to always have to export to another software to do them, and sometimes it's impossible if the scene is complex.

lens-flare shader

There is an OSL lens-flare shader by iReboot (aka Dylan Whiteman) which may interest you.

From his blog post referring to a lens-flare shader originally written for the Renderman language by Larry Gritz & Tony Apodaca of pixar, iReboot writes:

  I decided to try and port this to OSL - (...) I added a few features, such as
  user definable images for lens-flare elements and have got to a point
  where the shader can now be released.(...) - along with video tutorial links


Texture not moving with Rigged Object I have a rigged character with armor.  The armor is textured with some noise texture nodes (using cycles).  These look fine in single shots, but as the rigged armor moves the noise texture slides on the object's surface.  This is a problem for an animated video, of course.
The noise texture is set to use the object's coordinates, but I suspect it is using the object's "un-rigged" location rather than the objects location as it moves in response to the rig.  I sure hope that makes sense...
So is there anyway to counter this?  Is that what's going on here?  Any help would be very much appreciated.

Try using  Generated or UV coordinates instead (obviously you need to unwrap it to  use UV coordinates).

Cycles procedural textures are 3D, so object coordinates will center the texture around the origin of the object using the material.

This works fine when moving the object and it's origin as a whole, however in cases like yours it will appear to "slide".


How do I fix this ugly bevel? I'm making a coffee cup. My coffee cup base is a modified cylinder, and I'm trying to get rid of the sharp edges around the rim of the cup.

I tried to use the Bevel tool (Ctrl+B), but that got me these ugly faces instead of the smooth, rounded edge I wanted.

I want the edge of the cup to be smooth, like a real coffee cup. Is there a tool or modifier to do this? (I already tried the Bevel modifier, and it does not bevel enough)

Just use a cube and scale it up to the size of the cup on the Y and X axis. Make sure the cube intersects the cup from above just till you can't see the bevels anymore. Select the cup, add a boolean modifier, set it to "difference" and for "object", use the cube that you have made. Apply the modifier, delete the cube and your bevels are gone! You will maybe have some lag while using smooth shading...


How can I start using Freestyle? Blender 2.67 is out, and one of its main features is the long-awaited Freestyle integration.

I'd like to try out Freestyle, but it doesn't appear in the "Render Engine" dropdown. I assume some assembly is required. What will I need to start using Freestyle on Windows and Linux?

You're right, it doesn't appear in the render engine dropdown.

In version 2.66 it is in Render tab > Post Processing > Freestyle.

Thanks to RagnarSun, in 2.67 (and 2.67a) it is in Render > Freestyle.


Small difference in Texture UVs when in object mode :( when i have my mesh in edit mode it looks fine:

(look at the concrete seams). But as soon i switch into object mode they get distorted:

I just dont understand why. I had a bevel modfier applied earlier but it is applied as you can see in the modifier tab.
Does anybody know a solution?

Thanks in advance!

I fixed it accidentally, I just created a new mesh and joined it to the existing one with Ctrl + J and then the UVs updated and were ok.


Blender Character looks abnormally smooth I'm assuming its the lighting but if not will that mean I'll have to retexture my entire character?

The hood may have had smooth shading applied to it.  To remove this, I have two solutions:

If the character is one object, then select it. On the tools tab of the Tool Shelf there is an option under Shading called flat. Select that and the whole mesh should have flat shading.
If the character is multiple objects, then select the hood. Then repeat the step above to apply flat shading.

Hope this helps!


Water leaks through obstacle Every time I try to hold water with a obstacle, it leaks out. Here is one example I have made.

The shape has no holes, and the water is partially contained but slowly leaks out. This has occurred every time I have tried this. What could the cause be?

Setting the obstacle's volume initialisation to shell seems to have fixed it

I have no idea why this works if anyone knows why please add it to the comments.


How to avoid extraneous edges when using loop cut? In order to create the detail for the shape on the right of the image below:

I had to create a lot of loop cuts. But the loop cuts create all the extra edges further to the left of the model, which don't really serve a purpose. I'm trying to create this as an asset for a game, so keeping it low-poly is important. How could I have modeled it without creating so many extra edges? Should I just create an extra mesh (in the same object)?

In this specific case, I think think the best thing is to use the cut tool k.

In specific answer to your question, the way to create a loop cut, without having it go all the way down the surface, is ripping an edge v. In your case, you would rip the edge right along the extrusion, and the front edge to the right of it. Then make your loop cuts. You can then mend the edges if you wish, by deleting the extra edge (will remove the face of the wall), adding faces (such as tris, because in the game engine it converts to tris anyway) or by making an n-gon face over the whole section.

I hope this helps. If you give me your blend file I can make examples.


Rigging for Popup Book I've struggled with rigging a simple popup-book example; I don't even know if it's possible. A simple example:

This shows three states of a popup-book. The top state is the "open book" state. The book (green pages) lies open. It has a popup (blue) attached to the pages and starts perpendicular to the book.
The middle state shows the book partially closed. Closing the book causes the popup to rotate inwards and downwards.
The lower state shows the book halfway closed. The popup rotates even more. Note: The perspective is deceptive -- the topmost edge of the popup is lower than the attached edge.
I would like a rigging that allows me to animate opening/closing the book, and the popup rotates accordingly. I haven't figured out whether there is a working combination of forward/inverse kinetics, connected/unconnected bones, and constraints that would make this work.
Any advice is welcome!

I found a way to do this with a simple rig (see attached blend file).

There are two armatures, one for the book, the other for the popup.
The book armature (yellow bones) above controls opening/closing the book:

Each page (L and R) has two bones; the innermost bone controls opening/closing via simple rotation. The outermost ones are there only for targeting the IK constraints in the popup armature.
The tails of the inner bones (Page_L and Page_R) are positioned so they are attachment points of the popup.
A rotation constraint on Page_L and Page_R makes the book open on axis for the book binding.
Rotate Page_L to open/close the book.
It only needs forward kinetics for opening/closing -- no IK constraints.

This image shows the Popup armature (orange bones):

The Popup_Center bone is the root bone; its head is where the popup middle is attached to the book and its head is where the popup apex is attached.
The Popup_L and Popup_R bones extend to the book attachment points.
IK constraints keep the popup attached to the book pages:

Popup_L IK constraint targets Page.001_L of the Book armature
Popup_R IK constraint targets Page.001_R

By rotating Page_L to close the book, Popup_L is pushed, due to the IK constraint.
Popup_L pushes on Popup_Center, forcing it to rotate towards the book.
Popup_R also pushes on Popup_Center due to its IK constraint.
Some additional notes:

I probably could have gotten away with using only a single armature. With two armatures, I could modularize multiple popups.
A control bone for managing the rotation of Page_L would have been nice, but I don't know how to do that.
I probably could have been more flexible with the bone placements, using offsets, but I haven't learned yet how to do that.
Blender is amazing. What I thought would be difficult or impossible is actually easy, once I learned how IK targets work.
I would have liked to make an animated gif of how this works in a 3d viewport, but I don't know how do that (advice, anyone?)

Here is an updated blend file:


Copying weight painted faces from one .blend file to another So I have these two separate models, one is rigged and weight painted and another is just a copy with different bones and no weights. How can I copy the weights from the first model to the second one?
If they both existed in the same project I could figure it out but they are in separate .blend files.

Original model

Copied model with automatic weights

You can append the correct weighted model into the wrong weighted blend file, then just rename its vertex groups accordingly to the names of the new armature's bones.


How to generate a fake hand painted texture (Blizzard like), Borderlands effect or Pixel Art effect I want to generate a texture that looks like it has been hand painted to use with a game asset by baking the details of the high poly on the low poly, then composite the textures to get an hand painted texture effect without having to paint.

What texture do I need, how should i compose them and is there a technique to generate good colors?

Hand painted effect

One texture is needed: a normal map. I recommend you to bake it in 32 or 16 bits float in order to get more depth on your curvature map and to bake it at a minimum resolution of 2048*2048.

Once it's baked you will need to generate two maps from it:

Generate a curvature map from a normal map: https://blender.stackexchange.com/a/72602/23134
Generate a smooth curvature map from a curvature map: https://blender.stackexchange.com/a/100637/23134
to the second slot. We don't use Multiply so the value of your color will have no effect on your texture.

The node setup is simple, you must overlay the two maps, the order makes a subtle difference:

if the curvature smooth map is in the first input of the overlay node the details from the curvature map will be shadowed so it's more realistic I recommend it.
if the curvature is plugged on the first input, the details on it won't be shadowed making the result less realistic.

Add a value node, for the first input add a color ramp in between your curvatures and the value node, on the second input the curvatures. This will allow to use the curvature to change the brightness of the color so you don't have to worry about the value of your colors.

On the color ramp for the left cursor pick a cold color, it's a color closer to blue and saturated (= a lot of color), for the right cursor pick a warm color closer to yellow and desaturated (0.5 saturation maximum, you can go higher for effects like lava).

The result:

Top lighting

To create a top lighting effect for stylized games Diffuse/Color map (PBR games do not use lighting informations in their albedo textures) you can bake an Object Space normal. You can get more informations here on how to bake it: https://blender.stackexchange.com/a/72664/23134

Once it's baked you will need to separate the Green channel (it depends on your axis it can be another channel) to get a top lighting effect. Then you must overlay it to the curvature. Adjust the value, the default 1 adds too much lighting informations.

Texture a game character or creature (and how to make it a sprite)

To add some SSS on your albedo map you must bake a thickness map: https://blender.stackexchange.com/a/100725/23134

Like before all your map must be imported in Linear mode and you must again overlay the curvature smooth with the curvature map for your grayscale then add a value node and use a color ramp in HSV mode to pick the analogous colors. For the thickness map mix it with the base albedo, use a color ramp with R: 0.7 GB: 0.1 for the blood color, you don't need to touch the right cursor. For the factor of the mix node add a color ramp with the left cursor in RGB: 0.1 (you can adjust this value for the amount of blood visible, brighter = more blood visible) and move the right cursor to the middle (position 0.5). Then you can connect the alpha of the thickness map to the alpha of the output node for the transparency if you are baking a sprite.

Drawn lines effect

You can use a color ramp node in constant mode to fake a texture with drawn lines. On the color ramp the left cursor has a dark value the right cursor has the background color. The more you move the right cursor to the left the more lines disappears. Then add a relative blur. You can adjust the Pixel Width for the thickness of the lines.

You can overlay the curvature with the lines with the curvature smooth at 0.5 for example to get more color variations:

Retro texture effect

For a retro effect GIMP is needed. Import your fake hand painted texture, I recommend you the one with the top lighting effect.

Change the saturation, old games had saturated colors. Go in Color > Saturation..., you can increase is by 25% by entering 1.250.

Reduce the scale of the image, go in Image > Scale Image..., you can set it to 512x512, bellow too much details are lost for this texture. For the interpolation select None, using an interpolation will make the image blurry.

To reduce the number of color go in Image > Mode Indexed, enter the number of color you want. Use a very low number like for example 5 (at 4 the black color for the shadows wasn't visible). I suggest you to use a dithering effect it create a smooth color transition by adding points of the same color, the positioned effect gives a more retro style by placing the pixel more like a checkerboard.

Reset the scale of the image, if you export it in 512x512 in PNG the image will be blurred even with no compression. Set it back to 2048x2048 without interpolation.

Here is the result:

Should I export a Diffuse or Albedo map?

A diffuse map is a texture for non-PBR games (also means less real time lighting and less ressources used ideal for mobile games) so the map can include some lighting informations like using a multiply with an ambient occlusion or a soft light with a color channel of an object space normal map to add top lighting. You can also use them with an unlit shader so they do not receive any lighting and shadows for better performances.
In PBR we use an albedo that contains no lighting information (or a little amount for stylized textures) to make the asset works in every real time lighting conditions. Stay with the curvature and thickness map only. The ambient occlusion must be imported separately in the shader so it is only visible in the shadowed part of your asset and disappear when hit by direct lighting (for that you must set your game engine in deferred lighting instead of forward). Also use Linear color space in your game engine instead of gamma to make your PBR textures more realistic.

Where to use them?

Fake hand painted textures are popular on mobile games, MOBA and MMORPG. Those textures can be used as an hand painting base to finish them manually.

Those textures are popular on the Dota 2 Workshop, you can learn how to create an asset for the game here: https://blender.stackexchange.com/a/101830/23134


Is there a way to Import a Houdini Generated Volume (VDB) into Blender Cycles? Is there a way to Import a Houdini Generated Volume  (VDB) into Blender Cycles?

We are working on a Uni project, and we cant seem to get a VDB into blender working at all. Has anyone done this before and is able to help.

Much appreciated Guys!

Blender can use OpenVDB for smoke cache files (there's an option in the Smoke Cache domain settings to switch between Point Cache format and OpenVDB) but I don't know much about Houdini or whether the OpenVDB format it uses is anything like compatible with Blender.

Another option would be to transform your Houdini VDB file into a format that can be used in Blender - such as an image format as used in this answer to question "Voxel Data in Cycles". There the voxel data is converted (using Python - similar to the Smoke2EXR add-on mentioned in the link in that answer (see https://baldingwizard.wixsite.com/blog/tutorial-mesh-to-volume)) into an image containing multiple slices of the volume. Maths nodes can then be used to transform from the 3D coordinates into 2D coordinates within the relevant 'slice' and this can then be rendered as a volume.

Obviously for this to work you will need to develop something to convert from Houdini VDB into multiple image slices.

Note : It would also be useful if you could supply a sample Houdini VDB file to be able to allow others to investigate how this could be achieved.


Transparent material is "see through" when rendered in Cycles So I have a model that is separated into a few pieces and each piece has it's own material, the nose piece has a material transparency problem. I have the nodes set up correctly but the material only turns transparent when in Material Preview mode and when I use "Alpha Blend" in the blend mode options, in Cycles Render it makes the material "see through".

Now the weird thing is that the material stays black when switching to the other blend modes... but turns transparent when I move the nose piece slightly. I could fix it by moving the nose piece veeery slightly but I would rather not.

I still don't know why it appeared transparent but I found a workaround, I just used a second UV map. I didn't know you could use multiple UV maps...


Highlighting parts of objects throughout animation I'm making a technical animation to supplement a training document for a lab procedure.

I'd like to annotate the video by highlighting objects (or parts of objects) to draw attention to specific details. There wouldn't be any motion throughout the animation, so motion tracking wouldn't be an issue.

For example:

How can this be achieved within blender?

While you can animate the material colours as others have suggested you can also composite the change using masks.

Masks can be created in the Movie Editor for existing videos or in the UV/Image Editor if you just want to align a mask to the current render result or image. If your items were moving then you could animate the mask in the Movie Editor to follow the items, you can even parent them to motion tracked points instead of manually positioning each frame.

The bonus with compositing is that if you have already rendered the video or want to adjust an existing video it is much quicker than re-rendering the whole animation.


Can I use Cycles materials with Blender Internal? Is it possible to have a mesh coloured and textured in cycles and then have it displayed in internal?

The only reason I ask is because I am building a log cabin and want to put some windows in. When I have done glass in cycles (Nodes) it looks much better (realistic) but when I try to do this and go back into blender internal to finish the rest of the log cabin off the window and the mesh surrounding the window becomes undefined and discoloured.

Is this because I am trying to put cycles into internal or because I am doing something wrong?

You can do something like what your asking with multiple scenes. Bear in mind, you will have a lot of extra work/tweaking/headaches when you have to adjust two scenes, but if it's necessary it's worth the trouble. Just link objects that shouldn't change between scenes (i.e. camera/lights)

Scene Setup

Create a new scene
Move your cycles object (the windows) to "Scene.001" (CtrlL > Objects to Scene > Scene.001 and and delete the object from "Scene")
Select "Scene.001" and go to the world settings:

Add a new world
Set your render engine to Cycles
Switch back to "scene". You should notice that the render engine will change between the two scenes.
Link your camera and lights to "Scene.001" (but don't delete them from "scene"). You can now move your camera and lights around and they will have the same location/rotation/scale in both of the scenes.

Render both scenes with transparent skies.

Compositing

Go to the compositor.
Enable Compositing Nodes
Add a new Render Layers node and select "Scene.001" from the drop down.
Add an alpha over node and plug them in so that one scene is on top of the other.

You will now have a Cycles object rendered in a Blender Internal scene.


Python: Selecting object by name in 2.8 The following:

bpy.data.objects['Cube'].select = True

bpy.context.scene.objects.active = bpy.data.objects['Sphere.017']

don't work in Blender 2.8, they did in 2.79 though.
How should I select (multiple) objects with Python in Blender 2.8?

According to the API changes:

  In 2.7x, you could directly (de)select an Object from its select property. This has been removed in 2.8x, in favor of some get/set functions.

bpy.data.objects['Cube'].select = True    # 2.7x
bpy.data.objects['Cube'].select_set(True) # 2.8+

Proof using the Console:

>>> bpy.context.scene.objects["Cube"].select_set(True)
>>> bpy.context.scene.objects["Cube"].select_get()
True

API Link: docs.blender.org/api/current/bpy.types.Object.html#bpy.types.Object.select_set

Example on how to select a certain object in the scene and make it the active object:

ob = bpy.context.scene.objects["Cube"]       # Get the object
bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
bpy.context.view_layer.objects.active = ob   # Make the cube the active object
ob.select_set(True)                          # Select the cube

Example on how to select multiple objects by name:

for o in ("Cube", "Camera", "Light"):
   obj = bpy.context.scene.objects.get(o)
   if obj: obj.select_set(True)

Example on how to select all objects of a certain collection:

col = bpy.data.collections.get("Collection")
if col:
   for obj in col.objects:
       obj.select_set(True)


Cycles GPU Texture-duplicate memory Question Lets say we have 1024x1024 PNG texture called Texture.png
I Have multiple materials using the same texture, on import the textures were automaticly renamed to .001 .002 .003 etc.
And Im out of GPU memory

Is Texture.png and Texture.001.png just a single texture in the GPU memory or they are occupiing new space with each instance?

EDIT: this works on console, but not in practice, images are still there...

import bpy

for img in bpy.data.images:
    print("%s" % img.name)
    if( ".0" in img.name):
        img.name=img.name[:-4]
        print("%s" % img.name)

They are not the same. If I understand you correctly they are imported as different pngs and in that case they have to be loaded to gpu memory to be used. Why don't you reload one copy in node editor for all materials using this texture?

I set up a test scene with 3 cubes. Different materials for each but in the first screenshot the same texture used in the image texture node for each material. In the second screenshot there are copies of the same texture loaded and gpu memory load goes up...

Same texture in 3 different materials.

Different Textures (Copies) in each material.

Here is a screenshot of my node setup. Only one of the three different textures is in us. The other two are marked with no user by a 0 in front.


Baking rigid body transformations I have created a simulation using rigid bodies to create a nice pile of "things" that will be fairly realistic. Now I would like to save or bake these new positions and rotations from selected frame into object data. How can I accomplish that?

You can press Bake To Keyframes button in Rigid Body Tools panel.


How to activate deflection? I have a flow a sand falling on a plane created in Particles but I can't get it to deflect from the inclined plane under the flow. It keeps going through the plane. Supposedly there is a button for deflection but I can't find it. How can make the plane deflect the flow of sand?
Blender file attached.

I found the answer. RMD the plane in Object Mode. Go to Physics and then to Collision, then give Stickiness a high value, like 5. Now the flow of sand slides from the plane before continue falling by the side.


Complex extrusion howto I want to extrude a profile (either a mesh or a curve) along a "guide" curve such that:

Its local Z axis is and remains parallel to the global Z axis at every point of the extrusion
Its X axis must always intersect the center axis, parallel to the global Z axis
The rotation of the profile matches that of the guide-curve, which may be non-linear

What are my options? I am looking for an automatic way of doing it, i.e. not by a vertex-by-vertex manipulation. Should the only way possible be via python programming and you can englight me, please do so!
Perhaps you might wonder why I would want such particular restrictions, so you might find it useful to know what I am trying to do. I am trying to model a vertical wind turbine (VAWT), such as the one in this picture:
I am modeling one of the blades. Note that the blades' profiles remain perpendicular to the radius of the turbine at all times (see top view), and also remain parallel to the horizontal plane (see side view).
Update
Well I had not thought it necessary to show exactly what I was trying to model. I thought that the sample image of a VAWT would suffice to have blenders out here provide the right answer to my question. However, to quit puzzling readers, here I post an animation of the paths I want the blade profiles to follow:

There's a lot of different ways to do this. I suggest using modifiers for a non-destructive workflow. You can get the specific result you're looking for by using a few different modifiers, but perhaps the most straight forward is the Simple Deform Modifier.

Add the mesh for the propellor blade, with the origin centered along the Z-axis, and the mesh offset along the Y-axis. The origin position is key for the modifiers to work right.

2.Add an Empty, and rotate it accordingly (you will likely need to adjust the rotation after Step 3, depending on your configuration).

Add a Simple Deform modifier. This will be used for the bending of the mesh. Set the Origin field to use the Empty you created in step 2. Set the mode to Bend and adjust the Deform Angle as desired.

Add another Simple Deform modifier. This second modifier will control the amount of twist. Set the modifier mode to Twist and once again adjust the Deform Angle as desired.


How to rotate a vertex group? Edit Mode
Is it possible to rotate a vertex group around the 3D cursor or some other fixed point on the mesh?
Thank you kindly.

The Hook modifier can make another object (an Empty, here) grab a targeted vertex-group, and give the group its own transform, by weight.

A 0 'Falloff' radius is infinite.


Nodes in the node editor are different than on tutorial I'm new to blender and I'm trying to use the Volumetric light, I have watched some tutorials and none serves me, this for example

https://www.youtube.com/watch?v=67N7778WjLk

I use the version 2.72 b but when the boy tutorial, enter the node editor does not appear to me like I needed as indicated in the photo, someone can recommend me someone who can help me.

https://youtu.be/67N7778WjLk?t=3m36s

and me neither, not shown me the same components in the menu "add" in the node editor.

Thanks and sorry for my bad English.

Just to remove this question from unanswered list.

To have the same settings as in provided tutorial change rander engine from Blender Render to Cycles.


How Do I Make an Object Look Two-Dimensional, But Have The Rest of My Project 3D? I have recently had an idea of having a three-dimensional background and landscape, but all the people to look two-dimensional. I know you can enable freestyle rendering, but that affects everything and doesn't have the right look. I want to make something like the Disney short, Paperman. They used 3D software but made everything look drawn. I want to do this but only on a few objects. I am currently in the planning process, so I don't have any .blend files or images. I hope this is enough information. Let me know if you need any more details! Thanks!

I would suggest looking into using render layers and combine with Z depth, and that way you can set up freestyle ONLY on the layers that have the characters then.


Applying Textures in Blender Hello I'm pretty new to Blender, and I need some help with applying premade textures to models I've downloaded from blendswap.

So If I download this model for example: http://www.blendswap.com/blends/view/78361
and import it to blender, the model added doesn't have the texture. All the models that I import look like this: http://i.imgur.com/RhjGkse.png

How do i go about adding the texture that the author already made?

What do you mean by import? It is already a blend file, so you can only append or link data from the file into another file.

If you are appending some parts, make sure you are selecting everything you need and, in that case, that you change your render engine to cycles before rendering (it will render grey otherwise).
It should render correctly, that model doesn't have much for textures, the most noticeable is the chair color.

In the viewport, everything will look grey if you are on 'solid mode'. See more on that here: http://www.blender.org/manual/editors/3dview/shading.html


FBX file boujou track data lags behind video I got my FBX track from boujou in blender but I can't seem to get the track to move with my video, I've checked the frame rate and made sure all settings in boujou match blenders.

The track is always just lagging behind the video and I just can't figure it out. I'm not sure what else it could be.

You can clearly see my problem in my gif.

Did you pre-cached?
Also check your current timeline is running at 23.976 it looks like your video is not 24 full frame. Check your video´s fps, then the timeline (render), then the cache before you track.
You need to re-do the track after you set all those things up.
Please vote me up on my answer if you find it useful. Thanks.


How do I set FPS if I don't know what it is? I recorded a video on my Galaxy Tab E 9.6" (a samsung tablet) and dragged it into the blender video editor. The properties of the video (on windows 8.1) says that it has a frame rate of 30 FPS. I set the FPS in the dimensions tab in the preferences editor to 30 FPS.

I rendered the video (after adding a number of sound files) but the original audio and the video did not sync up and it gradually got worse. When I checked in the editor, the original audio was about 3 frames longer than the video. I then tried to troubleshoot by using a custom frame rate. I didn't know what it was so I tried to figure it out by trial and error I ended up coming up with something like 30.0001 FPS. I rendered again and it was still not synced up and again gradually got worse.

What I need to know is: how else can I troubleshoot this? Is there a way that I can have blender set the FPS to EXACTLY what the video is os it will sync up? Or is there some other method that I need to use so that it'll sync up?

Don't know if this is helpful but you can use mediainfo-gui to get all the information of the file. Or if you know how to use the terminal you can use:

ffprobe yourclipname.mp4


Ambient occlusion where two meshes overlap? I have a house (cube) that's on an uneven ground. On this example the ground is maybe a little to wavy to be realistic, but I find it looks rather good mesh-wise, with the house intersecting the ground, so it's not on a completely flat surface. See LEFT image.

However, there are no shadows on the house from the ground or vice versa, so it looks kind of fake.

Sun Strength 1.00 straight angle towards the house, which is slightly rotated.
World AO is on 1.00
No more lights

I made a mockup of what I expected (RIGHT) regarding shadows. How can I make it more realistic?

EDIT: Apparently it's something with the ground material, when I change it to simple diffuse, I get the desired result. I need to find out what can cause this though.

For this model rather than using the World ambient occlusion why not instead bake an ambient occlusion map on the model itself? There are hundreds of resources available for how to go about accomplishing this however I would recommend using this website as a source.

http://www.katsbits.com/tutorials/blender/basic-ambient-occlusion.php

You can bake the ambient occlusion on both the box as well as the ground mesh giving you more control in how it looks.


Can't disolve edge and faces I am very new to blender and I have a problem where I can't dissolve these two faces and I don't know why. Can someone help me ?

Link to the blender file if anyone need it : https://mega.nz/#!BxBkVA5b!Xz0vgBDgfhW32xzLA_DX5Xp-r9dFMtxl2wbwyY0Km5U

A face is a polygon. A polygon is an array of vertices.

The way it is interpreted is:

Make a first triangular part with vertices 1, 2, 3
Then make another one with 2, 3, 4
Then 3, 4, 5
Etc.

This does not allow to have holes in it except if there is only 1 hole, or in some special cases for example if the holes are triangular themselves (at least, I think, this is surely a complex topology problem...).

So, my though is that you can dissolve only if there is a path of triangles "calculable" all along this polygon. And I don't think this is the case here due to the 3 square holes. Or if you dissolve, the polygon will cover/overlap the windows.


How to show transforms of Child Of or Copy Transforms constraint I am trying to find a way to make the transforms from a Child Of or Copy Transforms constraint visible.

Let's say the bone is in its default position and with the constraint activated changes to a position.
I need to keyframe any transforms out of the default position.

How could one accomplish this? Child Of and Copy Transforms constraints don't change the transforms.

I found the solution it was an answer in this question: Is there a way to convert a constraint to a keyframe?

You have to use Bake Action and then tick "Visual Keying" and probably also select the bone you want to bake the action for. This will make keyframes for any visual transforms.

Also in Pose Mode you can select bones and hit Ctrl+A and then use Apply Visual Transform.

I think you can insert keyframes for it with I -> Visual Transform too.


Python node that replaces itself in the editor with a group? This might be a bit of a weird one, but I'm looking to write a Python node that will, upon a user's input of a folder path, replace itself with a node group that contains itself and other nodes based on the contents of the folder.  I'm trying to perform this transformation:

MyNode

User inputs folder path

MyNodeGroup:
    MyNode
    Other Nodes

Is this possible?

I imagine I'd have to create and instance the group immediately, then move my node into it along with any other new nodes that I need.  If it's not possible to move an existing node into a group, could I create an identical node and then delete the old?

Any advice on this problem is greatly appreciated!

Edit: Or, if groups are not the most appropriate mechanism for this, is it possible to maintain other nodes inside my node internally?

You can probably write a script that generates such node setup after being given a file path. Use the single selected node to read its inputs and outputs, then delete it by the script and attach generated nodes' IO to what you read.


Why are bones not connected both in rest and pose position? I was making a simple character to learn animation and how to use bones (I'm a beginner), I accidentally made a rotation that I didn't like, so I cleared the transforms, but it is different from the rest position. I looked closely and realised that two bones that are connected in pose position are not connected in rest position (pictures attached) what do I do to fix this?

here are "side by side"s

close up with bones showing

what it looks like in full view

thanks

Actually, when you are in Pose mode, the Rest Position put the bones at the same positions as in Edit mode. If you switch back to Pose Position you'll let all the Bone Constraints (and perhaps keyframes) act on your bones.

In your case, why, in Pose Position, is the calf bone in another position than in Edit mode (or Rest Position)? Because it has an IK Constraint and you can see the influence of this constraint, it will make the bone stick to its target, which is called "leg_ik.l".

So if you don't want your basic Pose mode to be this one, you need to stick your "leg_ik.l" to the tail of the calf (but in the process it will move some other bones so you will have to bring other corrections).


How do you cut off part of a mesh you don't want? I made a clothing mesh in the program  Sculptris a open source sculpting progam and then exported the mesh to Blender 3d. When I made the mesh in Sculptris I made alot mistakes on the pant leg and I do not like the way it looks  so I want to delete the part of the pant legs and redo it. However,  I do not know how to delete parts of mesh I do not like.  I am still much a newbie to Blender, I understand most the basics of the program but I am still learning all the tools in Blender.  I am sorry this such a newbie question.  Can you please explain it to me of what is the tool to use and how to use it?

Switch to Edit Mode.

You can do this by going to the Tab (Don't know what to call it) near the bottom, most likely called Object Mode and clicking it followed by Edit Mode. You can also press the Tab key, which is the shortcut.

All of the vertices should be selected, which you can tell if they are orange. We don't want all of the vertices selected. Press A to deselect all the vertices, it should go from orange to black.

Now you need to select the area you would like to delete. Press B and drag over the area desired. Make sure to rotate around the model since it won't select the vertices on the other side (and I don't know how to fix that but it should work either way)

After the vertices of the desired area has been selected press X and then click 'Vertices'

Hope this helps.


I have 11 shape keys but my script wont read above number 9 Here is the script:

import bpy

#get the selected object
selected_object = bpy.context.object

#add shapekeys
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)
bpy.ops.object.shape_key_add(from_mix=False)

#get its shapekeys
shape_keys = selected_object.data.shape_keys.key_blocks

#loop through shapekeys and replace the names
for index, key in enumerate(shape_keys):
    if key.name != "Basis":
        key.name = "Key 0" + str(index)

#loop through shape keys and replace the names
for key in shape_keys:
    key.name = key.name.replace("Key 01", "Open_Jaw")
    key.name = key.name.replace("Key 02", "Lips_Corner_In.L")
    key.name = key.name.replace("Key 03", "Lips_Corner_Up.L")
    key.name = key.name.replace("Key 04", "Lips_Corner_Out.L")
    key.name = key.name.replace("Key 05", "Lips_Corner_Dw.L")
    key.name = key.name.replace("Key 06", "Lips_Roll_Top")
    key.name = key.name.replace("Key 07", "Lips_Roll_Bot")
    key.name = key.name.replace("Key 08", "Lips_Corner_In.R")
    key.name = key.name.replace("Key 09", "Lips_Corner_Up.R")
    key.name = key.name.replace("Key 010", "Lips_Corner_Out.R")
    key.name = key.name.replace("Key 011", "Lips_Corner_Dw.R")

What is happening is the replace("Key 01", "Open_Jaw") matches "Key 011" and replaces the start of the name with "Open_Jaw".

One option is to do the replaces in reverse so that "Key 011" is replaced before you search for "Key 01".

Another way is to create and name each shapekey as you create it. Using the index of -1 will give you the last item in the list.

bpy.ops.object.shape_key_add(from_mix=False)
shape_keys[-1].name = "Open_Jaw"
bpy.ops.object.shape_key_add(from_mix=False)
shape_keys[-1].name = "Lips_Corner_In.L"

Which you can simplify into looping through a list of shapekey names.

keynames = [
    "Open_Jaw",
    "Lips_Corner_In.L",
    "Lips_Corner_Up.L",
    "Lips_Corner_Out.L",
    "Lips_Corner_Dw.L",
    "Lips_Roll_Top",
    "Lips_Roll_Bot",
    "Lips_Corner_In.R",
    "Lips_Corner_Up.R",
    "Lips_Corner_Out.R",
    "Lips_Corner_Dw.R",
    ]

shape_keys = bpy.context.object.data.shape_keys.key_blocks
for n in keynames:
    bpy.ops.object.shape_key_add(from_mix=False)
    shape_keys[-1].name = n


short view distance in 3d view? Ok so In blender, I'm making a city, but in the 3d view, it disappears when going to a certain distance:

I'm not using a camera or anything, this is user perspective
Help?

Try increasing the clipping end distance in 3D view > properties region (N) > View > Clip:


Make End of Rotation the Beginning Rotation of New Animation in Animation Nodes I would like to have an object animate between Start_1 and End_1. Every 50 frames the ending value is given a new random value, and the preceding end value becomes the new start value.

In other words, where the last euler animation ended is where the new euler animation starts. This continues on indefinitely.

I imagine re-assigned a variable in a loop is involved, but I haven't been able to get much further than that.

First, use the Repeat Time node to repeat the the animation every constant duration. Except, we are going to dynamically change the start and end of the animation. Now, if you floor divide the time by the duration, you will get an integer that is constant for the whole duration of the animation and increases by one every time the animation repeats. Since the random nodes are deterministic based on the seed, we can use that integer as the seed of a random node and use its output as the start of the animation, while the end of the animation will be a random node evaluated at the integer plus one as follows:

Note that the node seed is equal in both random nodes.


Is there a good tutorial to understand how the different material windows work? I'm getting mad at realizing how the material instances are assigned in Blender.
Coming from Max, it's driving me crazy to not understand WHERE the material library for the scene is.
I am branching here and there but without really a clue WHERE the material library is, and I can't have a concrete output with my materials, it doesn't work as I expect to.
Is there any decent tutorial to understand how to manage the materials in the scene and assign them to objects like instances instead than like copies and copies and copies of the same material?
Just to conclude: I am writing this question because I have an object that, no matter what, it doesn't want to show me one material.
I tried to move up and down the materials in the material panel, change it, etc.: no way.
And I don't know why.
Here is a video: https://photos.app.goo.gl/1T4hJL3fb2J6JgHz9
What am I doing wrong?

You need to open edit mode, then select faces you want to paint and with the right material selected press Assign. I hope it helps.


render multiple frames using a for loop, stack overflow after one image. Is there anyway to avoid stacking while rendering? I am trying to move the camera around an interested object, and then render frames along the camera trajectory. The trajectory part worked well, but when I tried to render frames and save the depth map from a node (see the attached code), I have overstack issue. Is there anyway to solve the problem?

PS: I am a newbie in Blender, so I don't even know if I did it completely wrong in the very beginning. Any suggestion would be appreciated, thanks.

SCENE_NAME='123'
viewCount = 0
stepSize=12
scene = bpy.context.scene
stickGroup = list(i for i in bpy.data.objects if 'stick' in i.name)
camera = scene.objects['Camera']

def getPath():
   myPath = savePathConfigure();
   myPath.gtSaveDIR =
   os.path.join(os.path.dirname(bpy.data.filepath), 'Dataset/'+SCENE_NAME+'/')
   myPath.outRGBpath = os.path.join(myPath.gtSaveDIR, 'RGB/')
   myPath.outDepPath = os.path.join(myPath.gtSaveDIR, 'Depth/')

   if myPath.pathConfig()=={'FINISHED'}:
      print(myPath.gtSaveDIR)

   return myPath

class getRGBHandler:
   def __init__(self, path_in):
      self.base_path = path_in

   @persistent
   def __call__(self, scene):
      bpy.context.scene.node_tree.nodes['File Output'].base_path = self.base_path
      bpy.ops.render.render(write_still=True)

class getDepthHandler:
   def __init__(self, path_in):
      self.base_path = path_in

   @persistent
   def __call__(self, scene):
      pixels = bpy.data.images['Viewer Node'].pixels
      np.save(os.path.join(self.base_path, str(viewCount)+'.npy'), pixels)

def moveCamHandler(scene):
   cameraOrigin = camera.location
   newTheta = stepSize* (math.pi/180)  # rotate the camera completely around the focused point
   # This rotating is in global coordinate system
   rotationMatrix =np.array([  [math.cos(newTheta), -math.sin(newTheta), 0.],\
                            [math.sin(newTheta), math.cos(newTheta), 0.],\
                            [0., 0., 1.]  ])
   goal = Vector(np.dot(cameraOrigin, rotationMatrix))
   gaze = Vector(np.array([0,0,0], dtype=np.double))  # look at the origin
   camera.location = goal

   gazeRay = gaze - camera.location
   camEulerAng = gazeRay.to_track_quat('-Z', 'Y').to_euler()
   camera.rotation_euler = camEulerAng

def callMyHandlers():
   saveDIR =getPath()
   myGT = groundTruthStruct(whatScene= SCENE_NAME, objectGroup = stickGroup)

   bpy.app.handlers.frame_change_pre.clear()
   bpy.app.handlers.frame_change_pre.append(getRGBHandler(saveDIR.outRGBpath))
   bpy.app.handlers.render_post.append(getDepthHandler(saveDIR.outDepPath))

# Main loop
callMyHandlers()

for i in range(30):
   scene.frame_set(i*stepSize+1)
   viewCount+=1
   scn.render.filepath = '/outputDIR/'+str(viewCount)+'.png'
   bpy.ops.render.render(write_still=True,use_viewport=True)
   scene.update()

I have a node tree like this (see image), what I want is the depth value. Directly adding a File Out Node will lose some accuracy (double -> int16).

Thanks.

This is just a guess, I have not verified this since I am not able to run  the code myself without the objects referred from it.

The frame_change_pre handler is the method getRGBHandler.__call__, which is making a call to bpy.ops.render.render. The render call, however, in its turn calls frame_change_pre handler triggering a call to getRGBHandler.__call__, which again calls render. This is causing an infinite recursion, resulting in stack overflow.

It may not be a good idea to call render from within the frame_change_pre handler. You might want to try and move it to the main code. I didn't quite get the logic, so I am unable to suggest where it should be. But am tempted to observe: main is already calling render, is there a need for another render in the handler?

Lastly, (in case you are unaware of this) there's an easier way to get the rotation matrix, namely:
mathutils.Euler([0, 0, newTheta], 'XYZ').to_matrix(). And
newTheta can be caluclated only once, since it depends solely on stepSize (math.radians(stepSize))? mathutils.Vector has methods for dot and cross products.


How to create a new action strip I deleted all animations via the blender file outliner and now I cannot add actions in the action editor as there is no action strip. Trying to add a new action strip in the Nonlinear Animation window brings up a search for action strips which is obviously empty. Screenshot below to illustrate.
Thanks

as moonboots suggested keyframing a bone generated a new action strip


Assign Materials based on mesh name our workflow for a job requires us to import alembic meshes from maya and render them in cycles.

I would like run a script that looks at the scene mesh names and assigns the corresponding material.

If the face sets and corresponding materials import with the alembic, would it be possible to assign materials based on the imported name so that materials can be assigned to groups too?

An answer to the first part of the question :

import bpy

# Replace with your materials
mat_a = bpy.data.materials.get('mat_a')
mat_b = bpy.data.materials.get('mat_b')
# etc.

# Link every mesh name to a specific material
mesh_dic = {
    'mesh_a': mat_a,
    'mesh_b': mat_b,
    # etc.
    }

# Circle every mesh and link if need be
for mesh in bpy.data.meshes:
    mat = mesh_dic.get(mesh.name)
    if mat:
        mesh.materials.clear()
        mesh.materials.append(mat)

Unfortunately I don't know the alembic in and outs enough to answer the second part but I guess this would be possible using this kind of script depending on what information you are able to import from the file.

Source


Child objects aren't moving with parent When I grab a parent with children assigned to it, only the parent moves. Also When I select multiple object and try to move them, only the active object (the yellow one) moves.
I must have accidentally toggled something. So, what shortcut did I accidentally hit?

If you link in an object from an external file you can't move it by default, even if you parent it to a local object. In this case the selected object should be highlighted in blue unless you alter the theme colours. You can make a proxy or make a local copy to move it, or move it in the original file.

A linked object will have a small file icon next to it in the outliner. This icon will also be seen in a few other places like the object properties. All values will also be greyed out.

The only other thing that should prevent a child moving with it's parent is a constraint.

Similar constraints are available for rotation and scale. Clicking the X in the corner will delete them or you can turn off the limit that is bothering you.

Something that can stop an object being moved by itself (but should still move with a parent) is locking the transform channels. Available in both the object properties and the properties sidebar, clicking these "padlocks" will prevent the related transform channel from being altered in the 3DView. You can actually alter the values displayed to move objects while they are locked, just not with g,s,r in the viewport.

Simply click the locks to unlock them.

The values may also have drivers attached to them. When a value is being driven it is highlighted in purple.

Right click on the value and select Delete Drivers.


Problem with UV unwrap rotation I have modeled a simple folded carton box. When i UV unwrap the mesh i get a rotated UV. Why? Maybe i miss something?

use pin.

in uv editor get 2 connected vert and make them aligned on an axis
then press p to pin the 2 vert.
unwrap model
un pin with alt + p
scale acordingly


Object Particles not rendering As the title says, I'm having a hard time rendering my particles in cycle (but they do appear in Eevee and viewport)
I checked the layer, the items visibility in render, the cameray ray, the emitter checkbox in the particle settings, and by all intent and purpose I think they should render?
But they don't, so I obviously missed some setting, and I'm now pulling the "help me" card
https://www.dropbox.com/s/b0sh0ppfl08s7mk/WIP.blend?dl=0
Can anyone tell me what I've missed, please? Thanks in advance!

You use Emitter particles for your static particle crystals ("sprinkles"). For static particles that don't change their position like grass, trees, sprinkles, sesame seeds on a burger, ... it's better to use Hair particles. They are static and always dead.
Emitter particles are used for animation mainly. For birds, fishes, moths, dust, and fluid. They have a lifetime and die.
Looks like you knew that and have made the settings accordingly: Only 1 frame animation and set Frame Start and End to 1, lifetime 1. Unfortunately, it does not work because in frame 1 the particles are still unborn and not rendered by default. The nasty thing is that you see them in the viewport.
Possible fixes:

use particle type Hair. You need to apply the scale of the instance object and scale it up a bit. For some reason, the particles are smaller when rendered as Hair.
or set Frame Start and End to 0
or tick the checkbox Render > Extras > Unborn in particle settings
or render frame 2 and tick the checkbox Render > Extras > Dead in particle settings
or use particle type Hair ;-)


bpy.ops.transform.rotate ignores pivot point I want to use python to rotate a vertices selection  in edit mode, around the pivot point (z-axis constrained).

The following command does not work as intented. It rotates the mesh but not around the pivot point, but around the object itself (as if the pivot point was in the center of the mesh).

bpy.ops.transform.rotate(value=0.378874, axis=(0, 0, 1), constraint_axis=(False, False, True), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)

Is this a bug? How can i do rotation around the pivot point?

Thanx,
Sp

I tried your suggestion but it does not seem to be a center_override in the "transform
.rotate function".

>> bpy.ops.transform.rotate(value=radians(45),
...     axis=(0, 0, 1),
...     center_override=(0, 1, 0),
...     constraint_orientation='GLOBAL')
Traceback (most recent call last):
  File "<blender_console>", line 4, in <module>
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\bpy\ops.py", line 189, in __call__
    ret = op_call(self.idname_py(), None, kw)
TypeError: Converting py args to operator properties: : keyword "center_override" unrecognized

Is my context wrong? or do I need to do something else before?

I also tried to change the pivot point by doing:

  v=getview3d()
  v.spaces[0].pivot_point='CURSOR'

but that did not help either (getview3d() returns  bpy.context.screen.areas[x] where x is the VIEW_3D area)
I also tried to change the origin of the object (in objectmode) and set it to cursor but when i rotated the mesh in edit mode, it ignored both the origin of the object and the pivot point.

I am still missing something...

Thanx and have a Merry Christmas!
Sp

Use bmesh operators.

There are a number of bmesh operators that can be used for this transform. Here is an example using bmesh.ops.rotate(...)

The transform is performed in global space by using the matrix world of its object. S = ob.matrix_world.copy().
Using the global location of the scene cursor as pivot point pp = scene.cursor_location
The space is transposed such that the centre of the rotation is (0, 0, 0). S.transform -= pp

Example, run in edit mode, rotates selected vertices around the global Z axis, about the scene cursor location.

import bpy
import bmesh
from mathutils import Matrix
from math import radians

context = bpy.context
scene = context.scene
pp = scene.cursor_location
ob = context.edit_object
me = ob.data
bm = bmesh.from_edit_mesh(me)
S = ob.matrix_world.copy()
S.translation -= pp

R = Matrix.Rotation(radians(45), 3, (0, 0, 1))

bmesh.ops.rotate(bm,
        matrix=R,
        verts=[v for v in bm.verts if v.select],
        space=S)

bmesh.update_edit_mesh(me)

It's not a bug

The pivot point for transform operators is set in the UI.  Quite likely you have it set to object origin.

To rotate, need an angle, an axis of revolution, and a point on that axis. The z axis has a direction of (0, 0, 1) and includes the origin point.

Think of a wall full of clocks the axis of revolution for all is the same and is normal to the wall.  However each set of hands rotates around the local "center" of each clock.

The point on the axis is set via the pivot point.

The rotate operator has the center_override option.  Example with it set to rotate around the global point (0, 1, 0).

Note: center_override appears to be a new property, explains why I hadn't used it before lol.. Check the documentation of the blender version you are using. (Can confirm it's available in 2.80)

>>> bpy.ops.transform.rotate(value=radians(45),
    axis=(0, 0, 1),
    center_override=(0, 1, 0),
    constraint_orientation='GLOBAL')

For the most part wouldn't use the transform operators, rather apply matrices directly to the vertices.

Prior to the property, would need to override the area , space and possibly region context properties and pass as an override to the context.


How long will a 10 second youtube intro take to render? I have had it rendering for hours upon hours and it all seems too much! I am not asking for a solution to speed it up, i simply want to know how long it should take!

I would also like a way to speed it up but not something technical, im new to Blender!

It depends a lot on the scene.  As a starting point, I would recommend rendering one frame and see how long that takes.  If your animation is 10 seconds and you are rendering at 24 frames per second then your whole animation will be 240 frames.  If it takes one hour per frame then your whole animation will take 240 hours or 10 days.  Of course, I'm assuming a lot without knowing about your scene.

The actual time it takes could vary greatly from my estimate.


Overlaying an image to cover a face in a video? I am trying to make a youtube video and in the part of the video I'm going to have a image of a face on top of my face to preserve my privacy. I tried going frame by frame with a picture that has a transparent background but somehow it didn't work.

You can track a point in your footage and overlay an image in the compositor.

Common practice is to blur a face, when wanting to preserve the privacy of someone in a video. I will explain this first, as it is quicker to achieve.

Bluring a moving persons face in a video

Load the video into Blenders Movie Clip Editor. Set the scene start frame, end frame and resolution.
Go to the first frame of the scene. In the Tools Tab of the Movie Clip Editor in the Track section, set the Tracking Settings to Previous Frame. Click the Add button in the Marker section, then click on the video to add a marker. The marker should be positioned on the face you want to track. Markers can be translated, rotated and scaled. G, R, S
With the marker selected, press Ctrl + T to track it.
Switch to masking mode and add a new mask.
Ctrl + click to add new masking points. Add new masking points and track the face shape, which you want to mask. To close the mask, press Alt + C. Mask points can be selected, translated, rotated and scaled as usual.
Parent the mask points to the track by selecting the track and all the mask points and press the Parent button in the Tools menu.
[Anonymously suggested: Alternately, in case you are facing issues with track selection, click each of the mask points one after another while pressing Ctrl + P after each click. This will directly parent the mask points.]

The masked points will now follow the tracking marker. The mask can be keyframe at any frame by pressing I. This may be necessary if the shape of the face changes. Mask keyframes can be viewed and edited in the Dopesheet in Mask mode. In the example, a key is used on the start and on the end frame.
In the node editor, go into Compositing mode and check Use Nodes. Add a Movie Clip node and load your clip.
If the scene size and the source movie clip size are different, connect the Image output of the Movie Clip node to a Scale node set to Render Size. Connect the Scale nodes output to a Blur node. Set the amount of blurring you want in the X, Y fields. Add a MixRGB node and connect it to the Scale and the Blur node. Add a Mask node and select the mask. Connect it to the Fac input of the MixRGB node.
Rendering the composite will blur the area, where the mask is.

Overlaying an image onto a moving persons face in a video

Do steps 1 - 3 as explained above.

In the properties panel of the Movie Clip Editor, check 2D Stabilization. Select the tracked marker and add it to the Tracks for Location.
In compositor add an Image node and load the image, which you want to lay over the face. Add a Transform node to be able to position it later. Add a Stabilize 2D node and select the video which we used in the Movie Clip Editor. Check Invert. Since the Stabilization works in the space of the movie clip, we need to bring the smiley image into the Movie Clip space. To do this, add a Set Alpha node and connect it to the Movie Clip. Set the Alpha value to 0. Add an Alpha Over node and connect it to the Set Alpha and the Transform node. Append the Stabilize 2D node after the Alpha Over. After the stabilization the smiley image follow the track in the correct space. Add an Alpha Over node and connect it to the Movie Clip node and the Stabilize 2D node.
Rendering this will overlay the smiley image ontop of the movie clip. The smiley image is matched moved with the stabilization node.


Save image as for example .png by a script My export script should export all images that the user might have used as textures. I don't have problems collecting the images. I also don't have a problem emulating being in an image-editor. The only thing I couldn't figure out how to do is how I can export the picture in any format. Here is a codesnippet how far I have got so far.

images is a list of images to export and they are all part of bpy.data.images. imageEditorArea is an existing image area because else the script doesn't want to run for some reason. exportDir is the directoy where all the images should go.

At this point I remember you that the user should not be able to change the loaction because he chose the location where the files should go already when he executed my operator

prevImage = imageEditorArea.spaces[0].image # want to keep the users selected image around
for image in images:
    imageEditorArea.spaces[0].image = image
    bpy.ops.image.save_as({'area': imageEditorArea}, # emulate an imageEditor
        'INVOKE_DEFAULT', # invoke the operator
        copy=True, # make a copy of the image
        filepath=exportDir + image.name) # export it to this location
imageEditorArea.spaces[0].image = prevImage # reset the image back to the original

The problem now is that normally, when you don't hand over a path to export the images to, one can choose an outputformat (something like 'BMP', 'JPEG', etc...). I can't figure out how one could achieve this without opening the fileselector.

You can try to use a low-level method. The Image class is documented
here.

The file format is stored in the attribute
Image.file_format.

The Image class offers two methods to save images:

save()
save_render(filepath,scene=None)

So you can probably save your image like this:

scene=bpy.context.scene
scene.render.image_settings.file_format='BMP'
image.save_render(filepath,scene)

You might try:

image.file_format='BMP'
bpy.ops.image.save_as({'area': imageEditorArea}, # emulate an imageEditor
    'INVOKE_DEFAULT', # invoke the operator
    copy=True, # make a copy of the image
    filepath=exportDir + image.name) # export it to this location


How to share variable among more than 2 operation I have a question about blender's python script.
I would like to share variables among more than two operations, however I don't know how to.

If I use global variable, it's easy to solve this problem.

selected_faces = []
class SelectFace(bpy.types.Operator):
    bl_label = "Select Face"
    def execute(self, context):
        global selected_faces
        selected_faces = ...   # get selected faces.
        .....
class OperationAboutSelectedFaces(bpy.types.Operator):
    bl_label = "Operation About selected Face"
    def execute(self, context):
        global selected_faces
        # some operation to "selected_faces"

However, I want to avoid using global variable.
So, I would like to rewrite this code as follows...

class SelectFace(bpy.types.Operator):
    bl_label = "Select Face"
    def execute(self, context):
        selected_faces = ... # get selected faces.
        .....
class OperationAboutSelectedFaces(bpy.types.Operator):
    bl_label = "Operation About selected Face"
    def execute(self, context):
        # some operation to "selected_faces"

Assuming operation sequence are as follows.

"Select Face"
"Operation About selected faces"

Thanks!

Finally, I solved this problem using static variable.

class SelectFace(bpy.types.Operator):
    bl_label = "Select Face"
    selected_faces = None
    def __init__(self):
        SelectFace.selected_faces = None
    def execute(self, context):
        SelectFace.selected_faces = ... # get selected faces.
        .....
class OperationAboutSelectedFaces(bpy.types.Operator):
    bl_label = "Operation About selected Face"
    def __init__(self):
        selected_faces = SelectFace.selected_faces
    def execute(self, context):
        # some operation to "selected_faces"

Thanks for your advice.


2 GPUs but only one render tile I have two GTX 1080 and for a while when i press F12 blender rendered everything with 2 tiles. Right now no matter what i do there is only one render tile. In system tab in user preferences i can ether select both GPUs or none, does anyone know a solution to this. BTW it is not hardware

Someone answered me elsewere.

Turns out you need to have your SLI "DISABLED" which is very confusing since you need to enable that to have better performance in everything else.


I have rendered my Blender Intro and it saved as a .avi file but I cant open it? I have rendered my intro as an animation and it has saved as a .avi file in a folder but I can't open it. What can I Do? I have tried different media files and everything. Help please!

Try rendering as png sequence images then editing them together in the Video sequence editor... this way you can try different formats without having to render all the work again ;-)


One material becomes dark/black after baking tried to bake all my house materials into one. But for some reason my roof texture ends up being black after the diffuse bake. I'm quite new to this stuff, but I'm sure I did it as the baking tutorial instructed and everything else seems alright. The original texture is greyish just like it looks in the original (left) object.
EDIT: Actually now that I compare the models more, everything seems to be a bit darker than the original, but I'm guessing it and what's happening to the roof are two separate things, so I'll wait for the answer and ask about the second thing later.

So, I found the answer at last. Here's for you that have the same problem:
I'm not quite sure why but if you have a full metallic material (perhaps it darkens less if your material is less metallic. Didn't have the time to play with the bake), the diffuse baking will bake the material as black. So to fix this issue disconnect the metallic map/put the metallic value to zero before baking diffuse and voilà the diffuse map will have the real color.


Make Tileable 45° Rotated Stripes I'm trying to get this pattern to repeat seamlessly so I can export it to a game engine. It's not too hard to get it working when the stripes are horizontal or vertical, but I'm struggling with the rotation. the stripes have to be slightly irregular, so they cannot be 100% parallel. I'm just using a mapping node small x, large y scale and rotated around z 315°. Solutions outside of Blender are welcome, too.

EDIT: here is the node setup.

For a 45° angle that can be done from generated texture coordinates with "X+Y distance" and the euclidian distance from the square center.

The node tree is in two parts:

Top line calculates the main diagonals
Bottom line adds random to it

top line
Add X + Y or 1 - X + Y to invert the direction.
Take the modulo in order to repeat regularly the diagonals.
Plug it back as X to the noise texture.
bottom line
This part is to add random variations along the diagonal.
As we want it to be symetrical, we take the distance from the center.
Then we divide the value so that it as less influence (compared to the main diagonal) for the noise texture.
And plug it as Y input of the noise texture.
noise texture
Use its scale to play on the thickness of the lines (adapt the Y influence scale in consequence).


How to convert curve to armature I have a bezier curve that I created in Inkscape and I want to convert it to an armature, where ecah node fo the curve is connected by a bone. See example below:

Is there a way to do this in Blender automatically?

Can also do this straight from the curves bezier points.

Test script, select the curve in object mode.  Note for cyclic curves cannot create a circular parent structure for bones, eg the first bone can't have the last bone as a parent. AFAIK.

import bpy
context = bpy.context
scene = context.scene
curve_obj = context.object
curve = curve_obj.data

arm = bpy.data.armatures.new("BezArmature")
arm_obj = bpy.data.objects.new("BezArmature", arm)
scene.objects.link(arm_obj)

scene.objects.active = arm_obj
bpy.ops.object.mode_set(mode='EDIT')
mw = curve_obj.matrix_world
arm_obj.matrix_world = mw
for spline in curve.splines:
    points = [bp.co for bp in spline.bezier_points]
    if spline.use_cyclic_u:
        points.append(points[0])
    parent = None
    for i in range(len(points)-1):
        bone = arm.edit_bones.new("Bone")
        bone.head = points[i]
        bone.tail = points[i+1]
        bone.parent = parent
        bone.use_connect = True
        parent = bone
bpy.ops.object.mode_set(mode='OBJECT')


How do I convert a 3D model into a bas relief using mist? I’ve finished working on the model of my girlfriend’s face (thanks for the help with that, actually) and now I’m going to move on to phase three. The plan is to make a coin with one side as a relief of her face. I’ve been searching around for ages, trying to figure out how to make a roman coin-esque relief out of it, but I don’t really get most of it. I found one, however, that might work, an that was on how it can be done with mist. I’m still not clear on it, though, so could I get some more information?

You can use a Mist pass to generate a height-map, and then use the height-map to control displacement. I'm assuming you want to print this coin, not just to render it, so the displacement is in a modifier, not a texture in a material, which would generate geometry only at render-time.

This example happens to be shooting down Z..

Arrange your model for a vertical shot, camera at (0,0, something),  looking straight down. In this case, Suzanne's ears were too high relative to the other elements, so I scaled her mesh in global Z. (The shot is going to be orthographic, so scaling in Z doesn't move anything in the picture plane)

Check the 'Mist' pass in Render Layers > Passes

In the Render tab, set the Dimensions your desired height-map size: (here, 4096x4096)  We need a high color depth in the output: I find it most convenient to set the Output to  'Open EXR Multilayer', so we can can recover the Mist layer later.. You can also set a 1-frame animation length here.
Set the camera to Orthographic, adjust the orthographic scale to contain your objects, check the 'Mist' display so we can see what we're doing in the next step...

In the 'World' tab, adjust the 0 and 1 levels of the Mist pass (the two dots at the end of the bar), to capture the depths of interest. Set the falloff to 'Linear'.

Shoot a height-map by hitting the 'Animation' button to save out your 1-frame animation. Or, if you shoot a 'Render' still, you will have to save the image out manually. You can see the map by selecting 'Mist' in the 'Select Pass' dropdown in the render window.

Model a blank coin, and subdivide it. Here, I've CtrlF > Grid Filled a circle, and added a rim.
U UV unwrap the model, looking through the camera, with 'Project from View, Bounds'

In the texture tab, load up your heightmap. You can split out the Mist Layer here. Uncheck alpha.

Assign a Simple subsurface modifier and a Displace modifier to the coin, using the texture you've just created, and you're there.

Phew! This took a lot longer to describe than to do.. don't worry.


Cycles multiple material and multiple importance sample light I'm having a problem with multiple materials and multiple importance sample options on the light.

I make a vertex color to assign the different material to the vertex. Node setup is in the screenshot. Also, I choose the multiple importance sample option on the sun lamp.

The problem is the shadow from invisible part of the prism.
I need to make a shadow only from a visible part. Also, there is no way to call a vertex group by name, only by color, right?

The problem was that there were zero diffuse reflection bounces. This value can be set in the Light Paths settings.


How to set camera horizontal and vertical FOV I get the settings of the camera I have to use in FOV angle unit(both horizontal and vertical). How to set it in Blender? In Blender you can only insert one FOV. I assume that is the horizontal FOV and how can you set the vertical one? Can anyone help me? Thanks in advance

I have found that the dimension along which the FOV applies depends on the image aspect ratio.
Let us define the aspect ratio as the ratio of width / height, such that an aspect ratio larger than 1 means that we are in a landscape configuration.

if aspect ratio > 1.0
  FOV is along width.
else
  FOV is along height.

You can verify this by setting your image dimensions to, for example, X:2000; Y:1000, and Camera lens FOV:90°. Switch to ortho views and check the representation of the camera against the grid.
See the following screenshots:

With that in mind, you can use specific FOV values.
Remember that values going into and out of trigonometric functions have to be converted to and from radians.
I use vfov to mean the required vertical FOV and hfov to mean horizontal FOV.

A. To specify the vertical FOV:

If your image is portrait or square:

just set the wanted value in the FOV field.

If your image is landscape:

Use FOV = 2 * atan((0.5 * width) / (0.5 * height / tan(vfov/2)))

B. To specify the horizontal FOV:

If your image is landscape or square :

just set the wanted value in the FOV field.

If your image is portrait:

Use FOV = 2 * atan((0.5 * height) / (0.5 * width / tan(hfov/2)))

(Note that you can simplify a bit if you compute the aspect ratio first)

Explanation:

We first find the focal length (in pixels) according to the required FOV, for example:

f = 0.5 * height / tan(vfov/2)
We use this to find the FOV along the other dimension.

hfov = 2 * atan((0.5 * width) / f)
thus,

hfov = 2 * atan((0.5 * width) / (0.5 * height / tan(vfov/2)))

Example:

We need a 90° vertical FOV on a landscape image of 2000×1000px.

vfov in radians = 90° * pi / 180° = 1.5707… rad.
hfov in radians = 2 * atan((0.5 * 2000) / (0.5 * 1000 / tan(1.5707/2))) = 2.2142… rad.
hfov in degrees = 2.2142 * 180° / pi = 126.87°.

Result:


Merge overlapping vertices of different objects The array modifier has an option to merge the overlapping vertices of two segments. Is there a way to do this with the overlapping vertices of two separate objects?

One advantage of this feature with array modifiers is that it allows other modifiers below in the stack to work on a contiguous mesh with no splits.

In the picture below, I have 3 objects that make up a single whole: two arrayed objects, and another to transition between them. They need to remain as separate objects because they have different modifiers. But the splits where the objects' vertices overlap interrupts the subsurf modifier, creating artifacts like the one circled.

The start and end caps of an array can themselves be 'live' (unapplied) arrays.

If 'merge' is checked in the array modifier, the start and end caps merge with the arrayed object.

So you can apply the array modifier to your transition object (no repeats) and set your first array as the start cap, and your second array as the end cap of your transition 'array'.


How to rotate tank treads animation using Bezier circle I have made an animation of tank treads animating along the x axis. Once I try to animate from the 51st frame to rotate into the Y axis, the whole mesh turns into chaos. What am I doing incorrect? I have tried merging the modifiers, but the animation of the treads then all become one mesh. I also saw this post but it doesn't show how to rotate the treads along rotating axis.
Tank Track Animation

If you parent the object to the curve, or if you parent both the object and the curve to an empty, it will work fine, as the axis will remain relative to the parent. If you don't, the object will go wild as you'll change the deform axis. Note that I also had to animate the tank treads on the right axis so that it moves along the curve, but it is the empty that makes it rotate.