[Plugin] Slender - Baking textures in Sketchup with Blender

[Plugin] Slender - Baking textures in Sketchup with Blender

Postby qpik » Sun Apr 30, 2017 2:50 pm

I just started developing this plugin. The most importent question at this stage is whether it's worth developing having Unity etc. around.

Note: I've been away for some time, so please move this topic, if it's in the wrong place.
Please also note I'm not a professional programmer, any help cleaning up the code is appreciated.


Info
  • Description: Exports SketchUp model do Collada file, in command-line mode imports into Blender scene, bakes textures, exports Collada file from and finally imports to SketchUp
  • System: Windows 10 64-bit
  • SketchUp version: 2017
  • Blender version: 2.78c
slender_shadows_4.jpg

Installation and running:
  1. Download and install latest Blender https://www.blender.org/download
  2. Download attached zip file and decompress it anywhere
  3. Open slender.skp file in SketchUp (any file will do, but this one is fail-safe, check: issues)
  4. Load slender.rb (with correct path) in SketchUp console
Functionality (all files are saved in plugin's folder):
  1. slender.rb:
    • exports model to slender.dae file with materials
    • updates slender.log file
    • exports sun direction to slender.sun file
    • runs slender.bat
    • waits for Blender to finish (reading log file) or stop in 30s
    • imports slender.dae
  2. slender.bat:
    • opens slender.blend scene (with enviroment lighting set up) in command-line Blender
  3. slender.py:
    • imports slender.dae file
    • imports sun direction from slender.sun file and rotates the sun
    • creates new UV layers with blank images
    • bakes full render to textures
    • creates new materials using baked textures and UV layers
    • exports and overwrites slender.dae
    • overwrites slender.log file
Issues to fix or add:
  • SketchUp:
    • textures on both sides of faces cause z-fighting issue
    • no textures cause Blender error
    • multiple component instances cause no texture issue
  • Blender:
    • add plugin menu/buttons
    • add support for sun
    • add shadows on/off detection
    • add support for various types of materials
    • add support for Cycles engine (GPU)
2
Last edited by qpik on Wed May 03, 2017 7:39 pm, edited 12 times in total.

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby JQL » Sun Apr 30, 2017 3:24 pm

I haven't downloaded the file, but the idea is to have this plugin baking Ambient Occlusion into sketchup textures?

I really like the idea of sending the model to Blender, doing something automatically there and reloading it back into Sketchup with the added effect.

I'll love see how this develops.
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Sun Apr 30, 2017 4:12 pm

Yes and no, the idea is to bake rendered scene in Blender and bring it back to SU.

I started with simple Environment Lighting (not exactly Ambient occlusion), but I plan on baking realistic sun shadows and possibly all kinds of lighting and materials (except live reflections and caustics). What I posted is just a couple days of work, re-learning Ruby and catching up on new SU API plus learning Blender and Python (amazing progress, I think the last time I looked at it was ca 10 years ago).

I just wonder if Unity or Unreal (haven't used them yet) are easy enough to make such plugin obsolete.
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby JQL » Sun Apr 30, 2017 6:48 pm

qpik wrote:Yes and no, the idea is to bake rendered scene in Blender and bring it back to SU.

I started with simple Environment Lighting (not exactly Ambient occlusion), but I plan on baking realistic sun shadows and possibly all kinds of lighting and materials (except live reflections and caustics). What I posted is just a couple days of work, re-learning Ruby and catching up on new SU API plus learning Blender and Python (amazing progress, I think the last time I looked at it was ca 10 years ago).

I just wonder if Unity or Unreal (haven't used them yet) are easy enough to make such plugin obsolete.


I've been investigating Unity and Unreal latelly from time to time.

What it seems to me is that Blender is capable of exporting 3d objects but the same is not happening with render engines.

You can have a baked lighting model inside Unity and Unreal for a great experience, but it would be very nice to have a baked lighting model inside Sketchup and use that in Layout for instance.

We have Lightup which is capable of a texture atlas and I believe it also can bake light in the model. However, Cycles is much more realistic.

There is also a plugin called BlendUp which seamlessly exports from SU to Blender and it does it very well. It doesn't bring back the model to SU though that can probably be done easily enough (I was never able to bring back a textured model myself...)
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Sun Apr 30, 2017 7:35 pm

JQL wrote:You can have a baked lighting model inside Unity and Unreal for a great experience, but it would be very nice to have a baked lighting model inside Sketchup and use that in Layout for instance.,

I guess it's worth a shot then.

JQL wrote:We have Lightup which is capable of a texture atlas and I believe it also can bake light in the model. However, Cycles is much more realistic.

I've been using LightUp some time ago, but I also found it not realistic enough and the lightmap wasn;t actually baked into the SU model.

JQL wrote:There is also a plugin called BlendUp which seamlessly exports from SU to Blender and it does it very well. It doesn't bring back the model to SU though that can probably be done easily enough (I was never able to bring back a textured model myself...)

I read about it but haven't tried. I always had the idea of Blender as this old, unfriendly Linux program and always used Kerkythea export. Cycles GPU was the thing that drew me to Blender now.

I added sun export/render.
slender_shadows.jpg

slender_shadows_2.jpg
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby JQL » Sun Apr 30, 2017 8:16 pm

So tell me one thing. Slender exports to blender does it all by itself and imports it back baked?

That is very cool.

I wonder if it is compatible with Thea for Blender.
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Sun Apr 30, 2017 8:54 pm

JQL wrote:So tell me one thing. Slender exports to blender does it all by itself and imports it back baked?

Exactly.

JQL wrote:I wonder if it is compatible with Thea for Blender.

If only it can bake textures then I'd say yes. The plugin uses existing importers/exporters, so its main purpose is to automate unwrapping meshes and creating materials.
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby JQL » Sun Apr 30, 2017 9:45 pm

And how will you make the material assignement?

Material code names? Like Glass, Metal, Wood and the likes? Or you won't get into material properties?
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Sun Apr 30, 2017 10:41 pm

JQL wrote:And how will you make the material assignement?

Material code names? Like Glass, Metal, Wood and the likes? Or you won't get into material properties?


I don't know yet, maybe. Or a class for managing materials in SU and exported to COLLADA. Probably the first solution would be easier to extend with external material libraries.

Specularity/bump etc. are worth supporting but reflections/refraction can't be really baked, so its no use going too much into detail.
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby JQL » Sun Apr 30, 2017 11:36 pm

Well, I think it'll be nice if you pull it off. I wish you good luck and I'm following the thread.
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby gio » Mon May 01, 2017 2:02 am

JQL wrote:Well, I think it'll be nice if you pull it off. I wish you good luck and I'm following the thread.


+1

Ciao,
Gio
0

gio 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby filibis » Wed May 03, 2017 1:26 pm

Hi qpik, this will definetely be a useful plugin and worth developing i believe.

Couple of things to note; i didn't know how to load a plugin via SU Console (assuming you meant Ruby Console?) and i found out i needed to type this with inverted commas: Load 'slender.rb'
You may consider to add info considering newbies to plugin world like me (: even at this stage to be able to test.

qpik wrote:
JQL wrote:So tell me one thing. Slender exports to blender does it all by itself and imports it back baked?

Exactly.

That just didn't work for me.
I opened your file and run the plugin via Ruby console and received the 'true' result but there is no COLLADA (.dae) file in the folder (there are textures exported though). And seems nothing happened.
Am i doing something wrong? If you could demonstrate with .gif or video, that would be great.
0
User avatar
filibis 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Wed May 03, 2017 3:02 pm

Have you unpacked the whole 'slender' folder from the zip file?
Do you have blender installed? Maybe the installation path is different than mine (C:\Program Files\Blender Foundation\Blender\blender.exe), check slender.bat in the 'slender' folder.
In sketchup open Ruby Console and type

Code: Select all
load 'C:/../../slender/slender.rb'

with the actual path.
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby filibis » Wed May 03, 2017 3:54 pm

qpik wrote:Have you unpacked the whole 'slender' folder from the zip file?
Do you have blender installed? Maybe the installation path is different than mine (C:\Program Files\Blender Foundation\Blender\blender.exe), check slender.bat in the 'slender' folder.
In sketchup open Ruby Console and type
Code: Select all
load 'C:/../..slender/slender.rb'
with the actual path.

Yes, unpacked, have Blender (2.78c) on default location.
But i found out that .dae and .log files are in my default plugin location (...\AppData\Roaming\SketchUp\SketchUp 2017\SketchUp\Plugins). So appearently my problem was copying 'slender.rb' file to that location in order to make the command (load 'slender.rb') work.

Now i tried your new code line with my path and it did some CMD stuff and received 'true' result on Ruby Console. But seems there is no imported result in SU. I tried importing that 'overwritten' .dae file but they seem identical. What should i expect at this point? Is it going to import baked result to side of the original model (as you show in first post)?
0
User avatar
filibis 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Wed May 03, 2017 4:27 pm

filibis wrote: What should i expect at this point? Is it going to import baked result to side of the original model (as you show in first post)?

The result should be the same as after importing COLLADA, a model ready to be placed in SU, but with shadows baked.
If you add
Code: Select all
pause
at the end of slender.bat you should be able to see any blender errors.
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby filibis » Wed May 03, 2017 6:40 pm

Well, i got home and i tried on my laptop, it worked like a charm!
I will see tomorrow what causes problem in the office computer (only difference is that's Windows 7 64-bit).


Then i created my own scene, it worked pretty well too.
Except when i tried to experiment with some interior scenes. See attachment for faulty result. It's completely dark inside (with some light artifacts).
0
User avatar
filibis 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Wed May 03, 2017 7:42 pm

Simple triangulation issue in slender.rb (you should see HOLES NOT SUPPORTED in Blender console).
Code: Select all
triangulated_faces => true

Fixed and reuploaded whole package. Result:

baked_result_comparison_v2013_qpik.jpg

baked_result_comparison_v2013_qpik.skp

After tweaking slender.blend scene (Environment Lighting Raytrace -> Approximate) which you can try with your own settings:
baked_result_comparison_v2013_qpik_1.jpg

baked_result_comparison_v2013_qpik_1.skp
1

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby filibis » Wed May 03, 2017 8:59 pm

Hmm, i see now better.
So, can we say it's not that suitable for interior stuff? Or is it possible to add other light types in addition to sun into baking process?
0
User avatar
filibis 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Wed May 03, 2017 9:19 pm

filibis wrote:Hmm, i see now better.
So, can we say it's not that suitable for interior stuff? Or is it possible to add other light types in addition to sun into baking process?


It's all a matter of translating objects from SU to Blender, then everything is possible.
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby JQL » Wed May 03, 2017 9:28 pm

qpik, you're using cycles or is this blender internal?
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby Rich O Brien » Wed May 03, 2017 10:16 pm

@qp

fantastic idea. Can't get it going yet so subscribing so I can flag updates
0
There's a frontroom and a backroom....reverse faces
User avatar
Rich O Brien 
Administrator
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Wed May 03, 2017 10:47 pm

JQL wrote:qpik, you're using cycles or is this blender internal?

So far internal, why do you ask?
0

qpik 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby JQL » Wed May 03, 2017 11:15 pm

Out of curiosity. I've seen great things coming from cycles and heard it's improving very fast.

Who knows where this plugin will lead so, maybe cycles would be a good bet.
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby filibis » Thu May 04, 2017 7:19 pm

filibis wrote:I will see tomorrow what causes problem in the office computer

I tried again in the office today, i noticed this code was missing in slender.bat
Code: Select all
%~dp0\slender.blend

(see attachment) I don't remember deleting it, maybe downloaded the .zip yesterday before you update or something idk :roflmao:
So i downloaded .zip again today, it worked fine. :thumb:
0
User avatar
filibis 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby Pixero » Fri May 05, 2017 9:32 am

A couple of question.

How does the geometry look when imported back into SketchUp?
Is it grouped the same?
Are the components intact?
Is the geometry triangulated or as it was originally in SU?
0
User avatar
Pixero 
Premium Member
Premium Member
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby filibis » Fri May 05, 2017 12:44 pm

Pixero wrote:How does the geometry look when imported back into SketchUp?
Is it grouped the same?
Are the components intact?
Is the geometry triangulated or as it was originally in SU?

Seems it imports one component that contains the whole geometry and everything inside exploded. Also triple clicking only select ones that shares the same material. See below for gif demonstrations.

Triangulation and other export features are optional (see attachment). (But making "preserve_instancing => true" doesn't seem to be working)


0
User avatar
filibis 
 

Re: [Plugin] Slender - Baking textures in Sketchup with Blen

Postby qpik » Fri May 05, 2017 2:00 pm

Unless I'm missing something there's no combination of COLLADA import/export settings in SU and Blender that would keep components. It's just how those exporters/importers work.

Triangulation solves issue with holes in faces, which are not supported, as far as I learned, in Blender.

The real question is whether keeping component structure is really necessary, I doubt it.
0

qpik 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 8 guests

Visit our sponsors: