Swap low resolution mesh for high resolution at render. #31625

Closed
opened 2012-05-28 17:21:19 +02:00 by Aaron Symons · 24 comments

Project: Blender Extensions
Tracker: Py Scripts Upload
Blender: 2.63
Category: Render
Python: 3.1
Script name: render_swap_lod.py
Author(s): Aaron Symons
Status: Open

%%%Features:

  • Swap low-res mesh for corresponding high-res at render
  • Swap low-res mesh for corresponding high-res in 3D View
  • User-defined naming convention

Setup:
The file should go into: scripts/addons/
Enable the addon by going to: User Preferences > Render > Swap L.O.D.

In order for it to work, you must adhere to a naming convention, example:

Low-resolution object:

  • Object Name - ‘my object_lo’
  • Mesh Data Name - ‘my object_lo’

Corresponding High-resolution object:

  • Object Name - ‘my object_hi’
  • Mesh Data Name - ‘my object_hi’

Manual:
Once everything is set, check the ‘Enable Swap’ checkbox to enable the swap. When you render the scene, all low-resolution objects will have the high-resolution mesh data, and will revert back to their low-resolution state after rendering.
Checking ‘Enable Swap’ also allows you to swap resolutions within the viewport, using the buttons that become active – useful for checking composition before rendering.

To use your own naming convention, check ‘Use Custom’ to display the text fields where you give the naming convention you’re using. Please note: what is typed in the 'Use Custom' text fields is for the script only; this will not change any object names or mesh data names.

%%%

**Project**: Blender Extensions **Tracker**: Py Scripts Upload **Blender**: 2.63 **Category**: Render **Python**: 3.1 **Script name**: render_swap_lod.py **Author(s)**: Aaron Symons **Status**: Open %%%Features: - Swap low-res mesh for corresponding high-res at render - Swap low-res mesh for corresponding high-res in 3D View - User-defined naming convention Setup: The file should go into: scripts/addons/ Enable the addon by going to: User Preferences > Render > Swap L.O.D. In order for it to work, you must adhere to a naming convention, example: Low-resolution object: - Object Name - ‘my object_lo’ - Mesh Data Name - ‘my object_lo’ Corresponding High-resolution object: - Object Name - ‘my object_hi’ - Mesh Data Name - ‘my object_hi’ Manual: Once everything is set, check the ‘Enable Swap’ checkbox to enable the swap. When you render the scene, all low-resolution objects will have the high-resolution mesh data, and will revert back to their low-resolution state after rendering. Checking ‘Enable Swap’ also allows you to swap resolutions within the viewport, using the buttons that become active – useful for checking composition before rendering. To use your own naming convention, check ‘Use Custom’ to display the text fields where you give the naming convention you’re using. Please note: what is typed in the 'Use Custom' text fields is for the script only; this will not change any object names or mesh data names. %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

%%%Wiki page: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Render/Swap_LOD

Sorry, I'm not sure how to edit the info.%%%

%%%Wiki page: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Render/Swap_LOD Sorry, I'm not sure how to edit the info.%%%
Author

%%%Latest file is: render_swap_lod-1.zip

This one has the links to Wiki and Tracker pages in the bl_info, whereas the other one does not.

Again, oopsy!%%%

%%%Latest file is: render_swap_lod-1.zip This one has the links to Wiki and Tracker pages in the bl_info, whereas the other one does not. Again, oopsy!%%%
Author

%%%UPDATE:

New version (v0.1.1) - http://projects.blender.org/tracker/download.php/153/467/31625/20878/render_swap_lod-2.zip

Changes (UI):

  • Put 'Enable Swap' and 'Use Custom' side-by-side in a box. Seems a little nicer.%%%
%%%UPDATE: New version (v0.1.1) - http://projects.blender.org/tracker/download.php/153/467/31625/20878/render_swap_lod-2.zip Changes (UI): - Put 'Enable Swap' and 'Use Custom' side-by-side in a box. Seems a little nicer.%%%
Author

%%%I've been making a silly mistake- renaming the zipped folder AFTER zipping!

This is the current version (v0.1.1): render_swap_lod-2-update.zip

Thanks, and sorry for my stupidity! :)%%%

%%%I've been making a silly mistake- renaming the zipped folder AFTER zipping! This is the current version (v0.1.1): render_swap_lod-2-update.zip Thanks, and sorry for my stupidity! :)%%%
Author

%%%One very important thing I haven't mentioned is that the high-res version must be on a different scene layer to the low-res!

So, for example;

low-res = layer 1
high-res = layer 2

Very sorry to anyone who has tried to use it so far and it's failed!%%%

%%%One very important thing I haven't mentioned is that the high-res version must be on a different scene layer to the low-res! So, for example; low-res = layer 1 high-res = layer 2 Very sorry to anyone who has tried to use it so far and it's failed!%%%
Author

%%%UPDATE:

New version (v0.1.2) - render_swap_lod-3.zip

Changes (CODE):

  • Cleaned up; in both the Swap_LOD and Revert_LOD classes, the same function was, basically, defined twice! Now, it's defined once.%%%
%%%UPDATE: New version (v0.1.2) - render_swap_lod-3.zip Changes (CODE): - Cleaned up; in both the Swap_LOD and Revert_LOD classes, the same function was, basically, defined twice! Now, it's defined once.%%%
Author

%%%UPDATE (CODE, UI, IMPLEMENTATION):

A near complete re-write of the addon.
As of: v0.1.3
Wiki (with screen-shots): http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Render/Swap_LOD
Naming convention of file upload now includes version number: render_swap_lod-v0-1-3.zip

During render, the low-resolution object's mesh data is swapped with a defined high-resolution mesh data.

To use it, simply select the low-resolution object and go to it's Object Data tab (Properties Window -> Object). At the bottom you should see three properties under the 'Custom Properties' panel, named: "swapRes_enable", "swapRes_high", and "swapRes_low". If these do not show, either collapse and expand the 'Custom Properties' panel, or click "Update" (Tools (T) -> Swap L.O.D. -> Update).

  "swapRes_enable" - Toggle to enable or disable it from swapping resolution
  "swapRes_high" - Name of the high-resolution Mesh Data to use
  "swapRes_low" - Name of the low-resolution Mesh Data to use (use it's own Mesh Data name) 

Once everything is set, check the "Enable Swap" checkbox (Tools (T) -> Swap L.O.D. -> Enable Swap) to enable the swap during render. When you render the scene, all enabled low-resolution objects will have the high-resolution mesh data, and will revert back to their low-resolution state after rendering. Checking "Enable Swap" also allows you to swap resolutions within the viewport, using the buttons that become active when checking this option – useful for checking composition before rendering.

Happy swapping!

Big thanks to Jason van Gumster (Fweeb) for his ideas and contributions to helping me make this a very flexible addon!%%%

%%%UPDATE (CODE, UI, IMPLEMENTATION): A near complete re-write of the addon. As of: v0.1.3 Wiki (with screen-shots): http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Render/Swap_LOD Naming convention of file upload now includes version number: render_swap_lod-v0-1-3.zip During render, the low-resolution object's mesh data is swapped with a defined high-resolution mesh data. To use it, simply select the low-resolution object and go to it's Object Data tab (Properties Window -> Object). At the bottom you should see three properties under the 'Custom Properties' panel, named: "swapRes_enable", "swapRes_high", and "swapRes_low". If these do not show, either collapse and expand the 'Custom Properties' panel, or click "Update" (Tools (T) -> Swap L.O.D. -> Update). ``` "swapRes_enable" - Toggle to enable or disable it from swapping resolution "swapRes_high" - Name of the high-resolution Mesh Data to use "swapRes_low" - Name of the low-resolution Mesh Data to use (use it's own Mesh Data name) ``` Once everything is set, check the "Enable Swap" checkbox (Tools (T) -> Swap L.O.D. -> Enable Swap) to enable the swap during render. When you render the scene, all enabled low-resolution objects will have the high-resolution mesh data, and will revert back to their low-resolution state after rendering. Checking "Enable Swap" also allows you to swap resolutions within the viewport, using the buttons that become active when checking this option – useful for checking composition before rendering. Happy swapping! Big thanks to Jason van Gumster (Fweeb) for his ideas and contributions to helping me make this a very flexible addon!%%%
Member

%%%hi & welcome :)%%%

%%%hi & welcome :)%%%
Author

%%%Hello there! :)

Sorry for all my posts yesterday. I like things clean and organised, but I was just too excited to get my first addon available that my mind escaped me a few times! Plus, as soon as I was uploading I found little improvements that could be made. :P

I hope my addon proves good. Any comments, or suggestions of improvements or features are welcome! :) I'm already thinking of some improvements, so you may see an update soon!%%%

%%%Hello there! :) Sorry for all my posts yesterday. I like things clean and organised, but I was just too excited to get my first addon available that my mind escaped me a few times! Plus, as soon as I was uploading I found little improvements that could be made. :P I hope my addon proves good. Any comments, or suggestions of improvements or features are welcome! :) I'm already thinking of some improvements, so you may see an update soon!%%%
Author

%%%The updated file (render_swap_lod-v0-1-3-update.zip) contains links to Tracker and Wiki pages. Whoops! :)%%%

%%%The updated file (render_swap_lod-v0-1-3-update.zip) contains links to Tracker and Wiki pages. Whoops! :)%%%
Author

%%%Slight update. It seems I haven't been registering it properly:

Prepended "bpy.utils" before register and unregister module.%%%

%%%Slight update. It seems I haven't been registering it properly: Prepended "bpy.utils" before register and unregister module.%%%
Author

%%%UPDATE.

I finally realised that it wasn't working properly- due to my lack of testing!

ISSUES (RESOLVED):

  • Hitting the "update" button wouldn't add the custom properties to new objects.

ADDED:

  • For newly created objects. the 'swapRes_low' property is now automatically given the name of the object's mesh data by default.
  • The UI panel now only displays in object mode context.%%%
%%%UPDATE. I finally realised that it wasn't working properly- due to my lack of testing! ISSUES (RESOLVED): - Hitting the "update" button wouldn't add the custom properties to new objects. ADDED: - For newly created objects. the 'swapRes_low' property is now automatically given the name of the object's mesh data by default. - The UI panel now only displays in object mode context.%%%
Author

%%%UPDATE:

Some code cleaning - subtracted two unnecessary functions. Apart from that, some slight rephrasing of a couple of descriptions/tooltips for easier reading.

Current version: render_swap_lod-v0-1-3-update4.zip%%%

%%%UPDATE: Some code cleaning - subtracted two unnecessary functions. Apart from that, some slight rephrasing of a couple of descriptions/tooltips for easier reading. Current version: render_swap_lod-v0-1-3-update4.zip%%%
Author

%%%UPDATE:

Added:

  • "Show Enabled" and "Show Disabled" buttons for a quick check and/or edit of properties (useful for bigger and more complex scenes)
    From here, the user can enable or disable objects from swapping, as well as view and change low and high-res Mesh Data used by the object (by clicking "Mesh Data")

Updated:

  • "Update" button automatically updates the "Show Enable" and "Show Disable" lists, as well as updating the new objects
  • Lamps and Cameras don't get the custom properties (why should they get properties that will never be used for them? wink)
  • Some minor UI adjustments

Happy swapping! :)%%%

%%%UPDATE: Added: - "Show Enabled" and "Show Disabled" buttons for a quick check and/or edit of properties (useful for bigger and more complex scenes) From here, the user can enable or disable objects from swapping, as well as view and change low and high-res Mesh Data used by the object (by clicking "Mesh Data") Updated: - "Update" button automatically updates the "Show Enable" and "Show Disable" lists, as well as updating the new objects - Lamps and Cameras don't get the custom properties (why should they get properties that will never be used for them? *wink*) - Some minor UI adjustments Happy swapping! :)%%%
Author

%%%UPDATE:

Changed:

  • I re-wrote the "update_objects()" function (used by the "Update" button), and added a function to check whether an object is new or not; "is_new_object()"
    This is a better system than the old one, as I found a couple of hiccups behind the scenes, which this new system seems to resolve! It's much simpler by design, allowing just one check to be done using one TRY-EXCEPT, instead of several IF-ELSE statements - which weren't 100% effective anyway, to be honest.

  • Slight change in UI; I added the "eye" icon to the "Mesh Data" button, and I'm also using the 'RESTRICT_VIEW' versions, as opposed to the "VISIBLE_IPO" ones I was previously using. ;)

  • I also noticed a couple of errors in the code, where I seemed to be assigning values where I wanted to check them, example; I had: obj.swapRes_high instead of obj['swapRes_high']

I haven't spotted anything else. So far, so good! :)%%%

%%%UPDATE: Changed: - I re-wrote the "update_objects()" function (used by the "Update" button), and added a function to check whether an object is new or not; "is_new_object()" This is a better system than the old one, as I found a couple of hiccups behind the scenes, which this new system seems to resolve! It's much simpler by design, allowing just one check to be done using one TRY-EXCEPT, instead of several IF-ELSE statements - which weren't 100% effective anyway, to be honest. - Slight change in UI; I added the "eye" icon to the "Mesh Data" button, and I'm also using the 'RESTRICT_VIEW' versions, as opposed to the "VISIBLE_IPO" ones I was previously using. ;) - I also noticed a couple of errors in the code, where I seemed to be assigning values where I wanted to check them, example; I had: obj.swapRes_high instead of obj['swapRes_high'] I haven't spotted anything else. So far, so good! :)%%%
Author

%%%I forgot to mention another good change!

The values of the properties are never lost now, for example; Object1 has:

swapRes_enable = True
swapRes_high = "a high resolution version"
etc....

Whe closing and re-opening the .blend file, those values will still be there.

This is a result of the re-written update system - nothing is ever lost! So, if you have twenty objects set how you want, you can be safe in the knowledge that those values will still be there the next time you open the .blend file. :)%%%

%%%I forgot to mention another good change! The values of the properties are never lost now, for example; Object1 has: swapRes_enable = True swapRes_high = "a high resolution version" etc.... Whe closing and re-opening the .blend file, those values will still be there. This is a result of the re-written update system - nothing is ever lost! So, if you have twenty objects set how you want, you can be safe in the knowledge that those values will still be there the next time you open the .blend file. :)%%%
Author

%%%UPDATE:

Added:

  • A "Never Swap" option. This is mainly so objects that will never be involved in high/low-res swapping won't be listed when showing disabled (keeping it to just those we need to see).
    This would be for things like floors, walls, and anything else that doesn't need to be listed here.

  • A "Show All" button, which lists every object in the scene, excluding lights and cameras

Apart from that, some more code cleaning.

I thnk it's reached the stage where I need some user feedback now, and getting it tested in real-world scenarios and big scenes. So, there probably won't be an update for a little while. That is, unless I think of some useful additions and/or changes. :)%%%

%%%UPDATE: Added: - A "Never Swap" option. This is mainly so objects that will never be involved in high/low-res swapping won't be listed when showing disabled (keeping it to just those we need to see). This would be for things like floors, walls, and anything else that doesn't need to be listed here. - A "Show All" button, which lists every object in the scene, excluding lights and cameras Apart from that, some more code cleaning. I thnk it's reached the stage where I need some user feedback now, and getting it tested in real-world scenarios and big scenes. So, there probably won't be an update for a little while. That is, unless I think of some useful additions and/or changes. :)%%%
Author

%%%Also! :)

If the user tries to swap resolutions and the mesh data name cannot be found, a error message will appear above the UI and details of the error to the Console (name of the mesh data that counldn't be found and the object it was supposed to be assigned to). This is just incase the user changes a mesh data name, for some reason, and forgets to update the fields in the addon - you never know, don't want to keep them wondering! ;)%%%

%%%Also! :) If the user tries to swap resolutions and the mesh data name cannot be found, a error message will appear above the UI and details of the error to the Console (name of the mesh data that counldn't be found and the object it was supposed to be assigned to). This is just incase the user changes a mesh data name, for some reason, and forgets to update the fields in the addon - you never know, don't want to keep them wondering! ;)%%%

%%%Aaron,
that sounds quite promising.
I was thinking about if flipping the default behaviour of the "Never Swap" option was perhaps better? As there perhaps are many more objects which you don't want to swap. But then i realized that this is not really the case ... rather the other way round.
And it's a list anyway ... i'm sure i will test this after my current aerospace project (when plan to follow one of the genious tutorials of the legendary cgcookie David Ward).

Many good artists around here ... and developers of course which make this possible. Quite impressed.%%%

%%%Aaron, that sounds quite promising. I was thinking about if flipping the default behaviour of the "Never Swap" option was perhaps better? As there perhaps are many more objects which you don't want to swap. But then i realized that this is not really the case ... rather the other way round. And it's a list anyway ... i'm sure i will test this after my current aerospace project (when plan to follow one of the genious tutorials of the legendary cgcookie David Ward). Many good artists around here ... and developers of course which make this possible. Quite impressed.%%%
Author

%%%Hi Jon,

The "Never Swap" option just prevents that object from showing in the UI list to keep things concise for the user.

David Ward actually inspired me to write this addon when watching one of his tutorials on his YouTube channel. He used low poly place-holders for his high poly models so he could get an idea of the composition, then swapped the mesh data of the place-holders with the high poly models when rendering. I thought this should be an easier process, so I wrote this little addon. :)

I'll be looking at this addon again and might be rewriting it, as I think it could do with another look. Plus, I have a couple of ideas for updates.

Thanks for your interest, and I hope you find it useful!%%%

%%%Hi Jon, The "Never Swap" option just prevents that object from showing in the UI list to keep things concise for the user. David Ward actually inspired me to write this addon when watching one of his tutorials on his YouTube channel. He used low poly place-holders for his high poly models so he could get an idea of the composition, then swapped the mesh data of the place-holders with the high poly models when rendering. I thought this should be an easier process, so I wrote this little addon. :) I'll be looking at this addon again and might be rewriting it, as I think it could do with another look. Plus, I have a couple of ideas for updates. Thanks for your interest, and I hope you find it useful!%%%

The new developer system is brilliant. Didn't notice this post before. Thanks for clarifying!

What a coincidence with David Ward. I remember the tutorial you mentioned. :)

Clearly very useful your addon! And even better and more useful now that I have to dig deeper into BGEngine too. Keep it up masters! (have to tidy up my addons too .. probably for 2.7)

The new developer system is brilliant. Didn't notice this post before. Thanks for clarifying! What a coincidence with David Ward. I remember the tutorial you mentioned. :) Clearly very useful your addon! And even better and more useful now that I have to dig deeper into BGEngine too. Keep it up masters! (have to tidy up my addons too .. probably for 2.7)
Member

hi,
This addon is currently Broken & not updated.
As part of maintenance & clean up of older addon pages I'm closing this Tracker Page for now.
Please feel free to re-submit an updated version & we can re-open the page.
Thanks.
Brendon.

hi, This addon is currently Broken & not updated. As part of maintenance & clean up of older addon pages I'm closing this Tracker Page for now. Please feel free to re-submit an updated version & we can re-open the page. Thanks. Brendon.
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#31625
No description provided.