text:
Cycles Toon shader size effects diffuse direct value
Here are three monkeys lit by the same sun lamp. They have only a Toon Diffuse shader set to color of 0.2 value, and size of 0.8, 0.5, and 0.2 respectively. But it can clearly be seen that their lit areas are displaying very different colors. When rendered, the difference shows up in the Diffuse Direct pass.

Does anyone know why this works this way, and what is going on mathematically? I want to make an adjustment to the color going into the shader based on the size to compensate for this and bring them all back to the same level of brightness in their lit area. Is it intended for the Toon shader to behave this way? Is this a bug?

Now you've had a really good answer, I feel more free to ask.. wouldn't EEVEE and Shader to RGB, manipulated, serve you better for NPR effects?

@RobinBetts Some of them. It has a lot more control. But it isn't a proper toon shader since you are ramping the light. So changing light intensity changes the size of your shaded area, which a Cycles toon doesn't. There's strong points to both for different styles right now. Once Eevee gets a real toon shader (hopefully) then it'll be different.

Ahhh.. I see. Maybe that also goes some way to explaining the way the Cycles shader  is implemented.. but you (I) would have thought they could have written @lemon's normalization in.. at least as an option.

According to the code currently here, and the sample_uniform_cone currently here, without smoothing the resulting diffuse intensity depends on the size of the toon shader node.
So we can compensate this value to invert the calculation:
The size is multiplied by pi/2 (so this is relative to half cone angle).
Then take 1 minus the cosinus of the previous result.
Then divide pi/2 by the previous result.
Last, multiply the intensity value by it.
As this last step is multiplication factor in the shader code, we need to divide by it in the nodes. This is done by this node group:

The result is not exactly perfect (should be some rounding or an error by me). But we obtain this:

So basically the size indicated(set) the max angle that the shader could reflect light, and the other area shared the same calculation of color (which is average)?

@Hikariztw, it seems to be. But there is other values taken into account and provided to the function: randu and randv. And don't know their calculation (have a look at the code).

That's weird... can't think of a reason to  calculate it this way ...

@RobinBetts weird? It is as it is in the code... for some reason the intensity relies on the diffuse surface. I don't know why though.

Oops, I meant them, not you. Great answer.

@RobinBetts, will try to find a way to ask (maybe Brecht) and report here if I've an answer.

@RobinBetts I thought they might want a more realistic color (yeah, in a toon shader...) than directly assign an user input color on it. So calculating an average intensity over that area make sense for me

Great answer! I'm making an Eevee shader group that I want to be equivalent to the Cycles toon. I've got it covering the same area, but if i've adjusted a color to work with the Cycles shader, then it ends up being too light or dark on the eevee version. So i can use this to either compensate for the cycles, or do the same change to the color in the eevee version.

@lemon Testing it out, it seems to be darkening the colors quite a bit. On a white object with enough light to look white with regular diffuse, the toon diffuse ends up coming out at .35 value. It is consistently that regardless of the size though. But it ought to be white at any size! Any idea why this is or how to fix?

@Drudge, hard to see there are many factors (lights, color management). Do you have some sample file for calibration (including eventually the Eevee shader)?

For information, suggested on blender-coders chat (by Jeroen Bakker): toon shader respects conservation of energy in Cycles and that may be why the colors are different depending on the size (@RobinBetts)

@lemon OK. Rooted in the fundamental conflict between the goals of  PBR and NPR. On that basis,  a purist would say there shouldn't be a toon shader in Cycles, I guess..

@lemon The EV shader will need to be for another topic. It looks like multiplying the value by 3 before combining the HSV makes the toon value match the brightest value on a regular diffuse. This holds up with just a single sun lamp at different strengths. But once you add world lighting, the toon gets too bright. So there's more to it. Here's my test file. It's just a comp of regular diffuse and toon with the group from your answer and the multiply: https://blend-exchange.giantcowfilms.com/b/6540/

@Drudge, no idea about this 3 value. don't see it in the code. Though, the linked code is called by something and I don't know where. Maybe a way can be adding this adjustment value as node group entry in the node group that makes the calculation, for flexibility (but 3 is really big for something supposed to be between 0 and 1, so that's strange)..

@lemon It's just a value I found that happened to look right when using only a sun lamp. There's got to be some proper amount to adjust by to have the toon shader achieve the proper amount of brightness in different lighting setups.

@Drudge, Thanks for the bounty. I agree there should be some calculation to find the value, but really don't know how. I think energy conservation law is the key, but this is handle externally to the shader (we for instance don't know the incoming light intensity).

@lemon sounds like a dead end for now then. i'm not really sure where else we could go from here? Thanks for what you were able to figure out.


text:
How are vertex indices determined?
How does the program decide what indices to assign to vertices? If you create a primitive, are the indices generated randomly, or by some base primitive setting? If you extrude new vertices, will they be the next number in sequence?
What happens when you join two objects together that have the same indices used? Which points get reassigned, and by what logic? Can anything be done to control which get re-assigned?
Are there any ways to recalculate, re-assign, or copy vertex indices?

How does the program decide what indices to assign to vertices?

new vertexes are appended to the end of the vertex list
duplicating vertexes adds them also to the end and their order is maintained
.. list too long..

It would be very time consuming to analyze every mesh operation/modifier and how it handles vertex indices and make a list for you (it will be like the above though in most cases if not in all). Instead you can reverse engineer this yourself:
Type bpy.app.debug = True into the Python Console
This will enable super top secret mode with next option available in Properties panel:

Now you can see the indices and how they change for what you are interested in:

Can anything be done to control which get re-assigned?

Nope, blender handles it internally.

Are there any ways to recalculate, re-assign, or copy vertex indices?

Sure, with python you can do anything to meshes, you can reorder the vertices. Just by building a new mesh with different vertex order from old one and then switching them.

Is there a way to change the indices colors as well? The dark blue on a dark background is sometimes bad to read.

@BrunoBieri Yes, you can go to UserPrefs > Themes > 3D View and change the Face Angle Text Color which these numbers use.

It seems this has been moved to another place in Blender 2.8. Any ideas where I could find it?

For Blender 2.8+ see https://blender.stackexchange.com/a/158495/1363

Jerryno did a great job of explaining mesh indexes in his answer, so I will focus on:

Are there any ways to recalculate, re-assign, or copy vertex indices?

Yes.
First let me clarify that there are more then just vertex indexes, faces and edges have indexes as well, but for the rest of this answer I will refer to just vertex indexes.
The simplest way to reorder the vertex indexes is with the Sort Mesh Elements tool, accessible from the 3D view header Mesh > Sort Elements. All the option in the dropdown menu run the same tool, and can be changed like any other operator by pressing F6 or in the Operator Properties section of the tool shelf.

If you want to do anything beyond reordering the indexes, that will require python.

...so, you select the mesh that has the "wrong" order, and a similar mesh with the target order, and do Edit (vertices) -> Mesh -> Sort Elements -> Selected?

no it does not copy some other mesh's vertices' ids. To quote the manual "Selected Move all selected elements to the beginning (or end, if Reverse enabled), without affecting their relative orders. Warning: This option will also affect unselected elements’ indices!" AKA not what you want it to do. "Selected" simply renumbers the selected vertices so that they are at the beginning (or end with reverse enabled) of the indices.

You can also sort mesh elements with Python, using the bmesh module:
import bpy
import bmesh
import random

ob = bpy.context.object
assert ob.type == "MESH"
me = ob.data

bm = bmesh.from_edit_mesh(me)
new_order = list(range(len(bm.verts)))
random.shuffle(new_order)

for i, v in zip(new_order, bm.verts):
    v.index = i

print("shuffled indices:")
for v in bm.verts:
    print(v.index)

print("update index()")
bm.verts.index_update()

print("indices returned to original order:")
for v in bm.verts:
    print(v.index)

print("shuffling again, followed by a sort:")
for i, v in zip(new_order, bm.verts):
    v.index = i
bm.verts.sort()

for v in bm.verts:
    print(v.index)

bmesh.update_edit_mesh(me)

It's important to call sort() after assigning new indices to actually apply the new order. After that, indices will be ordered 0..n, but if you check the indices drawn in viewport, then you'll see that they changed.

Will this re-order to 0..1..2..3..4..5..n incrementally? Some game engine don't accept face indices and just programatically generate it incrementally on run-time.

Not sure what you mean by incrementally... If you export from Blender after sorting, the indices should be in that order. I don't think that holes (e.g. 0, 2, 3, ...) are allowed in Blender.

I asked a question about that here. Can you check? :) https://blender.stackexchange.com/questions/79805/re-arranging-vertices

@CoDEmanX
Its a nice script that shuffles the verices. What do i need to change to sort the list from smallest to biggest? i tried sorted(new_order) but did not worked

@DGRL Smallest to biggest what?

@CoDEmanX  from 0 to last number

@DGRL I don't get the point. The order of bm.verts is 0 to last number by default. If you call bm.verts.sort(), nothing will change. The idea is that you assign a new order by setting the .index attribute accordingly for all the vertices, then call .sort() to apply that desired order. The mesh will then have the vertices reordered, and the indices will be 0 to last number again.

Great tip with bm.verts.sort(), thanks.

For whoever will find this helpful, here is how to display vertex indices in 'Blender 2.80':

In Preferences - Interface - Display, check 'Developer Extras'.

In the 3D View - Overlays, there should now be a 'Developer' section, check its "Indices" box - see screenshot below:

thanks for the answer. I am able to do Step 1, but how do you do Step 2? I do not see an option for "3D View" to click.

I just added a screenshot, hope that helps.

Also, don't forget to check "Text info" in the same panel, for some reason it is unchecked by default (on my end at least)

Thanks! (I am using Blender 2.8+ but hopefully the interface is similar -- let me check!)

Is it possible to change the font, size and color of the index overlay? It's very difficult to read.

source: Stack Exchange

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

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

sort: votes


text:
Unwrap tapered cylinder without UV distortion at tip

Here are 4 cylinders with a wave texture and their UV unwraps. From left to right:

Cylinder with default unwrap
The same cylinder tapered with proportional editing. Tip vertices are all at the same location. No change to UVs, texture tapers to tip properly.
The same, but with doubles removed. The UVs have changed, but the texture still works.
The same, but re-unwrapped with Cylinder projection. The texture is distorted.

My question is: How can I make UV unwrapping like 3 for 4, or other similar shapes that didn't start with clean UVs? Can I somehow split the tip UVs of 4 to be like 3? Can it be done without Cylinder Unwrap?
I am modeling mesh hair where each strand is roughly a tapered cylinder, but wasn't necessarily formed in such a way that I have clean UVs. But I need my hair texture to taper to the tips properly.

In mesh edit mode, mark edges as seams (in the edge menu -> mark seam).  Wherever you have a seam the unwrap operator will unstitch the seam in the UV map and unfold accordingly.
How you pick edges to mark as seams is dependent on what you're unwrapping. In this case you'll want to select the vertical edges towards the tip then mark seam.

When you unwrap these  should end up like your version 3.

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


text:
UV texture paint not working on sharp edges/tips?
I am trying to texture paint onto a mesh with a lot of sharp edges and tips. These areas do not seem to register with the painting, which creates artifacts. I have tried using different UV unwrapping methods and pretty much ever brush settings I can think of, but it doesn't help. Why does this happen, and how do I fix it?

maybe try to increase a bit the brush bleed value in the N panel > Tools > Options?

You could paint directly in the image editor, or just clean up that messy topology.

Bleed value doesn't make any difference. Painting in the editor isn't really viable. The topology is supposed to be sharp in these areas. It's not really messy, just complex.

Can you share more screen shots of exactly what conditions this is in, like what your UV map looks like, what your brush settings are, what your subsurface modifier is set to if at all, what edge crease you have set, and if you have tried face selection masking yet to drop color with the fill tool in a controlled way?

this could be an issue of uv layout.. try to check if your layout have large enough area and that they are big enough and not overlapping maybe..

After playing with the UV maps more, I have found that the problem went away if I didn't allow Seams/UV edges in those areas. I had thought I had ruled this out, but I had used too low of an angle on my Smart UV unwrap, and so had still ended up with an edge in those areas even though it wasn't marked as a seam.

Turn off backface culling in the options of your brush in paint mode.

Have tried it, no luck! Have also tried disabling falloff, and multiple different UV unwraps some of which had seams on these edges, and some don't. Also tried without subsurf.

please share the blend file of the problematic area.


text:
Equalize subdivision of a mesh
Say I have a mesh with inconsistent subdivision. There are some areas with really large faces and no details, and other areas with lots of tightly packed detail. For example, a building with detailed windows with window sills and trim on one side, and no windows on another.
I would like to subdivide or otherwise cut the large blank faces to be at about the same level of detail/face size as the detailed areas, but without further subdividing the detail. It does not have to be exact, and I don't care if it causes triangles, ngons, or other such bad topology. The goal is to able to standardize the mesh for purposes of vertex colors and the pointiness attribute.
Here is an example. On the right is what I have, on the left is what I'd like to turn it into.

The meshes are too complex to do it by hand. Is there any way to automate this?

You can select one of the edges that's too long and press ShiftG to Select Similar > Length. Then you can subdivide these edges as many times as needed.

The number of subdivision cuts can be specified in the Operator Panel:

For simple topology you may be able to dissolve edges.  Then use loop cuts again.
Loop Tools, which is an addon,  can also evenly space adjacent loops

Remesh Modifier does this well.  This is often useful for Text to Mesh.
Slightly off topic, but how do you work well with such a jarring UI theme? – NᴏᴠɪᴄᴇIɴDɪsɢᴜɪsᴇ 9 mins ago

Slightly off topic, but how do you work well with such a jarring UI theme?

@NᴏᴠɪᴄᴇIɴDɪsɢᴜɪsᴇ lololol...Thanks for asking what we've all been wondering. I just figured this is what it looks like when a bezier-slinger goes atomic.

You can use Ctrl+R, then either type in the number of cuts, or scroll up on your mouse wheel to get the number of divisions that you want.

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


text:
Kissing Spheres of Various Sizes (a plane of bubbles)
How can I create something like the bubbles in this picture?

They are kissing (not fusing like soap bubbles do) so there should be no overlap.
Is there a way to achieve this with particles?
I envision starting by making a set of large and medium-sized bubbles and then adding a second set of small ones with collisions turned on -that way they should fill the gaps. Is this a good practice or is there a simpler method?
(The large misshapen bubbles are cool but can be ignored for this specific question.)
Thanks in advance.

Particles don't do collision with each other. You can duplicate a bunch of spheres and use rigid body physics to do collisions.

if you add one or more hair particle system to a plane -> render -> and select object and for "dupli object" add a sphere on another layer, and set the random size. But that wont give you that "kissing" effect. I don't have much experience with particles, maybe there is more you can do with them. Using a physics simulation would probably give you a better result easier. and soft bodies could be used for large bubbles to get deformation, but that could take time to get right. Hint: using proportional editing with random falloff and scale on individual origins to randomly scale many spheres at o

This kind of bubble effect can be generated using rigid bodies and force fields. A mix of different size spheres are dropped on a plane and the force field causes them to pull together and space fill.

Procedure (tested on Blender 2.79)

Create the baseline geometry. Add a contained to drop the spheres into, add sphere of different sizes above the container. Set the contained as a passive rigid body. Set the spheres as active rigid bodies.
Add a force field actuator to the center of the container, under the floor. Set the force to a negative value to attract the spheres.
Set the gravity to a high number to pull all of the spheres to the floor and keep them there as they are pulled to the center.
Animate until everything is pulled together.

At this point, the spheres are reasonably packed and approximate the 'kissing spheres' stuck to a plane. Add the shaders and render.

Example Blender file -


text:
Random Hair Rotation
I'm trying to scattered crumbs using the hair system.  The problem is that all of the dupli objects are facing the same direction.  Is there a way to randomly rotate each particle (similar to the random size setting)?
Currently I'm achieving the effect by brushing the hair but this prevents me from editing the initial settings afterward.

You have to enable 'Advanced' particle settings. Then a tab for the particle rotation will show up. Enable it and set 'Phase' and 'Random to 1:

Now the particles will be rotated randomly:

By default the objects will be pointing up with their y-axis and also rotate around that axis. You can play around with the 'Initail Orientation' setting and its random value to get different rotation behavior.

Exactly what I was looking to do - thank you for the clear and concise answer!


text:
Hollow / Solidify a Mesh (Without Intersecting Faces)
The solidify modifier creates new geometry normal to the surface of a base mesh.  This works well in many applications but creates intersecting faces for many geometries beyond a critical thickness.

Are there any straight-forward, reliable methods of creating a more desirable internal mesh?  There are two acceptable outcomes:

Preserve the detail of the base mesh
Simplify the geometry (beyond a critical thickness)

There are manual methods of addressing the problem but this does not scale well; achieving a uniform wall thickness across any non-trivial mesh presents quite the undertaking.
This problem crops up frequently in the world of 3D printing where solid parts are needlessly resource-intensive.

I am not aware of any relatively automated method to achieve this since it is not trivial to calculate intersections and solve the resulting geometry. There are far better tools for these kinds of operations in the realm of NURBS and Solid modelling in CAD applications. With meshes you'd much better luck doing the opposite: designing the inner tighter curved "concave" geometry and add thickness outwards, though doubly curved meshes would still remain an issue.

@DuarteFarrajotaRamos : Agreed; I commonly use solid modeling tools but for models that were generated in a mesh-based application this is not an option.

Yes.  Depends on your definition of straightforward.  Using python and MetaBalls.  MetaBalls are volume based so you are guaranteed a manifold outcome with no self intersections.  However detail preservation will only be to the resolution of your offset and to the detail of the volumetric isosurface calculation with the metaballs.  I use several methods
1)  Add a metaball at every vertex of radius R = offset
2)  Add a metaball at every vertex and a meta elipse at the center of every face (circumscribed by the face)
I pre-process a copy of the mesh to have vertex density such that distance between metaballs is about 1/2 the desired offset.
Works great.  If you want code.  It's going to be a bear to read because it's part of an enormous dental project.
https://github.com/patmo141/d3guard/blob/master/meta_modelling.py
https://www.youtube.com/watch?v=Ih4_wb1tegE

Link is outdated. Also, would you help indicate in more detail what the process would be like. As the original poster, I have the same question to be solved. If this can be done via addon, that would seem like the best solution. I tried installing your addon, but it was targeted for advanced users of dental applications.

you can do way better now by just using solidify modifier followed by remesh modifier!

@patmo141Hi , i can't figure it out how did yo do it with meta balls ?


text:
Avoid Duplicate Vertices in Extruded Text
By default, new text objects are created with duplicate vertices.  When the curve is converted to a mesh, those extra vertices disappear.  However, if an extrusion value is added, the curve-to-mesh conversion does not remove the duplicate vertices.

Each letter ends up being comprised of disjointed sets of faces.  This might be a bug / oversight in bpy.types.Curve.fill_mode = 'BOTH' (the default value) which calls for the three sets of faces to be created independently.

Are there any fast and elegant methods of creating extruded text meshes without duplicate vertices?

I am creating text objects in a script and want to avoid using operators. It loops hundreds of times and needs to be fast.  With that in mind, I would be happy if an answer involved a code snippet that quickly and elegantly removes these extra vertices.

Why not do conversion first and then extrude as mesh or solidify it?


text:
Animation Nodes: Copy a selection/group of objects
I have several objects in a group. The objects are related to each other via modifiers. The modifiers are stuff like text objects following curves via the Curve modifier. If I select all of them and hist shift+D, then I can create a copy of the entire hierarchy, and the modifiers will automatically assign to the new version. For example, if I had TextObject with a curve modifier to CurveObject, then after duplicating, TextObject.001 will be on CurveObject.001.
You get the same behavior if you make a group instance and then explode it with Make Real. However, if you copy just one object at a time, then of course it still points to the previous version's curve. I can use the Object Instancer to make copies of single objects, but how do I do the whole lot? What's the proper way to go about this?
The overall goal is to copy the whole group, change some of the text in the text objects, then apply all modifiers and join the whole thing into 1 object.

I can only recommend creating everything explicitly. So your node structure should be something like:

Instance all the objects you want, possibly using the Copy All Option or by disabling the Copy From Source option and injecting the object data later.
Loop over all your objects, add missing modifiers as described in my answer here, and set modifier values using Attribute nodes.


text:
Acces unmodified Normals on object with Custom/Transferred normals
I have a complex mesh that I am giving custom Normals to via the Data Transfer modifier. The normals are coming from a simpler mesh.
I want to use both the original normals and the custom normals in different parts of the material. Mainly, the original normals for the Diffuse, and the simplified custom normals for the Glossy. However, once I have custom normals of any type, I can no longer access the original normals. The Geometry and Texture Coordinate node Normal outputs both give the Custom Normals. The True Normal gives the original normals, but with flat shading, so that is not helpful.
Is there any method to get at the original normals still? Or a way to modifiy the True Normal in the material to be smooth shaded?
For a static model, this could be achieved by baking either the original or custom normals to a texture and using that. But that is not an option for meshes that deform as far as I can tell?

You can use a script to set the normals to the vertices colors. The downside is, the smooth shading will be Gouraud instead of Phong.

For baking to a texture, you'd want to bake a normal map of the difference between default and custom normals. But you'd have to re-bake it for every pose. Same with vertex colors.

Animation Nodes can be used to compute the vertex color maps in near realtime, I will write an answer, maybe it will help you get somewhere.

What about duplicating your "complex mesh" inside itself, but assign different vertex group to it. Data Transfer can use vertex group, so you can assign it to yours original mesh, while keep copied mesh with original normals. Just distinguish meshes inside shader with use of vertex colors or texture mask. By multiplying this mask on Normal output, you can extract Normals from copied mesh. And finally use Mix of desired shader and Transparency to hide copied mesh.

Animation Node can be used to assign vertices normals to vertices colors in near realtime. Using those normals in cycles won't yield the same results as the Phong smooth shading cycles uses, however it provides very similar results.
Background Information
Understanding How Vertex Colors Work
The name Vertex Color is a bit misleading, it should be noted that color data is not stored per vertex, but rather per loop. A loop is basically a vertex of a polygon, so if a vertex is part of four polygons, it will compose four loops, to understand this better, lets look the following illustration:

The above is a mesh with 4 polygons, each polygon has 4 vertices and subsequently 4 loops. We represented loops by colored dots, you notice that each vertex compose either 4 loops as blue loops, 2 loops as red loops or a single loop as violet loops. Now, If we were to color all loops white expect the blue loop in polygon three, we will get something like this:

There are some advantages of storing colors in loops instead of vertices, the main advantage being the ability to color polygons. If colors were stored in vertices, it would not be possible to color a polygon with a single color, think about it ! To color a polygon using loops, we just have to color all loops in the polygon with the same color:

On the other hand, to color a vertex, we have to color all loops that are part of the vertex, same-color dots in the above illustration:

In case of coloring vertices, the fragments (pixels or dots) in polygons will be colored according to a convex combination of the colors of its vertices (a bilinear interpolation for quads), such interpolations are particularly useful to represents smooth shading in your case !
So if we were to color vertices based on some color list, we will have to identify the loops that are part of each vertex (same-color dots in our illustration) and color those loops based on corresponding color from the color list. We will also explain polygon coloring for completeness.
Understanding How Loops Are Stored In Meshes
Vertices have indices which we can use to identify and select them by, the same goes for polygons and edges. How are loops ordered and how can we identify them? To answer that, let us consider this simple cube as a study case:

Where polygon indices are shown in red and vertices indices are shown in blue. The ordering of loops follows two rules:

Loops of the first polygon are stored first, loops of the second polygon are stored next, and so on.
Loops in individual polygons are sorted from the lowest vertex index to the highest.

We can represent the loops as an ordered pair $(x, y)$ where $x$ is index of the polygon it is part of and $y$ is the index of the vertices that it is composed of, and the set of ordered pairs for quadrilateral mesh will be:
$$
\begin{aligned}
&(0, 0), (0, 1), (0, 2), (0, 3),\\
&(1, 0), (1, 1), (1, 2), (1, 3),\\
&(2, 0), (2, 1), (2, 2), (3, 3),\\
&(3, 0), (3, 1), (3, 2), (3, 3),\\
&\dots
\end{aligned}
$$
To understand this better, we drew the indices of the loops over the study case :

Coloring Polygons
In order to color polygons with flat colors, we have to color all loops in a polygon with the same color, in the above case, in order to color the polygon with index zero, we will have to color indices $(0, 1, 2, 3)$, to color the polygon with index one, we will have to color indices $(4, 5, 6, 7)$, and so on. Notice that the indices are in the pattern $(0, 1, 2, \dots)$, grouped in groups of length equal to the number of vertices of the polygon, so all we have to do is generate a list such that the first $n$ number of colors are the color of the first polygon where $n$ is the number of vertices in the first polygons, the second $n$ number of colors are the color of the second polygon where $n$ is the number of vertices in the second polygons and so on. In practice, we loop (iterate) over polygons, get the number of vertices in it ($n$), get its color from the color list, append it to an initially empty list $n$ number of times. An implementation in animation nodes is as follows:

Don't worry about the Set Vertex Color Subprogram, we will study it in a second. Notice that we used the polygon normals as colors in here. Also, we represent colors using 3D vectors; because they in fact are (Vertex Color doesn't support Alpha Channel).
Coloring Vertices
Vertices coloring is a bit harder to understand but easy nonetheless. Lets look at the study case one more time:

Remember that in order to color vertices, we have to color all loops that compose that vertex, in the above case, $(0, 4, 8)$ should have the color of the vertex at index zero, $(1, 5)$ should have the color of the vertex at index one, and so on. Notice that polygons are merely an indicator of which vertices are in each polygon, now remember that loops are stored in the same order of polygons, so the algorithm for generating the loops colors is as easy as looping (iterating) over polygons, using the indices of the polygon to get the colors at the same indices, append the colors. Take your time to understand it, you will only understand it if you think about it. An implementation in animation nodes is as follows:

Notice that we use the vertices normals as colors in this example.
Set Vertex Color
Animation Nodes currently does not have a node to set vertex colors directly, so we will have to write a small script to do that, a possible way to do it is as follows:
#Create a vertex color map named "Normals" if it is not already created.
if "Normals" in Object.data.vertex_colors:
    map = Object.data.vertex_colors["Normals"]
else:
    map = Object.data.vertex_colors.new("Normals")

#Loop over Colors and assign them to the vertex color map.
for i, color in enumerate(Colors):
    map.data[i].color = color

The script creates a vertex color layer named Normals which is then filled with the data from the Colors list, the Colors list is a 3D Vector list of $n$ Vectors, where $n$ is the number of loops in the mesh.
Answer
You probably already know how to set the vertex normals to vertex color map by now, we did it couple of time above, so such a node tree should achieve what you want:

But wait, there are some things to take care of. Blender only store the colors in the interval $[0, 1]$, but our vectors are signed, ideally in the interval $[-1, 1]$ if normalized. This can be handled by linearly remapping the $[-1, 1]$ interval to the interval $[0, 1]$ in Animation Nodes, then in cycles use the inverse remapping function to transfer the vectors back to the interval $[-1, 1]$. The remapping function can simply be $\frac{V + I}{2}$ where $I$ is the identity vector matrix, and the inverse remapping function will be $2(V - I)$. Notice that $V$ has to be normalized, because while Animation Nodes doesn't care about the magnitude of the normals, cycles does, and will yield unexpected results if not handed normalized vectors. Moreover, normalization has to be done in Animation Nodes due to the assumption we made that the vectors are indeed normalized in the remapping function.

I'm trying to give this a try, but i'm having trouble getting this node setup. Object Mesh does not seem to exist, only Object Mesh Data which doesn't have a Vertex Normals output? I'm using 1.6 as 2.0 doesn't seem to work with blender 2.79 (python version error)? If you can give a bit more info on how this setup works that would also be great. Is Vertex Sampler the above script? If so, what is Vertex Color?

Looks like 2.0 isn't working because of a custom build I'm using. Do I need 2.0 though? Thanks.

I found a version of 2.0 that works with my build, and it has the proper node options now. But I still don't really get what's going on, or how to setup the subprograms.

@Drudge The Object Mesh node does have Vertex Normals, but it is a hidden input, almost all AN nodes have hidden inputs, you can make it visible through the N menu. The Vertex Color is the script node, the Vertex Sampler is the loop. More details will force me to explain things that are way out of the scope of such answer, I will try to provide such details and provide some links to check out in order to understand this better.


text:
How to remove IBL from scene
Was curious how one might go about NOT using an hdri and image based lighting in a scene. For example if you wanted to have a static value for an ambient light value and then use only direct lighting from various light sources, vs having the ambient light value based off of one of the hdri images.

Feel free to correct me, but I think you want something like this. The setup below keeps the HDRI image, but removes it's light influence. Instead, you can influence the background value using a Value node connected either to the Color or the Strength input. The trick is to separate the light influence from the background image using the Is Camera Ray output of a Light Path Node.

I do believe this would do the trick! Then if I didn't want the background image to display at all I just wouldn't link it to the mix shader. Is that correct?

If you don't want any HDRI (lighting or image), omit the mix shader, light path and image, and just connect it like Value > Background > World Output

This works beautifully! Greatly appreciated.


text:
Export children as root level objects
In my blender scene I have several objects that are parented to an Empty. I use this Empty to move the objects around the scene without having to manually move each one. Works like a charm.
However when I export my scene and load it into my program, the child objects of my Empty are only accessible as nodes of the Empty as opposed to being their own reference-able objects.
Is there a way within blender to, upon export, make all child objects of Empty their own object?

I've been researching this more and what I might be wanting is a group of objects vs parenting to an empty. I will test this and post my results.

The solution to this issue was in fact to remove the empty keeping the children (applying any transformations made using the parent), and then create a group of objects.
Creating a group of objects can be done by selecting each object you wish to have in the group and pressing ctrl+g. To select all objects in the group, simply select one object, press shift+gand select group.


text:
Children of parent maintain current position after parent removed?
I have several objects set as children of a parent object. Whenever I remove the parent object (an empty in this case), the position of all of the children are skewed. I'm guessing that this is do to them being moved after the parent relationship was made? I'm looking for a way for all of the child objects to maintain their current positions after the parent has been removed. Is there a way to do this?

Select the children and then press Alt+P, where 3 options will be presented in a popup menu. The option to Clear and Keep Transform will clear the parent of the children and allow them to keep their current scale, position, and rotation.


text:
Using 3d scanned textures
I have been debating on purchasing a 3D scanner to make point cloud references of objects to model for games. For example, use the scanner to create a point cloud object of a character, then import the point cloud into blender and model around it to create a polygon mesh. This part I'm clear on. My dilemma lies within extracting the texture of the scanned point cloud image for use on the polygon mesh. Does anyone know how one could go about this, or if something of this nature is doable?

Why have it export to a point cloud? Why not a full on 3D scan? From there you could retopologize it and you're have easier to see infomation than you would from a point cloud. You'd probably also get the texture info also (you'd have to correct it to fit the UV map of the retopologized object though). Just keep in mind that 3D scanned textures are usually pretty low resolution.

I am going to be looking into this retopologizing. I had no idea of it's existence until you mentioned it.

This blog post explains how to retopologize a mesh and bake the normal maps from the hi-polygon mesh to the low polygon mesh. This was exactly what I was looking for, but didn't know what the process was called (baking normal maps).
Another blog post that goes into greater detail on baking normal maps.
I would also like to thank @TARDIS Maker for pointing out that 3D scans could be done as a full on mesh and not only point clouds, AND for shining the light of retopologizing hi-res meshes. I had no idea this process existed.


text:
Isolate light cast on a surface through glass
I have a white plane and a glass object on top of it, with 2 spotlights casting light through the glass object. This causes a lot of light to be cast onto the white plane.

I want to turn the plane into alpha, either in the material or in post and isolate just the glass object and the cast light. Something like a shadow catcher, but for this refracted light instead of shadows. Is this possible?

Try this one: https://blender.stackexchange.com/questions/134048/how-to-reflect-catch-light-but-be-invisible-on-render/134075#134075

On a suitably simple scene, you could use the diffuse indirect pass on a separate renderlayer to get just the caustics. That way rendering twice and subtracting isn't required.

Alpha masks will not work for this
Alpha is for blending one image on top of another so it will not work with light, because light should be added, not blended, but you can separate only the light information.
Separating light information
To separate light going through the glass object you would need to render it and then render a version without it. In this case it happens that the light that we need is going through glass, so if caustics are disabled the render will come out without it. Or if you wanted the light to be only from a specific light source you could disable the light source instead. You should just subtract the image without the light from the image with the light and you will be left with the light information that now could be added to another image. Note that it is important to work with 32bit color depth here.

Separating glass
Glass is a lot harder to separate since it has refractions and internal reflections. You can have a look at this post, but I ignore internal reflections here. the refractions are also not completely accurate, because they come from a plane and not from realistic directions. To have more accurate results, it would be possible to separate glass to components like internal reflections with render passes and light paths node in the materials so it can be reconstructed in a more acurate way with different refractions. That gets a bit complicated, let me know, if you wish to explore this further.

I may be misunderstanding the answer, but I'm not sure this is what I'm after. I'm trying to be able to convert the white background to alpha so that I can layer the object+its cast light over other backgrounds (this is for a website which has a changing background)

If you want to put an object on another background, alpha mask is enough, however if you want to shine light on another background, you have to add(as in add values together) light to it. It should be addition( and it should be done with linear values, not sRGB) - that's another blending operation than mixing colors according to a grayscale mask. Note how on the checker background, the light does not replace colors but makes them lighter. CSS now supports some blending modes. I think screen should be close enough.

I just want to overlay the image. It's for a website header that is partially transparent and will show the website's background through it. So I'm trying to turn the white background of my setup into alpha without losing the light cast onto it from the glass.

If you use only alpha, you will loose the light cast, because it is cast on whatever is in your render, not the background it would be above. You could composite your header with CSS mix-blend-mode Property You would need images of your background, your objects without the light mixed with it with regular alpha and then you would need to add the light on top of everything with 'screen' blend mode so it brightens the images below in areas where it shines.

I understand that I can't have the background be only alpha. I am trying to turn the areas that don't have light cast on them from the glass into alpha so that it can be properly layered over other images.

@Drudge The typical kind of alpha (aka straight/unassociated) — the kind implemented in browsers, for instance — doesn't do emissive blending. That is, there is no way to contort the alpha channel such that areas where light is meant to be added will be correctly handled. In addition, the whole operation must take place in a linear color space, which as far as I know also isn't supported natively by any browsers. As a work around, you could perform the compositing yourself in javascript or webgl with a <canvas> element, or precompose the images.

@gandalf3 It sounds like this is a lot more complicated than I though. I don't know what most of what you are saying here means, but I get the issue. I don't need to keep everything perfectly photorealistic here, I just need to get some opacity so that the website's background shows through instead of the current white plane I rendered it on. So areas with no object or light spill should be 100% transparent, and the lightspill should be partially transparent, depending on the amount of light. But it's sounding like I need to just move to a different concept entirely here.

@Drudge You can try to hack it, but the practical upshot is even if you get something that might look okay against one background, it'll will likely look ugly against another. If you want to go that route, I think your best bet is to over-expose the caustics heavily so that you don't run the risk of having darker caustics against a lighter background (which will look very wrong indeed). The linked example was made by simply plugging the isolated caustics into both inputs of the set alpha node.

CSS supports screen blending mode. That is far from correct way to do it(it works with non linear sRGB values and the math is completely incorrect as well), but if you have the light information separated as light on black as in my answer and mix it with the background in screen blending mode, you may get results that do not look completely wrong visually.


text:
Randomize the radius of a curve
I have a curve object that includes several curves. I want to randomize the radius of each separate curve piece. Each point on the curve piece should have the same radius, but each piece has a different random radius.
Some control is necessary. I want to be able to set a minimum and maximum number for the radius.
Is there any existing methods or addons to do this? How about with python?

To do it manually, in edit mode use L to select linked points and adjust the radius property which will be applied to all selected points. The radius property can be found in the properties sidebar N.

Or you can automate it with python. A curve object can have multiple splines, each spline then has multiple points. Note that bezier curves and nurbs curves use different property names for the points. For bezier curves it is bezier_points while nurbs curves use points.
import bpy
import random

c_obj = bpy.data.objects['BezierCurve']

for s in c_obj.data.splines:
    spl_rad = random.random()
    # change to s.points for nurbs curves
    for p in s.bezier_points:
        p.radius = spl_rad

If you like to do this procedurally, you can use Sverchok Add-On to quickly access those joined curves, get the points of each curve, regenerate them as NEW Curves all with random radius.

If you want to keep the original single Curve object with multiple Spline, you can really use Python and directly targetting the Bezier Point Radius. Visually shown here using Sverchok:

Thanks to SV Dev Zeff also we have this way to do it:

Alternatively you can also use bpy I think:
import bpy
bpy.data.curves['BezierCurve'].splines[0].bezier_points[0].radius = 6
bpy.data.curves['BezierCurve'].splines[2].bezier_points[0].radius = 3

If you have a single curve object that includes several curves, changing the Bevel Depth in the Geometry panel will change the radius of all curves in your object...
One way to do what you want, is to create several curve objects and to join them in a same group named 'curve_group' (this name is used in the following script).
Running the following python script will change the depth randomly from 0.01 to 0.1 :
import bpy
from random import uniform
for obj in bpy.data.groups['curve_group'].objects:
    obj.data.bevel_depth=uniform(0.01, 0.1)
    obj.data.bevel_resolution=5

Thank you for the response! It looks like this sets the Bevel Radius for several curve objects. I need to set the radius of control points of multiple splines within the same curve object.


text:
Object not outlined in Viewport despite Outline Selected enabled
I'm working on some models someone else made as part of a project. The .blend files they've given me have several objects that get no selection outline in the viewport despite Outline Selected being checked. Other objects work normally. I assume there must be something else that can cause an object to not be outlined, on a per object basis.
Can anyone tell me what this might be? I cannot find any differences between the settings of objects that do and don't have selection outlines.

plz attach screenshot of outliner or attach the file

Sounds like a bug to me. Did you tried appending all objects into a fresh file?

have you tried to select them and then move them? If it doesn't work, their selection is restricted. Go to the outliner (right top corner on the default screen) and search for your objects. On the right side there will be an eye, a cursor, and a camera. Clicking on the cursor will toggle if the object can be selected.

Cannot attach the file as it's the property of the client. Appending to new file doesn't fix it. I can move and interact with the objects normally.

I had the same problem for a few days.
After searching for a solution online without result, I simply just randomly clicked here and there... – and found the solution that worked for me. That is:

Select the object (which has the problem with a missing outline).
Change it to sculpt mode.
Change it back to object mode. And the outline appears again!

I still don't understand why. :)

I have this same problem, but the fix above doesn't solve it.  Seems mysterious.

Toggling doesn´t work. Was appointed previously. Down voted.

There are lots of answers being given to this question because there are lots of causes. I've marked this as correct because this was the problem that caused me to ask the question in the first place.

For the people who are having the same problem in Blender 2.80 (and up), make sure to enable Show Overlays in the viewport (it is the icon with two circles).
Check Outline Selected from this menu. For some reason Blender hides the highlights along with the cameras and lights upon disabling it.

I'm using 2.90.0 and had the same problem. I wonder if this would have solved the problem, except I already tried something else that fixed it.

Thank you! This works in 2.90 too! I would have reinstalled Blender. (which also would've worked)

I went around and around with this for a bit today and the solution for me was to click the button to the left of the 'Overlays' pulldown.  The tooltip reads "Display overlays like gizmos and outlines".  This did the trick.
Seems like a silly place to bury the toggle for that functionality, but what do I know.

If anybody is referring to Blender 2.8, this solves the problem.

Press "N" keyboard key. Go to DISPLAY: uncheck "ONLY RENDER".
You should have your selected object outline back again.

Having found myself in the same predicament inadvertently I was a bit frustrated as you get so used to seeing the outline of the object you are manipulating. I found though in my case it was a case of ticking the 'Only Render' box in the display settings! I guess there may be other circumstances in the display and setup settings which could cause the outline of the selected object to be not visible.

yet, it is another one who gets the result for the "correct" answer. Okay, I am seeing some biased manipulation here....
Thanks anyways to those who truly know the correct answer was mine.

Its no big deal really I think. I answered the question on 31 jan and from what I can see you answered this 2 days ago. I'm not after points or anything, just trying to help where I can with what I know.

I encountered the issue recently in Blender 2.8:
I found out, that the issue only appeared in Layout mode and it seemed like the workspace was somehow broken.
I simply added a new Layout Workspace ("+" at the right top navigation >> "General" >> "Layout") and deleted the broken one.

Minutes ago, I had this problem in 2.90.0.  I had four 3D Viewpoint tiles up. Three smaller ones worked fine, while the big one didn't show the outline. Solved it by breaking the big one into three, joining the original three over the new three, breaking these each into two, then joining those new ones - hard to describe, but basically tile gymnastics such that the original malfunctioning tile is gone and a new one is created. Just don't break the original one into two and rejoin - that does nothing.
After seeing the answer by frosty Warlock, I wonder if by default new 3D Viewports have that button on by default, and in my original malfunctioning viewport it was off and I didn't notice.

I had this problem and found that the object I was trying to select was the parent object for several others, and I suspect that some of that tree of relationships included objects which were not selectable in the scene browser.
I decided that I didn't like having the target object be a parent anyway, so severing those child relationships solved the problem.  It seems like Blender was deciding "if you try to select an object and some of its children aren't selectable, don't light up the parent."

There are apparently many ways this can happen, but if you are a new user make sure you are not on the "layout" tab on the top, you need to be on the "Modeling" tab.
I had the same problem where it appeared that nothing would outline, but it was from me inadvertently being in the wrong tab.

Blender 2.8: you might have disabled selection (arrow icon)
go to top right "Filter" icon -> make sure second arrow "Selectable" icon is pressed -> enable arrow icon for your object

In blender 2.8:
I fixed it by clicking (show overlays) viewport overlays,
And check box wireframe (under geometry).
The object outline showed up again.

This solution has already been posted.

Now in blender 2.92 is in the shading menu

Which Blender version are you using? Apparently this is an ongoing bug happening since 2014. Someone reported it  before, but was archived as more user informations was required:
https://developer.blender.org/T42276
I've downloaded the .blend file in the bug reporting thread and I think is fixed in  version Blender 2.8, but maybe you can try with your problematic files and if the bug is still there try to provide the required information to the developers to finally fix it.

In the top right corner of the screen click the Show Overlays option to resolve this problem in Blender 2.8

This answer has already been posted.


text:
Difference between Shadow pass and Diffuse Direct?
What are the differences between the compositor's Shadow Pass and Diffuse Direct Passes in Cycles? I know one is that the Shadow Pass only responds to lamps and not mesh emitters. But even on renders that only use point lamps, it still seems to be different.
What other differences are there?

The Shadow Pass is not as interested in the gradient intensity of the reflected light (like DiffDir) as it is in where the emitted light is not directly reflected back to the camera.  This probably involves a threshold, even though I haven't looked at the code.  From my tests, it seems that once the reflected light falls below a certain point, only then does it become non-white on the shadow pass.  Whereas the purpose of the diffuse pass is to show the gradient direct light intensity:

Also, when you add another type of shader into the scene, the similarities between DiffDir and Shadow continue to diverge since the shadow pass is affected by them as well.  An interesting phenomenon occurs when the Glossy Shader is at 0.0 roughness... it becomes totally black.  This is because of what I said earlier about direct light reflection.  As you probably know, when glossy is perfectly reflective, no off-axis light will be reflected back to the camera.  Therefore, you get nothing on the shadow pass.  But if you give it some roughness, it shows up.  That's because it's reflecting enough directly emitted light to breach the threshold.  The center cube below has a glossy shader applied:

Diffuse Pass Vs Shadow Pass.blend
Here is a simple setup up for exploring the differences.  There are two scenes in the blend file.  One uses a white small point light and the other, a white world light.  There are 8 basic materials, Diffuse, 50% Transparent, 100% Transparent (as based on the Value parameter in the HSV of the color of the shader being set to 0.5 and 1), Glossy, Emission, "Low Density" Volumetric, High Density Volumetric, and Translucent.  I would try different things while constantly observing/toggling between the two passes.


text:
Mass replace names in vertex groups
I have a character that is setup with a rig and vertex groups. I want to switch to using Rigify. Rigify has the same bones as the current setup, but different names. To save time weight painting, I need to rename all the bone weight vertex groups to match the bone names used by Rigify instead of the current rig. So I need a tool or script that will take a bone name such as lowerarm_L and rename it to Forearm.L (or whatever rigify calls it.) I can make the bone name list myself.
I will need to do this on multiple characters, so making a script out of it would be very helpful. How can this be done?

The list of vertex groups can be found in the object properties, we just need to search for the names we want and rename them.
You could fill in name_list from the start or just add one or two names as you find them and re-run the script. This is set to rename vertex groups in the active object.
import bpy

name_list = [
    # old name - new name
    ['lowerarm_L','forearm.L'],
    ['lowerarm_R','forearm.R'],
    ['upperarm_L','upper_arm.L'],
    ['upperarm_R','upper_arm.R'],
]

v_groups = bpy.context.active_object.vertex_groups
for n in name_list:
    if n[0] in v_groups:
        v_groups[n[0]].name = n[1]

Note that matching names this way is case-sensitive, for an insensitive match use -
v_groups = bpy.context.active_object.vertex_groups
for n in name_list:
    for vn in v_groups:
        if vn.name.lower() == n[0].lower():
            vn.name = n[1]

Have you looked into the Name Panel Addon?
It's really versatile batch naming tool for various data blocks, including Vertex Groups and batch name copying.
It even has some advanced features like Auto Naming, though I've never used those myself.
It's totally free and open source, although I'd consider buying it over at the Blender Market if you find it useful or if it helped you, simply to show encouragement and support to the developer.
I'm planing on doing it myself.

That looks really useful for a lot of things. I am still figuring out how to use it, but it does not seem to let me make a list of term to replace other terms with. I have to do it one at a time still? It looks like I'll still need a script if I want to rename all my groups from a pre made list with one click (although a script that calls this addon would probably be easier.)

The addon is quite powerful but also a bit hard to grasp at once. I only use a limited subset of the features myself, but as far as I know you can only find and replace one item at a time, so maybe a script that calls the addon is the solution. The author is quite open to suggestions, maybe he can come up with something although he mentioned being in the midst of a big rewrite, so he may not want to change much in the current addon iteration


text:
Relation between Fresnel IOR and Layerweight blend?
I know that the Fresnel and Layer Weight nodes do much the same thing, but with one accepting a proper Index of Refraction, and the other a value between 0 and 1. I have always used the Fresnel node as it allowed me to simply look up the proper IOR of any specific material online and plug it in. However, if I wanted to use Layer weight, how would I go about translating an IOR, which I've seen as low as .18 and as high as 2.5, into a value between 0 and 1 to get the same effect out of layer weight? Is there a conversion formula or ratio?

If you want to use a specific IOR I'd say just use the fresnel node.. I only really use the layer weight node when I don't care what the IOR is and I just want a certain effect ;)

By comparing visual results from both LayerWeight's Fresnel and Fresnel Node on a test sphere I concluded that these settings give similar results:

Blend:  0.00  0.10  0.50  0.70  0.80  0.90  0.95  0.98  1.00
  IOR:  1.00  1.10  1.70  3.30  5.10  10.0  20.0  50.0  1000

The Y scale is logarithmic
Confirmed by Brecht (thanks) the conversion formula is:

IOR = 1/(1 - Blend)
Blend = 1 - 1/IOR

Layer Weight node:

Layer Weight Facing output mixes the two shaders based of angle of incidence.
The Fresnel output mixes them based on fresnel formula (Dielectric fresnel weight), which is a function of angle of incidence. The exact math is here: Wiki
The Blend slider adds additional blending between the two shaders: at 0 it will be green and at 1 it will be red.

On the other hand the Fresnel node allows for proper IOR input:

I use Fresnel node when dealing with glass-like materials, where the light goes through - where it bends at the interface. I can set proper IOR for the interface this way.
I use Layer Weight node when dealing with reflectivity, it allows for better control over the transition on the surface (how smooth it is) and over how the materials are mixed (with that blend slider). This suits artistic approach better when you are eye-balling stuff.

If Blend is adding additional Blender, then when using the Layer Weight node, what determines the IOR that it's using? I don't really understand the complex math enough to follow much from that link. Is there a way to translate IOR into a value between 0 and 1 and use it in layer weight accurately? And if you could, would that be even close to physically accurate?

@Drudge I don't know if it's physically accurate (depends on the coding that developers know) but by comparing the results from both nodes on a test sphere you can use formula: IOR = 1 - log(1 - Blend)

Correction: That formula is wrong it has a different graph function than what it should. It matches in the border cases but that's all. See the plot what the graph is.

The formula is IOR = 1/(1 - blend)


text:
OSL script includes and reuse
Is it possible to include one OSL file in another so I can use the functions from it or must I copy and paste everything every time I want to reuse it?
OSL seems to have #include functionality, but is there a way to use it for script files within Blender?
(I'm using internal script files, but I can change if that helps.)

After some experimentation, it appears that #include-ing OSL files works with external scripts, but not internal.
The OSL compiler takes a shader file as input, and seems to use the directory of that file as a base for further includes. It also looks in the \scripts\addons\cycles\shader directory.
If external scripts are used, the OSL compiler therefore looks in the correct directory, and will find included files correctly.
If internal scripts are used, the script being compiled is moved by itself to a temporary directory, given a random name, and deleted afterwards. This means that internal scripts cannot use #includes unless the included files are placed in the \scripts\addons\cycles\shader directory.


text:
CollectionProperty with inherited types
Is it possible to store different types (with a shared base class) in a CollectionProperty?
I want each object to have a set of "Components". Each of these components will have its own PropertyGroup that contains various different settings.
e.g. something like the following:
class Property_Component(bpy.types.PropertyGroup):
    type = bpy.props.EnumProperty(items=component_types_array)

class Property_ComponentList(bpy.types.PropertyGroup):
    components = bpy.props.CollectionProperty(type=Property_Component)

class Property_Component_Water(Property_Component):
    wave_height = bpy.props.StringProperty(...)
    color = bpy.props.FloatProperty(...)

class Property_Component_Terrain(Property_Component):
    max_height = bpy.props.FloatProperty(...)

# other component types...

However, I'm having trouble actually creating the different types. I know what type to add to the collection, but calling component_list.components.add() just creates an object of type Property_Component, instead of the derived type, and I don't seem to be able to assign an object of the correct type afterwards.
Is there a way to do this? or some way to work around this?
Something magical with PointerProperty's? Or maybe just give each object an instance of every component (ick), with a boolean to show if it's actually used or not?

Related

This is not possible in Blender. Blender's API is build on defining exactly what type is in a collection. It is not possible to add other types (even if they are subtypes) to that collection.
The reason for this that blender does not store the type of the item with the item. It always uses the class that has been given by the type parameter of the CollectionProperty as the class. If your addon will rename your class Blender will still be able to fill the list as it is defined by the CollectionProperty.
Best way to solve this is to do the reverse and add use a 'type' enum to your PropertyComponent. I assume that your type was already created for this.
class Property_Component_Water(object):
    wave_height = bpy.props.StringProperty(...)
    color = bpy.props.FloatProperty(...)

class Property_Component_Terrain(object):
    max_height = bpy.props.FloatProperty(...)

class Property_Component(bpy.types.PropertyGroup, Property_Component_Water, Property_Component_Terrain):
    type = bpy.props.EnumProperty(items=component_types_array)

class Property_ComponentList(bpy.types.PropertyGroup):
    components = bpy.props.CollectionProperty(type=Property_Component)

Note: You need to be aware of not redefining attributes with the same name multiple times.

Doesn't this mean every component will use as much memory as having one of each component? If you have 100 component types and 10000 components, you now use a million components worth of memory, no?

I tried using a PointerProperty to allow storing different types in the collection, but that doesn't work either:
class Property_ComponentNull(bpy.types.PropertyGroup):
    pass

class Property_ComponentWrapper(bpy.types.PropertyGroup):
    component = bpy.props.PointerProperty(type=Property_ComponentNull)

class Property_ComponentList(bpy.types.PropertyGroup):
    component_list = bpy.props.CollectionProperty(type=Property_ComponentWrapper)

...

    wrapper = component_list.components.add()
    wrapper.component = bpy.props.PointerProperty(type=get_type_from_id(self.type)) # ERROR! wrapper.component is read_only

Apparently the pointer property in the wrapper is readonly for some reason. TT
So for now I'm assuming this isn't possible, and just adding an instance of every type to the component list, with a boolean to indicate whether it's actually enabled or not.

As a separate issue, it looks like you have to use mixin classes for property group inheritance, something like this:
class Property_Component: # does not derive from bpy.types.PropertyGroup
    type = bpy.props.EnumProperty(...)

class Property_Component_Water(bpy.types.PropertyGroup, Property_Component):
    ...

Doing it the way I originally tried resulted in the base Property_Component properties being inaccessible to layout.prop().


text:
Generating sleepers for railroad track
Using this object as bevel curve, it is easy to generate railroad tracks. Now, how would you do add sleepers at regular intervals along the track?

with dupliframes for example?

Array modifier springs to mind as sleepers are somewhat of an array. It does however depend upon the way you want to extract (excuse my use of language, English is not my native language) your track.
If you intend to make some straight track, I would first create the tracks, 60 cm looks kind of right. Create a sleeper next and join it all as one object (sleeper as "root" works fine for me). I hope the included pictures enlighten you a little.

A straight track might look like this and can use an relative interval of 1:

To create a curve, this method is to crude: you get a lot of jagged connection, though if the track is only a very minor part of your scene, it might work. I reduced the interval to 0.95 to avoid gaps in the outside curve.

As you may see from my examples, I replaced your nice track-profile with a fairly crude modified cube.
I hope this helps you a little, kind regards, Christiaan

If you're being picky, and want continuous track and no curve-distortion on the sleepers.. you could use Dupliframes.

Create the curve that will be the route
Create a single curve (with two identical splines) that will be the profile of the rails
Create a solid (cuboid) sleeper

Here, looking down in Z, the sleeper oriented as you would expect, with respect to the rail profile.
The objects are to scale with the route curve. Ensure CtrlA > all transforms are applied, and the objects therefore share a pivot point at the origin.

Now Set the rail profile as the Bevel Object for the route curve in
its Data > Geometry panel.
Set an animation length of the number of sleepers you want to lie along the track
Assign a 'Follow Path' constraint to the sleeper object Target: the route curve, 'Follow Curve' checked, Forward:Z, Up:Y. The sleeper should jump to the route. Do not hit 'Animate Path' for this method.
At Frame 1 of your animation, right-click > keyframe the 'Offset' field of the constraint to 0, and at the last, key it to the last frame number.
In the sleeper's Object > 'Duplication' panel set the duplication to 'Frames'.

Note that you can not key the 'Offset' field if the sleeper 'Duplication' is set; put it back to 'None' to make revisions.
You may need to  select a sleeper, and go into a Graph Editor window to set the animation curve of its constraint offset to Linear, to prevent an ease in and out of the number of sleepers at the beginning and end of the route. Select its 2 Keyframes, and hit T > Linear.

To make the Duplis into instances, you can hit CtrlShiftA > 'Make Duplicates Real'
It's possible this method is too much fuss for the difference it makes.

Chaining the "Array" modifier and the "Curve" modifier solves the problem. The sleeper mesh should be aligned with its longest side in the y direction.


text:
Specify target files from command line
Short question:
blender -b knob.blend -s 1 -e 2 -a -o //__targets/knob_#.png

Does not write to the desired files, but 0001.png, and 0002.png. I want the files __targets/knob_1.png and __targets/knob_2.png. It appears that blender ignores the target option in this case. What should I do to make it work?

Blender executes the command line options in the over they are given, so Blender sees the command to render (-a) and then sets the command to set the output path (-o). This means the output path gets set after the render has happened.
You just need to swap the order of the commands so you have:
blender -b knob.blend -s 1 -e 2 -o //__targets/knob_#.png -a

Is there a way to set a complete new harddisk path in the command line like "D:\mypath" as the target folder? This isn't working for me for any reason in Blender 2.92.


text:
Is it possible to use compositor when baking?
I am using the compositor to add fog effect to a scene I want to use for a skybox. To create the skybox texture, it is possible to render six planes separately (set camera to 1:1 aspect ratio 90 deg fov), but that is a lot of work. Or maybe there is another way to fade out distant objects.

If you are in cycles perhaps use actual geometry with a volumetric material to make the fog and simulate distance fading?

@DuarteFarrajotaRamos Good point, but I always get the scene to dark, and it increases the render time alot.

If it is too dark then it's probably because it is too dense, never really tried it myself, but for fog I think it has to have really low density value. As for render times not really much one can do, maybe exclude fog effects from everything except camera visibility.


text:
Embedd color managment LUT into blend file
I have started to use filmic-blender, which solves alot of lightning problems (I think it should be embedded into blender as soon as possible). However, now the blend files are not stand-alone, so I cannot just take the blend file, and render it on another machine, without copying the color managment LUTs.
Is it somehow possible to embed that information into the blend file?

If an equivalent version of blender with the filmic feature is installed on the render machine, it should have the luts. I don't see it as any different than making sure the right version of blender is on the render machine. Is this not the case?

@ToddMcIntosh The stock blender does not come with that profile. You need to get it separately from GitHub. I want the render to work without the requirement of installing any addons beforehand.

The current master on the buildbot site has it built in I believe without installing anything extra. It's not in the official release yet though.

https://builder.blender.org/download/

I see that blender 2.79 ships with these new profiles by default. As a side note, I claim that it does not matter if you do full path tracing or a simple raster-scanline rendering with the Phong model. The thing that kills your effort is clamped RGB values. Especially for glossy materials in colors other than red yellow green cyan blue magenta, and gray. Reason: these colors have the same intensities across all non-zero channels, making them immune to hue-shifting.


text:
Store material without an object
When I search for how I can keep a material when removing an object, I only get answers to the opposite question: How to remove the material. I want to remove the object but want to keep the material. Is that possible?

Related - http://blender.stackexchange.com/questions/2448/what-does-users-means-in-term-of-datablocks

The material isn't deleted with the object; the former will only have 0 users and hence will be deleted on reopening the file. To avoid that use Fake User option:

Gives the material a ‘fake user’, to keep the material data-block saved in the blend-file, even if it has no real users.

More info on datablocks and fake user - What does "users" means in term of datablocks ?


text:
Check if blender was compiled with openmp
Is it possible to check if Blender was compiled with OpenMP? How? The installed package is
2.70+git201404250132.3b75d6c-0irie1~trusty1

This might be a better question for Stack Overflow.

@maddin45 I looked for build options in the about box.

@Houssem. But this is from a git repo. They claim it is off in the build bot builds.

Probably the easiest way is to use the Python console and enter getattr(bpy.app.build_options, 'openmp')

In the Info Editor go to Help and choose System Info. Open the internal text editor and select the created file: system-info.txt. Under build flags look for -fopenmp.

Note that the build flags depend on your system. For gcc -fopenmp is needed to compile with openmp support.


text:
Projected convex hull in plane
Consider an object like this one:  Is it possible to, and if it is how, automatically generate a body that is convex for every cut along the xy-plane, without destroying the radial variation in along the z axis.

I realize that this can be tricky do on a general mesh, where the edge loops are not strictly planar. Instead I thought that following approach could work:

Manually add some horizontal edge loops to a new mesh, at chosen z coordinate
Use the shrinkwrap modifier, with the non-convex mesh as target
Scale each loop such that all vertices within one loop has the z coordinate

Instead of shrinkwraping and scaling, it should also be possible create new loops by intersecting radial edges with horizontal planes. Anyhow, we have created a set of horizontal edges, that encloses the geometry well.

Apply the convhull operator on the edge loops individually
Connect vertices to generate new faces

If I am not wrong, it should be possible to script steps 2-5. Here tips on appropriate python APIs is of interest. However, the procedure fails after step 4, since the convhull operator pollutes the mesh with new, coplanar and overlapping faces, that I do not want. Is it possible to remove that extra geometry automatically?

I solved the problem with the following algorithm

Create N horizontal planes of appropriate size
For each plane

Apply the boolean modifier (intersect the plane with the target object)
Extrude the plane in the z direction, giving it some height
Apply the convex hull operator
Remove the extra plane created in step 2
Remove any vertices inside triangles

Merge planes into one object
Bridge the edge loops
Remove interior faces (they were left from the convex hull operator)

Here is the Python script with room for some improvements: https://gist.github.com/milasudril/960f5c2c4c3735f3fdea566cfdc003d9


text:
How to avoid crashing?
Whenever I try to render a file (it's a bear based on a tutorial from youtube) Blender crashes after finishing Building BVH. Is there a way to prevent that or it's helpless?

Try to increase memory cache limit in User Preferences>System

@Denis it was on maximum :/

Mind specifying a bit more about your system (CPU, memory, GPU) and scene (number of faces, memory used before rendering, render engine, using CPU or GPU)?

@TLousky I don't know the GPU, memory used before rendering, render engine, nor if it was using CPU or GPU :( memory is 1,25GB, Intel(R) Celeron(R) M CPU 450 @ 2.00 GHz, and number faces is around 15.

What is the Blender version used in tutorial and by you ? See for the version on the splash screen, or in the very top of the Blender window (called Info Window), just in the middle. You might also want to provide link to the tutorial.

@MrZak I use 2.75 and in the tutorial he used 2.70. The video can be found here: https://www.youtube.com/watch?v=LCghBIUZyuM

Are you able to make preview render ? (It is made with Shift+Z while in the 3D View). And what is the step of the tutorial you're after ? It seems in the end the model should have something around 100 000 polys, with hair

does it crash while packing BVH, or right after. This would mean that you have an issue with the size of your lightmap, If using one, just drop the resolution in 'world properties' and see where it works.


text:
Mixed textures in blender shifted off, any idea how to solve it?
So, I've been texturing this model for days now, following a tutorial but after mixing the textures to get the ideal skin tune, I did a quick render and the textures are shifted off, they are far from the place they should be and the colors are not strong either.

His mouth is near his right eye and nose while his eyes are on the right side of his head. The problem is, and the reason why I have absolutely no idea, how to correct this mistake is, if I check the textures one by one, then it shows up correctly like this:

Anyone can help me? I am desperate at this moment :(
By the way, I was using this tutorial: https://www.youtube.com/watch?v=vAwpRyES21I

Did you do UV unwrap?

Yes, I did, but the problem is still there :/

Could you show the texture's Mapping panel? (https://www.blender.org/manual/render/blender_render/textures/mapping/introduction.html)

Of course. Here: http://s29.postimg.org/6gh640j4m/forquestion.jpg

And the panel above (Image Mapping)? Is Repeat set to 1-1? If you want, consider the option to upload your blendfile (or a part of it) for a deeper inspection http://blend-exchange.giantcowfilms.com/


text:
cross-shaped armature with pushable center
I should like to create a cross-shaped armature where I can push the center while the outer points stay in their place.
How would I best go about that?
One idea that crossed my mind was that if we can use the Inverse Kinematics constraint to build something like this:

Then perhaps there is a way to build something like that?

When I try, though, I fail because setting the bone with the IK constraint as parent of the second middle bone will detach the middle bone from the bottom bone. When I manuall re-attach it (parent with "keep offset"), I get this:

Which moves the bottom bone rather than rotate it.
I'd appreciate your help with this.


text:
Is it possible to add a Child Of modifier without changing position of the child?
Currently, when I add a child-of modifier, the child jumps to the parent's head and rotates.

Why is that?
And more importantly, can I have blender not do that and keep the bone where and how it was, instead?
(I just want to "parent" a second armature to the first as if I had one armature where I parented with keep offset.)

Yes, in the constraint, click on the Set Inverse button. By default, the child will stick to its parent, but if you click Set Inverse it will keep its original position (like a Parent > Keep Offset).

A little explanation as to what Set Inverse does might be nice here.

ok it's done   ;)


text:
How do i set Cycles render to GPU?
Im still very new to blender and would like to know how i can do this i cant seem to find any options for it.

Possible dupe.. http://blender.stackexchange.com/questions/7485/enabling-gpu-rendering-for-cycles. What card and os are you using?

Im running Win 7 home premium 64 Bit and a GTX 770 Nvidia

Please see the question I linked to, provided you have the latest drivers and an updated copy of Blender it should help you get up and running.

I switched it to CUDA but it will not allow me to save the settings now

Ctrl + U should work to save your config. Try resetting to factory default settings then saving it again.


text:
How can i make more realistic lighting/materials
Im looking for tips to create more natual looking light like you would get from the sun and tips on making my materials look a little less fake looking the image below is using the glossy and glass shaders but still looks to un-realistic.

Try use a HDR image texture: https://www.youtube.com/watch?v=_4IN4V1SM-A You may also add some Ambient Occlusion in a World tab, since your image is a bit dark.

You'll need something to be reflected.
If your world is just black, there is nothing to be reflected by your material.
As suggested by Gonzou, I'd try a HDR / IBL image.
Alot of those Images can be found here:
http://www.hdrlabs.com/sibl/archive.html
Those will lighty your scene / object and so there is something to be reflected.

Speaking of materials i'd suggest this tutorial:
https://www.youtube.com/watch?v=rzXNZkEoTAk
It's quite helpful to get a bit more interesting looking materials.

Fresnel is pretty important also...


text:
How do i cut a hole into a mesh?
As you can see i added three torus shapes to the center of the model but i would like to cut out the insides of those torus to leave circles in them how can i do this?

Unfortunately this question has been closed as a duplicate, while the answer to the duplicate question is not sufficient for your question. First of all, select a face of every torus by shift-right click. Keep pressing Ctrl-numpad + until all torus shapes are completely selected. Press P -> selection to seperate the torus shapes from the object. Go to the modifier panel, and add a boolean modifier. Set operation to union and object to the new torus object. Go to object mode and apply the modifier. Go back to edit mode, where you can select and delete the necessary faces to create a circle.


text:
Removing creases with sub divison
Im trying to create a cyclinder with the bottom and top rounded but when i use the Sub divison modifier it leaves these creases at both ends and if i use a loop cut to smooth it out it makes the object to flat at both ends and not rounded how can i fix this?

Related - https://blender.stackexchange.com/questions/734/how-to-smooth-shade-an-object-while-retaining-hard-edges

@MrZak I think he is trying to not have sharp edges.

@PGmath yes, probably it was better to say the main thing is topology.

Those ugly creases are caused by the n-gon cap.  The Subsurf modifier works best with quads and doesn't work well at all with n-gons.
Here are two alternate methods of filling the cap which produce quads, and thus much better subdivision modeling.

The first example was made by selecting the n-gon face and then hitting E (exturde) and then S to scale the extrusion inward.  You could move the extruded part up to make the top less flat.
The second example was made by joining half the opposing vertices, making a quad fan.  This could also be done by using the Grid Fill option.  Again, the central vertex could be lifted up to make the top more round.


text:
Why does my cycles preview cause my PC to freeze
Whenever i switch to the rendered view my whole PC freezes every so many seconds is there something not right in blender or is my PC just not up to it anymore?

Even with the default scene?

Even with the default scene yes. My PC is roughly four years old now so i do believe it might be time for a upgrade?

Is the whole pc freezed or just Blender's window? Since wich Blender's version did you experienced this problem? Are you using CPU or GPU? The average-4-years PC should be able to handle the default scene

Im using GPU render i will switch to the render preview it still work for about three seconds before freezing around about ten seconds and so on and so on.

How does it respond to CPU? GPU might have issues IDK.

It seems like your CPU/GPU can't handle Cycles.
Cycles samples the scene as fast as it can, I think your computer freezes while trying to sample the scene:
 (You can find this at the top of the 3D view.)
I suggest trying a simpler scene and seeing if it stops freezing on that one. If it doesn't, I would believe there might be a problem with your CPU/GPU or it is not supported by Cycles.
It may just be a problem with having the wrong computing device selected. If you have a supported GPU you can select it under User Pref > System:

And then selecting GPU under the rendering tab:

And if that still doesn't work, try selecting the CPU instead.
And if all that fails, I recommend getting a better GPU/CPU. You can compare and find the best one for your price here: http://olivieramrein.com/2012/02/25/blender-cycles-best-hardware-using-the-benchmark-spreadsheet-analysis/

I just experienced this, and in my case it has been caused by having 5x View-mode subdivision on a UV sphere. Probably not what caused it for you, but this info might help someone else.


text:
How can i fully remove fire flies?
I turned off Reflective Caustics and Refractive Caustics but my image is still full of fireflies how can i fully remove them?

That looks mostly like noise to me, try cranking up the samples.  254 isn't much for an interior scene.

The samples are at 254 but its still coming out rather noisy.

That's what I am saying, interior scenes are pretty noisy so 254 isn't much, try increasing it.

Note that the render samples are set to 254, while what is shown on screenshot is preview render (Shift+Z), controlled by preview samples; so that image is rendered using 10 samples. To see how image looks exactly on 254 either render it or increase preview samples.

to reduce them as much as possible,
-set clamp indirect and direct to values near 1 or 2
-use standar lamps as much as possible, geometry lit obejects tends to generate more noise, on most situations.
-try also using branched path tracing to test which rays are the ones generating the noise.

What I see in this image is noise, not fireflies. What you are seeing is a preview render at only 10 samples, which is nowhere near enough for an interior scene. Simply try rendering with more samples. You may need 1000 to 5000 samples to completely remove all the noise.


text:
How can i let my rigid body simulations continue for longer?
My timeline will only go upto 350 frames then the simulation will end. I have tried to increase the end time for it but it will not work is there another way i can do this?

You can change the start and end frames of a rigid body simulation under the Rigid Body Cache rollout of the Scene properties tab.


text:
How do i change the collision box position?
As you can see in the picture i have set up a small resized cube and made it a ridgid body however the collision of it is not in the same position as the cube how can i move it to fit?

From the screenshot it looks like the origin is off center (the small yellow dot in the center of the collision bounds box). In object mode select your cube and in the tools panel, under the 'Tools" tab click the 'Set Origin' dropdown and choose 'Origin to Geometry'. That will snap the origin back into the cube where it belongs.

@Rei Welcome to the site :) If this answer answers your question, consider marking it as accepted.


text:
Blender game engine touch screen
I want to make a touchscreen application in the blender game engine.
it's basically an information kiosk type application
Does anyone know of any addons that can detect touch events?
I think I can get by for now with Mouse events, as it's a single touch application.
But any advice or would be appreciated.

You might be able to leverage Kivy's event processing with Blender's game engine. It's an entirely Python based framework.


text:
Blender scripting- How do I link Nodes?
Im trying to figure out how to link two nodes in Python.  So far Ive found some pretty limited documentation here, but it gives you no idea what arguments the operator takes or how to use it.
So for example lets suppose that I wish to create a diffuse node, a glossy node, and connect them to a mix node which is connected to the material output.
bpyops.material.new()
bpy.ops.node.add_node(type="ShaderNodeBsdfGlossy", use_transform=True)
bpy.ops.node.add_node(type="ShaderNodeBsdfDiffuse", use_transform=True)
bpy.ops.node.add_node(type="ShaderNodeMixShader", use_transform=True)

How do you connect these nodes? And am I doing this right?

This is done with links.new(), see http://blender.stackexchange.com/q/5413/599


text:
How to keep a bone in-between other bones?
In my rig I would like to keep a bone in-between two other bones, so it is always in-between the two bones when rigging.

In the screenshot, the bone should always be between Bone 1 and Bone 2 when they are posed.
Is this possible? I tried looking through the different bone constraint, but can't figure out to use one or more of them to accomplish this result.

You need 4 constraints:

Copy 100% Location from 1st bone
Copy 50% Location from 2nd bone
Copy 100% Rotation from 1st bone
Copy 50% Rotation from 2nd bone

But if the reason for the middle bone is to fix the deformation, you should fix that in the weight painting. If the reason is to keep the volume of the middle part, then it is ok.

Thank you. This solution solves my problem. The reason was to keep the volume. I've been trying to figure this out for a couple of days now.

You can use a combination of copy location constraint and stretch to constraint with a bone connected between the bone 1 and the bone 2. It's easier to explain with a blend file  :

Thank you for the file. I can see how the constraints were used to accomplish this now.


text:
Cloth Bake: Save frames in timeline as shape key?
I've run a cloth bake. It runs from frame 0 to 60. I can see the results in the timeline from frame 0 to 60. I want to save various frames as a seperate shapekey for the cloth. For example I want to caputure the result at frame 20 as a seperate shapekey, and capture the result at frame 40 as a seperate shapekey.
Is there a way to do this blender?

Make sure the "NewTek MDD format" add-on is enabled in the user preferences, and then select the object and go File > Export > Lightwave Pointcache (.mdd).
This will save a mesh cache file of the cloth simulation. Then you can remove the cloth simulation entirely (or just disable it if you might want to make changes later), and then import the .mdd file you just exported (File > Import > Lightwave Pointcache (.mdd)).
This will apply each frame of the simulation as a separate shape key on your object, and animate them on and off automatically for the appropriate frames.

You can then delete all the shape keys that you don't want and remove the animation by right clicking on them and choosing Clear Keyframes.
If you have a few too many shape keys to remove by hand, a little bit of python can save a lot of time:
import bpy

obj = bpy.context.object

keys_to_keep = ["frame_0020", "frame_0040"]

i = 0
for s in obj.data.shape_keys.key_blocks:
    obj.active_shape_key_index = i
    if s.name not in keys_to_keep:
        bpy.ops.object.shape_key_remove(all=False)
    else:
        i += 1

Ok, thanks. I'll try out what your saying later on. I'll update this post on the results. It looks like a solution that will work

Ok, I tried it out. It seems to work great. However, I found if the animation is not 100% complete from the start to end, when exporting it causes blender to hang. For example if the time line is set to go from 0 to 100 frames, and you only have run the animation to 50 frames, then when you do the export, Blender hangs up. Other than that, the plug in is working good.

You can choose the frame range at the bottom left when exporting - it defaults to match the scene frame range, but you can tell it to stop at frame 40 if you want to. If the simulation for a certain frame isn't cached or baked when you export it, it'll get calculated during the export (which is why Blender hangs).


text:
Timeline keyframe not showing when changing to different transform rotation representation
I created an animation, and created key frames when the rotation mode was set to Quaternion. Now I want to display the transform in easy to understand XYZ euler. The problem is, the rotation box does not indicate the keyframe exists in this mode, because the values are not in yellow.

Do I need to re-enter the key-frames again?
I would think I shouldn't have to since the XYZ is just a different representation of the Quaternion.

The quaternion, euler and axis angle rotations are stored as three different properties, the rotation_mode is used to determine which property is used for rotation.
Yes you will need to re-create the keyframes if you want to use a different rotation mode. You can choose the quaternion rotation mode, move to a keyframe and then change to euler and add a keyframe to the euler values as they will then match the values of the quaternion, then repeat for each keyframe of the rotation. If you have a lot of animation to do then a python script could be used to automate this.