text:
how to make UIList interactive for object manipulation
I have the following data in my script:

Any mesh object, referenced as context.active_object
bpy.types.Object.markers = CollectionProperty(type = Marker), where Marker is a class containing just id, name and single vector to store location
ui with the UIList, on which I draw elements from the markers list

I have also a number of classes for making data, addings objects, etc. The script allows to easily click on a mesh and add new empty in the 3dcursor location. I have all those empties parented to the object, and I'm collecting their names in markers collection. All items for a mesh object is draw in a list using UIList. Here is my draw_items function:
class MarkerList(UIList):
    def draw_item(self,context,layout,data,item,icon,active_data,active_progname):
        if not item or item.name == '':
            layout.row().label('no name for id'+str(item.id),icon='CANCEL')
        else:
            if item.name in bpy.data.objects.keys():
                ob = bpy.data.objects[item.name]
                layout.prop(data=ob,property='name',icon='PINNED',emboss=False,text='')
            else:
                lab = layout.label(icon='QUESTION',text=item.name)

Now, the UIList is showing props using their names (data=ob, property='name'). That's OK, BUT, if somebody double click the name, it could be changed. This change also changes the name of the real empty object. I would like to update also markers list for that change, but I do not know how.
So, IS there any kind of 'update' function which is called after changing the name of the prop from the list? Or 'notify', or whatever. I would like to keep markers as a simple list of names and locations, but also I would like to allow user to change their names. If that's not possible, alternative question is: how to block names change in the UIlist?
Also, sorry for poor formulated question, I had no better idea how to ask how to detect name change of objects changed in UIList and invoking some additional action after that (ie. updating my markers list name).
Here is the UIList:

The counter is just a IntProperty added to bpy.types.Object.
Here is the name double clicked in the list:

It is automatically selected and user can change the name of the real object.
Here is the name changed by the user:

After this change, the real name of the object is changed, which is desired. I don't know, how to update the name in my own list, so I put the condition:
if item.name in bpy.data.objects.keys():

in draw_items to at least show this in the list. But I want to update my own data instead. After name is changed, the following info appears in the info window:

My list is looking like that at this stage:

My outliner is showing the change of new name of the object parented:

So, any advice will be most welcome. I can either block this editing behaviour (how?) or allow to detect name change of specific item and update markers data respectively. The script is going to manage thousands of those objects.

In draw_item() you pass item and then use if item.name in bpy.data.objects.keys() - if you rename a key in bpy.data.objects and it no longer compares to item.name then that tells me that item is at least a copy or part copy of the data in bpy.data.objects.
This means the fix will be to update the name in both bpy.data.objects and item.
The fix will depend on what is in the rest of your code. Maybe an extra refresh of the data in item. One possibility is using bpy.props, by utilising the update feature of bpy.props you can have a small function that will update both your item data and the objects name property, that would mean having the list show your list of item properties not bpy.data.object properties.

Yes, that's exactly what I want to. However, I do not know how to react to the event of change name in list element, and how then apply this to change something another.
I have a simple elements on the list, taken from the class which inherits from PropertyGroup. Should I define some method in that class? If that's possible, then I see some light in the tunnel.

It seems that documentation here https://www.blender.org/api/blender_python_api_current/bpy.types.PropertyGroup.html?highlight=propertygroup#bpy.types.PropertyGroup is telling nothing about update method :(

Ahh, I see!!! Only now I noticed that you've already provided me with the right documentation piece, thank you.


text:
how to match deinterlaced video to audio using Blender VSE
I have a single audio-video strip in VSE which has video part 2x longer than audio. I can not deinterlace it and have proper av-sync. Here is a more detailed description:
I'm using last Blender 2.73 and I'm working on linux (having 10+ years of linux and blender exp.).
The video is recorded by Panasonic HC V750 camera in default 1080i mode. The ffmpeg -i shows the following info about this recording:
ffmpeg version 0.8.13-6:0.8.13-0ubuntu0.13.10.1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 15 2014 13:48:35 with gcc 4.8.1
Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)
Input #0, mpegts, from '00000.MTS':
  Duration: 00:00:55.75, start: 0.848900, bitrate: 12290 kb/s
  Program 1
    Stream #0.0[0x1011]: Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s
    Stream #0.2[0x1200]: Subtitle: pgssub

I've set up Blender properly to have 1920x1080 100% resolution, and I've selected 25fps, PAR 1:1, time mapping 100:100 (everything fairly standard).
Of course the video strip is twice as long. I've checked [x] deinterlace checkbox for the video strip. Now I want to have 25fps deinterlaced video, but I'm unable to set this.
Things I've tried on deinterlaced strip:
- cutting it by moving right video strip handle to the length of audio doesn't work (video is just trimmed in about half)
- rescaling speed of video strip using Effect->Speed control doesn't work (video is too fast).
How to make the deinterlaced video synced with audio and how to force the deinterlaced video strip to be of the same length as audio strip (which is timed in real seconds)? Another way: how to convert 1080i50 to 1080p25 using Blender only?
please help, thanks in advance

Could you provide a small (3/4 sec) portion of your video file? Maybe a workaround can be found, but without a test on the specific "patient" we'll never be sure it would work for it

You specified 'blender only' but your question made it clear you are using ffmpeg. I do believe the quickest way to solve your problem is to use ffmpeg to convert your source video to a format you can use. As an ffmpeg user (but no expert) I would try various command-line options until I found something usable. It might be something simple as "ffmpeg -i sourcevideo.mpg -o destvideo.mp4" although you may need to specify a video codec to remove the interlacing.

Unfortunately I don't have appropriate video right now, but every one recorded with interlace at virtual 50fps is suffering the same problem: it appears twice as long as sound strip for 25fps setting. Deinterlace algorithm used in Blender is very good, however those movies usually have really 25fps, but are perceived as they have 50fps. Maybe that is the source of the problem?

Might help? http://blender.stackexchange.com/a/49219/2843

Sorry but the bottom line is that Blender doesn't like the formatting of this media. Sorry. It is frame segmented instead of strictly interlaced and just confuses the ffmpeg that Blender uses. I have the same problem with media from my Sony P&S camera.

I managed to solve that problem - see my linked answer above.

Deinterlace
The "deinterlaced" property involves only the vertical resolution.
The checkbox "deinterlace" does the job.
As you said, check De-Interlace in the property panel of the strip before exporting...

Resample
From file info:
Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1) -> 50.00 (50/1)
The problem is that your video is 50fps and you set 25fps in the render panel.
Blender manages the video as an image sequence, therefore:
50 frames at 50 fps = 1 sec.

50 frames at 25 fps = 2 sec.

On the other hand, the duration of the audio is fixed and it doesn't change with the framerate.
This is because your video is two times longer than audio.
To convert 1080i50 to 1080p25 using Blender only, you can export an image sequence setting
Frame Step: 2

Then, you can mix the original audio with the new image sequence.

I believe that you loose temporal resolution with this method (actually dropping frames). Which the OP was happy to do but this won't solve the problem of retaining the full 50fps with audio sync (which wasn't in question).

@3pointedit thank you. I've edited my answer to explain better

I'm not sure I understand correctly this wonderful explanation. Here I'm advised to render only the each second frame, from 1000 frames video, which makes 500 frames. At the same time there is deinterlace enabled, so, what exactly is the result? I mean: is deinterlace changing the number of frames in raw material (from 1000 to 500) or not, and what is performed first: deinterlacing or frame dropping? And if I do not set frame dropping, will I get two-frames long stills, 1000 frames with 500 of them different? Please clarify this problem a bit more, if you don't mind.

I've edited the answer to clarify the difference between Deinterlace and Resample. In my opinion, the order doesn't matter

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Balloon Pop Animation
How can I make a balloon pop in Blender?
Here's a reference:

I've seen the "ClothFX" add-on, but I couldn't get this result with it.

Just a small observation: the reference isn't realistic, my extensive study of slo-mo baloon popping videos on tik-tok tells me a baloon doesn't pop to many small pieces - it rips but tends to stay a single piece. I say this because either the reference is wrong, or you're fine with solutions being stylized as opposed to maximizing realism.

Create the balloon shape with the help of Cloth simulation (enable the Pressure and also the Self Collisions options):

When you're glad with the shape, apply the Cloth modifier, animate the inflate effect with a shapekeys and AltS:

Duplicate the object, make it invisible at the frame you want it to explode. Use the Cell Fracture operation to cut off the copy in several pieces, put their origin at their geometry, give them Rigid Body physic, cut off the Gravity in the Scene panel, create a Force Field > Force to make the pieces explode, make them visible when the object is supposed to explode:

you're a legend

how do you make objects visible/invisible in an animation?

You can keyframe the Disable in Renders option of the object in the Outliner (camera icon), you can also keyframe it in the Object panel > Visibility > Show in Renders. For the multiple pieces you'll create the keyframes for one of these pieces only then copy the animation data (select all the pieces, shift select the one that has the action then Ctrl L > Link Animation Data)

You can explode inflatables using stack of modifiers including Cloth
and Force Field with both carefully tweaked and animated parameters.

You need to prepare your mesh for exploding by marking edges as sharp using any known method including by hand.
Edge Split modifier splits the mesh along the specified edges.
Weld - merges the split parts back but just temporarily, notice the animated Distance value.
Cloth Modifier with Pressure physics enabled (see the blend file)
Subdivision Modifier (optional) to smooth the cut edges and overall mesh.

Test the simulation and start adding key frames to important for the simulation values - turning them on and off.

Here is a Blend file to play with:

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Grid Pattern / Wrinkles
Want to achieve similar blanket Marked as "?". How to make grid bumps with wrinkle after the cloth simulation & baking etc?

Even a single displacement could work, perhaps, with a specially crafted displacement image, like this:
I just created this in Gimp, quickly but you get the idea.

Note: it has a black border, to displace the squares, and a white/grey pattern to displace the cloth texture.
When using two separate displacements (two images) you could set their influence separately in Blender, though, with my single image relative displacement weights are set by the image shades (black maximum, grey intermediate, white none).
a quick test:

Displace modifier (like Normal option in texture settings in Blender Internal) uses grey as 0 influence, while black and white - maximum values, where black - for intruding, white - for protruding.

? so...what color is making the cloth texture (not the "grid", but what is inside the squares), in my quick example? If white and grey are both evaluated 0 influence, shouldn't the squares appear completely flat?

White is not 0 influence; it's maximum for protruding, i.e. by default it'll affect geometry to go up and black - down; grey will be 0. In your example white parts of clouds make the geometry become moved up, wihle grey parts make adjacent geometry leave as is (roughly). If you would set there black color instead of grey the effect of bump would be more visible.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
How to enable and disable Add-ons via Python?
Problem
I'm creating an addon loader that allows developers to test their addon in realtime from their external development environment (like eclipse and pydev). Since Blender does not reload all addons automaticly I have to deactivate and reactivate the addon (the refresh button does just update the addon list)
My Idea
I thought I could dig a bit in the Blender sourcecode and use the original code that activates and deactivates an addon. I found several things (in space_userpref.py line 1227 & line 1263) that could do what I want, but it never worked.
I need
the simplest way of de- and reactivating an addon with a known name.

Sounds like: http://blender.stackexchange.com/a/32035/3710 ?

This problem is very similar, But as far as I understood your stackexchange post this workflow is limited to single file-addons. I want to create an addon that can manage huge projects with submodules and multiple files and is capable of making backups and automaticly incrementing the version number. I know the process mentioned in  link , but this workflow distracts developers from coding. That's why I want to make the gap between external environment and Blender as small as possible by automating everything in between.

There is an API to manage addons to bypass operators, see addon_utils, this isn't exposed in the API docs because its mainly to manage internal functions. But the API is quite stable now.
addon_utils.enable(
        module_name, default_set=False, persistent=False, handle_error=None)

addon_utils.disable(
        module_name, default_set=False, handle_error=None)

Typically its enough to call:
import addon_utils
addon_utils.enable("my_addon")
addon_utils.disable("my_addon")

Use default_set if you want the value to be stored in the preferences, (although these will have to be saved for the new configuration to be used on restarting Blender).
See the docstrings in the source:
https://developer.blender.org/diffusion/B/browse/master/release/scripts/modules/addon_utils.py

Since you ask about reloading, see this question on recursive reloading.
https://stackoverflow.com/questions/28101895/reloading-packages-and-their-submodules-recursively-in-python


text:
Rotating & Scaling
How can I rotate something without having to roll the mouse around the screen? Can I change the rotate to work with simple up/down or left/right movement?
How can I scale something on 2 axes in the ortho view simultaneously without using the "Constraint Axis" checkboxes after the scale operation. Now I've had to do that, or scale it in one axis first, and then the other. I tried using the little circle in the center of the manipulator thing, but it was scaling in 3 axes.
Also.. how can I get the scale to work with simple up/down or left/right movement? Scaling gets weird when the mouse cursor is close to the center of the scaled things, so far I've never needed the negative scaling...

edit: Trying to clarify the simpler rotation & scale.
Rotation: Activate rotation with the manipulator or the shortcut. Move mouse right for positive rotation. Move mouse left for negative rotation. Is it possible to change rotation to function like this?
Scale: Activate the scaling. Move mouse up for increase in the scale. Move mouse down for decrease in the scale. Is it possible to change scale to function like this?

This is slightly hard to understand what you're talking about. Could you add some screen shots to explain it better?

The stack exchange format works best when just 1 question is asked at a time, might be better if you could ask them separately.

Basically the same question. SixthOfFour answered nicely.


text:
How to render geometric normals?
When we import a mesh into Blender, we can get a lot of information, and normal is one of the properties.
The Normal in Render Layers in the Compositing is connected to File Output, and export in exr format:

We then form a point cloud with normal (without faces). The result is:

and the correct normal should be:

And we also found that the length of the normal is not equal to one, so how to render the numerically accurate normal, and what's the meaning of the Normal in Render Layers? In addition, what is the difference between normals obtained in "Shading" and "Compositing"?
Here we provide data and code for the test:

step 1: /home/lab9/Installs/blender-2.92.0-linux64/blender --background --python /home/lab9/Documents/blender_render/blender_0_render.py -- 0 1 1 "test"

step 2: python blender_2_postprocess.py

step 3: python test.py

Please pay attention to modify the path_pfx in the file.
And the colored point cloud is (the rightmost is correct):

I found the following three settings, please point out any errors:

Normal(World Space) in Geometry Node

Normal(Object Space) in Texture Coordinate Node

You can convert to Camera Space by

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How to render mesh face index?
How to render an image in which pixel stores the index on the corresponding face?
We can render barycentric coordinates image in Parametric (Shader Editor >> Geometry node), but how to access the corresponding face index?

Is it related to ptex_face_id in Attribute?
And there's Object Index, Material Index, but no Face Index in  Indexes.

Perhaps all you need is menu View > Viewport Render Image?

I tested it and couldn't get the desired result.
While rendering the depth map, it's convenient to record the index of the surface, but I don't know how to do that.

What is the desired result? Can you describe the difference between the desired result and Viewport Render Image outcome?

I upload an image here.
For example, when rendering a depth map, each pixel records the distance in the z-direction to the nearest surface to form a depth map. Can the index of the nearest surface be recorded to form a new image for other purposes?

You can probably do it with geometry nodes but I don't know how. You could easily do it by using Python to bake the index to eg. a UVMap you can read in the shader, but you'd have to rebake it whenever you change the mesh...

I am not too familiar with geometry nodes either. I don’t know if Raycast Node in Blender 3.0 can do this, or if there are other simpler methods.
I can generate a UV face index based on texture coordinates and treat it as a texture map to render. I will try to do this later.

There are some attributes(matrix) associated with each face of the mesh. When the mesh does not deform, it only needs to be calculated once.
I need to render the mesh from different angles, and do some calculations according to the attributes of the face corresponding to the pixel.
So I hope to be able to render the index of the face and perform subsequent calculations along with Parametric in Geometry Node.

I'll expand on my comment. Here's a partial answer that will give you the polygon index in a shader. Maybe you can use that to do what you want.
First run this script to bake the polygon index into the U coordinate of a UVMap named PolyIndex. The active object should be the mesh you want to bake. You'll have to re-run the script whenever you edit the mesh to get the UVMap up to date though.
import bpy

ob = bpy.context.object
assert ob and ob.type == 'MESH'

if bpy.context.mode != 'OBJECT':
    bpy.ops.object.mode_set(mode='OBJECT')

mesh = ob.data
uvs = [0.0] * (2 * len(mesh.loops))

for poly in mesh.polygons:
    for loopi in poly.loop_indices:
        uvs[2*loopi] = poly.index

if 'PolyIndex' not in mesh.uv_layers:
    mesh.uv_layers.new(name='PolyIndex')

mesh.uv_layers['PolyIndex'].data.foreach_set('uv', uvs)

Then in the shader, you can get the polygon index with this

According to your code, I can connect Emission and Material Output after the X in Separate XYZ.

From the result, there is interpolation at the edge boundary. How to avoid this kind of interpolation?
And there are some outlier values at the position corresponding to edge_index=9, 10(without triangulate) in the rendered image, why is there such a singular value and how to avoid it?

See this Q about rendering solid colors.

"When using Eevee set the Filter Size in the Film panel to zero, for Cycles select Box Filter." can solve the problem of interpolation.

I upload a video here. The rendering of some views will produce incorrect pixel values at the edge boundary(it is actually the index of the backface instead of the visible front face). I don't know if the outlier pixel values are caused by the small offset like this. I will study this problem again later.

2.1. The position of incorrect pixels is affected by: Render Properitied >> File >> Overscan(I don't know why), but the position still changes on the edge boundary.

Base on the answer of scurest, I can get the following result(top: Geometry Parametric, bottom: triangle face index), you can check pixel-level correspondence in tev:

To distinguish from the background, I add an offset to face index: uvs[2 * loopi] = poly.index + 1, and I shuffled the face index to make it easier to visualize(the colors of adjacent faces may be almost the same under 256 different colors):
import cv2
import numpy as np

path_img_idx = "UVMap_TriFaceIndex_01.exr"
img_idx = cv2.imread(path_img_idx, -1)
img_idx = img_idx[:, :, 0].astype(np.int32)
max_idx = np.max(img_idx)

lut = np.arange(1, max_idx + 1)
np.random.shuffle(lut)
lut = np.array([0, *lut]).astype(np.int32) # 0 for background

img_idx = lut[img_idx]  # https://stackoverflow.com/a/67765996/10636347

img_idx = (img_idx / max_idx * 255).astype(np.uint8)
img_idx_vis = cv2.applyColorMap(img_idx, cv2.COLORMAP_JET)
cv2.imwrite(path_img_idx[:-4] + "_vis.png", img_idx_vis)


text:
Why does the normal map look inconsistent?
Data: 3D RIGGED PEOPLE >> rp_carla_rigged_001_FBX in free-3d-people.
Setup for "rp_carla_rigged_001_yup_a.fbx": Default + Eevee + Transparent + Camera(0,-3,1)
Color:

Normal:

Normal in "Non-Color"(There are still obvious inconsistencies among different UV islands):

Seams from Islands:

Code for visualization:
import cv2
import numpy as np
from vedo import *

path_img="/home/lab9/Pictures/untitled.png"
img_ori = cv2.imread(path_img, -1)
img_ori = cv2.cvtColor(img_ori, cv2.COLOR_BGR2RGB)
img_ori = img_ori[300:400, 810:850, :]

img = img_ori.copy().reshape(-1, 3)
img = img / 255.0
img = img * 2 - 1

if True:
    plt = Plotter(axes=2)
    B = Box(pos=(0, 0, 0), length=4, width=3, height=4).alpha(0.1)
    O = np.zeros_like(img)
    L = Lines(O, O+img, c="r")
    plt.show(B, L)

Result:

Question: I have a need to render a normal map as a texture.
When choosing a color map("_dif.jpg") as the texture, it looks consistent.
However, choosing the normal map("_norm.jpg") as the texture looks inconsistent, but the results of the visualization are all pointing to the positive direction of the Z axis (it should be considered correct).
What about the inconsistencies between the rendered result(as color) and the visualization result(as normal/vector)?
What transformation can I do to make the normal map look more "consistent"?
Update1: (based on Blunder's comment)
I create a plane in Blender, after sub. 100 and sculpt:

Another two planes:
without rotation:

with rotation:
000 090
270 180

Baked result:
without rotation:

with rotation:

Correction code for the second UV island, rotateX=90 equals:
x_new = -y_old
y_new = x_old

import cv2
import numpy as np
from vedo import *

path_img_N001 = "N.001.png"
path_img_N002 = "N.002.png"
img_N001 = cv2.imread(path_img_N001, -1)
img_N002 = cv2.imread(path_img_N002, -1)
img_N001 = cv2.cvtColor(img_N001, cv2.COLOR_BGR2RGB)
img_N002 = cv2.cvtColor(img_N002, cv2.COLOR_BGR2RGB)

tl = (192, 576)
bl = (447, 576)
tr = (192, 831)
br = (447, 831)

img_N001 = (img_N001 / 255.0) * 2 - 1
img_N002 = (img_N002 / 255.0) * 2 - 1

ou = tl[0]
ov = tl[1]
img_N001 = img_N001[ou : ou + 255, ov : ov + 255].reshape(-1, 3)
img_N002 = img_N002[ou : ou + 255, ov : ov + 255].reshape(-1, 3)
img_N002[:, [0, 1]] = img_N002[:, [1, 0]]
img_N002[:, 0] *= -1  #!

if True:
    plt = Plotter(axes=2, shape=(1, 2), sharecam=False)
    B = Box(pos=(0, 0, 0), length=4, width=3, height=4).alpha(0.1)
    O = np.zeros_like(img_N001)
    L1 = Lines(O, O + img_N001, c="r")
    L2 = Lines(O, O + img_N002, c="g")
    plt.show((B, L1), at=0)
    plt.show((B, L2), at=1)
    plt.show(interactive=1)

We can see that after rotation correction, the result is consistent.

Maybe we can restore the relative rotation between UV islands by the following observation:
The first plane(without rotation):

The second plane(with rotation, rotX=90):

The second plane(with rotation, rotX=180):

The result obtained after top-right rotation correction (bottom not processed, still inconsistent):

Now the problem is: are there any Off-the-shelf tools to calculate the rotation parameters of UV island?

Your normal map image texture needs to go through a Normal Map node before being used in a shader. Make sure the Normal Map node is set to Tangent Space. See if that works.

I just treat it as a Diffuse Map for rendering, because I want to explore the other properties of Normal Map.

Also set the color space to non-color data

Some gamma correction may be required to restore normals with correspondence color space. But there are still obvious visual inconsistencies between UV islands.

The normal image's job is not to look visually consistent through an Emission node. It holds the vector data for the normals. This visible seam is there because the UV islands are differently rotated. The Normal Map node takes care of this. Its output is correct if you set Color Space to Non-Color data.  https://i.sstatic.net/FO2MN.jpg (example: 1-low-poly cube with normal, 2-normal through emission node, 3-hi-poly cube)

I have updated some info.. How to restore the rotation parameters of UV Island? Do you know some related websites?

As Blunder offered in comments, it looks different across the seam because the UV islands are differently rotated across the seam.  This is normal and expected.
A tangent space normal map is a (remapped) array of vectors in the tangent space of the sample that they modify.  Tangent space is a special, per-sample space where the +Z vector points in the same direction as the surface normal and the +X vector points in the direction of increasing U (from the UV map.)  So when there are seams, that +X vector is probably going to be pointing in a different world direction, so the normal map can look discontinuous even if the vectors it contains, properly interpreted in world space, are not discontinuous.
You ask, "are there any Off-the-shelf tools to calculate the rotation parameters of UV island?"
There are plenty of ways to figure out which direction the tangent is pointing.  One way to do it is to plug a 1,0.5,0.5 color into the normal map, which represents a normal pointing in tangent space's +X direction.  Or, we could just plug a tangent node into output, which is the same thing. Either gives us the world space vector representing the tangent, the thing which is discontinuous across your mesh that causes the normal map to be discontinuous:

We can see that the tangent is discontinuous across the seam, and that discontinuity will show up in any tangent space normal map we make for this mesh, again, even though the vectors the normal map represents won't be discontinuous.
We could bake those tangent vectors if we wanted, probably to a floating point .exr to preserve negative values and precision (or remap to the 0,1 range, like we do with normal maps, and save as a .png or something.)
But the tangent is a vector, and you want rotation.  Rotation is relative-- what do you want rotation relative to?   The world +X axis?  That's mostly doable, but it will fall apart for faces in the world YZ plane, and we'll start to have terrible precision as faces approach that plane.  It's just like this radial tangent on the left.  There's a pole on the top of Suzanne's head where the answer doesn't make any sense:

And the tangent for the cube projection model, on the right, demonstrates even more discontinuities than you have, so a cube-mapped tangent isn't some natural, no-rotation choice either.  The whole problem is a little bit like how to cover a sphere with hair.  It can't be done without any discontinuities or poles.
There's no right answer for where the tangent should point, so there's no single reference for what is the rotation of the tangent.  This is related to why we use tangent space normal maps to begin with, because we need some baseline coordinate system to measure normal maps on deforming meshes, and we need to make an arbitrary (but stable) choice about one of the basis vectors of that coordinate system.  If there were some "true tangent" to which we could measure our tangent's angle, we'd use that instead.

This answer's an education. Very nice.

Just for the sake of completeness, I just remembered that you can use the Solid shading with the Normal Matcap to display the model in normal map colors:

The Solid mode does not display any normal map data from the material. But you can render Matcaps as material as described here: Matcap materials as a material for render?
If you combine this with the model's normal map then you can render her in these normal map colors.
In the Render Settings > Color Management set View Transform to Standard. This way you will see the raw colors. It should be 8080FF (hex) for everything that is perpendicular to the camera.

Shader nodes:


text:
Blender 2.8 Smoke: Unable to render color in render view using cycles

Hi Guys,
I was following a tutorial by Remington on Youtube [Smoke Fluid][2], I followed it exactly step by step with out changing anything. The only difference was that he was using Blender 2.79 and I am using 2.80.
The problem that I faced was that when I was previewing the smoke animation in Cycles view it wouldn't render the smoke color transition, I even tried sticking to one color but as you can see from the image above that I was unsuccessful. I have no idea why this isn't working, I tried changing the color by selecting the domain and then going into the shader editor but then the transition of color would not appear instead it would just switch to another color.
If anyone can troubleshoot this and help me I would really appreciate it.
Attached the blend file as well.

Please share your file at: https://blend-exchange.giantcowfilms.com/

I just did it, thank you for letting me know.

You can move in the shader editor by hold the middle mouse button and move the mouse. You navigated to a wrong place, that's why you see nothing in the shader editor. If you hit the home button, the view will snap to see the whole node layout. The principled volume shader node can adjust the smoke's color, it worked for me with your file.

I made the changes to the volume shader node but it does not achieve the tutorial result, I keyframed it and it just transitions from one color to another. Were you able to replicate the effect of the tutorial link that I shared. Could you please share the blend file with me with the changes that you made to achieve the effect. Thank you

I found it. So if you want to change only the new, inflowing smoke's color you have to use the Smoke Color parameter of the flow object. But don't decrease the density to 0. And in the domain's shader's Color Attribute use only small letters don't use capitals. And of course bake the simulation again after the modification.


text:
Remove vertices based on texture
Is there a way to apply a black and white texture to a object and remove all vertices mapped to a point where the texture is black?
I want to build a hollow earth globe and remove all vertices where there is land.

Do you want to actually remove the vertices from the mesh or just hide them so they won't be rendered?

I want to actually remove them, because it's supposed to be 3d printed.

Create a Vertex Group.
Add a Vertex Weight Mix modifier.

Set Vertex Group A to the one created in the previous step.
Set Default Weight B to 1.
Set Mix Set to All.
Add your texture to Texture Mask and set Textue Coordinates.

Add a Mask modifier and set the Vertex Group.
Apply modifiers (optional).

I added the texture, projected the uv map and created the two vertex groups, but it still didn't work. I know it's something obvious, but I have little experience with blender. Could you please start the answer from the point you add the texture?

Possible problems: a) Have you added the vertices of your object to the vertex groups with the correct values? To do that, go into Edit-mode, select everything, go to one of the vertex groups, set the Weight slider below to 0/1 depending on the group, and then click "Assign". b) Do both modifiers look just like above?

I know the texture is correct (or half correct) because on the 3d view the texture is showing it, but when I render it doesn't. Also the vertex are right because I can select them with the select button.

For the Texture in the Modifier, click Texture Mask: + New, then click on the very right button that appeared (mouseover description: "Show texture in texture tab"), there, set "Type" to "Image or Movie" and open the correct image in the "Image" area below.

let us continue this discussion in chat

Thanks, it worked. I didn't assigne the weights, and I tried to change them by selecting the vertex group and sliding the weight. I had to assign the groups again with the correct weight. Thanks!!


text:
Create Shortcuts to Toggle Actions?
I know you can create and edit shortcuts in User Preferences > Input, but I can't figure out how to make a shortcut to toggle something on/off.
For example, I can right click on the Shade Smooth button on the Tool Shelf,
(N in the 3D view)
and select "Create Shortcut" but I only can get one shortcut to shade smooth or shade flat, not one or the other based on what the current shading setting is.
So my question is,
is it possible to create a shortcut to toggle a setting?

That really depends on how the value is stored internally.
Blender already have operator for toggling Boolean values, like bpy.ops.wm.context_toggle. This operator alone is applicable to modify lots of properties, like active 3D view space's Only Render (space_data.show_only_render) or scene's Simplify (scene.render.use_simplify).
Some other settings may look like binary values of some property, but in fact not. Face shading is actually only accessible as two operators: faces_shade_flat and faces_shade_smooth. To toggle between both states, you'd have to write a new operator that toggles which of the two operators to execute based on another property, like a custom BoolProperty inserted to a Mesh object.

A detail, but you could toggle face smooth/flat with bpy.ops.wm.context_toggle but you would only be able to toggle a specific face index, which is- of course, not what you want.

To have a shortcut toggle something e.g. the flat/smooth shading, there would already have to be an operator that does that as a shortcut can only call an existing operator. So the answer is that any tool that already toggles something can have a shortcut set but anything that doesn't already toggle would have to be recoded.
For example you could write your own addon which checks the the current shading type and inverts it and then assign a shortcut for your addon.


text:
What is the difference between the SculptDraw brush and the Brush tool?
What is the difference between the F SculptDraw and the F Brush tools in sculpt mode?
From what I can see they appear the same:

There's no practical difference so far as I know. Other brush types also have this apparent duplication, for example texture paint and vertex paint have both a Draw and a Mix brush that do the same thing.

In texture painting there are three similar brushes (they are different, but I don't know what the exact differences are) here is an example.
In vertex painting there are three other brushes that also seem the same. (example)

Other than a couple of adjustable default settings, this looks like the only difference.

Draw should say Brush, but they are the same.

I went through every setting and the only difference that I can see is the one of them has the Texture Brush Mapping set to View Plane and one has this value set to be Tiled. This is not significant enough to justify an extra brush.
I'm guessing that this is just an oversight from some testing a developer was working on but you'd likely have to ask one of them.  I think Psy-Fi is doing most of the Brush Tools work right now. He is usually on IRC in #blendercoders on freenode. You could drop by and ask. I suspect that he is top of the food chain so far as this question goes.

They are in blender all the way back to at least 2.63 (the oldest version I have on my hard drive atm)

To see the differences, go to Outliner Editor>Datablocks Information Display>Brushes and then open the Brush that you desire and expand RNA to see the setup.
The "Brush" Brush has a 1 pixel radius whereas the Draw and SculptDraw brushes are set to 35 pixels.
The Unprojected Radius varies among all three brushes.
The Sculpt Draw Brush has a 10% spacing whereas the Brush and Draw brushes are set to 5%.
Everything else appears to be identical.
X = Cycles between Brush, Draw and SculptDraw Brushes.
- Blender 2.72b

If you read the answers give you will see something important. These brushes have input from a Wacom pad such as the brush angle, pressure and location. I think it might change more if you have these inputs.
You can also set the rotation of the texture manually if you look at the nettings in the N settings area.
More importantly, try these two brushes with a texture using a picture of a white lines on a black background. Make sure that your dynamic texture is on and set to 1 pixel (yes it might overload older computers so go with 5 or so). With brush you will not see much happening but with sculpt draw you will see your texture on your mesh. A huge difference!
Douglas E Knapp. Hope this helps! Email me if you have questions.


text:
Is it possible to use the output of a Renderlayer in the material nodes of another RenderLayer?
Is it possible to use the rendered output of one renderlayer in the materials on another render layer?
How can I achieve this?

Yes, this is possible.
You can achieve this with an Image Sequence Texture node:

Set up two render layers with each layer excluding the other:

Set up compositing nodes so the render layer that is being used to influence the materials renders out to a separate directory.
This is possible with the File Path node:

Render only the influencing layer once to that directory by Pinning  that render layer.
The file will be named something like Image0001.png. Rename it to Image0000.png
Set up the material you want to be influenced.
You can pull in the result of the other render layer by adding an Image Texture node, setting the image to Image0000.png, setting the Source to Image Sequence, and setting the Offset to -1

This is the result of the other render layer.
Render the animation. (CtrlF12, or Info > Render > Render Animation

Here is a simple test with two spheres (one on each layer) and a moving light source:

Keep in mind that with this technique, the two layers are one frame apart.
This could be fixed by rendering the influencing layer completely beforehand, and adjusting the offset accordingly.

You should probably use exr for temporary storage. Also, is it possible to let it overwrite temporary images, if you only need a temporary swap image.

@user877329 As far as I know there isn't a way to override the frame number being appended to the filename, but you could use a post render hook and a little bit of python

In deed, it would be nice to have a "Feedback texture" (usable from both shaders and compositor). Then you could easily use the output from cycles to affect growth of plants.


text:
Is it possible to deselect freestyle edges?
Is it possible to deselect freestyle edges?
For example, I enabled Material Boundary in Render layers → Freestyle Line Set → Edge Types to draw lines on all edges between faces with different materials:

Is it possible to explicitly exclude an edge from freestyle drawing so I can have all material boundary edges drawn except for ones I specify?
e.g:

In Edit Mode select the edge and Mark Freestyle Edge Ctrl+E,F
In the Properties window > Render Layers > Freestyle Line Set:

Enable Logical AND.
Enable Edge Mark and the (Exclude Edge marks) X button next to it.

Result:

For some reason it does not work for me. Nothing seems to be drawn with logical AND enabled?

@gandalf3 I've uploaded the blend used to create the above image for you to inspect. I suspect you have additional edge types enabled, in that case you can stick with Logical OR and enable Exclude edge material boundary (X button).

Thanks, using OR works. Though I'm still confused as to why AND was not working. As far as I can tell, the settings are identical to your example, but when I tried it, this was what was drawn. Here is my .blend file

In your file, the top and backside faces have the same material assigned, so there's no material boundary edge being drawn.


text:
Text objects are messed up when using Offset
Sometimes when using the Offset  parameter in Text object data > Geometry > Modification to shrink or fatten characters, some characters will get incorrectly displayed:

The default Bfont is more immune to this then most other fonts I tried, where this starts happening even with an Offset factor of .001.
What causes this and how can I correct it?

I think this happens when glyphs outlines have unusual spline orderings, got any links to fonts where this happens?

@zeffii This font has this issue with a positive offset of .001. Bfont breaks at .026.

The uppercase L in that font has a stray line segment https://i.sstatic.net/52hy3.png -- you could use fontforge to inspect fonts, usually if fontforge has an issue with a font it's a bad sign. If you find issues on fonts from Google WebFonts, those are generally checked better before being added -- then it might be a bug.

I tried reporting a bug a year ago with some fonts that drew badly, the official response was - "This is an issue with scan-fill, blenders geometry filling doesn't support overlapping lines".

While this isn't a fault with blender's font parser I think I can offer some insight.
To give this context, this doesn't only happen with fonts, it happens with all 2D Curves that self intersect when offset too.

Font Weights
If you have a bit of respect for typography then you don't 'fatten' fonts. Fonts are designed with certain visual weights in mind, an indiscriminate offset messes with this delicate balance of geometry and empty space. As an example Helvetica has between 34 and 51 weights depending on flavour, each is 'fattened' by hand and tweaked in subtle ways.
No doubt you don't have to pay any attention to what is considered proper use of fonts, that's part of the fun. For the moment this is the way the Blender engine offsets 2D filled curves, without respect for potentially self-intersecting geometry. If you really want fatter letters but can't find the right weight in the font family then consider doing it in Inkscape/Illustrator, and importing as an SVG. SVG is imported as a 2D curve.
Other reasons a font may render poorly
Fonts or 'digital typefaces' vary in enormously in quality. A substantial amount of free fonts has defects that may not be immediately obvious in 2D graphics packages (they may have more elaborate font loading mechanisms).
With the font you suggest, the area in question is tricking blender into thinking it has to deal with an extra line segment, this line segment however doesn't connect to any other segments and also doesn't form a closed loop with itself.
In Inkscape if you pick this Embossed Font and make a text object, with just the uppercase L, and convert it to a path (Path > Object to Path) you will notice this stray line segment. It shouldn't be there, but it is. Inkscape ignored it, but includes the path anyway.

This is also exactly where blender throws its hands in the air.

I'm sure if you inspect the other fonts where this peculiar stuff happens, they too suffer from stray line segments, and maybe self intersections.
A fix
You can edit fonts inside Blender, and remove the usual suspects.
With the font in object mode, go to:
Object -> Convert To -> Curve from Mesh / Text, or AltC-> Curve from Mesh/text
Now you can deal with stray lines, (delete them) and still apply Extrude, etc.  Unfortunately this operation doesn't allow you to correct typos in the existing text object any more, because it has been converted to a Curve.

Would Bmesh have this sort of issue too?

@gandalf3 i think I read your question incorrectly, For offset I suppose the Positive offset code could be improved to deal with the result of self intersecting edges


text:
Python: Apply object operator to dupli objects
I wanted to apply an object operator (shade_smooth/flat) to linked/dupli objects, but can't find a way to pass the object to this operator.
import bpy

# flat or smooth
flat = False

for ob in context.scene.objects:
    if ob.dupli_group and ob.dupli_group.objects:
        for dob in ob.dupli_group.objects:
            if flat:
                bpy.ops.object.shade_flat()
            else:
                bpy.ops.object.shade_smooth()

Of course this doesn't work, because it applies on selected objects only. Was surprised to see this even works from the python terminal, without the need to override context.
Any clues?

This uses selected_editable_objects, You can find out which attributes are used by passing in a Python context, and then check the terminal for where each requested attribute is printed.
(Yes, we know this isnt an ideal way to design the API, however this is internal C code which defines which context variables are used).
import bpy
from bpy import context

# flat or smooth
flat = True

# use a 'set' to avoid duplicates, can convert into a list after.
selected_editable_objects = set()

for obj in context.scene.objects:
    if obj.dupli_type == 'GROUP':
        group = obj.dupli_group
        if group:
            for dob in obj.dupli_group.objects:
                selected_editable_objects.add(dob)

context_py = context.copy()

context_py["selected_editable_objects"] = list(selected_editable_objects)

if flat:
    bpy.ops.object.shade_flat(context_py)
else:
    bpy.ops.object.shade_smooth(context_py)

Note: this would be more efficient to de-duplicate based on the object data, since its possible many objects reference the same data. But for the example above, its simpler to just take unique objects.

It works! On local objects, I was wondering about it working on linked meshes.
An animator asked me if they could switch smooth/flat shading on linked characters, to better check deformations. Is this possible? I get a "Warning: Can't edit linked mesh or curve data" when running this.

@Pablo Vazquez - for linked data the operator intentionally disallows this. so. no quick solution. Theres nothing stopping you going over every mesh and setting all faces, but this is a bit of a hassle from a Python script. (though with foreach_set it could be fast enough).

bpy.ops.object.shade_flat() and bpy.ops.object.shade_smooth() set the shading on all selected objects. The active object doesn't matter - if it's not selected, it won't be affected.
# Deselect
for ob in context.scene.objects:
    ob.select = False

# Select
for ob in context.scene.objects:
    if ob.dupli_group and ob.dupli_group.objects:
        for dob in ob.dupli_group.objects:
            dob.select = True

# Set shading on all selected objects
if flat:
    bpy.ops.object.shade_flat()
else:
    bpy.ops.object.shade_smooth()


text:
Where is the color selection for text menus?
I want to change the color of the File, Edit and View menus:

And all the similar menus such as the 3D view menu:

Where can I find the settings for these text menus?

This is in the the group Pulldown under User Interface as Text.


text:
How can I fix this scaling issue I have?
I'm trying to scale the cube to be the size of the house.. but this happens.
https://youtu.be/1nITnqzOprI
Is there a way to solve this?
Edit:
Scaling the X axis only deforms the cube. I'd like to make the cube the same width and length as the house.
Edit: The only way I can get what I want is if I extrude and then merge the vertices. Which is a bit longer solution.

Hi. A video can be ok, but ideally videos should be supplemental to good question content, e.g. a good, descriptive question and screenshots. We ideally want people to be able to answer the question (or see if they have the same problem) as easily as possible. Also, external links may at some point go down, which we try and avoid.

I think your mesh is not aligned with its own object's local axes.. (you may have reoriented the cube in Edit Mode). So the Local axes are aligned to Global axes, but the mesh isn't, it wouldn't make any difference whether you transform in Local or Global. It's probably quickest to start with a new cube.
But you could select its top face, and CtrlAltSpace create a Custom Orientation from it, checking 'Use after Creation' and then transform the object in that space, SXX,SYY, etc.
You could even reoirient the cube's local axes to one of its faces, by snapping a helper cube to one of its faces,CtrlJ, joining the object to the helper, and deleting the helper in Edit Mode.. but in this case, that would be silly.

As you can see in the bottom left corner you are scaling the cube on the global X-axis. I'd recommend pressing X two more times to scale on all axis again.

For some reason there's no difference between global and local X scaling..
I really did want to scale X axis.. or at least that face to make it the same width of that house.. while maintaining the square shape.


text:
A part of my blender render is invisible?

For some reason, a part of the render is invisible.
It might be the material (i didnt make it), but i don't know how to fix that
https://www.dropbox.com/s/k3o1mocp7xd9nsz/CarPaintMaterialPacked.blend?dl=0
The paint was taken from this but the color was changed a bit
https://www.dropbox.com/home?preview=problem.blend
this is the problematic part of the object.

are you sure you've shared the good file?

yes im sure i have

@sairaajm. You didn't share the right file. See this screenshot.

if I press 0 to see through the camera I see an orange sphere, and when I render I also see an orange sphere, not what you show on your screenshot

yeah thats the color not the object, but when i use the color with a changed hue, the result is pictured.

@sairaajm We need need the original with the problem in order to help you.

I added the original, but for some reason, the color has to be added again.

it's a wrong link  ;)

https://blender.stackexchange.com/questions/114119/a-part-of-my-blender-render-is-invisible

I've answered to your question in your new topic, I don't understand the link between the 2 questions though...

Please don't post the same question twice


text:
ignore self-shadows for a cel shaded effect?
So For this project i'm trying to achieve somewhat of a cel-shaded look. Cel Shading is an attempt to make 3D Art look 2D, But The Main problem I've found with Cel Shading effects is the shadows are "too perfect" so our pattern seeking brains immediately know it's really 3D.
The Problem: I need an object to Receive shadows from external objects, and cast shadows onto external objects, But not receive any self shadows.
The closest i have gotten to figuring out how to make it look this way has been to match the lighting using invisible objects, and use them as brushes, while everything else is a canvas. however i'm still looking for a better (preferably just node-based) way to create the effect cause using dynamic paint is a pain to setup and match for every light and sometimes impossible.
Example with Problem Areas

Example of how it SHOULD look

I Used EEVEE to Render this as it handles stylized shaders better, Although I am fine with a setup that only works in cycles too (Preferably EEVEE Though)
Another Example of this effect with a point lamp
Note: The wireframe is just a visualization of the light cutoff

I Think what i'm looking for is a way for the lights to ignore the normals of the object and allow the light to illuminate the backside of objects, while still casting shadows on everything but itself. I have no idea though, and there may be a better method.
Thanks!

Would you be prepared to use OSL?

Never used it before, and i wouldn't understand any of the code, but if it works then yeah

I should have mentioned, it's CPU only..

A h, yeah thats not super great.. I plan on using this for an animation so im not sure how well thats gonna work out

I think you'd need to be compositing multiple render layers, one where the object's materials cast shadows and one where they did not.  It would not be pleasant to implement for multiple objects acting this way.  Note that normals and occlusion of light are two different, unrelated things.

Does changing shadow mode to none works for you? it ignores self shadow (EEVEE only) https://imgur.com/a/zta0vqo

@Mysticreator Doing this still allows it to receive outside shadows (Good), but there's still the problem of needing the light to pierce through to the back end of the object, as well as casting shadows onto other objects So this is probably one piece to the puzzle

there are two things in blender that i know does not make self shadow. emission and grease pencil and non make shadows on others as well

In Cycles (Could potentially work with Eevee with a replacement for the toon shader, see this video for an explanation of shader-to-RGB and color ramp to create an Eevee toon effect):
EDIT: Try this setup as your material with no other changes, I believe it gives you the effect you're looking for. It checks if a light ray ends on the material (making it a shadow ray because anything behind it is shadowed), and if so, makes it a black transparent shader. If not, it uses the toon:

I used a really bright small light source to really exaggerate the effect, and you can see it has very heavy glow on the object, yet absolutely no self-shading, and casts shadows as well!

For more precise control, change the color of the transparent shader to white, which makes shadows truly transparent. From there, you can swap the mix shader inputs to access either the shadowless material or materialless shadow.
Previous answer that did not cast shadows:
1: Set up your scene. I'm using a similar object to yours, with a red material and an emissive plane for lighting.

2: Set up your object's material. I'm using a Cycles toon to get flat shading.

The render now looks like this, with an obvious self-shadow in the bottom right:

3: navigate to Object Properties>Visibility>Ray Visibility on your object, and uncheck Shadow.

The render now receives lighting from the plane, but does not self-shadow:

This doesn't cast shadows on lower objects, but you may be able to tweak it to what you’re looking for. Hopefully this helps!


text:
Texture uses UV, Pixel effect uses Object Texture Coords
My goal here is to be able to rotate the object, and have the image rotate with the UV map, But have the pixel effect rotate relative to an outside object, but given the setup i'm using I don't know how to get it to work

If there's a better pixel effect that supports what I need that works too.
From what i found, I Basically need a setup that gives a pixel effect to a UV Texture coordinate like this:

But I want the Pixels Stay upright relative to an empty (Or the world)
I've Tried for multiple hours experimenting with literally every combination of nodes I can think of that could work, But I'm not amazing with math.
If anyone trying to solve this needs any more info on the problem, let me know
Thanks!

So you mean, you want to keep the rotation even when it's rotated?

I need the image itself to rotate with the plane, but the pixel effect to rotate with an empty that i will keep upright, or the world

Oh alright, okay

Wow, this confused me. I believe it's possible! I can't figure it out for now but there's better pixel effect: https://imgur.com/a/aBkCwR3

Ah yeah I figured out that pixel texture too, But didn't really help me get the effect to work any better. Thanks for trying though, I have no idea why something so seemingly simple is near impossible apparently

Two parts in this node tree:

Find the rotation of the empty

This is done using two radial gradient textures, one from the UVs one from the empty and get the difference.
As the gradient goes from 0 to 1, there is a discontinuity at the limit. To compensate that we look if this is a negative value and if it is set it back positive adding 1.
Then map from 0, 1 to 0, 2*pi in order to have the angle.

Use this rotation before snaping

From the angle above, rotate, snap and rotate back.
Note: set the image texture interpolation to closest as snap node may make glitches if not (this is not done in the file below).

Woah, that's clever :O

YES THATS PERFECT! There was a little bit of a graphical error in EEVEE which had me worried, but changing the image interpolation to Closest instead of Linear fixed it

Yes snap alone (no other calculation) does that without closest.


text:
Line Art Modifier - Light Contour Issue
Alright so I'm doing some work with the line art modifier, but whenever I use the Light contour effect it results in a choppy jagged line seemingly based on the model's geometry.
According to Blender's Official update notes, it appears like it would work as intended, but It's not working for me even on a simple sphere.
This is the desired result:

Hi Marux. After the Line Art modifier add Smooth modifier with 5-7 Repeats and Keep Shape turned on. You should probably need to Move the Plane object outside of the Collection and use another Grease pencil on it, because the smoothing of its contours won't look very good.

Already tried that, It jacks up a lot of other lines, especially sharp edges and corners. It also doesn't align with where the line is SUPPOSED to be, so that's a no-go.

I just tried it and get the same problem from a minimal setup.
Interestingly, if you look at the scene from a different angle than the camera, the outline of the sphere also looks jagged like the light contour – the jagged pattern just comes together from the camera's perspective to look smooth. Since the light contour seems to be based on a 'virtual camera' looking at the sphere from the position of the light, I guess it makes sense it also gets that jagged pattern when not looking from the light's position? (Still don't know if bug or some obscure setting.)

Interestingly, the outline of the sphere also being jagged when looking at it from the side is not new (I also get it in 3.2). However, I can't find anyone mentioning it online or any information on how to smooth that one out, either. But that makes it seem like there should be a setting for it somewhere and it is not a (recent) bug.

Your result seem to be as it should be. If you take a look at the demo file 0_cast_shadow.blend provided in LineArt: Shadow Functionality. - Blender Archive - developer.blender.org by its developer:

The developer used a combination of Simplify and Smooth modifiers to refine the shape of the contour lines.
Without it, it looks like this:

The mesh objects also have a high mesh density using Subdivision modifiers to help negate the effect. Otherwise, it looks like this:

I reproduces your scene:

I also created two line layers and two lineart modifiers to handle the light contour and the "rest" of the lines individually:

To make this look good:

Select the sphere and add a subdivision modifier level 3 (you can press ⎈ Ctrl3, or add one manually in the Properties Editor > Modifiers tab)

Add a Simplify modifier (make it target the light contour modifier if you made one) and play with the Length and Angle settings

Add a Smooth modifier (make it target the light contour modifier if you made one) and play with the Iteration settings

I couldn't find a way to simplify specifically the contour over the area of the sphere where the topology pinches:

So I advise rotating that sphere to "hide" that part, or use an icosphere that has a uniform topology:

Weird that the official blend file for this effect is still using what seems to a be a really roundabout and unintuitive "fix". Thanks for the help though!

It's an in-development system, there are lots of roundabouts right now.


text:
Applying armature scale messes up the action
It's a question derived from this initial question. Scaling the armature messes up the action because it changes the bone locations. How can I apply the scale of the armature, but keep the original action?
Before applying:

After applying:

Here is the original armature with an action.
Edit : So I was finally able to fix the problem with WiSHFul97's method, applying the scale, going into the Graph Editor, typing Location in the filter, I just needed the Pivot Point to be set on 2D Cursor, then scale on the Y axis down to the armature original scale!! thanks WiSHFul97!!

Since F-Curve points for each bone are calculated w.r.t. the rest position of the bone, we can kinda get away with scaling them w.r.t. y=0 axis.
see this for clarification:

In this gif, I created 3 dummy bones and animated them. Then I scaled them in object mode and applied the scale. Then in the pose mode I selected all the bones and in graph editor, I selected all the location curves and scaled them on the y-axis by 2. You can see the root bone is now traveling 4 units and the scale is 1 in object mode.

thanks, I was finally able to fix with this method, each time I forgot something, like setting the Pivot Point to 2D Cursor in the Graph Editor


text:
Bump map appears pixelated
Since this morning I can't make any bump map work properly, they always appear pixellized, in OpenEXR format or with 32 bit Float, either in 2.8 or 2.9, it doesn't seem to be the Terminator effect either, so I don't know what I'm missing here, can it be a graphic card problem (even though it used to work fine before)?.
Here is a screenshot of the result:

The file is here:

In your screenshot, it looks as though you were using a png-file format for your bumpmap (instead of EXR, as you wrote). Is this intentional?

actually i've tested several formats, png or exr, and it doesn't change anything, but I'm going to upload a file with the exr packed as well, I realize it's not the case here

Have a look at the bump mapping section here https://docs.blender.org/manual/en/latest/render/eevee/limitations.html?highlight=limitation%20bump#materials

Or confirmed by Brecht https://developer.blender.org/T58522

thanks but could you please ellaborate? It doesn't work with Cycles either

I'm not aware of all the technical aspects. But the chapter in the documentation is the same since several versions. Procedural inputs are ok, but images have this 2x2 pixelated thing.

Ok so I guess we need to avoid bump and prefer normal maps for the moment, thanks

If I understand well, it works again. Do you have a file that works well to be compared with the former one?

It looks like the picture was not a proper 32 bit Float png, my last test was better, needs confirmation though...

So I have the confirmation that there's a problem even with a 32 bit Float, a quick trick to smooth it is to use a very light SSS (in french): https://www.youtube.com/watch?v=6eoZt0W2UA0&feature=youtu.be

@moonboots, merci de partager l'information mais je ne suis pas sûr de comprendre une vidéo en français.

sorry I thought you were french, actually he just gives a very low amount of SSS with very low Radius values and it smoothes the pixellisation, tell me if you want me to write a full answer to make it clearer

@moonboots, actually I'm (and you're too, I think?)... was a little joke ; ). I've just gave a look at this short video. The trick is interesting and simple.You should write an answer about that maybe?

oui français  ;)   ça marche je vais rédiger une réponse

Though, just tested it on your file. Not so simple to tune.

I realized that my file was probably not 32 bit Float, maybe a wrong move with Krita

My problem was that my image was 8 bit, it needs to be 16-Bit Float or 32-Bit Float. It won't work either if I paint (or blur) a 8 bit image and convert it to 16 or 32 bit, it needs to be 16 or 32 bit before painting. Also it needs to be PNG, not JPG, and the Image Texture needs to be set to Cubic, not Linear.

Thanks, compatriote (!! : )

et vive la France of course

cocorico for the update

@L0Lock Thanks  ;)   it was a lingering problem and it took me time to find the answer, for a long time I thought Blender was not able to correctly manage b&w image for bump maps

that would have been sad.

BTW, png is fine-ish because it can do 16bis, but ideally you want 32bits if you can, so that would often be tga raw or exr. Though, one way to get away with decent-enough details is to have a map that was made using 32bits and then down sampled to 16 or even 8 bits but with dithering. It will not be as good, but in many cases it's decent. That's often the only thing used in video games that look HQ.

ok thanks for the precisions  ;)


text:
VSE: How to automatically snap the cursor to the selected strip?
Is it possible to automatically snap the cursor to the start (or end) of the selected strip? I know that I can manually move the cursor and if I keep pressing Ctrl it will snap to the start and end of the strips, but it's not the same as automatically making it jump to the start of the selected strip.

You can jump to next/previous strip with page up/down, but there is no function for going to the selected strip specifically.

oh ok, thanks tintwotin  ;)


text:
Array + Curve modifier deformation in blender 2.81
In blender 2.81 the array + curve technique does not work as expected
i've got a hedge with an array modifier and a curve modifier, to make it follow the path i want. It is working just fine in 2.80, but in 2.81 the mesh is completely flat with the exact same settings and when i try to ajust the settings, i just cant achieve the same effect than in 2.80
I hope that there is a way to solve this because i love the new features of 2.81 but with this problem i just cannot use it

This is most likely just a case of finding the right rotation for the object and the curve. Try rotating your curve and see how it behave. The curve modifier is very well known to need the right rotation between your mesh and curve to act properly.

https://blender.stackexchange.com/questions/65567/problems-with-curve-modifier/65571#65571


text:
Rigid Body stops at the upper surface of a hollow cube
I am very new to blender and so forgive me if the question sounds vague. I am trying to create a scenario where I have a hollow bin with cloth on its edges and drop some objects into it (In Blender 2.8). I created the hollow bin by subdividing the default cube and deleting the upper face. later, I added a few planes with cloth simulations which will collide with the cube and rest on it. I have then animated the objects to fall into the cube at a frame where the clothes have settled in. In order to support the collision between the cloth and the active rigid body, I have added passive rigid body properties to the cloth. When I run the simulation, The active rigid body objects do not fall in the cube. Instead, they stop just above the cube and stay there until the simulation ends. I have made all the collision shapes as mesh.
Can someone please help me with the issue.

Possibly your bin needs solid walls and floor (using the Solidify modifier and recalculate outside normals) rather than a cube with upper face removed.

The first thing is, the cloth needs to be active if it is going to be deformed in anyway during your simulation.
The second thing is the result of the collision distance being too high. Finding and reducing that will decrease how far above the cloth the falling objects are when the collision is detected.......

Hi Jarrett. Thank you for the response. The said settings are already available. The cloth is always active and the margin of collision is the smallest value possible (0.001). I have added an image to show how the cloth simulation is working. This behaviour is as expected. The problem is, when I try to add an object (like another cube or some .stl files) and make it an active rigid body, it doesn't fall into the hollow bin and stops at the surface.


text:
How can I ensure that my 'rig_ui.py' file is loaded when the armature is linked and overridden in Blender 3.6?
I managed to delete rig_ui.py the script of my rigify armature after renaming things somehow (at least i think that is the problem), and i don't know what to do to restore its original functionality, other than going back several files behind the actual one i got so i tried this fix:
Fetched the script from some versions behind (no code has been changed so it should be the same here) then manually pointed to the 'rig_ui.py' file in Blender by adding a Datablock pointer custom property to my rig just like:
How to make a Text File dependent of an Armature object so that it appends with it to other projects?.
(in blender 3.6)
However, when I link and then override my rig into a new project, the 'rig_ui.py' file doesn't seem to be automatically ran, it's just there. How can I ensure that my 'rig_ui.py' file is not only loaded but also executed along with my rig when I link it to another Blender project?
also i got the file and my preferences checked, those are not the problem afaik


text:
White Noise in Blender Z Pass with alpha value in Mix Shader
I am trying to get the depth value using z pass from my scene which is a simple head model, but while rendering there is white salt and pepper noise in the hair and eyelash. I have saved in both png after normalizing and in openexr file with the raw data.
While looking into it I figure it out that both the object are using alpha value from the diffuse and opacity texture file. Below are the composite pass I am using -

Following is the node editor for hair/eyelash object -

Following are the image and corresponding depth (z pass output) as png in with the original alpha values -

Then I manually edited the alpha channel value in the texture image of the hair:
I edited the alpha as 255 where there is a alpha value present ( > 0)

This reduced the noise a lot but at the same time its reduce the rendering quality of the hair mesh as well -

I have also tested with changing the max bounces for transparency and transmission but it did not change the result
Is there any further solution of this issue...
Blend File Link :
https://drive.google.com/open?id=1LzJ-RiZzgxlY1aGHTTAAaS0OrGTseyvc

Does it make a difference if you connect the alpha socket from your texture to the alpha socket of the Principled BSDF and remove the Mix Shader and Transparent BSDF?

@Robert I tried but it's not giving any improvement in the z-pass result, I have added the blend file in the original post

Switch to Branched Path Tracing
Switch the sampling method to Branched Path Tracing and set Min Transparent Bounces to 32 or higher to eliminate the noise.

Also, it is better to use Mist pass instead of Depth.

You need to map the value from 0-1 to 0-100, depending on your mist settings, to match the depth pass.

Thanks to skw Stefan Werner for the Branched Path Tracing hint. https://blenderartists.org/t/cycles-depth-and-mist-passes-for-a-transparent-material-give-a-lot-of-noise/1192751/5

Stay with Path Tracing
If you need to stay with Path Tracing, which seemingly ignores Min Transparent Bounces, you can create a new view layer with material override.

The material will be with Camera Data node and mixing by the object index N.

Change the object indexes of all the particle objects to N, easily with Copy to Selected.

It gives the same result as the mist pass.

Thanks, @unwave for your reply, I am pretty new to blender and using for my research purpose. I didn't get mixing by the object index part. In my case, there is only two object mesh one is the hair mesh and the other is the eyelash as I am importing this character from iclone. Could you please explain or provide some tutorials I can follow? I have also added my blend file in the original post for your reference.

@shubhajit An object index is an integer value of an object you can give it to later access it in the shader and compositor node editors. I did some tests with EEVEE depth and mist passes and also a filtering of the flakes in the compositor. It gives usable results too. Can you specify what you are trying to achieve?

Thanks @unwave for the explanation, I am trying to get the exact depth information in openexr format and their corresponding rgb images, I am importing these characters with from the iclone character creator pipeline in either alembic or fbx format and render it in blender with different camera positions and camera parameters. I have attached the blend file in the original post.

@shubhajit The noise seems to be a long standing bug that should be reported if it has not already been.

@shubhajit Try this fix https://blenderartists.org/t/cycles-depth-and-mist-passes-for-a-transparent-material-give-a-lot-of-noise/1192751 or use EEVEE with Alpha Hashed. Set Mist Pass from 0 to 100 m, linear, and map range It from 0 - 1 to 0 - 100 in the compositor. You have to enable it first. It will appear in World Properties.

Thanks a lot @unwave, following material override and changing the minimum transparent bounce reduce the noise significantly.

@shubhajit Check the updated answer. It is easier, you don't need material override.

minimum transparent bounce and Branched Path Tracing works @unwave,  but it almost doubled the render time

How did you get the viewport to display z-depth in your first image? Unless you made a material that fakes this by colouring each object by depth? Thanks for the answer regardless.

@MohamadZeina It is the Viewport Shading Render Pass setting. https://docs.blender.org/manual/en/latest/editors/3dview/display/shading.html#rendered

I think I solved it for me, the first option option above did not work as the sampling method choice doesn't seem to exist anymore.
But I get a perfect result in a couple of clicks doing this:

Rounding alpha to integer
I'm late to the party but perhaps the answer can be still useful to someone.
So, z-depth and mist fireflies appear when, in cycles shading nodes, non-integer alpha is introduced(so, greater than 0 but lower than 1).
Before:

Given that anyway it's not possible for a z-depth and mist pixel to carry information of two distances at the same moment (with the exception of anti-aliasing in mist), a workaround specifically to this issue is to eliminate those half transparencies by rounding to integer before plugging in the mix shader node where transparency is introduced. You might want to render separately depending on your setup.

I stumbled across this solution for the scene I was working on. Go to render passes tab and set alpha threshold to 0. I could use the depth pass just fine with no fireflies after doing this. Hope it could also be useful to someone.


text:
Need help with subdivision surface
I was trying to add the subdivision surface to this object so I can later add a displacement modifier, but when I add it, even on Simple it creates some weird geometry bugs, can someone help?
https://i.sstatic.net/htnd0.jpg

could you post .blend file of just the wall?

Its because how the mesh is shaped as it contains ngons so if you would add subsurf modifier it would create weird geometry

try creating a good mesh without tris and ngons just with quads.
Here I've converted ngons to tris and quads by selecting all the ngons and Hit Ctrl+T in Edit Mode. Then ngons will be converted to tris and quads.

Then by bevel edges you can see that some of the shape remains same..

So, the solution is to create a new mesh with good geometry just with quads if possible. and bevel all the edges that curve when subsurf modifier is used.
If you can create the mesh its great. If not try using Booltool addon it would save lot of time in creating these kind of meshes.


text:
How can I find 'Visibility panel' in Object tab?

▲ I want to find Visibility panel in Object tab like the pic above.

▲ But I can't find it. Visibility panel is omitted.
How can I find Visiblitiy panel?

Are you using a alpha or beta version of Blender 2.80?

You're right. I was using beta version, and have solved the problem. I didn't think about it. Thank you very much! :)


text:
How to make objects appear when I want to see without clicking 'Disable/ object in render'

For example, I want to make object appear from keyframe number 100 to keyframe number 200. And I don't want to see that object on 3D viewport and in render too. I already know the way clicking 'disable object in render' in Outliner menu. But that doesn't work on 3D viewport, so I want to know other way.

Keyframes can be added for the visibility settings. Select the object and open the Object tab. In the Visibility panel you can adjust the settings and insert a keyframe either through the context menu or by pressing I.
For your specific problem, you could insert a keyframe at frame 0 with Show in Viewports and Show in Render disabled, then a keyframe at frame 100 with Show in Viewports and Show in Render enabled, followed by a keyframe at 201 with both disabled again.

Thank you for answer, I understood it. But 'Visibility' isn't in Object tab..

If you have an object selected you should see the tab with orange square icon as depicted in the screenshot above. That is the object tab and should contain the Visibility panel.

There are Montion Paths, and Viewport Display penals. But there isn't Visiblity panel between them. Is it better to make another question for this?

Yes it's better to make a new question and please add a complete screenshot.

Okay, will do. Thank you

(If someone who are using alpha or beta version blender, install 2.8 released recently. here)

There are many ways to achieve this, and I'm not sure if there are any "best practices" or generally recognized ideal ways of doing so. Here are two simple ones, though:
Approach 1: Scale 0 to Finite Scale in 1 Frame
Keyframe the object's X, Y, and Z scales as 0 when you don't want the object to appear:

And at some desired finite, positive scale when you do want it to appear:

Be careful to ensure that the transition from 0-scale to finite-scale happens within a single frame if you really want it to look like the object appearing/disappearing instantaneously.
That's it. Click play/render your animation.
Approach 2: Keyframing Alpha Channels in Nodes
I'll assume use of the Eevee Renderer for this example, but you can do something similar (with a few modifications) in Cycles. Suppose we want a simple blue sphere to appear on frame 50. One way to do this is to add this material to our sphere, key-framing (see yellow highlights) its mix shader to be fully transparent on frame 49:

And to be fully blue diffuse on frame 50:

Note that this only works as expected in Eevee when the material has its blend type set to a mode that will hide portions of the object which are transparent. (see red circle in images, where Alpha Clip is chosen, although Alpha Hashed and Alpha Blend will also work in this simple example)

I learned two simple solutions, thanks to you :)


text:
Space Colonization Tree
Currently im trying to make an addon for the Space Colonization Algorithm in Blender. At the moment i only have a skeleton as a tree. Does anybody have an idea on how to thicken the tree so it does look somewhat realistic? I already tried the skin modifier, but that makes everywhere the same thickness and thinning it down by hand is not a possibility. And the bevel modifier behaves strangely since i probably have too many points.
Thanks,
Nebeig

edit: I tried it with the following code:
import bpy
radius = 0.4

obj = bpy.data.objects['Tree']

bpy.ops.object.modifier_add(type='SKIN')

for v in obj.data.skin_vertices[0].data:
radius -= 0.00025
v.radius = (radius,radius)

print(v.radius[:])

but blender chrashes when i try to execute the script.
    from random import randint, random, uniform
from copy import copy, deepcopy

def getDistance(p0, p1):
        return sqrt((p0[0] - p1[0])**2 + (p0[1] - p1[1])**2 + (p0[2] -
p1[2])**2)

   # importiert von https://blender.stackexchange.com/questions/5898/how-can-i-
   create-a-cylinder-linking-two-points-with-python

class Tree:
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_label = 'Tools Tab Label'
    bl_context = 'objectmode'
    bl_category = 'SC'

def __init__(self):
    # Vektor operationen

    def div(x,y):
        return(x[0]/y, x[1]/y, x[2]/y)

    def sub(x,y):
        return(x[0]-y[0], x[1]-y[1], x[2]-y[2])

    def normieren(x,y):
        länge = sqrt(x[0]**2 + x[1]**2 + x[2]**2)
        return((x[0]/länge + x[1]/länge+ x[2]/länge)*y)

    def length_squared(u):
        return sum([a ** 2 for a in u])

    def add(u, v):
        return [a + b for a, b in zip(u, v)]

    def norm(u):
        return setlength(u, 0.5)

    def scale_by_scalar(u, scalar):
        return [a * scalar for a in u]

    def length(u):
        return math.sqrt(length_squared(u))

    def setlength(u, l):
        return scale_by_scalar(u, l / length(u))

    branches = []
    leaves = []
    verts = ()
    closeEnough = 0 # False

    #leaves generieren
    for i in range(0,150):
        leaves.append(Leaf((uniform(-4.0,4.0),uniform(-4.0,4.0),uniform(4.0,9.0)),0))
        #bpy.ops.mesh.primitive_uv_sphere_add(size=0.1, location=leaves[i].pos)
        i =+ 1

    #Stamm machen
    root = Branch(None,(0,0,0),(0,0,0.5))
    branches.append(root)
    current = root

    max_dist = 3
    min_dist = 1
    while closeEnough == 0: # False
        for i in range (len(leaves)):
            g = 0
            g = getDistance(current.pos, leaves[i].pos)
            #print(g)
            if (g < max_dist):
                print('schlaufe 1')
                closeEnough = 1
            if (closeEnough == 0):
                print('         schlaufe 2          ')
                nextPos = tuple(add(branches[i].pos,branches[i].dir))
                branch = Branch(i,nextPos,branches[i].dir)
                current = branch
                branches.append(current)
                if (g > 100):
                    break

    #Der eigentliche Algorithmus
    def grow(self):
        self.record = 100000
        for i in range(len(leaves)):
            leaf = leaves[i]
            closestBranch = None
            self.closestDir = None

            #Den nächsten Ast bestimmen
            for j in range(len(branches)):
                #print(j)
                branch = branches[j]
                dir = sub(leaf.pos ,branch.pos)
                d = length(dir)
                #print(d)
                if (d < min_dist):
                    leaf.reached()
                    break
                #elif(d > max_dist):
                elif (closestBranch == None or d < self.record):
                    closestBranch = branch
                    self.record = d

            #Dessen Richtung bestimmen
            if (closestBranch is not None):
                newDir = tuple(sub(leaf.pos, closestBranch.pos))
                newDirnormed = norm(newDir)
                #print(newDir)
                closestBranch.dir = tuple(add(closestBranch.dir,
   newDirnormed))
                closestBranch.count += 1

        #alle Blätter entfernen die erreicht wurden
        for i in reversed(range(len(leaves))):
            if (leaves[i].erreicht == 1):
                del(leaves[i])

        branchcopy = deepcopy(branches)
        #print(branches[0].dir)
        for i in reversed(range(len(branches))):
            branch = branches[i]
            #print(branch.count)
            if (branch.count > 0):
                branch.dir = tuple(div(branch.dir,branch.count))
                newPos = tuple(add(branch.pos,branch.dir))
                newB = Branch(i, newPos, branch.dir)
                branches.append(newB)
                branch.reset()

    for i in range(70):
        grow(self)

    # this assumes all vertex positions are unique (= do not overlap)
    # create a mapping from vertex position to vertex index
    verts = {b.pos:i for i,b in enumerate(branches)}
    # create vertex pairs as edge by locating vert index based on
coordinates
    edges = [ (verts[b.pos],verts[branches[b.parent].pos])for b in branches
    if b.parent is not None]
    # replace vertex mapping by simple list of coordinates
    verts = [b.pos for b in branches]

    mesh = bpy.data.meshes.new("tree_mesh")
    mesh.from_pydata(verts, edges, faces=[])
    mesh.update()

    obj = bpy.data.objects.new("Tree", mesh)

    scene = bpy.context.scene
    scene.objects.link(obj)
    #remove doubles muss man noch machen

    obj = bpy.data.objects['Tree']
    for v in obj.vertices:
        v.select = True
        bpy.ops.transform.skin_resize(value=(0.695461, 0.695461, 0.695461))
        v.deselect = True

tree= Tree()

If you add the skin modifier to your mesh, it will create a 'skin_vertices' object in it, where you can access to the radius of the vertices...
For example: bpy.data.objects['Obj'].data.skin_vertices[''].data[0].radius = (1.0, 1.0)

Probably something wrong with your mesh... that script works ok here. Post your blend file for inspection.

I resolved the problem by setting the name of the radius variable to something different than radius.

Try the Sapling Tree Gen add-on. You should have it in your copy of Blender and activate it.


text:
turn multiple scripts into addon
I have multiple scripts that i would like to turn into an addon. I already have everything it needs, but i when i click the button to enable the addon in the user preferences it says:
  bpy.utils.register_class(SCAPANEL)
  ValueError: register_class(...): already registered as a subclass

I imported every other file I need via from .example import example and put these files in one folder. I even looked up other blender addons, but that didn't help either.
Edit:
def register():
   bpy.utils.register_class(SCAPANEL)
   bpy.utils.register_class(SCA)
   bpy.utils.register_class(Skin)
   bpy.utils.register_class(removeDoubles)
   bpy.utils.register_class(thin)
   bpy.types.Scene.Tree = bpy.props.StringProperty()
   bpy.utils.register_class(particlesystem)
   bpy.types.Scene.Growth_limitation = bpy.props.BoolProperty()
   bpy.types.Scene.limiter = bpy.props.StringProperty()

def unregister():
   bpy.utils.unregister_class(SCAPANEL)
   bpy.utils.unregister_class(SCA)
   bpy.utils.unregister_class(Skin)
   bpy.utils.unregister_class(removeDoubles)
   bpy.utils.unregister_class(thin)
   bpy.utils.unregister_class(particlesystem)
   del bpy.types.Object.Tree
   del bpy.types.Object.Growth_limitation
   del bpy.types.Object.limiter

register()

These are only the register and unregister functions. I noticed that my panels sitll shows up, even though the box is not ticked. When I try to execute my script it says, that it cannot perform a relative import.

From the information provided it is only possible to be certain that there is a problem with the code. If the answer does not satisfy you, you will need to share the code obviously.

The error is pretty self explanatory you are trying to register an already registered blender class. Often this is due to not unregistering the class properly, noticeable particularly if  you are testing enabling and disabling your addon.

Enabling an addon calls register
The issue in new code posted is the lack of
if __name__ == "__main__":
     register()

(pretty much ubiquitous in all blender addons and UI code etc etc, or for python command line scripts) Without this conditional register() will be run on import (Worth noting on import __name__ is the module name, ie not matching "__main__").
When an addon is enabled it is imported and calls its module.register() Henceforth your code is registering a second time and throws the error on the first class registered in register method.
The conditional code is there so scripts can be tested in the text editor.
Note: another thing to look for:  for registered classes the bl_idname property is how they are known to blender.

Yes that worked. But now it says "cannot perform relative import" when i try to import a class form another script.

I could solve the problem. I named the main file init.py and put every python file i needed in a .zip folder.


text:
Visible light beam with a specific shape
By using Cycles, I'd like to create and move a visible light beam with a specific shape, for instance, a pyramid. The beam should interact with other objects, without going through them but producing shadow regions behind them. In other words, I would like to reproduce the behaviour of a light beam impinging on opaque, not reflecting objects. I already created the shape of the beam but I am not able to assign the desired behaviour, i.e., the light behaviour. May you be so kind to help me?
I want to make sure that the light beam does not go trought an obstacle that is in his way, as example the iron barrell in this photo.

Can you give an photo example of what you are trying to do?

You might consider variations on this.. it would depend on exactly the shape you were going for


text:
Is there a quick way to move a keyframe to a specific frame?
What is the easiest/fastest way to move a keyframe to a specific frame?
In other words, is there a way to type in an absolute frame value with modal numinput (which uses the delta by default)? E.g. type G140 to move a keyframe to frame 140?

This is old but I just added a proposal to make double G switch to absolute keyframe placement.

In the latest development version (after official 2.69), you can type with math, like this:
Gtarget_frame-current_frame
e.g.: If you want to move keyframe from 120 to 140, you can type G140-120.
Tip: it also supports copy/paste feature, which means, you can CtrlC on the current frame number displayed on Timeline header, then G140-CtrlV), which makes it relatively quicker.
But indeed, a one-stop method may be useful here.

Fastest so far, but I wish there was a modifier key or something to move keyframes with absolute frame values..

For anyone else who finds this, the 'G' command in this context is the action 'Transform: Translate' if you can't remember what the obscure magic shortcut is.

I think that the best you can do is type the preferred frame into the Timeline 'Current frame' field then apply a Snap to (ShiftS) frame function on the selected Keyframe.
It would be neat to have another snap to function as you suggest to reduce the amount of mouse clicks involved.

Agree. It would be neat to implement sort of Offset snap to support multi-frame offset, (Shift S currently only work with single frame) just like the Snap to Cursor (Offset) function for snapping in 3D View.

What you can do is:

Open a new editor window and set it to the Action Editor.
Go the Top of the Action Editor and select the frame you want to move.
Press G and click where you want it to be.

Thanks for your answer, but I was hoping for a way to type the frame number with the keyboard. Sometimes with long animations and scenes with many frames it can require a lot of scrolling and zooming to be able to click accurately. I'm trying to find a faster way to do this.

Oh ok :) ... i just realised its you lol


text:
Is there a way to snap color ramp stops to equal distances?
Is there a way to snap stops in the Color ramp node to equal distances from each other?
For example, when you add a new stop by pressing the Add button, the new stop is added halfway between the selected stop and the stop to the left, but this doesn't allow for equally aligning 4 stops.
You actually could align four stops, by doing something like adding a stop in the middle, then adding stops in between the ends and the middle stop, then adding stops in between those stops and the middle stop, etc. However, this quickly gets complicated.
Is there a simple way to align stops evenly?

Set the Outliner display mode to Datablocks. Locations and colors for color ramps are in Materials → Material → node Tree → ShaderNodeTree → Nodes → ColorRamp → ColorRamp → ColorRamp → Elements → ColorRampElement
This gives you access to position and color values. Key frameable as well.

While this is probably bad python, I post it anyway until something better comes along
If it's a compositor node
import bpy
colramp = bpy.context.scene.node_tree.nodes.active # get the active node
total = len(colramp.color_ramp.elements) # how many colors are in the ramp?
c = 0.0 # first stop
step = 1.0 / (total - 1) # define the spacing according to the total number of elements
for e in colramp.color_ramp.elements: # iterate through the elements
    e.position = c
    c += step

If it's a material node
import bpy
mat = bpy.data.materials['Material'] # Put the name of your material here
colramp = mat.node_tree.nodes.active # get the active node
total = len(colramp.color_ramp.elements) # how many colors are in the ramp?
c = 0.0 # first stop
step = 1.0 / (total - 1) # define the spacing according to the total number of elements
for e in colramp.color_ramp.elements: # iterate through the elements
    e.position = c # position is
    c += step

The colorramp in question has to be selected.

bpy.context.scene should get the active scene

Cool. Should work. At least it did here. Took me a while but it was fun to find out.

I get an error, line 3, in <module> AttributeError: 'NoneType' object has no attribute 'color_ramp' The color ramp node is selected. Running print (bpy.context.scene.node_tree.nodes.active) in the console returns None

which OS do you have? I tested it in 2.68, works without problems. Because I get <bpy_struct, CompositorNodeValToRGB("ColorRamp")>

I'm running Archlinux. (doesn't work in linux.. possible bug?)

works in ubuntu as well. now I tested it successfully in 2.67, 2.68 win and 2.68 linux

let us continue this discussion in chat


text:
Is it possible to add a button to an existing panel or node with python?
Is it possible to add a new button to an existing panel or an existing node that runs a custom operator?
How can I do this?

Yes. You need to find the class that defines that panel (usually pretty easy to do by right-clicking a button or setting in the panel and choosing Edit Source). From there, you just need to define a function and append it to that class. As an example, I do this in my Render Music add-on (in __init__.py, starting at line 82). Below is the relevant example that adds two checkboxes (properties defined by the add-on) to the Render Panel (RENDER_PT_render):
def render_panel(self, context):
    user_prefs = context.user_preferences
    addon_prefs = user_prefs.addons[__package__].preferences

    layout = self.layout
    layout.prop(addon_prefs, "use_play")
    layout.prop(addon_prefs, "use_end")

# Registration

def register():
    bpy.types.RENDER_PT_render.append(render_panel)

# Unregistration

def unregister():
    bpy.types.RENDER_PT_render.remove(render_panel)

You explain how to add a panel to another, but not how to remove in the unregister method. I believe it is by using remove instead of append.

Yes. That is correct. I left it off in the reply because I didn't want to confuse the issue too much. The unregister function is in the full source that's linked, though.

Note: Edit Source is available by enabling "Developer Extras" in the preferences menu (Preferences > Interface ).


text:
How to make freestyle lines stay the same size?
Is it possible to make freestyle lines stay the same width relative to the distance from the camera?
The way free style lines behave by default, they stay the same width in pixels, but vary relative to the size of rendered objects.
How can I make freestyle lines appear small when rendered on objects far away (as the object appears small) and large on objects close to the camera? (as nearby objects appear large)

Yes, it is possible. Here is how:
First change the Line Thickness parameter under Properties tab > Freestyle to Relative (1)

Next go to the Render layers properties, or just click the icon in the Freestyle panel (2). Then go to the thickness tab (3), and then Add a Distance from Camera modifier (4) .
You then have to check the invert box (5) to that the lines decrease in width over the distance. You will see a parameter slider box called Range Max (6) , this value should be the distance of the farthest object away visible in the shot.You can use the Fill Range by selection, or do it manually. In my case the object is about 100BU away. Value Min (7) and Value Max (8)  control the ending width and starting width, respectively.

Note:

For animations you might have to set keyframes for these values
You can ignore the Base Thickness parameter
The Distance from Object modifier can achieve similar results and may be more suitable for animations.
Lines are drawn based on edges. One long cube is only going to have the same width through, regardless of the modifier.

Final Result:

If you go to the Freestyle Line Style panel, go to Thickness and add a Distance from Camera modifier. It seems like a good idea to select all objects in your scene and press Fill Range by Selection, so the range matches your scene. Value min and Value max are basically how thin or thick your lines can get. Also tick Invert else objects far away will get a thicker line.