How to unify face and vertex normals I created a model in another program, and imported it to Blender to map the UVs. Parts of the model are symmetrically flipped mesh planes. I noticed in Blender that the mirrored objects display as darker, and on further checking, I find that the face and vertex normals are in one direction and the "vertex-per-face" normals are opposite.

I've tried the Recalculate Outside and Flip Normals commands, but that just inverts them without unifying the direction. How can I flip JUST the "vertex-per-face" to get them all in the same direction, as they are in the original un-mirrored object that was copied?

Those purple lines are normals generated by Auto Smooth. It has checkbox under the Object Data tab > Normals rollout. I would recomend you just turn that feature off. If you want some complex shading, you should generaly use Sharp Edges with an Edge Split Modifier.


Evaluated mesh data from edit mode Is there a way to get evaluated mesh from within edit mode without using to_mesh?

depsgraph.id_eval_get(obj).data works only from object mode.

Currently to_mesh is the only way of getting evaluated mesh from within edit mode.


How to render an environment to a Cube Map in Cycles Usually, when I create environment maps I do it in Cycles. I render out a single equirectangular image, and it's easy.
But recently I find myself creating content that needs to work in Blend4Web, which means using the Blender Internal schema.
So the way BI handles environment maps is: It expects a cube-mapped texture with the six faces placed as follows:

The above image is from the Blend4Web Manual.
Here is another reference to this cube-map format: A rather old Blender Internal tutorial. (It lists incorrect Z axis values)
Cycles does not offer a cube-map option for panoramic rendering:

Currently I am using a custom .blend I made to Cycles-bake the equirectangular environment map onto a UV-mapped "round cube" and the cube's faces are animated to unfold into the correct layout, which I can then render - but the seams are visible, and I think there must be a better way of doing this anyway.
How can I render out such a cube map directly from Cycles?

Here is how I solved this - and there's a download link at the end.

(Coordinates written as 1,2,3 refer to X:1 Y:2 Z:3, for example.)

Setting up the "Cube Cam"

Add a Camera and an Empty at location 0,0,0 and set rotation of each to 90,0,0 degrees. If you choose "Arrows" for the Empty display type it may help avoid confusion later.

Parent the Camera to the Empty. The reasons for rotating and then parenting in this order are so that the Camera's coordinates will match the reference image above, and so that the Empty's -Z will point in the same direction as the Camera's when the Camera is facing forward.

The Empty allows the Camera to be easily repositioned, because the Camera's keyframed rotation will be relative to the Empty, not the World.

Set the Camera's Focal Length to 16mm (or 90° Field of View). This is necessary for the "faces" of the cube map to touch exactly.

Set your render dimensions to a power of two, such as 512, 1024, etc.

Leave the Start Frame at 1. Set the End Frame to 6. There will be one frame for capturing each direction of a cube's faces.

Keyframe the Camera's rotation accordingly in these frame numbers:

90, 0, 90 (left)
90, 0, 180 (backward)
90, 0, 270 (right)
0, 0, 0 (down)
180, 0, 0 (up)
90, 0, 0 (forward)

Optionally, you can add a guide object containing text labeling the directions (visible in the viewport, but not in renders), and parent this to the empty as well. And you can group these three objects (Camera, Empty, text guide) together, so that they can be easily appended to other .blend files.

At this point the Cube Cam setup can be appended into any .blend file.

After appending, from within the new .blend:

Go to frame 6, where the Camera is facing forward.
Make sure the Cube Cam is the Active Camera, by selecting it and choosing View > Cameras > Set Active Object as Camera.
Use the Empty to position the "Cube Cam".
Set the frame range from 1 to 6, and specify the Output file name to be something like "cube_tile_".
Set the Render Dimensions for X and Y to a power of 2, for example, 1024x1024. This will be the resolution of each of the 6 tiles.
When ready to render, click the Animation button.

This method of rendering directly from the environment scene is quick and easy, but there is still some distortion that shows up, revealing the cube shape of the cube map if you look closely. The way to eliminate this is to first render an equirectangular (or mirror ball) environment map, and then render that to a cube map.

Equirectangular Map to Cube Map

First, let's review the steps for creating an equirectangular map to begin with. It's pretty simple.

Step 1: Adjust the Camera settings to be Panoramic, then choose Equirectangular for the type.

Step 2: Set the render Resolution so that X is twice that of Y.

Choose a resolution that is significantly higher (perhaps double) the pixel detail of what one of the final cube map's tiles will be. So if one tile of the cube map will be 1024x1024, and two of those tiles will be stacked on the Y axis (doubled), then doubling that to 8192x4096 would give 200% pixel density on Y (and 266.6% on X because of the difference in ratio).

Here's a diagram to make it easier to understand:

Render!

Now, back in the Cube Cam .blend file, in the World context  click the Use Nodes button and go to the Node Editor for the World. Create the node setup for a panoramic environment:

You won't need many samples for this. I did some testing and found that no sample count higher than 20 produces any visible improvement, so I recommend rendering at 20 samples.

Save this .blend file to reuse later.

In the Environment Texture node, click Open to load a specific panoramic image, and render it out as an animation to 6 cube map images.

You can use an image editor such as GIMP, or Blender's compositor to combine the 6 image tiles into one cube map image. Two advantages of doing this in the compositor are that you won't need to rely on other software besides Blender, and you won't need to manually position each tile every time you create a cube map - once you've set it up, it's an automated process.

Edit: While it's really cool that Blender can composite tiles into a single cube map, I have since discovered a faster way to do this using imagemagick. Example syntax:

convert \( 0001.png 0002.png 0003.png +append \) \
        \( 0004.png 0005.png 0006.png +append \) \
        -background none -append +repage cube_map.png

If you still want to do it all in Blender, continue reading...

Putting it All Together With Compositing

In a new .blend (or new Scene, if you prefer), create this node setup in the Compositor:

Let's examine it in more detail.

The Value node for "Tile Size" should be set to the X and Y resolution of one tile (or you can think of it as one "face" of the cube map). So the final image resolution should be this amount times 3 across (X) and this times 2 down (Y). For example, if one cube tile is 1024 pixels, the render resolution should be set to 3072x2048. You don't even have to do any math in your head - just type 1024*3 into input field X, and 1024*2 into input field Y. Blender will calculate it for you. (Okay, maybe 1024*2 is easy, but you can surely see how this shortcut is useful.)

Each Image node is set to load a tile of the cube map (1~6):

These six nodes determine the position of each tile in relation to the whole image, or "canvas":

Set the Multiply nodes to the following values:

The Alpha Over nodes are just for layering the tiles, while preserving transparency (in case you ever need to composite a cube map that contains alpha data). These can be left at their default settings.

A Scale node, which I have labeled "Get Size" takes in the image data of one tile, then scales it to the size of the render (which, as mentioned, should be three times across and two times down in proportion to the size of one tile).

That image data is then sent through a Set Alpha node because the image data is not necessary - all we need it for is getting the correct dimensions. What we get out of the Set Alpha node is a transparent "canvas" that is the size of the render dimensions.

So that's basically it. You can render the image and it will be composited!

I've published a toolkit for creating cube maps to Blend Swap under a CC-0 license. You can Download it Here.


Promblem with creating sharp glossy glossy material for metal drinking bottle I'm trying to recreate this drinking bottle

which as you can see has quite a sharp reflection, so I first tried to use just a sharp glossy shader

which doesn't look like any real object at all because it doesn't interact with light really.
So instead i tried two things: I first mixed it with a normal glossy shader, which just created a weird high light, so then I mixed it with a diffuse shader which created a better result, but looks still is a little off, especially on the edges

So, now to the actual question: how could I create the sharp reflection of the bottle, while still letting it interact with light normally, without creating diffuse high lights?

First of all: if you want to have reflections on your bottle you need something in your scene to show in the reflection. as of now, you just have your light source, a grey plane and the ground background. that's not ideal to check how your material reflects things. (read the answer here why those wavy reflections appear).

I'd recommend using an HDRi to light your scene. here you can grab some for free.

Material:
I'd recommend using the principled Shader. it uses Fresnel to make the reflectiveness be dependent on the view angle.

that's a pretty basic setup, but you can work from there. I'd also recommend using a normal- or displacement map to mimic the bumps of your bottle.


Shader receive light cast shadow with its color I'm trying to create shader like this image of dice.

As you noticed, there is some shadow from dice which cast color of dice, how can i create something like that.

Enable Refractive Caustic + Glass shader

It's not shadow, it's light!

The effect you see in the picture is a phyisical effect called "caustics".

White light get into the dice volume. There's in a certain quantity of light that is absorbed by the dice's material. Th red component is not absorbed, so is free to get out of the volumes and reach into the camera, letting we see the cube red (different shades of red because not all the cube surroundings are full white light sources). Not all the "filtered" rays (made of red light only) go directly to the camera, some of them also reflected on the plane surface coloring it a bit.

Blender Cycles can emulate that effect if you enable the Caustics by ticking the check boxes near the cursor in the picture below:

First of all you must use a Glass shader, or the light will not penetrate your object's surface.

Without Caustics, the object project a soft shadow on the opposite side of the light source. The plane is grey, so the shadow will result in a darker grey because less light can reach that points.

Refractive Caustics option takes in account the light that travels through a material.

In addition, the base plane from the photo is sligthtly glossy (you can almost see the dice mirrored) so I would suggest to use a mix of a diffuse and glossy shader in order to get some color bleeding also on the sides where the caustics aren't.

Final result:


Where do I go to add paths(curves) in Blender 2.77? I only see the option to create mesh. There's no "Add" tab as presented in most tutorial videos that used older versions of Blender. Any help?

You are probably in mesh editing mode (which allows only to add meshes)

I presume you see that :

Go back in object mode :

So you have the add menus :


Is there a good way to join these two objects up? Blender Newb here. So take with a grain of salt. : )

I'm learning blender for my job so I'm trying to 3d out some of our past work. I've got this monument sign I'm trying to do to teach myself.

In the picture I've got you can see there is the horizontal curved blue object and the vertically curved purple. I'm trying to get these two curved object to meet at the yellow line to form a doubly curved edge.

Is there anyway to do this without haven't to piece the vertices together one by one?

Let me know if you need more info.

There are a few approaches I might use.

Boolean modifier is the most straight forward route - make the blue and purple parts larger so they overlap, and then use the intersection operation. A route like this usually works well in CAD software, but it's often not the best in Blender.

A better approach in Blender is using its mesh editing tools like proportional editing (the o key in edit mode).

Start with a plane, rotate it to face the front and press TAB to enter edit mode.
Use S + X to sale in one axis and S + Y to scale in the other, and G to position it into the right space.
Subdivide it using loop cut, to get a bunch of edges along where it needs to curved (use the scroll where to increase the number of cuts):

Select the one or two vertices in the top middle (using RMB and SHIFT+RMB if selecting two). Press o to use proportional editing mode. Press g to start moving the vertices. Press z to only move on the Z axis. Use the scroll wheel to increase the size of the white circle so you start moving all the vertices at once. You can try SHIFT+o to cycle different fall offs ("Inverse Square" worked best for me):

The bottom is also curved. We'll fix that later.
Now do the same for the other axis from the top view (press 7 on the numpad), but this time select both the top vertices and bottom vertices. Again, use g to grab, and now y to constrain to the Y axis.
Let's fix the bottom edge. Turn proportional editing off using o. Switch back to front view using 1 on numpad. Select the whole bottom row by holding ALT and clicking and edge (or B and drawing a box around it). Press S to start scaling, z to constrain to the Z axis, and 0 to scale to zero.
The whole thing may need its position fixed now. a to select all and use the on screen widget to move it around one axis at a time

To finish it, and add the ridge at the top, you can use extrusions:

Select the top row using ALT+LMB
Press e followed by y and drag the mouse to extrude outward along the Y axis
Press e followed by z and drag to extrude upward along the Z axis
Press e + y again to extrude it inward


How would I make perfect diagonal edges in a rectangle In the pic attached I'm trying to make a perfect diagonal edge across the face as I've so beautifully illustrated in MS paint. I've tried subdividing and moving the vertices along the edge so that they look close enough, but 1) they aren't the exact distance and 2) I have to create the vertices on the opposite diagonal side which is a pain.

And I have tried using the ruler/protractor tool but that's been fairly useless so far because 1) it disappears when I go back into edit mode so I can't place my vertices exactly where it was, and 2) you can't enter exact values in it, so when you get down to a measurement like 3.4000005cm you'll never be able to match it on the other side (if that makes sense).

Any suggestions to go bout this? Theres probably some stupid easy solution to it but I've been at this for HOURS and still can't figure it out.

One way to get diagonal based lines like that is to use Offset Edge Slide which will add loopcuts on both sides of the present edge. However one edge is needed, so select opposite vertices and press J to join them with the edge and split the face.

Then select the edge, open Toolshelf (or press Ctrl+Shift+R) and drag the mouse for the effect.

Regarding the edge you create for this tool to work.
You can dissolve it afterwards but note that it creates quite horrible Ngon in the middle which is better to avoid. It all depends on the purpose of the model but it's best to stay away from this geometry to avoid any problems later on.


Render Crash / CUDA error Hey all,

CUDA error: Out of memory in mem_alloc_result, line 850

I'm unable to render a model I quickly put together (Is it considered simple?) When I attempt to render the scene, my system will completely crash/lock up or blender will force quit.

I'm using blender 2.8 with cycles as my render. I have GPU + CPU selected underneath CUDA in the user prefs and am trying to render at 1080x1920.

My hardware specs: GeForce GTX 1070 8gb, 16gb ram, Intel i7-7700 @ 3.60ghz

I'm confused because I feel like my model is basic. I have a sunlight lamp and materials using only a diffuse.

https://drive.google.com/file/d/1fRTEdryDYASwWVkwFRNJOR1_GJ7NGgyA/view?usp=sharing

Can anyone point me in the right direction on getting this solved? I've uploaded the blend file here if anyone would be kind enough to inspect what's going on. I'm new so I'm just trying to figure out if this is user error, or if I need a better computer!? Thank you so much! -K

Out of memory errors can always be traced to the same source:

  Your scene and render settings exceed the resources available in your computer.

You've set subdivision surface settings for Render to a high number, some have it set to 6!

Do you need that many polygons? There is a huge penalty for using such large values:

For every subdivision level the number of polygons increases exponentially.

At level six you are generating 4225 extra quads for every quad of the original object... Enough to choke most computers.

Use proper modeling and less subsurf to describe the shape of the objects. You should rarely need more than a subsurf level of 3. Straight shapes with flat faces might not need any subsurf at all.

Read: Blender render crash when using subsurf modifiers..

Also keep in mind that denoising will use a lot of memory, as it has to keep information from all the surrounding tiles.

Read: Why does Denoising take up so much memory?

Try reducing the tile size as well.


How to apply the ocean modifier to get an animated object? How to apply the ocean modifier to get an animated object, (not a static which have  froze in a single phase)?

Export the mesh as an .mdd file format.
Remove any deformation modifiers on the object. Apply the Ocean modifier. The object needs to have same amount of vertices as while exported but strip down any animation on it.
Add Mesh Cache modifier and import the file into it:

Now you baked the object's animation. Tadaa!
You can also apply your modifiers as a shape key. To do this for every frame you need to do some scripting though.


How do i frame selected objects in non-local viewport? Is it possible to frame selected objects in my viewport (see image), i mean every time a frame selected all the other non selected objects disappear? and if this is possible what is the feature name to create hotkey.
I would be very grateful for any tips, suggestions or help in this matter. Thanks Stewart

I'm not sure if this cover your needs, but you can enable addon Stored Views. Located in 3D View > Sidebar (N)
From there you can save any view or camera view and switch between them.


Model gets squished because of Spline IK Recorded a video of the issue happening:
https://youtu.be/LFoUrE1OHwQ

Added a gif in case the video goes down:

The head of my character gets squished when one of the controls for the Spline IK is in certain position. The squish gets diminished if I turn on Y Stretch in the modifier but I need it to have 0 squish going on.

This is not the first time this happens, so I must be doing something wrong while rigging or there must be an option I don't know about... Any ideas?

This is just a workaround as this behaviour seems more like a bug and this solution can break the position of the controllers depending on your setup, but you can set the Spline IK constrain on a copy of the bone chain and use it as an intermediary mechanical rig. I'm not at home right now so I'll upload later. But the setup is simple:

Make a copy of the chain that receives the Spline IK.
Set it up so it receives the Spline IK instead.
Reparent or reconstrain the Control Rig to the new chain.
Remove the Spline IK constrain from the original one.
Add copy rotation constraints (and an optional copy location constrain to the root of the chain)  from the new bone chain to the original one.

Now your chain receives the rotations from your controllers but preserve their scales.


Intersection of beveled curve object I am just trying to create a simple outlined heart for a 3d print job. So I modeled a curve for the heart and added a circle as bevel object. The result looks like I want it to have..

But switching to wireframe mode shows that the resulting object has intersected vertices / faces which will cause my 3d print to fail...

Is there a simple thing I am missing on my task to just get the outlined object without intersections?

Here is what it looks like and where my problem is:

I tried to convert the result into a mesh and apply a skin modifier which took ages to calculate and did not work as desired. Also the solidify modifier did not work...

Thanks a lot for your comments!

This may still involve too much hand-editing for you..

Create your profiled curve to produce a deliberate overlap with its reflection - (you're looking for a good  clean cut down the Y axis) .. here the mirror modifier is only there to vizualise the result

Having converted to mesh, in an orthographic view, Use the knife tool, constrained, to cut through the mesh (K),(C),(Z) Rip the selected edges(V, select the excess faces, (mouse over, L), and delete them.

Add a mirror modifier with merge and clip, and in edit mode, bring the halves together until they just snap, and draw them apart again slightly.

There may still be a few editing decisions on the seam, after applying the mirror modifier, removing tris, bringing some vertices together, but not many, if your mesh is not too dense...

and the result is quite clean.


Can I rotate objects the with 3 orbits around it like in Unity or SketchUp? I have a really hard time percieving depth on screen so after I move or rotate an objects it ends up anywhere but in the place I wanted. The problem with moving the object is easily solved by holing the axis and moving the object along it, but I can't find anything like this for rotating. Is there a setting or an addon I can use to have 3 orbits around the object so I can rotate them instead of directly rotating the object? I tried rotating objects while holding x/y/z, but that didn't help much.

If you press R the object will rotate on the view axis. If you press R then X, the object will rotate on the X axis only. If you press R twice it will rotate on both axis except the view one. If you press R and then Shift + X it will rotate in both axis except X.

If you set the curve in the selector on the header of the 3D view you will have your "Rotators" around the object.


How to edit 2.8 UI icons? Blender 2.8 comes with a set of monochromatic icons which seem to be stored inside datafiles/icons/*.dat.

How can these icon files be edited/replaced with other/custom icons?
Where is documentation about the icon format and how to compile/generate these *.dat files?

Summary

(Not official: based on own research)
Two kinds of icon
I think that "the monochromatic icons", the small ones used in menus etc, are not present as separate files in the compiled releases of Blender because they are compiled in the binary code. By the way, they are not necessarily monochromatic: this isn't "forced" in the code, it's just a design choice made for version 2.80.
The ones that you find under datafiles/icons/*.dat, that come with the built releases, are the (usually colored) ones that are used, for instance, in the tool shelf (see pic below)

So which ones do you want to change?
To change the small "menu" icons
you will need to recompile blender from source after having updated the blender_icons16/*.dat and blender_icons32/*.dat files in the $SOURCE2.8/release/datafiles/ folder, and to do so you must first edit the vector image $SOURCE2_8/release/datafiles/blender_icons.svg

and then update and make the icons, roughly following this guide (a bit old but I think still valid)
To change the bigger "tool" icons
I'm not sure how to change the (usually) colored ones that are not compiled into Blender (i.e. the ones that are present as separate .dat files in the downloaded blender builds). They seem to be generated via this blender_icons_geom_update.py script that pulls the design from a icon_geom.blend file that is present in Blender's Library Resources SVN repository.
I've found this message that confirms that the process is currently not documented:

«Currently, it’s just a .blend file that generates the icons.

[...] Once we are more finished with the tools we will probably document how people can do this, if anyone wants to make new icons, or change them.»

William Reynish (billreynish), Apr 28 2018

Documentation?
There is anyway another script: blender_icons_geom.py that contains a documentation of the pixmap format which could be what you are looking for:
This is a simple binary format (all bytes, so no endian).

The header is 8 bytes:

:0..3: ``VCO``: identifier.
:4: ``0``: icon file version.
:5: icon size-x.
:6: icon size-y.
:7: icon start-x.
:8: icon start-y.

Icon width and height are for icons that don't use the full byte range
(so we don't get bad alignment for 48 pixel grid for eg).

Start values are currently unused.

After the header, the remaining length of the data defines the geometry size.

:6 bytes each: triangle (XY) locations.
:12 bytes each: triangle (RGBA) locations.

All coordinates are written, then all colors.

Please note
To answer your question I have just made a short investigation across the repositories and forums, but I have never tried myself to edit these icons.
One thing is for sure: if you do something like
cp brush.gpencil_draw.draw.dat ops.mesh.bevel.dat

the "bevel" tool actually becomes a little pencil (this proves that the "tool" icons are read directly from the datafiles/icon folder).


I want to contribute my own codes I  want to contribute my own codes to the blender community. How do I do this? Can somebody help me out?

If you want develop python addons, build one and advertise it on forums such as https://blenderartists.org/forum/ (there are probably many other good places as well, this is just what I use). Make sure you include good documentation on what it does and how to use it, or people are less likely to try it. If you want to sell it, https://blendermarket.com/ provides this option.

If you want to contribute to the main development of blender, you should read through https://wiki.blender.org/index.php/Dev:Contents first. After that, you can discuss things on the developer mailing list or on IRC (see https://wiki.blender.org/index.php/Dev:Doc/Contact for more details) and submit patches at https://developer.blender.org/


How do you add single free floating vertices as primitives at a given XYZ coordinate postion I am sure this question has been asked before but I have searched and searched and I can't find it (I even vaguely remember asking it in 2013 5 years ago).

I am easily fooled by perspective illusions, and prefer to plot rather than to sculpt, in 3D, because of this.

Is there a way I can make single vertices a primitive in the primitives menu, like that darn monkey (long live suzie), so that I can place a bunch of points in a row with minimum effort, and then connect them and create edges and faces at the end?

I vaguely remember reading about a potential plug-in solution, but that was quiet a while ago, and I can't find my source, so I'm totally lost

It was the Extra Objects addon.

I was going to use it to create a point primitive, so I misrembered it and used the wrong keyterms while searching for it.

I did have a neat/convenient idea while trying to figure this one out, I'm not sure if that's a seperate question or just an alternate solution though (about the point plotting box).

So if something like that exists [the enmasse point plotting box], feel free to comment it to me, if it doesn't then I guess I'll have to ask/or/find some more questions later [about making plugins, and creating a tiny little app/menu for that in blender]


How to invert colors in the image sequence editor I want to create a multiply style replace effect but the reversed color scheme. easiest way I can think of doing this is to invert the colours of the strip I am working with, but I cant find out how to do so. In this image, I would like the back to be the fill of the text and the text to be black.

Just add a Curve Modifier to the Strip and "invert" the diagonal line by inserting two points top-left and bottom-right:


Every time I add a new mesh it goes behind the background image, how to make it on top? I have a background image on the side view angle, I added a new mesh to model a part of my image but can't for the life of me put the background image behind the mesh...
Edit: Solved it, Depth parameter of the image was set to Front, I have set it to default and it took care of the issue, thank you

New objects are created at the location of your 3D cursor. You can Shift+ Right-click to position your cursor. Alternatively, edit its 3D corrdinates in the 3D cursor popover menu:


How to use Python script to generate many lines in Blender and then animate line color and thickness? I'm very new to Blender and to writing Python scripts for Blender. For the project I'm working on, I'd like to be able to create 10,000+ straight lines (see image below) and animate them so that their colors and thicknesses change (individually) over the course of the animation.

What is the most efficient way to create the lines using a python script? My understanding is that I can't use simple edges because they don't have any thickness.

I tried making the lines as Bezier Curves, however, the script couldn't run in a reasonable amount of time once there were over several thousand lines/curves.

Any help on how to create a large number of lines like this would be very much appreciated.

You can do this easily with Animation Nodes.

For connections we need initial locations and final locations, So I'm using planes i.e vertices location but you can choose anything (Sphere/Cube mesh, number of objects etc). Now, to connect each vertices a plane (say A) to all vertices of a plane (say B), I have made two "Subprogram Loop" Nodes which basically make individual sets of vector lists. Then using using "Spline from points" node make the connections from those vector lists. In the "Curve Object Output" node, you can animate any parameter (Bevel depth, Bevel Start, Bevel End etc) of a curve.

Here is, examples with two, three planes and with a icosphere, but you can add any number planes (or other mesh object). To make more complex and control connections, you can also use other nodes like "KD Tree" and "BVH Tree" which are available in Animation Nodes.

:)

Here is Node Tree:-

Here, for two planes and subdividing them:

For three planes, so on:

For different type of objects:


How can I join these two meshs together? This question refers to my previous question 'How to transform a plane into a honeycomb?' I'm trying to join the hnoneycomb with the face surrounded by a red border. Thanks for your help.

This can be done using the Pivot Point, Snapping, and View Transforms.

We start with the honeycomb, and the target mesh in random positions (the line of green faces are the target faces):

Next, we want to do a little setup.

Set the Pivot Point to cursor, and set the snapping to vertex, and change the type from closest to active.

Note: You don't need to enable snapping, when you want to use it simply hold down Ctrl while doing a transform.

The first step is going to be getting one corner of our honey comb to match up with one corner or our target face

to do this, select the honey comb, and then Shift select on vertex along its one of the outer edges so it appear white:

Now using G-Ctrl, move the mesh to align with one corner of the target:

Next, select one of those two vertices, and use Shift-S>Cursor Two Select to bring the cursor to that vertex. Now if you use R to rotate, you can see that the mesh pivots around that point.

In order to make this a little less visually confusing, free hand rotate the mesh around the cursor until it is roughly in the right place. This doesn't have to be exact.

Next select a face along the target row of faces:

and then hit Shift-Numpad 7. *Whoosh* you world has been turned upside down.

What has happened is that the view port as been aligned to the face. We can now use R to rotate around the view port axis, and snap our mesh into place along that axis (carefully note which vertex is active):

Select that face again, and this time use Shift-Numpad 1 to go into a view that is aligned to the front of the face.

Repeat the similar steps as above:

Finally, the honey comb now lines up along the back of the line of faces, however, it is still at an angle. TO fix this last one, select one of the faces along the honey comb that runs paralleled to the line of faces:

Try Shift-Numpad 1, or 3, until you get a profile view, and then snap into place:

Your honey comb is now aligned.

Note: I used View Transforms for this example. I was originally going to use Transform Orientations, but realized that they were needlessly complex. However, if you do lots of this kind of stuff, they are worth learning about.


Fluid Simulation Not Working, updated software and have done hours of research Running 2.92
Blender user since 2019.
I'm trying to fill a glass with liquid.
I can't get the fluid simulator to work consistently. I've been fiddling around with it and had limited successes, but can't repeat them with the exact same settings. When it has worked, the the liquid isn't visible when rendered and I can't figure out how to add a material property.
I've gone as far as to uninstall and reinstall the software.
File host on OneDrive
https://1drv.ms/u/s!Agn7HNH2KWg_bkA85v1K7lw-GeA

disable guides

change resolution division to 90

change cache type to modular, check resumable

free data

bake data

check mesh

bake mesh

you get:

blend file:


creating mesh on an isosurface I have a function like $f(x,y,z)=\text{constant}$. It is not straightforward to solve $z$ as a function of $x$, $y$, and $\text{constant}$ analytically.
So, I want to choose a Constant value, draw that isosurface, and create a mesh on the surface.

1) is there any way to draw a function like $f(x,y,z)=\text{constant}$ without solving it?

2) If I want to set a range for all $x$, $y$, and $z$, how can I do this?

Thanks in advance for your reply and comments.

Cheers

The following is a workaround rather than a complete solution. It doesn't answer your actual question, in that it doesn't generate a mesh representing the equation, thus you can't use image textures or do more elaborate things, like sculpting or rigging. It renders a visual representation of the equation, by using volumetric shading and some math nodes. Moreover, it's Cycles specific. What it does do, is work well with any implicit equation of three variables, as long as it uses functions that exist in Cycles math nodes.

So, how to do it...
Add a cube, which will serve as the bounding box (ShiftA followed by M followed by C or Add -> Mesh -> Cube).
Press N to open the properties panel, unless it's already open, and change the values for Dimension to the proper values, and apply the scale (CtrlA followed by S or Object -> Apply -> Scale). If for example you want to cover the range (-0.5, -0.5, -0.5) to (1.5, 1.5, 1.5) all dimension values should be set to 2.000, and if you want to cover the range (-1, -2.5, 0) to (5, 5, 5), the dimensions should be x = 6.000, y = 7.500, z = 5.000.

Now the box has the correct dimensions, but its origin is at its centre. With the above examples, the ranges will now be (-1, -1, -1) to (1, 1, 1) and (-3, -3.75, -2.5) to (3, 3.75, 2.5) respectively.
To remedy this, Tab into edit mode, and move the box along each axis, until it covers the range you need. Press G followed by the axis along which to move it, followed by the amount by which to move it, followed by Enter, for example G followed by X followed by Numpad 1 followed by Enter to move it by 1 along the x axis. For the above two examples, you need to move it by (0.5, 0.5, 0.5) and (2, 5, 2.5) respectively. When you're done, Tab back to object mode.

At this point, it's perfectly ok to move, rotate and scale the box, as long as you do so in object mode and don't apply any transformations. Also keep in mind that scaling is a bit special: unless you scale equally along all three axes, you will end up with different step size along the axes. This may be good or bad, and the decision is yours to make.

Open up the compositor, and make sure the shader editor is active and that Use Nodes is checked (the purple rectangles in the image below). If there is a button named New, click it, to create a new material.

Click the image to see a larger version

The nodes above corresponds to the equation sin(x)+sin(y)+cos(z)=1, which is the one you ask about in Creating mesh on a surface with two variables.

The nodes in the red rectangle give the coordinates with (0, 0, 0) at the object's origin. It's similar to using Object coordinates of the Texture Coordinate node, however the object coordinates places (0, 0, 0) at the centre of the bounding box, which isn't what we want.

The Separate XYZ node (the blue rectangle) does what its name suggests.

The nodes in the yellow rectangle are the left side of the equation.

The nodes in the green rectangle are the right side of the equation. This probably requires some explanation. If you simply use the Less Than 1.000 you will get everything inside the volume. To simulate a surface with a slight thickness, I subtract everything below some value that is less than 1 (0.9 in the image). The closer you set this to 1, the more it will look like it's infinitely thin, but the higher you will have to set the density to make it appear opaque.

The multiply node controls the density. The higher you set this, the more it will look like an opaque surface.

The Volume Absorption and the Volume Scatter are the shaders at work here, and the Add Shader combines those. You need not use absorption and scatter exactly like this, and you may use Mix Node instead of add, if you prefer. Just to remember to use volumetric nodes, and connect to the Volume socket of the Material Output node. The usable shaders for volumetric shading are Volume Absorption, Volume Scatter and Emission.

The Texture Coordinate connected to the Color sockets of the shaders, just maps the shading coordinates to a colour. Red along the X axis, green along the Y axis and blue along the Z axis.

Here's the result:

And here's an example .blend (it's not exactly identical to the example, but the concept is the same):


How to obtain max and min of f-curve in python I am making an add-on for Blender. You can find it here: https://github.com/rubeste/Blender_f-curve_select
I need to support the normalization of the curve as well. So, I need to calculate the f-curves position.
I currently do this by getting the minimum and maximum value of the curve and creating a range between 1 and -1.
My problem is that I do this calculation by looking through the whole animation. This takes time, and I only tested it with 3 curves.
I was wondering if there is a better way to obtain the minimum and maximum. Or if I can get the value I want via a different method.
def calculateValeOfNormalizedCurve(self, context, fCurve, frame):
        start = context.scene.frame_start
        end = context.scene.frame_end
        values = []
        value = fCurve.evaluate(frame)
        i = start
        while i <= end:
            values.append(fCurve.evaluate(i))
            i += 0.1
        max = np.max(values)
        min = np.min(values)
        return ((value-min)/(max-min)*2)-1

Vectorize evaluate with numpy
Having done similar via What's the range of values on a sound-baked f-curve?
Can vectorize the fcurve evaluate method and pass in an numpy array of frames, then  using methods available  get the minimum maximum etc.
Will find this much quicker than looping as in question code above.
Test script finds the minimum of each fcurve of each action from frames 1 to 250 using 0.01 subframe increments.
import bpy
import numpy as np

frames = np.arange(1, 250, 0.01)

for action in bpy.data.actions:
    print(f"{action.name}")

    for fc in action.fcurves:
        print(f"{fc.data_path}[{fc.array_index}]")
        points = np.vectorize(fc.evaluate)(frames)

        print(f"min {points.min()} at {frames[np.argmin(points)]}")


Blender Eeve: transparent texture How could I put put a node with a transparent texture coming from a picture? I don't want any reflexion, just display a normal image.

So to get alpha working on a texture, click in the material on "Use Nodes" and change the color to use an image:

Also make sure to set the Settings/Blend mode of your material to Alpha Blend:

Then, open the Shader Editor to edit the nodes, and make sure that the alpha is set to Premultiplied in the settings (press N) of your texture. Then, create a node (Shift-A) Transparent BSDF, make sure it is white, and mix it with your image, using the alpha as factor (if you want to keep material, you can use the Principled BSDF node as input to your color instead):

This gives you something like that:

If you get a white border around edges, make sure that you selected Alpha: Premultiplied.


Why do my leaf and grass textures have black outlines when rendered? I've recently finished exporting and texturing a bunch of psk meshes from a game in blender. My current plan is to cover these meshes in collision models and then export/compile them to a map editor (the hammer editor) where I will make a map using these custom models. I've never used blender before so this has been an interesting experience for me.
However I have run into a potential problem.
The main worry I have at this present moment is with the vegetation textures. Textures such as leaves and grass carry a black outline (pictured below) this outline is quite chunky and because of my little experience with blender I have no idea whether it will carry over once I export/compile the model.

As you can see below the texture I'm using does not contain this black outer

This happens albeit to a lesser extent on grass too...

Can anyone tell if there's something I need to do to fix this or even if it needs fixing at all. I checked the game files and the meshes and textures had the same file names and match each other in the UV editor.

From the image of your texture, it looks like the BaseColor has a built in alpha component. If that is the case, you must connect it like this in addition to changing the blend modes:


Setting up UV direction I have created a hallway in Blender, and then I applied "Smart Unwrap":

The unwrap doesn't look absolutely perfect, but I thought it would do the job.

Then I exported the model as an fbx and imported it into Unity.
In Unity, I applied a material to it which has a texture assigned.

For some walls it looks fine, but for some walls, the direction of the UV map is changed for some reason, and the texture doesn't look right:

How could I set up the "direction" of the UVs in Blender and not just hope that it will work out alright (which it obviously doesn't)?

Thank you very much!

When you do Smart UV Project you can generate UVs with islands.  Then you can select the pieces that need to be rotated and rotate them by pressing R 90 Enter.  You can also scale the pieces generated by pressing R 90 Enter.


Cycles + Glass + Light, Preview different than render Anyone knows why the preview (left bottom) looks different than the render (bottom right)?

What i tried to achieve is something like that

i dont know what is going on?!

There are one or more objects, which are visible in the viewport, but hidden in the render.

Tick the camera symbol for all objects, which are supposed to be rendered.

If you want to clear all render restriction, go to the 3D Viewport, and press W in Object mode and choose Clear All Restrict Render.


Unable to change number of vertices after adding a bezier circle in blender 2.83 Once I add a bezier circle, there is no option to change the number of vertices anywhere. As you can see, the box at the bottom has no option to add vertices. If I click edit mode, the bottom box also disappears. I am a beginner in blender so a detailed reply will be helpful. Also, once the circle is added, I have pressed F6 (as suggested in other answers) but nothing happened.

You have added a curve circle, instead of a mesh circle. A curve circle does not have vertices, it has control points, but these cannot be adjusted when adding the object. A mesh circle will have the option to adjust the number of vertices.
Press Shift+A> Mesh> Circle to add a mesh circle. Then the Adjust Last Operation panel (the panel in the bottom left) will show the option to adjust the vertices.


How can I render a model with both alpha textures and backface culling? I just started learning Blender a couple weeks ago, I'm using it to make renders of Pokémon models.
I would appreciate it if someone could help me get a render of this model (Malamar): https://www.models-resource.com/3ds/pokemonxy/model/13117/?source=genre
I was unable to make it look like the sample image, specifically, the stomach part (the one with the yellow dots and the tentacles surrounding it) and the pink part of the tentacles.
I made some progress in Blender 2.79 Blender Render and Blender 2.82
In Blender 2.79 Blender Render I couldn't get the alpha texture to work, it makes the body transparent in the viewport but it shows the background behind instead of the yellow dots... When rendered, it is not transparent.

I managed to make the pink part, which looks all weird without the backface culling option activated, look good by activating the shader nodes. But I couldn't make the alpha texture show trasparency.

In Blender 2.82 I made more progress, I managed to get both the trasparency and the bakface culling but the backface culling makes the pink part of the tentacles look totally different.

If possible, I would also like to know from someone more experienced whether I got the alpha texture correctly or not. Is it normal that when I change the color in the Transparent BSDF node the color of the yellow dots changes as well?
Thank you very much.

Try this arrangement for your model. The way you have it setup in your image, you're mixing white with your image using alpha as a factor. If you want transparency, you will have better luck with this arrangement. Pay attention to the right side where I highlighted the blend modes - these are necessary for transparency. Pick Alpha-Clip, Alpha-Hashed, or Alpha-Blend (whatever looks best), just not Opaque. This should be applied to the Shadow Mode as well - depending on what type of shadows you want for your transparency.

Hope this helps


Why is my Genereted Rig on the ground? I am trying to generate a rig for a figure I created. I am using blender 2.83.4.
When I generate it, it is below the figure. Like it is oriented on the z=0 plane. I gave both the armature and the figure the same origin. Why did it sink through the floor?

This happens because of difference in location of armature origin , in Object and Edit Modes.
Simply reapplying armature location , will sync it in both modes.


Is there a way to extrude in a smart way? Is there an easier way to extrude models a certain way

As far as I know there's no magic button (like E) to extrude the way you want.

The simplest/fastest way I know is using Loop Cut and Slide in Face/Edge-edit mode (see picture).

It can become a very fast operation, if you get into the habit (see GIFs below).
Basically you use loop cut and slide to create faces where you need them and then you just move your face (instead of extruding it).

In this first situation I'm just hitting CTRL+R to start the "Loop Cut and Slide" command, I create one edge in the face and I slide it to the border, do the same in the other direction (to the other edge), then I select the face and I move it on the Z axis.

And here I'm doing the same but I do just one cut and slide it to the lower edge.


Certain Faces not Appearing after .OBJ Model Export So here's a pistol that I've been working on for quite some time now using Blender 2.79b. It is the first model I've ever worked on and it has been shaping up surprisingly well. The problem that has recently popped up though is the fact that when I try to export the model below as an .OBJ file, multiple faces are excluded and end up looking from this:

To this:

A you can see, multiple faces are suddenly gone and some graphical glitches are present. I'm not really sure if the fact that I applied a Boolean Difference Modifier at most of these meshes has something to do with this issue, but anyways I would appreciate it extremely if you could help me resolve this issue :)

They are not gone, they are flipped. GE don't render the backside of faces, unless you specifically tell them to.
You can tell that's the case, because the part that's missing in Blender has a blueish color.
Select that part, go into edit mode and hit CRTL + N
if that doesn't change anything, go back into edit mode and press CRTL + F and choose Flip Normals


Lighting problem in cyles I have a problem with lighting that i can't fix, I have a mesh in the form of a light bulb with an emission material set to the strength of 5000 and no matter what i up the strength to the bulb object has practically no effect on my scene, I will also mention that there is some glossy material in the scene aswell, Sorry if this question is noobish but i am still learning the arm of blender any help would be greatly appreciated

Cycles doesn't really like very small light sources with very high lighting intensity.

They are very 'hard to find' computationally speaking. Cycles is a Path Tracer and will cast rays from the camera until the reach a light source, if the light source is too small it is very hard to hit, statistically speaking, creating very noisy renders that take a very long time to render.

Large light sources with an average lighting intensity are much better suited.

Keep you detailed lamp model if you like, but don't make it the light source of your scene.

Add a fake light material to it then use a real lamp object or a simpler geometry like an emission plane to actually light your scene up. Also avoid transparent or blocking geometry over your light sources, like the glass bulb.

You can then make fake light in cycles How to make the light emission invisible? or How to make a cycles light emisson object invisible to the camera?


Can't properly unwrap a simple mesh UV distortion, apparently some scaling/dimension issue because unwrapping after making the mesh 500 times bigger fixes the problem.

That's a simple one-sided curved object (7 faces) located perfectly straight (pic. 1). So I expect UVs to be perfectly straight as well. But it gets slightly angled (pic. 2) which is critical for my tiling texture.
Making the mesh much bigger and applying the scale makes the unwrapping process behave right and expected (pic. 3)

Binary rounding errors are possible if the values used are very small or very large, or have a lot of significant figures. Blender uses 32bit floats to store values, so it is very possible to observe binary rounding errors in Blender in some cases. However I believe this is more likely because of the unwrapping algorythm used(maybe binary rounding errors are more visible when using it - I am not sure). If you try choosing Conformal instead of Angle Based this will probably solve the issue:


Switch between sculpting brushes When sculpting I often want to switch between brushes. I find this a rather lengthy process. I have to open the sidebar and click on the icon and then click on the new brush I want to use. Is there a faster way to switch between brushes?

M = Mask Painting
K = Snake Hook Brush
Shift+C = Crease Brush
C = Clay Brush
Shift+T = Flatten/Contrast Brush
L = Layer Brush
G = Grab Brush
I = Inflate/Deflate Brush
P = Pinch/Magnify Brush
S = Smooth Brush

1 = Blob Brush
2 = Clay Brush
3 = Clay Strips Brush
4 = Crease Brush
5 = Fill/Deepen
6 = Flatten/Contrast Brush
7 = Grab Brush
8 = Inflate/Deflate
9 = Layer Brush
0 = Mask

Shift+1 = Nudge Brush
Shift+2 = Pinch/Magnify Brush
Shift+3 = Rotate
Shift+4 = Scrape/Peaks
Shift+5 = SculptDraw
Shift+6 = Smooth
Shift+7 = Snake Hook
Shift+8 = Thumb

Graphic below, slightly outdated. Twist was renamed Rotate and Shift+Number hotkeys re-assigned.

Current as of Blender 2.79a


Soft Body Object-Collision Object Interaction Not Working Thanks in advance to this wonderful community that has helped me a ton on the way.  With that preface, here is my problem.  I am trying to get the most basic of simulation to work correctly.  The top cube is a soft body and the bottom cube is a collision object.  I can't get these two objects to interact at all.  I have tried adding a collision modifier to the soft body cube (in addition to the soft body modifier).  The soft body cube also doesn't have the soft body goal (as I am trying to get a bouncing effect where the cube bounces off of the plane).

The normals of both objects are facing the right direction.  I have also played a ton with the inner and outer settings of the collision object to no avail.  What're your guys' thoughts?

Below is the beginning of the animation and the end of the animation (where the cube just falls through the surface of the collision object).

Also do you have to bake it before it will interact correctly?  I already tried that as well and nothing happened.

I also thought it might have to do with the fact that I had no vertex groups specified on my soft body object.  I did, however try subdividing the cube a bunch and still nothing was happening.

You need to add the Collision physics to the object that yhe soft body should be colliding with, not to the soft body itself. Also, check your normals to ensure they’re pointing ‘outwards’ (otherwise the collision won’t work).

Another issue can be where the Soft Body/Cloth collision ‘Inner’ setting (on the non-soft body mesh) is set too large - it ahould never exceed half the thickness of the mesh or it can have undesired consequences (drawing the soft body through from the ppposite side).

Also, fast moving collisions can potentially get through the surface before they are detected. To address this, increase the Min steps (and Max if you need to increase Min even higher) in the Soft Body Solver settings.

After reviewing the Blend file I noticed that the collision object and the soft body are actually on different layers. For the collision to be active (in fact, for any physics effects) the meshes must share the same layer. To move objects to a different layer you should select them, hit M and click on the desired 'target' layer on the popup panel, holding Shift to select multiple layers if desired. Note that moving layers doesn't necessarily invalidate the soft body cache but this can be triggered by simply selecting the Soft Body object and going into and out of Edit mode (TabTab).


How do I offset each bone's keyframes to be 10 frames later than the previous bone? I would like to get something like in the image:

I have this code, but it moves all the keyframes 10 frames to the right:

import bpy
for action in bpy.data.actions:
   for fcurve in action.fcurves:
     for point in fcurve.keyframe_points:
        point.co.x += 10

I need to move each bone's keyframes 10 more frames than the last one. How could I do that? And how could I access a specific bone's keyframes and move just them?

Amended code to do somewhat what you want.

Shifts keyframes 0 for first fcurve, 10 for next, 20, 30...

Have made it adjust only the action on the active object.

import bpy

ob = bpy.context.object
ob.animation_data_create()  # lazy way to make animation data exist
action = ob.animation_data.action
if action:
    for i, fcurve in enumerate(action.fcurves):
        for point in fcurve.keyframe_points:
            point.co.x += i * 10

Please use consistent 4 space indent

Re finding which fcurve is which see https://blender.stackexchange.com/a/111326/15543

To order the fcurves firstly by data_path, and secondly by array index eg

pose.bones["bar"].location.x
pose.bones["foo"].location.x
pose.bones["foo"].location.y

Use something like

fcurves = sorted(action.fcurves, key=lambda fc: (fc.data_path, fc.array_index))


macbook pro rendering issue I have a macbook pro early 2013 model with i7 processor and nvidia m650 graphics but when i go to the settings to enable gpu rendering there is no option to select it only cpu rendering can anyone tell me why this is?

You need to install the latest Nvidia Driver for you graphics card. You can download them from  the nvidia website here: Mac Nvidia Drivers. After you have done this you need to restart blender and the CUDA option should be available under the System Tab in you User preferences.


Select Interior Face, how to make it work? I have created a cube with interior faces all over the place.
The vertices and edges have all been collasped. Running the
Tool Select > Interior Faces ... does strange thing.

Does anyone know how this tool is suppose to work, cause it
does not seems to work as it's name implies. I have uploaded
a blend file, just in case someone could actually select those
interior faces with it.

Questions were asked here and here, but they do not
show why this tool don't seem to work at all.

This tool is very limited. All it does is exactly in it's description:

Difference between an edge with 2 face users and edge with 3 (or more) face users:

All this tool does is for every face it checks if all it's edges have more than 2 face users. If yes, such face is selected.

This tool does not 'think' spatially and doesn't understand volumes at all. Here is an example when it will succeed and when it will fail:


particles in particle system rendering on the same place I have a particle system where I want to use a vertex group for the density(normal stuff).
But I am also using a vertex weight edit modifier with a mask to control the vertex group.

When I'm previewing the vertex group everything seems ok.

But when I later tried to use that group in the particle system. Every particle just spawns in the same place and I have no clue why this is happening.

I have checked for solutions but the vertex weight edit doesn't have a lot of documentation

I found out what was wrong.
I needed to check use modifier stack under particle properties>>>emissione>>>sorce>>>use modifier stack


How to replace these paths with Python? I have some objects, linked from other blend-files. I want to get access to their paths in Python, but I can't understand, how to find this data. Any ideas?

These linked files are in:
bpy.data.libraries

You can have their filepath with for instance:
[lib.filepath for lib in bpy.data.libraries]

The path is relative to the current blend file, so you can have absolute path with:
[bpy.path.abspath(lib.filepath) for lib in bpy.data.libraries]

In the documentation:

Libraries
Path utilities


Can you Animate like in Stop Motion Animation? In Stop Motion Animation, the proccess is very simple, you have a piece of clay (or something else) and you tweak/remodel it after every frame.

Is there a workflow in blender, that lets you resculpt your model and move it, without rigging it, that is still practical?

For example like the transformation from bruce banner into hulk, while walking.

What you want to do can be done using shape keys. There are many tutorials on Youtube this is one of them Shape Keys Tutorial


intensity color with custom ray tracing I want to change how light is calculated. Therefore I need my own raytracer. How do I write my own simple raytracer using python?

Answering my own question. Will happily accept improvements & suggestions to the answer.

Reference the full script on github or at the end of the answer.

Note, that this will be the wrong approach in most cases. Your own bpy raytracer will lack features and be slow and inefficient. There are other APIs (nvidia link>) which are probably more suited for this purpose.

When testing, use small resolutions and few lamps.

To calculate the colors of an image, for each pixel, we have to:

Shoot a ray and check if it intersects. If it doesn't, this pixel stays at an alpha of 0.
If a ray hit an object, get the hit position.
Send a ray to each lamp in from the hit position. If this new ray hits another object, the lamp is obstructed and will not contribute lighting to this pixel. Otherwise calculate the light contribution (with the lamps color, intensity, falloff and object normal) and add it to the pixel.

I'm going to use numpy to store the pixel values and copy them onto an image at the end. This is faster than manipulating a reference to a blender image.

import bpy
import numpy as np
import mathutils

I will store a reference to the scene, the lamps, and the render settings. The width and height of the image can by directly deduced from the render settings. I will use the sensor_width as a fixed constant and calculate the sensor_height relative to the images dimensions. For 2.8, we have to access the view_layer when using the ray_cast function of the scene.

scn = bpy.context.scene
view_layer = bpy.context.view_layer
cam_mat = scn.camera.matrix_world
cam_loc, _, _ = cam_mat.decompose()
lamps = [ob for ob in bpy.data.objects if ob.type=='LAMP']
cam = scn.camera.data
render = scn.render
horizontal = cam.sensor_width/2
vertical = horizontal/render.resolution_x*render.resolution_y

width = render.resolution_x
height = render.resolution_y

Construct the base image array and the corresponding rays. Read this answer and this post on how blender stores images.

For now we will create a pixel list which looks like this:

[y coordinate][x coordinate][rgba index]

and can by done with numpy

pixels = np.zeros((height, width, 4), dtype=float)

The rays are a grid starting from (0, 0, 0) and pointing downwards. The focal length equals their negative Z coordinate and their x, y range is stored in the sensor settings.

ray_width = np.linspace(-horizontal, horizontal, num=width, dtype=float).reshape(1, -1)
ray_width = np.repeat(ray_width, height, axis = 0)
ray_height = np.linspace(-vertical, vertical, num=height, dtype=float).reshape(-1, 1)
ray_height = np.repeat(ray_height, width, axis = 1)
ray_depth = np.zeros((height, width), dtype=float) - cam.lens

rays = np.stack([ray_width, ray_height, ray_depth], axis = 2)

Each ray will have to be transformed by the camera's transformation matrix and be shot from camera_position in direction of camera_position to transformed_ray.

Now we iterate through all the pixels in the image by x, y coordinates. We get the ray for each pixel and transform it by the camera's matrix_world. If the ray cast hit something, that means this pixel should be colored and visible.

for y in range(height):
    for x in range(width):
        ray = cam_mat @ mathutils.Vector(rays[y, x]) - cam_loc
        result, loc, nor, ind, ob, mat = scn.ray_cast(view_layer, cam_loc, ray)

        if (result):
            intensity = base_intensity[:]
            pixels[y, x] = intensity[0], intensity[1], intensity[2], 255

To make lights influence the pixel's values, check if there is a clear path from the last ray_casts position loc. If yes add this lights color and to the intensity. I used a linear falloff like 1 - (point_light_distance / lamp_light_distance). Multiply this by the result of the dotproduct of the surface normal and the direction to the light. This will stop making only faces which directly face the light receive the full amount of light.

        if (result):
            intensity = base_intensity[:]

            for lamp in lamps:
                dir = lamp.location - loc
                dirn = dir.normalized()

                start = loc + dirn * 1e-4
                hit,_,_,_,_,_ = scn.ray_cast(view_layer, start, dirn)
                if not hit:
                    multiplier = max(0, min(1, 1 - dir.length / lamp.data.distance)) * lamp.data.energy * max(0, dirn.dot(nor))
                    intensity[0] += multiplier * lamp.data.color[0]
                    intensity[1] += multiplier * lamp.data.color[1]
                    intensity[2] += multiplier * lamp.data.color[2]

            pixels[y, x] = intensity[0], intensity[1], intensity[2], 255

Finally, create a new image (or use an existing one) and replace the images pixels list with our flattened pixels array.

img = bpy.data.images.get("name")
if (    (not img) or
        (img.size[0] != width or img.size[1] != height)):
    img = bpy.data.images.new("name", width, height)
img.pixels = pixels.reshape(-1)

Full script

import bpy
import numpy as np
import mathutils

scn = bpy.context.scene
base_intensity = list(scn.world.color)
view_layer = bpy.context.view_layer
cam_mat = scn.camera.matrix_world
cam_loc, _, _ = cam_mat.decompose()
lamps = [ob for ob in scn.objects if ob.type=='LIGHT']
cam = scn.camera.data
render = scn.render
horizontal = cam.sensor_width/2
vertical = horizontal/render.resolution_x*render.resolution_y

width = render.resolution_x
height = render.resolution_y
rays = np.zeros((height, width, 3), dtype=float)

ray_width = np.linspace(-horizontal, horizontal, num=width, dtype=float).reshape(1, -1)
ray_width = np.repeat(ray_width, height, axis = 0)
ray_height = np.linspace(-vertical, vertical, num=height, dtype=float).reshape(-1, 1)
ray_height = np.repeat(ray_height, width, axis = 1)
ray_depth = np.zeros((height, width), dtype=float) - cam.lens

rays = np.stack([ray_width, ray_height, ray_depth], axis = 2)

pixels = np.zeros((height, width, 4), dtype=float)

for y in range(height):
    for x in range(width):
        ray = cam_mat @ mathutils.Vector(rays[y, x]) - cam_loc
        result, loc, nor, ind, ob, mat = scn.ray_cast(view_layer, cam_loc, ray)

        if (result):
            intensity = base_intensity[:]

            for lamp in lamps:
                dir = lamp.location - loc
                dirn = dir.normalized()

                start = loc + dirn * 1e-4
                hit,_,_,_,_,_ = scn.ray_cast(view_layer, start, dirn)
                if not hit:
                    multiplier = max(0, min(1, 1 - dir.length / lamp.data.distance)) * lamp.data.energy * max(0, dirn.dot(nor))
                    intensity[0] += multiplier * lamp.data.color[0]
                    intensity[1] += multiplier * lamp.data.color[1]
                    intensity[2] += multiplier * lamp.data.color[2]

            pixels[y, x] = intensity[0], intensity[1], intensity[2], 255

img = bpy.data.images.get("name")
if (    (not img) or
        (img.size[0] != width or img.size[1] != height)):
    img = bpy.data.images.new("name", width, height)
img.pixels = pixels.reshape(-1)


Is it possible to set the Output name based on the current Timeline marker? I've got a scene with timeline markers. Example: "Bob", "John" etc.

I want to set the Output file name to match these markers, so that I can hit Render Animation and have Blender change the output file names to match the timeline markers.
So when the playhead reaches the "bob" timeline marker, the output filename is changed to "bob.png"

How would I go about making a Python script to automate this?

Following script renders every frame in the timeline if it is a marker assigned to it. It uses the existing output file path and and the current marker name as output file name.

import bpy
import os

# get the scene
scn = bpy.context.scene

# get the output path
output_path = scn.render.filepath

# iterate through markers and render
for k, m in scn.timeline_markers.items():
    frame = m.frame
    marker_name = m.name
    scn.frame_set(frame)
    scn.render.filepath = os.path.join(output_path, marker_name + ".jpg")
    bpy.ops.render.render( write_still=True )

bpy.context.scene.render.filepath = output_path

.blend


Some vertex groups on the armature have their location offset I am relatively new to blender. So this is my first time rigging with vertex groups. To my understanding, I have done everything properly when rigging my vertex groups to my armature: unparent all the meshes, join the meshes, match the name of the vertex groups to the bone names. So after I add the armature modifier to the mesh and select my armature as the object, some of the vertex groups are offset.

The weird thing is, the vertex groups are in the correct position in edit mode but not in object mode.

The animation works fine except for the few vertex groups that have the offset.

I hope it answers your questions:
In Edit mode you should align the bones with the lamp arms:

Also, stick the IK target head to the tail of the IK bone, otherwise, as soon as you switch to Pose mode, your IK will move away from its current position to stick to its target:


Smooth shader and subsurf shadow problem As you can see in the pictures I made a mesh and added loopcuts to it for the smooth face shading that it's using but there is an undesired shadow, which isn't seen from higher angles. When I apply subsurf it also gives a shadow but only on half of the selection...

without subsurf (just smooth face shading):

without subsurf (just smooth face shading) from different angle:

With subsurf:

file:

Some of the normals are incorrect. Select everything in edit mode and press Ctrl-N and that will recalculate the normals and fix it.


Separate reflection based on object index cycles It is possible to separate the reflected background , for example having 2 glossy objects A and B and a hdri image as background  to reflect. I want to have a blurred version of the hdri reflected on object A and a crisper version(or diferent hue) reflected on object B.
I am aware that using the light path node and substracting   glossy and singular ray   it is possible to split the reflection one object having the sharp Bsdf , but i need two glossy objects with roughness non zero each .
thank you

Starting with two objects with the same glossy material.

Give the objects different Pass Index.

Enable Object Index in the render layer

In the compsitor use an Id Mask node and select the pass index of your object and use that to mix the blurred image with the non blurred one:


Armature advice for the hip region I'm using a basic armature: a couple of bones for the hand, a bone for the abdomen, chest, neck, head, clavicle, arm, forearm, thigh, shin, ankle, foot and toes. I'm use poles and targets for the arm and leg.

This basic setup works fine for walking animations, attacking, tree chopping etc. but as soon as I attempt an animation where the model is picking something up or crouching, it looks awful. The buttocks completely disappear and the abdomen is pushed in by the thighs. I've tried to weight paint my way out of this but I suspect I need more bones around the hip region to stop this from happening.

Does anyone know any good resources for improving armatures? Keep in mind that this is for a game so I'm aiming for minimal bones. I can post my blender scene on pasteall if that would help.

No, you don't need to add extra bones. You may need to rearrange some of the existing bones.

Remember, when something doesn't work like real life, the best thing you can do is try to mimic real life.

Here's a picture I drew, with proper weights on the leg and a diagram of how the real bone structure is.

Notice how the effects of the leg bone has are very little on the glutes. This will help with crouching as the but won't have to stretch out in order to reach a full squat. Above the hip joint there should be little to no weight, except a little on the abdominal muscles, which need to suck in a little in order for the leg to not collide with them.

I think this should solve most of your problems; it always works for me.


Can't export to .PLY, option grayed out The PLY export option is grayed out meaning I can't export models to this format.

Can you clarify the contents of your scene? PLY is a very niche model format and has a lot of limitations when it comes to the data that it can package. You might want to read up on this page.
Try just exporting a simple scene and see it that works. If you can export PLY with just some simple geometry, then it must be something contained in your scene that isn't able to be exported.

Everything seems to be working fine for me with just some simple geometry in the scene. If it's still grayed out with just some simple models in your scene, then you might want to try re-enabling the PLY export add-on in user preferences.

How to re-enable the PLY exporter in blender:

Go to File --> User Preferences (Ctrl+Alt+U).
Click on the Add-ons tab at the top of the window.
In the search box, type "ply."
Make sure the checkbox is ticked next to "Import-Export: Stanford PLY format."
Click Save User Preferences towards the bottom right hand corner of the window.

If the problem still persists, then you'll probably want to ask your client if he or she can accept another file format. PLY is a pretty non-standard format and I can't imagine what situation they would be in to only be able to use that format.
The last thing that I want to add is that you must have objects selected inside of your scene to export them. To export everything in the scene, just his A and then export.


How to make nice curvy contour on high detailed (sculpted) mesh? I run into the problem that I have quite irregular (bumpy) contour shapes from certain angles on my sculpted model.
So I have this form:

And I want to correct it to look something like this:

The only way I know in sculpting mode to adjust the form is the grab tool, but it is very hard and time consuming to solve this.

the reason of that resides on the actual geometry of your mesh, seems to have to many vertex and a very nested topology. I recomend you to try reduce your vertex acount from the beggining and use the subdivision surface modifier it'll round your shapes but it'll still will follow the topologhy.
You can try to use remesh modifier or decimate modifier to reduce vertex number. But you'll loose all the sculpted allready details.
good luck!


Extending Sverchok - Development of new nodes in a separate addon TL;DR: Is Sverchok designed to have their node list extended by third-party addons? If so, are there any formal templates to follow?
I would like to play with the idea of developing new nodes for Sverchok in a separate addon to provide domain-specific functionality that would not make sense to be contributed to Sverchok itself (e.g. generating meshes to be exported to third-party software). My understanding so far is that this would be a two step process:

Create the nodes. This seems to be well documented in Sverchok, and the many nodes included provide many examples of varying complexity.
Add the nodes to the menu. This is the bit that I am struggling with. I have not found documentation / example templates to this end, hence the question. There is sverchok-extra and this file seems to make nodes available in Sverchok's menu. Would this be the way to go?

I am aware of the custom nodes one can create in Sverchok itself via scripted nodes, but it does not feel the right way to develop an addon that saves the specific nodes and makes them available in the menus for future, easy reuse.
Thank you.

look at ladybug addon for sverchok and even more to sverchok extended nodes addon
https://github.com/nortikin/sverchok/wiki/Dependencies#side-extending-packages
also. But make an issue on nortikin/sverchok for that to proper integration


Getting the number of faces a certain vertex is part of I am in edit mode and using bmesh to get all faces. I am iteration through the faces and their vertices. Now I want to know on how many faces the vertex, I currently have, is part of.
For example this green vertex is part of many faces.

Right now I have:
for f in mesh.faces:
    for v in f.verts:
        # some stuff before
        # now I need the number of faces the vertex c is part of
        # some other stuff

I know I could simply run through all faces and save the coordinates of the vertices and compare them with other faces and their coordinates - but maybe this can be done more easily.
Thanks!

a very nice feature of bmesh :)

import bpy
import bmesh

me = bpy.context.object.data

# Get a BMesh representation
bm = bmesh.new()   # create an empty BMesh
bm.from_mesh(me)   # fill it in from a Mesh

for f in bm.faces:
    for v in f.verts:
        lf = v.link_faces
        print('num faces:', len(lf), 'faces: ', lf[:])
    break


how to keep sharp points using subdivison surface I have created a beast and I want it to have sharp teeth, but as long as I'm using subdivision surface modifier, the points are smooth. If I try it without the subsurf, they don't look like teeth at all and as long as it is one point, I can't add an aditional edge loop. So how do I get them sharp?

This is how your tooth topology should look like:

You can add more loops to the body of it to shape it differently as you want it.


Is it possible to disable the mouse wheel? I don't see any way of disabling the mouse wheel, or at least to make it not control the zooming. The reason I need to know is that my mouse has an extremely sensitive wheel and I end up zooming in and out uncontrollably when I'm just trying to rotate the view, which is obviously something I need to constantly do. I used some registry edit method to disable the mouse wheel but it only seems to affect some programs and Blender is not one of them. I'd appreciate any help.

It should be doable by removing (or changing) the Key Bindings in Blender. Go to File -> User Preferences -> Input and look for any Key Binding which is connected to the Wheel of the mouse. Like this:

In the example I'm deleting the binding for the Zoom in 3D View only. So in 2D Editors, you could still use it if you like. Otherwise, you'd need to remove it section by section.

To get it back, use the Restore button that shows up after you change or delete a binding (it will stay there as long as your keymap is different to the Defaults). If you want to keep your Blender Prefs this way, click Save User Settings


How can I simulate metamerism in Cycles? Different combinations of spectral wavelengths can produce the same apparent color. For instance, true yellow is 570nm-590nm, but computer screens produce it by mixing red and green. Both yellows look the same, but they are not really the same!

It's easy to demonstrate this effect in Blender. Cycles operates in RGB-only mode. It cannot simulate any colors in the visible light spectrum except for red, green, and blue. Secondary colors are combinations of the 3 RGB primaries.

To Cycles, yellow = red + green and cyan = green + blue. When you layer 2 planes with yellow and cyan glass shaders above a white emission plane, green light passes through. Each plane lets 2 wavelengths of light pass through it.

To Cycles, red and blue are pure primary colors. When you layer 2 planes with red and blue glass shaders above a white emission plane, what you see is black (not purple!) Each plane lets just 1 wavelength of light pass through it, and all light is blocked since the wavelengths are different.

Is it possible to make colors in Blender act as their own true wavelengths/spectral distributions instead of a mixture of red, green, and blue? If you do that, layering translucent yellow and cyan planes will result in black, just like layering red and blue. If you make 2 different colors that respond to a range of overlapping spectra, layering them will allow some light to pass through (resulting in a non-black color).

Can blender render colors with custom/non-RGB spectral distributions?

https://www.youtube.com/watch?v=uYbdx4I7STg

It's easy to demonstrate this effect in Blender. Cycles operates in RGB-only mode. It cannot simulate any colors in the visible light spectrum except for red, green, and blue.

This isn't correct.

The reference space primaries are determined by the colour management system. In theory, any reference space primaries within, or even beyond, the spectral locus can be selected. More specifically, any three light rendering engine can cover any area of the spectral locus, including imaginary coordinates beyond it, depending on the coordinates for each of the three lights.

  Is it possible to make colors in Blender act as their own true wavelengths/spectral distributions instead of a mixture of red, green, and blue? If you do that, layering translucent yellow and cyan planes will result in black, just like layering red and green.

This has nothing to do with spectral, and rather a difference between additive light and subtractive (multiplicative) light systems.

  Can blender render colors with custom/non-RGB spectral distributions?

If you mean "greater than three light" models, no. With that said, architecturally, a three light rendering engine isn't terribly far off from a spectral n-light rendering system; they crunch numbers in more or less the same way. The differences come in with respect to how the values are defined.

RGB however, isn't what it seems you think it is. RGB is literally any arbitrary set of three coloured lights, which are determined as a protocol layer in most instances in an raytracing engine. That is, the raytracing engine typically will just crunch numbers as though they were energy, and not care what colours are indicated by the intensities of the three lights. In this respect, RGB doesn't imply any specific colours of reddish, greenish, or blueish light, nor even that the labels represent reddish, greenish, or blueish lights but potentially something altogether of a different hue to what the somewhat arbitrary labels suggest.

There is nothing stopping someone from using spectral based primaries, such as those found in REC.2020, in Cycles for example. This is aside from the fact that Cycles and Eevee aren't properly colour managed, making the usage and interaction a bit tricky.


How do I twist a curve (by rotating a segment)? I have already searched everywhere but those threads are about making rope-like objects.

I am trying to animate start and end values of a curve's geometry. But I want it to twist midway. I am trying  to rotate it's segment on Y axis as in the image but it is not working.

Here on the left is what I want to achieve and right is what I have. I tried rotating the segment/vertex on Y axis but its not working.

You're looking for the Tilt (Ctrl+T) function.


How to make one object pass through the holes of another? I'm making a connect4 animation, I've made all the pieces for it, and I'm using rigid body physics to simulate the piece dropping into the board, but it stops when it hits the top of the board, as shown in the picture. I've double checked the sizes to make sure the piece is smaller than the hole, I've also tried changing the collision margin like in this question, but i'm unsure where to go from there
for reference, the piece is an active-type rigid body while the board is a passive-type rigid body

Most likely you have your collision set to the default of 'Convex Hull' in the Rigid Body settings. Try changing to 'Mesh'.


Rock Generator says it doesn't work in 2.8 I've tried all the steps from searching other threads about using the Rock Generator in 2.8.

Every time I install the add-on  there is a yellow exclamation that says the add-on needs to be updated for 2.8.

Any ideas on how to get it working?

The error message you're seeing means that the add-on has not been updated for 2.8.  Until it is, it will not work in Blender 2.8.

You can either use it in Blender 2.79 (assuming it's compatible with 2.79), or wait for the add-on to be updated for 2.8.


BGE - how to keep child off, and pose for armature? I have a two problems at the start with BGE. In my scene there are two metarigs (rigged and skinned) with objects, which they interact.

When I start BGE first - one metarig go into rest pose, but the second metarig standing in pose normal

Second - objects not keep they "child off":

How to solve this problem?

Just re-parent the first metarig - all you have to do is press CtrlP.


how to animate camera zooming and FOV keyframes you know how you can, like, stretch the camera out to change the FOV? how do I make a keyframe of this movement, to sort of zoom in and out?

Inside the properties for the camera is a value for Focal Length

If you hover over the value and hit 'I' on your keyboard, you will create a keyframe for that value - at that frame.


Create light rays in Cycles I am trying to create something like volumetrics with a falloff: beams of light that shine visibly into the air from an emissive object, becoming gradually less visible as they get farther from the object.

This strikes me as involving some sort of volumetrics, which Cycles supports (yay!), but extruding the actual geometry out and giving it an emission volume shader either produces extreme blocks of light or none at all (and it doesn't have that cool flame appearance).

Plain text on a plane would be perfect!

Using a Gradient texture you can fade the volumetric emission off however you want:

In this case, since it should fade out spherically from the center of  the ring I used a spherical gradient:

The vector input of the gradient node defines the position and size of the resulting gradient.
Since in this case we want the center of the gradient to be in the center of the ring, the Object Coordinates (0,0,0 at the object's origin) are what we want. The multiply node scales the coordinate system, which lets us control the size of the gradient.

In the image above the rays are made up of an extruded text object:

For linear gradients, you might not even need the gradient node. For example, the Generated coordinate system has 0,0,0 at one corner of the object's bounding box and 1,1,1 at the opposite corner. Using this, you could fade an object out along it's length by using one of the axis as the gradient:


'Tris to Quads' on narrow faces does nothing As the question title states I tried importing a svg file, went to Edit mode A to select ALL, and control F, selected tris to quad and it won't work.
What am I doing wrong?

here's the blend file

Try increase the maximum angle threshold, this will give you quads, but they won't be very square.

For better results, run: Mesh -> Faces -> Beautify Faces first.


Why the alignment not match hi need help learning with the reference image I have align the side (right hand view) when im trying to align with the left hand view (front view) Mesh getting disturb

You have to realize that the reference is from side in orthographic view and from front in perspective. Try to check your model how it looks in perspective. You have to adapt some changes and model it by your guess to make it real, this reference inst good for modeling by exact shape from both views.


Faster blur effect in Blender VSE Blender's Video Sequence Editor allows you to use the Gaussian Blur effects strip to blur the image or video, however, it uses a lot of CPU and the rendering is slow like a hell. It takes around 2 minutes to apply a blur of 80×80 to a single frame of a 1920×1080 video which is unacceptably slow. It even makes the system lag a lot.

Are there any ways to make the blur effect faster?

Since I figured out the answer, I'll answer my own question.

Blender's Video Sequence Editor is an awesome tool; however, it lacks some functionality like some effects the Compositor has.

For example, there is no Fast Gaussian Blur which is a lot faster than the normal Gaussian Blur with a minor margin of error (see this page for a comparison; it's not exactly the Blender's implementation, but it's pretty close). Furthermore, as far as my preferences go, I actually prefer the look of the Fast Gaussian to the normal Gaussian Blur.

So, since there's no direct way of using the compositing feature for the video strips, the question is, are there any workarounds?

Fortunately, I was able to find a working add-on for that, it's called Edit Strip With Compositor.

Note: There's another add-on mentioned in this thread called VSE to Compositor, but it doesn't work for Blender 2.76b.

So, let's get to it.

In order to install and enable it, follow these steps:

Firstly, download the latest version (it's the version 0.14 for Nov
20, 2015).
Next we need to extract the Python script from the archive.
Now, you can either install the script from the User Preferences or if you want to make it system-wide, you can copy it to the Blender's add-ons folder (in my system it's /usr/share/blender/2.76/scripts/addons). Note that this might require some administrative privileges.
Then you need to go to the User Preferences in Blender and activate the add-on.
If you want to enable it by default (on Blender's startup), don't forget to click the Save User Settings button.

After enabling it, you can start using the compositing functionality for the VSE. Here's a demo of it; however, he uses the other add-on mentioned above in the note, but they're not that different.

To apply the effects from the Compositor to the VSE strip, you need to follow these steps:

Select a video strip first (yes, unfortunately, you cannot apply the effects to the effects strips itself, but you can apply other effects on top of it).
Press N on your keyboard to open the Properties panel.
Scroll down in the Properties panel until you see the Edit strip with Compositor section.
Click the Set master scene button.
Check the Show options checkbox.
In the Compositing, choose the Compositing option from the drop-down list.
In the Editing Screen, choose the Video Editing option.
Optionally, you can enable the Add Viewer option.
Click the Create Comp from strip button on top of the section.
Click the Edit Composition button.
Now, this should look familiar. It should get you to the Blender's Compositor. Let's add the Blur effect. Open the Add menu by pressing Shift+A and select Filter → Blur from there.
Drag the Blur node over the connection path and once it becomes white, make a single click.
From the drop-down menu, select Fast Gaussian instead of Gaussian and choose your X and Y values for the blur size.

It should look something like this (except for the Backdrop which I have disabled):

Switch back to the Video Editor layout and voilà! You can notice that the blur effect is much more responsive now.
In order to animate the effects, you need to switch back to the Compositor and utilize the keyframing from there.

Related questions:

Can I add the output of the VSE as input to the node diagram? — Blender Stack Exchange
Blur video track in Video Editor? — Blender Stack Exchange


Set material of a vertex group of a certain face I have a mesh and I want to know how I can color the whole vertex group of a certain face. I currently can color a face from a list as shown below, but I want to set the material of the whole vertex group of each of these faces in the list instead of just the faces.

for poly in bpy.data.objects['Mymesh'].data.polygons:
    #set material 1 for the whole mesh
    poly.material_index = 0

for a in list:
#set material 2 for some faces - I want it instead to set the material of vertex groups
#of these faces in the list instead of just the faces
bpy.data.objects['Mymesh'].data.polygons[a].material_index = 1

You can modify a previous answer to do this:

import bpy

o = bpy.context.object

for p in o.data.polygons:
    # Get all the vertex groups of all the vertices of this polygon
    verts_vertexGroups = [ g.group for v in p.vertices for g in o.data.vertices[ v ].groups ]

    # Find the most frequent (mode) of all vertex groups
    counts    = [ verts_vertexGroups.count( idx ) for idx in verts_vertexGroups ]
    modeIndex = counts.index( max( counts ) )
    mode      = verts_vertexGroups[ modeIndex ]

    groupName = o.vertex_groups[ mode ].name

    # If this polygon belongs to a specific VG, change its material
    if groupName == "VGwereInterestedIn":
        p.material_index = material_index # The material slot we want to use to shade polygons in this VG

EDITED:

I revised the code to answer the actual question, while leaving the above answer in case it interests other users. The code below takes a list of face indices and a material index, and assigns the material index to all the polygons that belong to these faces' vertex group/s.

import bpy

o = bpy.context.object

# List of face indices that represent vertex groups we want to shade with a specific material
myFaceList = [ 0, 100, 52, 32 ]

# Index of the material for shading the vertex group/s of the faces above
materialIndex = 1

def find_polygons_vertexgroup( p ):
    # Get all the vertex groups of all the vertices of this polygon
    verts_vertexGroups = [ g.group for v in p.vertices for g in o.data.vertices[ v ].groups ]

    # Find the most frequent (mode) of all vertex groups
    counts    = [ verts_vertexGroups.count( idx ) for idx in verts_vertexGroups ]
    modeIndex = counts.index( max( counts ) )
    mode      = verts_vertexGroups[ modeIndex ]

    return mode

for pi in myFaceList:
    # Find the current polygon's vertex group index
    vgIndex = find_polygons_vertexgroup( o.data.polygons[ pi ] )

    # Iterate over all polygons and change their material VG is the same
    for p in o.data.polygons:
        p_vgIndex = find_polygons_vertexgroup( p )

        if p_vgIndex == vgIndex:
            p.material_index = materialIndex


Glass shader looks dark depending on exposure setting, even though there is enough light in the scene to compensate I always work with sky and sun light high values to emulate real light, this leads me to use negative values on the exposure, usual linear workflow for better GI bounces, this causes the glass shader to look black, somehow, is there any setting to correct this or is it a 2.8 bug?

here you can see how only changing the exposure setting and the world intensity cahnges the shader appearance

I can replicate this - both by changing the Color Management 'Exposure' setting or by changing the Film 'Exposure' setting - although the two seem to be scaled differently, with the -10 -> +10 Color Management setting changing by a factor of 2 for each unit change (so '0' is 1, '1' is 2, '2' is 4, '3' is 8, etc. - with similar for negative values, so '-9' in your example seems to actually relate to a 'Film' exposure of 1/2^9 = 1/512 - so negative values are actually valid in this case.

After varying various other factors, I managed to get around the 'darkening' by disabling the 'Indirect Light' setting in the Light Paths panel (at 2.8 - at 2.79 this was in the Sampling panel). This seems to indicate that the issue is that the Indirect Light is being lost due to being below the Indirect Light clamping setting. Setting Indirect Light clamping to zero (to disable clamping) fixes the issue in my case.


How can I print only keyframes from code below? I just want to print a log if the current frame contains keyframe

is there any method lile: IsKeyframe or something similar?

import bpy
import math
import random
import time

ctx = bpy.context
ops = bpy.ops
obj = ctx.object

ctx.scene.frame_start = 0
ctx.scene.frame_end = 112
ctx.scene.frame_current = 0

for i in range(112):
    ctx.scene.frame_set(i)
    print("Frame %i" % i)

Finding keyframes is a little bit trickier, since any object in the scene could have a keyframe at a given frame.

So this script will check all objects for keyframes at each of the frames between beginning and end, and print out any keyframe on any channel, for each of the objects. It will also print out the value of that channel at that keyframe, just in case.

import bpy

S = bpy.context.scene
O = bpy.context.scene.objects

def isKeyframe( f ):
    for o in O:
        for fc in o.animation_data.action.fcurves:
            kfs  = [ kf.co[0]     for kf in fc.keyframe_points ]
            if f in kfs:
                amp = fc.evaluate( f )
                print(
                    "kf at %s for %s[%s] val: %s" % ( f, o.name, fc.data_path, amp )
                )

for i in range( S.frame_start, S.frame_end ):
    isKeyframe( i )

If you want this to apply only to the active object, use this code instead:

import bpy

S = bpy.context.scene
O = bpy.data.objects
o = bpy.context.object

def isKeyframe( f ):
    for fc in o.animation_data.action.fcurves:
        kfs  = [ kf.co[0]     for kf in fc.keyframe_points ]
        if f in kfs:
            amp = fc.evaluate( f )
            idx = fc.array_index
            print(
                "kf at %s for %s[%s(%s)] val: %s" % ( f, o.name, fc.data_path, idx, amp )
            )

for i in range( S.frame_start, S.frame_end ):
    isKeyframe( i )

Sample output for a scene I just tested:

kf at 33 for Lamp[scale(0)] val: 1.0
kf at 33 for Lamp[scale(1)] val: 1.0
kf at 33 for Lamp[scale(2)] val: 1.0
kf at 70 for Lamp[rotation_euler(0)] val: 0.6503279805183411
kf at 70 for Lamp[rotation_euler(1)] val: 0.055217113345861435
kf at 70 for Lamp[rotation_euler(2)] val: 1.8663908243179321

EDIT: Must add a small disclaimer to this answer. This is will only print out keyframes on objects. This doesn't show keyframes on compositor nodes, scene settings and other non-object related properties. To get those, You need to alter the code a bit and read the fcurves from the specific keyframed element in question.


2.8 Can't find "Create orientation" in the menus, therefore can't add it to "Add to quick favorites" does not work in Search Search says "create orientation" is in Transform menu, but it's not there.
Where is it ?

I did map my own key combination for it, but still.
The one from 2.79 ,   Ctrl+Alt+Space

Would be much easier if anything could be added to quick favourites directly from Search, to streamline the processes even more.

 "Add to quick favorites" does not work in Search

Is it what you're looking for? You can right click to create a shortcut: