Wings 3D Development Forum
YafaRay Plug-in - reviewing for Yafaray 3.0 - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Design & Development (https://www.wings3d.com/forum/forumdisplay.php?fid=6)
+--- Thread: YafaRay Plug-in - reviewing for Yafaray 3.0 (/showthread.php?tid=2053)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - micheus - 07-21-2016

(07-21-2016, 01:18 PM)david.bluecame Wrote: I got the GUI working now by giving up on the array and setting the 32 passes as independent items.
I thought that kind of "loop" creating one ID for each one of the 32 pass was doing that. Blush


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - oort - 07-21-2016

Micheus,
Remember that before Wings 2.x, it was possible in the Material Properties dialog to add Modulators for a material by clicking "New Modulator". If this was possible again, would that give David what he needs? Maybe that is still not possible with wxwidgets... Sad

David,
Install a Wings 1.5.x version to see if that would be what you want.

oort


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - micheus - 07-21-2016

David, since the DEF_RENDER_PASS* are defined as disabled, there is no need for that sequence of defines.

This sequence bellow - in export_prefs() - also doesn't need to be that way:
Quote: {render_pass1,?DEF_RENDER_PASS1},
{render_pass2,?DEF_RENDER_PASS2},
...

it was my bad use a tuple instead of an atom as id for the new fields as I suggested you:
Code:
RenderPass =
        lists:foldl(fun(N, Acc) ->
                         Acc++[{{pass,N},?DEF_RENDER_PASS}]
                     end, [], lists:seq(1,32)),

In that code I suggested you, replace it by:
Code:
RenderPass =
        lists:foldl(fun(N, Acc) ->
                         Id = io_lib:format("render_pass~w",[N]),
                         Acc++[list_to_atom(Id),?DEF_RENDER_PASS}]
                     end, [], lists:seq(1,32)),

That way you can go back to the logic I tried to suggest before and have less code to write.


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - micheus - 07-21-2016

The old code updated, just for reference:
Code:
%% Render
-define(DEF_RENDER_PASS, disabled).
-define(DEF_LIGHTING_METHOD, directlighting).
...

export_prefs() ->
    RenderPass =
        lists:foldl(fun(N, Acc) ->
                         Id = io_lib:format("render_pass~w",[N]),
                         Acc++[list_to_atom(Id),?DEF_RENDER_PASS}]
                     end, [], lists:seq(1,32)),
    [{subdivisions,?DEF_SUBDIVISIONS},
     ...
     {bokeh_rotation,?DEF_BOKEH_ROTATION},
     {dof_distance,?DEF_DOF_DISTANCE}] ++ RenderPass.

export_dialog_qs(Op, Attr) ->
   ...
   {vframe, render_pass_frame(Attr)}
   ...

render_pass_frame(Attr) ->
    PassLabel = ?__(1,"Pass"),
    lists:foldl(fun(N, Acc) ->
          Id = io_lib:format("render_pass~w",[N]),
          Value = get_pref(Id, Attr),
          Acc++[{hframe, [
                        {label, PassLabel ++ io_lib:format(" (~w)", [N])},
                        {menu, render_pass_menu(), Value ,[key(list_to_atom(Id))]}
                   ]}]
        end, [], lists:seq(1,32)).

render_pass_menu() ->
    [
        {?__(1,"Disabled"),disabled},
        {?__(2,"Combined"),combined},
        {?__(3,"Diffuse"),diffuse},
        {?__(4,"Glossy"),glossy},
        ...
    ].
...



RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - david.bluecame - 07-21-2016

Hello,

With the "individual items" code I got Render Passes working :-) (although it requires some changes I made to Core that will be available in the upcoming YafaRay v3.0.1-beta)

I will try later Micheus' latest changes to optimize the code.

Some examples :-)

Combined pass (typical pass as you know it)
[Image: ExampleGlassRings%20pass%20combined_zpsbr6iiozf.png]

Z-depth pass:
[Image: ExampleGlassRings%20pass%20z-depth-norm_zpsqp4vgzry.png]

Debug pass - Normals
[Image: ExampleGlassRings%20pass%20debug-normal-...3ejdtw.png]

Direct diffuse only pass
[Image: ExampleGlassRings%20pass%20diffuse_zps4qbu862k.png]

Indirect light pass:
[Image: ExampleGlassRings%20pass%20indirect_zps4gqfbj18.png]

Refraction pass:
[Image: ExampleGlassRings%20pass%20refract_zpsugyi9sfd.png]

Reflection pass:
[Image: ExampleGlassRings%20pass%20reflect_zpsr6qnb2fq.png]

Hello, Micheus.

When I tried your latest code I initially got this during compilation:
erlc -Werror -pa ../../ebin -pa ../../intl_tools -I ../../intl_tools -I ../../src -I ../../e3d +debug_info -o../../plugins/import_export wpc_yafaray.erl
wpc_yafaray.erl:2198: syntax error before: '}'
wpc_yafaray.erl:2190: function export_prefs/0 undefined

I found an extra "}" in the line
Acc++[list_to_atom(Id),?DEF_RENDER_PASS}]

So I changed it to:
Acc++[list_to_atom(Id),?DEF_RENDER_PASS]

It compiles but then I get this error in runtime when I try to enter the Render->YafaRay window:
wpc_yafaray:command/3: bad return value: {'EXIT',
{badarg,
[{erlang,list_to_atom,
[[114,101,110,100,101,114,95,112,
97,115|...]],
[]},
{wpc_yafaray,
'-export_prefs/0-fun-0-',2,
[{file,"wpc_yafaray.erl"},
{line,2198}]},
{lists,foldl,3,
[{file,"lists.erl"},{line,1262}]},
{wpc_yafaray,export_prefs,0,
[{file,"wpc_yafaray.erl"},
{line,2196}]},
{wpc_yafaray,export_dialog,2,
[{file,"wpc_yafaray.erl"},
{line,2190}]},
{wings_develop,time_command,2,
[{file,"wings_develop.erl"},
{line,81}]},
{wings_plugin,command,3,
[{file,"wings_plugin.erl"},
{line,139}]},
{wings,raw_command_1,3,
[{file,[...]},{line,...}]}]}}

I agree it's much nicer and good practice to do this as an array, with much more compact and scalable code. However, it's too much effort I think, and as it's already working with the "independent" items code I would suggest to keep it that way.

If the multiple defines are not needed, can I just use the same for all the render_passXX atoms?


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - micheus - 07-21-2016

David, for your information...
in the line:
{menu, render_pass_menu(), get_pref(render_pass1,Attr), [{key,render_pass1}]}
in plugins we must to use the key() function:
{menu, render_pass_menu(), get_pref(render_pass1,Attr), [key(render_pass1)]}
that is because it can happens different plugins to use an Id with same name, so by using the key/1 function we are introducing a plugin id and your render_pass1 will become {yafaray,render_pass1} (that yafaray comes from ?TAG and you can find the code at the begin of the source code).

About the code problem, I'm just coding it now and I will check the problem.


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - david.bluecame - 07-21-2016

Hello,

I changed the defines and updated the atom assignments to the defines. It seems to be working fine still. I've updated my github code.

However, when I do the change you suggest in your last post, it no longer saves the changes when I click ok (??)


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - micheus - 07-21-2016

This fix the problem:
Code:
RenderPass =
        lists:foldl(fun(N, Acc) ->
                         Id = list_to_atom("render_pass"++integer_to_list(N)),
                         Acc++[{Id,?DEF_RENDER_PASS}]
                     end, [], lists:seq(1,32)),
there is another problem I'm checking


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - david.bluecame - 07-21-2016

About the key, I noticed most of the GUI items use the "key,atom" and at the end of the panel they add "key(pnl....)"

So, I've made this change and still seems to work:
[...]
{hframe, [
{label,?__(202,"Render pass32")},
{menu, render_pass_menu(), get_pref(render_pass32,Attr), [{key,render_pass32}]}
]}
],[key(pnl_render_passes)]}

Would that be acceptable?

I've updated my github code with that.


RE: YafaRay Plug-in - reviewing for Yafaray 3.0 - micheus - 07-21-2016

(07-21-2016, 02:47 PM)david.bluecame Wrote: About the key, I noticed most of the GUI items use the "key,atom" and at the end of the panel they add "key(pnl....)"
Id's that are not plugin specific (for some controls like tabs, frames) we can use that way. It can be possible there are some "lost" Id's using the "wrong" way, but as soon I put my eyes on them I change. Smile
last year I had reviewed all three render plugins and tried to make them as most similar (standardised) as possible.

----
About the code, let's do that way... (if that is not a problem for you Smile)
You keep working on the version your get work and I work on it to replace the code to be "optimized" adjusted to be in accord with the other part of the source.

I tried to render a simple cube and set three passes only then - after start - yafaray crashed (got Windows freezing dialog) with this in the wings3d log:
Code:
Erlang/OTP 19 [erts-8.0] [64-bit] [smp:1:1] [async-threads:10]

Eshell V8.0  (abort with ^G)
1> wings-2.0.5.1.g8d4d.dirty
Reading preferences from: f:/unixlike/mingw64/home/AppData/Roaming/Wings3D/Preferences.txt
Using GPU shaders.
Exporting  to: c:/TEMP/wpc_yafaray-6220-RY6OAO.xml
for render to: c:/TEMP/untitled.tga
Mesh w_Cube1: triangulating...done
Mesh w_Cube1: exporting...done
Rendering Job started <0.88.0>:
> f:/PROGRA~1/YAFARA~1/bin/YAFARA~1.EXE -ccd -pp "F:\Program Files\yafaray_v3\bin\plugins" -f tga wpc_yafaray-6220-RY6OAO.xml c:/TEMP/untitled
[11:59:17] INFO: YafaRay Core (v3.0.0-beta) Windows 64bit MinGW GCC
[11:59:17] INFO: Environment: Loading plugins ...
[11:59:21] INFO (+ 4s): Environment: View number=0, view name: '', camera name: 'x_Camera'
[11:59:21] PARM: Using [4] Threads.
[11:59:21] PARM: Using for Photon Mapping [4] Threads.
[11:59:21] INFO: Kd-Tree: Starting build (12 prims, cr:0.8 eb:0.33)
[11:59:21] INFO: Scene: total scene dimensions: X=2.004, Y=2.004, Z=2.004, volume=8.0481, Shadow Bias=0.0005 (auto), Ray Min Dist=5e-005 (auto)
[11:59:21] INFO: DirectLight: Photonmap building time: 0.0s (4 thread(s))
[11:59:21] PARM: DirectLight: Rendering 3 passes
[11:59:21] PARM: Min. 1 samples
[11:59:21] PARM: 1 per additional pass
[11:59:21] PARM: Resampled pixels floor: 0.0% (0 pixels)
[11:59:21] PARM: Max. 3 total samples
[11:59:21] INFO: Rendering pass 1 of 3...
Progress: [                                                          ] (0%)[11:59:21] INFO: DirectLight: Rendering pass 1 of 3...
Progress: [#                                                         ] (2%)Progress: [##                                                        ] (5%)Progress: [####                                                      ] (7%)Progress: [#####                                                     ] (10%)Progress: [#######                                                   ] (12%)Progress: [########                                                  ] (15%)Progress: [##########                                                ] (17%)Progress: [###########                                               ] (20%)Progress: [#############                                             ] (23%)Progress: [##############                                            ] (25%)Progress: [################                                          ] (28%)Progress: [#################                                         ] (30%)Progress: [###################                                       ] (33%)Progress: [####################                                      ] (35%)Progress: [######################                                    ] (38%)Progress: [#######################                                   ] (40%)Progress: [#########################                                 ] (43%)Progress: [##########################                                ] (46%)Progress: [############################                              ] (48%)Progress: [#############################                             ] (51%)Progress: [###############################                           ] (53%)Progress: [################################                          ] (56%)Progress: [##################################                        ] (58%)Progress: [###################################                       ] (61%)Progress: [####################################                      ] (62%)Progress: [#####################################                     ] (64%)Progress: [######################################                    ] (65%)Progress: [#######################################                   ] (68%)Progress: [#########################################                 ] (71%)Progress: [##########################################                ] (73%)Progress: [############################################              ] (76%)Progress: [#############################################             ] (78%)Progress: [##############################################            ] (79%)Progress: [###############################################           ] (81%)Progress: [################################################          ] (84%)Progress: [##################################################        ] (87%)Progress: [###################################################       ] (89%)Progress: [####################################################      ] (90%)Progress: [######################################################    ] (93%)Progress: [#######################################################   ] (95%)Progress: [########################################################  ] (96%)Progress: [######################################################### ] (98%)Progress: [##########################################################] (100%)
[11:59:21] INFO: DirectLight: Sample multiplier = 1.0, Light Sample multiplier = 1.0, Indirect Sample multiplier = 1.0
[11:59:21] INFO: DirectLight: Rendering pass 2 of 3, resampling 1126 pixels.
Progress: [                                                          ] (0%)Progress: [#                                                         ] (2%)Progress: [##                                                        ] (5%)Progress: [####                                                      ] (7%)Progress: [#####                                                     ] (10%)Progress: [#######                                                   ] (12%)Progress: [########                                                  ] (15%)Progress: [##########                                                ] (17%)Progress: [###########                                               ] (20%)Progress: [#############                                             ] (23%)Progress: [##############                                            ] (25%)Progress: [################                                          ] (28%)Progress: [#################                                         ] (30%)Progress: [###################                                       ] (33%)Progress: [####################                                      ] (35%)Progress: [######################                                    ] (38%)Progress: [#######################                                   ] (40%)Progress: [#########################                                 ] (43%)Progress: [##########################                                ] (46%)Progress: [############################                              ] (48%)Progress: [#############################                             ] (51%)Progress: [###############################                           ] (53%)Progress: [################################                          ] (56%)Progress: [##################################                        ] (58%)Progress: [####################################                      ] (62%)Progress: [#####################################                     ] (65%)Progress: [######################################                    ] (65%)Progress: [#######################################                   ] (68%)Progress: [#########################################                 ] (71%)Progress: [##########################################                ] (73%)Progress: [############################################              ] (76%)Progress: [#############################################             ] (78%)Progress: [###############################################           ] (81%)Progress: [################################################          ] (84%)Progress: [##################################################        ] (87%)Progress: [###################################################       ] (89%)Progress: [#####################################################     ] (92%)Progress: [######################################################    ] (93%)Progress: [#######################################################   ] (95%)Progress: [########################################################  ] (98%)Progress: [######################################################### ] (98%)Progress: [##########################################################] (100%)
[11:59:21] INFO: DirectLight: Sample multiplier = 1.0, Light Sample multiplier = 1.0, Indirect Sample multiplier = 1.0
[11:59:21] INFO: DirectLight: Rendering pass 3 of 3, resampling 1244 pixels.
Progress: [                                                          ] (0%)Progress: [#                                                         ] (2%)Progress: [##                                                        ] (5%)Progress: [####                                                      ] (7%)Progress: [#####                                                     ] (10%)Progress: [#######                                                   ] (12%)Progress: [########                                                  ] (15%)Progress: [##########                                                ] (17%)Progress: [###########                                               ] (20%)Progress: [#############                                             ] (23%)Progress: [##############                                            ] (25%)Progress: [################                                          ] (28%)Progress: [#################                                         ] (30%)Progress: [###################                                       ] (33%)Progress: [####################                                      ] (35%)Progress: [######################                                    ] (38%)Progress: [#######################                                   ] (40%)Progress: [#########################                                 ] (43%)Progress: [##########################                                ] (46%)Progress: [############################                              ] (48%)Progress: [#############################                             ] (51%)Progress: [###############################                           ] (53%)Progress: [################################                          ] (56%)Progress: [##################################                        ] (58%)Progress: [###################################                       ] (61%)Progress: [#####################################                     ] (64%)Progress: [######################################                    ] (65%)Progress: [#######################################                   ] (68%)Progress: [#########################################                 ] (71%)Progress: [##########################################                ] (73%)Progress: [############################################              ] (76%)Progress: [#############################################             ] (78%)Progress: [##############################################            ] (79%)Progress: [###############################################           ] (81%)Progress: [################################################          ] (84%)Progress: [#################################################         ] (85%)Progress: [##################################################        ] (87%)Progress: [####################################################      ] (90%)Progress: [#####################################################     ] (92%)Progress: [######################################################    ] (93%)Progress: [#######################################################   ] (94%)Progress: [########################################################  ] (98%)Progress: [######################################################### ] (98%)Progress: [##########################################################] (100%)
[11:59:21] INFO: DirectLight: Overall rendertime: 0.2s
[11:59:21] INFO: imageFilm: Flushing buffer (View number 0)...
[11:59:21] PARM: --------------------------------------------------------------------------------
[11:59:21] PARM: YafaRay (v3.0.0-beta) Windows 64bit MinGW GCC | 200x200 | 3 passes | Render time: 0.23s | Total time: 0.23s | CPU threads=4
[11:59:21] PARM: Direct Light  RayDepth=12  | photon maps: 0.0s [4 thread(s)]
[11:59:21] PARM: AA Settings (box): Tile size=32 passes=3 samples=1 inc_samples=1 resamp.floor=0
[11:59:21] PARM: sample.mul=1 light.sam.mul=1 ind.sam.mul=1
[11:59:21] PARM: col.noise=0 AA thr=0.02 var.edge=10 var.pix=0 clamp=0 ind.clamp=0
[11:59:21] PARM: --------------------------------------------------------------------------------

Rendering Job returned: -1073741819
Export time:     0.034"
Render time:     39.424"
Total time:      39.458"
Rendering error: -1073741819