Highpoly instancing script for Blender 2.8 (WIP)

Hey guys,

This is my first python script for blender 2.80:
Blender 2_80_Proxy Tools.py (11.8 KB)

The script creates ‘vray proxy’ like vertex cloud representations of highpoly objects as I think that is a feature which is missing in blender especially when it comes to foliage in architectural visualistion or landscape scenes. (Some inspiration was taken from Manuel Geissinger’s BlenderProxy Addon)

To do that it makes use of collection instances and offloading the original highpoly objects in a separate library file, if desired.
I tested the script with tree models with 1mio+ polygons. In particle systems with up to 10.000 instances my viewport is still responding very well, compared to the solid display of the same models. To a certain point the vertex cloud representation is more accurate then bounding box. With high numbers of instances the view gets very crowded, however, masses are still readable in my opinion.

Proxy%20Tools%20Description
So far I kept the panel quite simple:

  • Reduce Vertices determines the amount of vertices that will be deleted when creating the vertex cloud and accordingly its density
  • Offload Geometry will create a separate proxy_library.blend file to store the highpoly object if checked, if not, all objects and collections that are created by the script will be unlinked from the scene but still remain in the current .blend file
  • Create Proxy will create a vertex cloud representation of the active object

I am uploading it to get suggestions on how to fix some errors like the pre and post render buttons/ operators as they do not work as I want them to.
Their purpose is to prepare the scene for preview render by changing the viewport visibilities and display types of the proxy objects. That way it is possible to render the highpoly objects in preview. (For final renders it is not necessary to press these buttons)
The error occurs after creating the vertex cloud proxy. I guess it’s because the operators are meant to effect certain objects in the scene but exactly these objects are removed while the script is running. The result is that the display type of the objects is not changed correctly.
I don’t know if there is another way to change the object’s display type apart from bpy.context.scene.objects.display_type or if I am just using the wrong arguments for the operators. I am open for tips and suggestions on how to correct that.

Moreover, I would be glad if some of you are willing to test the script and report any bugs or inconviences that need to be fixed. Also, if you have tips to improve the script’s performance or anything else I would be happy to know.

As this is my first script I want to apoligize in advance for any style mistakes in the code. It is still work in progress and far from being perfect. Help is always welcome.

All that being said, I hope you like it and that it supports you in your workflow.

Greetings,
xrogueleaderx

18 Likes

Thanks , excellent idea :grinning:

Thanks for sharing, absolutely awesome initiative.

You’re welcome, i’m glad somebody finds it usefull.

I hope this newer version is a little more convinient.
Blender 2_80_Proxy Tools.py (13.4 KB)

Changes:

  • You can now install it just like a regular addon from the .py file
  • Pre/ Post Render buttons work now
    Pre Render sets the display type of all proxy objects to bounds and turns the highpoly objects visible for viewport render
    Post Render turns highpoly objects invisible and sets the display type back to ‘solid’ (vertex clouds)
  • I added the possibility to define custom paths for the original objects.
    Make sure you safe each object in its own file because the current script will completely overwrite the content of an existing file. Previously store data will be lost. I am searching for a way to fix that
  • Create Proxy now works with objects that have modifiers

I also did some tests to figure out the limits of the addon:
I set up a plane 2000 x 2000m with three particle systems that use proxy objects. Three highpoly trees (740.000, 850.000 and 1.800.000 faces) were turned into proxies and scattered on the plane.

The first set up I did was with 30.000 instances (34.000.000.000 faces) in total. You can see the results below. Navigation is still good but the viewport got a little glitchy (might have to do with the scale of the scene itself). These gltches didn’t effect the actual renders.

With 90.000 instances (100.000.000.000 faces) in total the viewport started lagging slightly but the performance was still ok.

At 150.000 instances the viewport finally gave up but in that case you still could reduce the amount of displayed instances in the particle system’s settings.

For comparison, using normal linked collection instances I didn’t get past 3.000 instances with the same set up The viewport was unusable at this stage.

(btw my computer: Ryzen Threadripper1950x, GTX 1080 ti, 32GB RAM)

So that’s the current state for now. I think it would be nice to have differently coloured vertex clouds for each object like Forest Pack does but i don’t know if that is even possible. If someone has any idea how to implement that or other improvements please let me know.

Greetings,
xrogueleaderx

3 Likes

Nice Update ,

For color variation you can use the node object info random , color variation for each object

For random vertex color there is a script but this works for to make random colors for the leafs for example not sure if this is going to work with a complex tree for small plants this works fine

https://blender.stackexchange.com/questions/76520/how-to-get-random-color-variation-on-a-single-mesh/76583

Maybe you can ask for some help from blenderstackexchange , i’m sure they have a solution to make this addon better

Look forward to your solutions :grinning::grinning:

And it works fine with duplifaces :

1 Like

Very nice render. And great to hear it’s working with duplifaces as well. Did you have to modify the collection instance to make it work?

Regarding your suggestion on randomizing vertex colors, the script could be a good time safer. :+1:
My actuall problem is something else though. The proxy objects consisting of loose vertices are always displayed as black-greyish clouds which makes it hard to distiguish between models if you have higher counts. That’s the way it is hard coded in Blenders source code. I was able to figure out the file which is responsible for this coloring and did some succesful tests to change it.
Now I am trying to wrap my head around the vertex color code (or alternatively the cycles diffuse color displayed in the viewport) to get it somehow to effect the loose vertices color and get a color variation.

Any help would be greatly appreciated :smiley:

For Dupliface or instance with blender 2.8 i have changed nothing , it works just fine , for the color variation i have use the object info random node

1).For plants you can use the random vertexcolor script to loose vertices and drive this to hue sat/lum etc… to get some colorvariations
2).Another option you can make a swith to select random texture by the vertexcolor
3).You can make a plant with 10 or 5 different leaves that way you have somecolorvariation that you can drive with hue/sat etc …

Basicswitch example to randomize for example the texture or Color .

Basic idea to use the random vertcol to drive for example a ramp for colorvariation

With seed and vertcolors or you drive this by location


HI im blender newbie, thanks for this script but im having an issue this is my car object i want to make it proxy, i have first made CRTL+J to merge into one piece, everything fine until i hit create poxy, blender crash and closes, whats making blender crash to much polygons? or i need reduce it polycount?

thankyou!!

Hi relox,

I encountered the same problem with the 2.80 release.
It seems like Blender has a problem with the operator that clears all material slots of the proxy object causing the program to crash.

This updated version should work without crashing but it doesn*t clear the materials at the moment. If necessary you can delete them manually.
Blender 2_80_Proxy Tools_v1_1.py (13.5 KB)

Greetings,
xrogueleaderx

Hi Benny,

sorry for replying that late.
It looks like there is a misunderstanding in our both intentions.
What you are explaining is how to use the Vertex Color information of a mesh to color the mesh itself.

However, that is not what I am looking to achieve.
Here an example of proxy object derived from a shrub.

When selected, the vertex cloud reads well on the dark background. But if I deselect it, the dark color of the individual vertices makes it hard to distiguish the vertex cloud from the background or other proxy objects.
The vertices’ color (not to confuse with Vertex Color in this case) is hard coded in Blender’s draw code and I am searching for a possibilty to color these individual vertex clouds randomly (like colored wireframe mode) to make objects more readable against the background and other obejcts.

Something like this:


A colored display like Corona Proxy would be a great start and like FP by materials the ultimate goal :slight_smile:

2 Likes

I was waiting for something like this for a long time. As an archviz artist I need to place lots of trees in environment scene will try it out. Thanks for the addon.

You can display the empty with a image , not the best solution but better this then nothing

That would be an option but I personally would value the volumne display higher at this point.
I will come up with a solution for this eventually :smiley:

4 Likes

Awesome, blender so need an improvement in this area, I’ll test it when I have time

1 Like

indeed volume display is the point of this ! the only thing missing is colors of the vertex like the forest pack example up above, this could be a dream !

also there’s octane who only shows the origin point as a proxy, no geometry at all !. It could be really cool for blender, even better perfs i assume !

1 Like

Noob question:
how to modify the proxied object?

Actually, it’s a good question. At the moment the addon doesn’t offer such a function. So you would have to do that manually.

In that case, it depends on wether you used ‘offload geometry’ or not. If you did you will have to navigate to the proxy.blend and do the adjustments there. There was an addon called ‘Edit linked library’ which can open linked files in one click or so but I don’t know if it was or will be ported to 2.8.

If you didn’t, you can set the outliner to ‘Blend File’ which displays all datablocks in your file. In ‘Collections’ you will find the proxy collection with the highpoly (hi) and lowpoly (lo) object. You can link the original highpoly model to the scene and do your adjustments. Note that the vertex cloud proxy will not adap to the changes to the highpoly mesh. If you do a lot of changes I would suggest you create a new proxy to keep the proxy display accurate.

For local materials it’s a little easier. You can go to the shader editor and select the material you desire to change. For preview you can off course use the pre render button to make the object visible in cycles viewport render.