Is Sunflow limited in Sweet Home 3D?

This topic has been viewed 10934 times and has 16 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

Sunflow offers other types of light (Point Light, Meshlight/Area Light, Directional Lights, Cornell Box) or global illumination (Instant GI, Irradiance Caching, Fake Ambient Term).
Is there a reason why these were not taken into account in Sweet Home 3D?

The configuration of these parameters is not very detailed in the Sunflow documentation and I noticed differences in terms with the source code .
Is it possible to test or integrate these "new" options in a plug-in or a derived version of SH3D?
EnkoNyito
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Is Sunflow limited in Sweet Home 3D?

Post by Puybaret »

There's no limitation. Feel free to test anything you want in SunFlow from a plug-in or a derived version of Sweet Home 3D.
Some classes of SunFlow project are missing in [font=courier new]lib/sunflow-0.07.3i.jar[/font] but I don't think they are related to the features you mentioned. Anyway it shouldn't be difficult to rebuild a full version of SunFlow by removing [font=courier new]<exclude>[/font] elements found in [font=courier new]buildForSweetHome3D.xml[/font] entry of sunflow-0.07.3i-src-diff.zip found in source code. This file contains the modifications I introduced in SunFlow to fix some bugs and add support for missing features.

Good luck! [:)]
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

There's no limitation. Feel free to test anything you want in SunFlow from a plug-in or a derived version of Sweet Home 3D.
Ok, so I continue my tests.
Some classes of SunFlow project are missing in lib/sunflow-0.07.3i.jar but I don't think they are related to the features you mentioned. Anyway it shouldn't be difficult to rebuild a full version of SunFlow by removing <exclude> elements found in buildForSweetHome3D.xml
By following your method to rebuild a full version of Sunflow I did not notice any difference from the original file of source code.

Is it possible to retrieve a Sunflow error message to display it in Sweet Home 3D?
Examples from the LightServer.java file:

Code: Select all

"LIGHT error: Unable to trace virtual photons, no lights in scene"
"LIGHT error: Photon mapping enabled, no virtual photons to emit"
EnkoNyito
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

I get these messages with the "igi" global illumination

Code: Select all

this.sunflow.parameter("gi.engine", "igi");
this.sunflow.parameter("gi.igi.samples", 64);
this.sunflow.parameter("gi.igi.sets", 1);
this.sunflow.parameter("gi.igi.c", 0.00003f);
this.sunflow.parameter("gi.igi.bias_samples", 0);
for SunSkyLight or ImageBasedLight only.
The consequence is a completely black image and a progress bar stuck in indeterminate mode.

So I changed the behavior of the progress bar.
It is also possible to disable virtual photons by choosing igi.samples=0. The higher this value, the greater the rendering time when there is no visual difference.
EnkoNyito
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Is Sunflow limited in Sweet Home 3D?

Post by Puybaret »

Is it possible to retrieve a Sunflow error message to display it in Sweet Home 3D?[/code]
If you comment the line

Code: Select all

UI.set(new SilentInterface());
in PhotoRenderer class, logs will appear in the console, so you could probably implement [font=courier new]UserInterface[/font] another way to keep SunFlow messages.
I get these messages with the "igi" global illumination
The messages are missing [:(]
But anyway, I'm not sure I can help you on these parameters. I don't remember having tested them...
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

If you comment the line
UI.set(new SilentInterface());
in PhotoRenderer class, logs will appear in the console
Yes, in the Eclipse console.
The messages are missing
Only if SphereLight is used in addition.
But anyway, I'm not sure I can help you on these parameters.
Some parameters are not very understandable even with the help of the Sunflow doc.

Thank you for answering!
EnkoNyito
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

When the other types of lights or global illumination offered by Sunlow are properly implemented in Sweet Home 3D, they do not necessarily improve the current configuration.


With these parameters,

Code: Select all

this.sunflow.parameter("gi.engine", "igi");
this.sunflow.parameter("gi.igi.samples", 0);
this.sunflow.parameter("gi.igi.sets", 1);
this.sunflow.parameter("gi.igi.c", 0.0000001f);
int bias_samplesMax = 512;
int bias_samples = (int) (bias_samplesMax / (Math.pow(4, antiAliasingMax)));
if (bias_samples < 1) {
    bias_samples = 1;
}
this.sunflow.parameter("gi.igi.bias_samples", bias_samples);
this.sunflow.options(SunflowAPI.DEFAULT_OPTIONS);
the "igi" global illumination is similar to "path" with an equivalent rendering time.

Image Image


The PointLight type

Code: Select all

power = 100 * power;
this.sunflow.parameter("center", new Point3(lightSourceLocation.getX(),
    lightSourceLocation.getY(),
    lightSourceLocation.getZ()));
this.sunflow.parameter("power", null,
    power * (lightColor >> 16) * (this.homeLightColor >> 16),
    power * ((lightColor >> 8) & 0xFF) * ((this.homeLightColor >> 8) & 0xFF),
    power * (lightColor & 0xFF) * (this.homeLightColor & 0xFF));
this.sunflow.light(UUID.randomUUID().toString(), "point");
does not allow to have soft shadows and differs from the SphereLight type.

Image Image
Image Image
Image Image
Image Image
EnkoNyito
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

Emmanuel, how can we retrieve the coordinates of the vertices of a plane object so that its rotations are taken into account as light?

My attempt is not very conclusive.

I transformed this plane object

Code: Select all

g Plane_1_1_1
usemtl None
v 0.0 100.0 -0.05
v 100.0 100.0 -0.05
v 100.0 250.0 -0.05
v 0.0 250.0 -0.05
vn 0.0 0.0 1.0
f 1//1 2//1 3//1
f 1//1 3//1 4//1
in light,

Code: Select all

id#1=Meshlight#Vertical
name#1=Vertical shape sh3d
category#1=Light sources 2
icon#1=/Vertical shape sh3d.png
model#1=/vertical_shape_sh3d.obj
width#1=100
depth#1=0.1
height#1=150
movable#1=true
doorOrWindow#1=false
## Mandatory for light source
lightSourceX#1=50
lightSourceY#1=0
lightSourceZ#1=75
lightSourceColor#1=#919189
## Optional for light source
##lightSourceDiameter#1=
elevation#1=100
modelSize#1=325
creator#1=Enko Nyito
which gives in the Home.xml file.

Code: Select all

<light catalogId='Meshlight#Vertical' name='Vertical shape sh3d' creator='Enko Nyito' model='1' icon='0' x='50.0' y='-0.05' elevation='100.0' width='100.0' depth='0.1' height='150.0' modelSize='325' power='0.1'>
   <lightSource x='0.5' y='0.0' z='0.5' color='00919189'/>
</light>
I notice that the position of the light source is not the same.

By implementing the TriangleMeshLight type,

Code: Select all

...
int samples = 4;
int np = 4;
int nt = 2;
power = power / 100;
this.sunflow.parameter("radiance", null,
    power * (lightColor >> 16) * (this.homeLightColor >> 16),
    power * ((lightColor >> 8) & 0xFF) * ((this.homeLightColor >> 8) & 0xFF),
    power * (lightColor & 0xFF) * (this.homeLightColor & 0xFF));
this.sunflow.parameter("samples", samples);
this.sunflow.parameter("points", "point", "vertex", parseFloatArray(np * 3, light, lightSourceLocation));
this.sunflow.parameter("triangles", parseIntArray(nt * 3));
this.sunflow.light(UUID.randomUUID().toString(), "triangle_mesh");
...

private int[] parseIntArray(int size) {
    int[] data = {0, 1, 2,
        0, 2, 3};
    return data;
}

private float[] parseFloatArray(int size, HomeLight light, Point3f lightSourceLocation) {
    float[] data = {lightSourceLocation.getX() - light.getWidthInPlan()/2, lightSourceLocation.getY() - light.getHeightInPlan()/2, lightSourceLocation.getZ() - light.getDepthInPlan()/2,
        lightSourceLocation.getX() + light.getWidthInPlan()/2, lightSourceLocation.getY() - light.getHeightInPlan()/2, lightSourceLocation.getZ() - light.getDepthInPlan()/2,
        lightSourceLocation.getX() + light.getWidthInPlan()/2, lightSourceLocation.getY() + light.getHeightInPlan()/2, lightSourceLocation.getZ() + light.getDepthInPlan()/2,
        lightSourceLocation.getX() - light.getWidthInPlan()/2, lightSourceLocation.getY() + light.getHeightInPlan()/2, lightSourceLocation.getZ() + light.getDepthInPlan()/2};
    return data;
}
I get those results.
Image
Image Image Image

The TriangleMeshLightWithNoRepresentation class

Code: Select all

public static class TriangleMeshLightWithNoRepresentation extends TriangleMeshLight {
    public Instance createInstance() {
        return null;
    }
}
does not allow to have a wire 3D shape like the SphereLight type.

For comparison, the same light panel with the type
Image Image
EnkoNyito
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: Is Sunflow limited in Sweet Home 3D?

Post by Puybaret »

Did you try to apply some 3D transformations on the vertices?
Studying [font=courier new]exportLightSources[/font] in [font=courier new]PhotoRenderer[/font] class might be helpful...
Emmanuel Puybaret, Sweet Home 3D creator
enkonyito
Posts: 607
Joined: Thu May 28, 2015 4:52 pm

Re: Is Sunflow limited in Sweet Home 3D?

Post by enkonyito »

Yes I had tried but not as it should because I had not understood that the position of the light source is a percentage of the width, depth and height.
I applied this methodology to the vertices of my object and it works.
Image Image Image
Since taking vertices into account is manual, only one shape is possible.

By generating a transparent or invisible 3D shape, the light panel is rendered opaque when it is turned on.

For the wired 3D shape, I realized that the object had to be already in the .obj file.

The TriangleMeshLightWithNoRepresentation class does not cause the expected effect.
Image Image
EnkoNyito
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest