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 - david.bluecame - 07-20-2016

Hello,

YafaRay has no inbuilt GUI capabilities so it cannot show a window, it just saves (or autosaves every certain time) to disk.

On a different matter, I have a question for you about the plugin. I'm trying to implement Render Passes, but for it I need each Render Pass (from 1 to 32) to be able to choose from an enumeration of items. For example:

Render_Pass_1 choose from { disabled, combined, diffuse, glossy, etc, ...}
Render_Pass_2 choose from the same enumeration
etc, until Render_Pass_32

I could write a menu with all the enumerated items for each Render Pass but that would be horribly inefficient and difficult to maintain. Is there any way to define a predefined enum set of strings that I can reuse for several variables so in the UI each Render Pass can choose from a list with the same available options?

Thanks!

Ideally the type of code I'm looking for is this (pseudo code):

Enum definition:
define render_pass_available_values = { disabled, combined, diffuse, glossy, etc, ...}

For the GUI:
for i=1 to 32:
label "Render Pass" + i
RenderPass[i] = select from render_pass_available_values

For XML export:
for i=1 to 32:
print "<RenderPass" + i + ">" + RenderPass[i] + "</RenderPass" + i + ">"

Something like that... is that possible?


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

From the top of my mind I think you cold do something like this bellow. I don't have a way to test it here at my work.

In somewhere that you want to insert it in the export_dialog_qs(Op, Attr) by calling render_pass_frame(Attr):
Code:
%% Render
-define(DEF_RENDER_PASS, disabled).
-define(DEF_LIGHTING_METHOD, directlighting).
...

export_prefs() ->
    RenderPass =
        lists:foldl(fun(N, Acc) ->
                         Acc++[{{pass,N},?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 = {pass,N},
          Value = get_pref(Id, Attr),
          Acc++[{hframe, [
                        {label, PassLabel ++ io_lib:format(" (~w)", [N])},
                        {menu, render_pass_menu(), Value ,[key(Id)]}
                   ]}]
        end, [], lists:seq(1,32)).

render_pass_menu() ->
    [
        {?__(1,"Disabled"),disabled},
        {?__(2,"Combined"),combined},
        {?__(3,"Diffuse"),diffuse},
        {?__(4,"Glossy"),glossy},
        ...
    ].
...
This is a supposed code for create the fields in dialog. To read the fields to fill the export file will be very similar to render_pass_frame.
I'm not an erlang expert, so it can be wrong. Undecided

Could you try this code?


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

Thank you, Micheus, that was really helpful!

I've implemented and adapted your code, just for the GUI for now (not yet in the XML export process), but I have a problem. I can actually show the passes and select them from the dropdown menus, but the values don't get stored after I click OK :-(

My latest test code is here: https://github.com/DavidBluecame/wings/blob/yafaray_v3/plugins_src/import_export/wpc_yafaray.erl

This is how the Render Passes window appears, nice but unfortunately not saving the values:
[Image: render_passes_UI_zpsdqmiwek9.png]


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

David,
I may be wrong but I think you need to add the render pass setting in the code below: I think it would go at the bottom of the list to be in sequence. I may be wrong since I have not worked on the code in so long.

Would it be better to list the type of pass and then set the passes for each type? That would make the list shorter since the user could choose Basic and then choose Shadow and then set that variable to pass number 2 or any other. Just a thought. I am not sure I understand how this feature in YafaRay works.

oort

Quote:%% Export Render Options Dialog Settings
export_prefs() ->
RenderPass =
lists:foldl(fun(N, Acc) ->
Acc++[{{pass,N},?DEF_RENDER_PASS}]
end, [], listsConfusedeq(1,32)),
[{subdivisions,?DEF_SUBDIVISIONS},
{keep_xml,?DEF_KEEP_XML},
{render_pass,?DEF_RENDER_PASS},
{threads_number,?DEF_THREADS_NUMBER},
{threads_auto,?DEF_THREADS_AUTO},
{lighting_method,?DEF_LIGHTING_METHOD},
{use_caustics,?DEF_USE_CAUSTICS},
{caustic_photons,?DEF_CAUSTIC_PHOTONS},
{caustic_depth,?DEF_CAUSTIC_DEPTH},
{caustic_mix,?DEF_CAUSTIC_MIX},
{caustic_radius,?DEF_CAUSTIC_RADIUS},
{do_ao,?DEF_DO_AO},
{ao_distance,?DEF_AO_DISTANCE},
{ao_samples,?DEF_AO_SAMPLES},
{ao_color,?DEF_AO_COLOR},
{pm_diffuse_photons,?DEF_PM_DIFFUSE_PHOTONS},
{pm_bounces,?DEF_PM_BOUNCES},
{pm_search,?DEF_PM_SEARCH},
{pm_diffuse_radius,?DEF_PM_DIFFUSE_RADIUS},
{pm_caustic_photons,?DEF_PM_CAUSTIC_PHOTONS},
{pm_caustic_radius,?DEF_PM_CAUSTIC_RADIUS},
{pm_caustic_mix,?DEF_PM_CAUSTIC_MIX},
{pm_use_fg,?DEF_PM_USE_FG},
{pm_fg_bounces,?DEF_PM_FG_BOUNCES},
{pm_fg_samples,?DEF_PM_FG_SAMPLES},
{pm_fg_show_map,?DEF_PM_FG_SHOW_MAP},
{pt_diffuse_photons,?DEF_PT_DIFFUSE_PHOTONS},
{pt_bounces,?DEF_PT_BOUNCES},
{pt_caustic_type,?DEF_PT_CAUSTIC_TYPE},
{pt_caustic_radius,?DEF_PT_CAUSTIC_RADIUS},
{pt_caustic_mix,?DEF_PT_CAUSTIC_MIX},
{pt_caustic_depth,?DEF_PT_CAUSTIC_DEPTH},
{pt_samples,?DEF_PT_SAMPLES},
{sppm_photons,?DEF_SPPM_PHOTONS},
{sppm_bounces,?DEF_SPPM_BOUNCES},
{sppm_search,?DEF_SPPM_SEARCH},
{sppm_radius,?DEF_SPPM_RADIUS},
{sppm_times,?DEF_SPPM_TIMES},
{sppm_passes,?DEF_SPPM_PASSES},
{sppm_ire, ?DEF_SPPM_IRE},
{volintegr_type,?DEF_VOLINTEGR_TYPE},
{volintegr_adaptive,?DEF_VOLINTEGR_ADAPTIVE},
{volintegr_optimize,?DEF_VOLINTEGR_OPTIMIZE},
{volintegr_stepsize,?DEF_VOLINTEGR_STEPSIZE},
{use_sss,?DEF_USE_SSS},
{sss_photons,?DEF_SSS_PHOTONS},
{sss_depth,?DEF_SSS_DEPTH},
{sss_scale,?DEF_SSS_SCALE},
{sss_singlescatter_samples,?DEF_SSS_SINGLESCATTER_SAMPLES},
{raydepth,?DEF_RAYDEPTH},
{gamma,?DEF_GAMMA},
{bias,?DEF_BIAS},
{exposure,?DEF_EXPOSURE},
{transparent_shadows,?DEF_TRANSPARENT_SHADOWS},
{shadow_depth,?DEF_SHADOW_DEPTH},
{render_format,?DEF_RENDER_FORMAT},
{exr_flag_float,false},
{exr_flag_zbuf,false},
{exr_flag_compression,?DEF_EXR_FLAG_COMPRESSION},
{aa_passes,?DEF_AA_PASSES},
{aa_minsamples,?DEF_AA_MINSAMPLES},
{aa_jitterfirst,?DEF_AA_JITTERFIRST},
{aa_threshold,?DEF_AA_THRESHOLD},
{aa_pixelwidth,?DEF_AA_PIXELWIDTH},
{clamp_rgb,?DEF_CLAMP_RGB},
{aa_filter_type,?DEF_AA_FILTER_TYPE},
{background_color,?DEF_BACKGROUND_COLOR},
{save_alpha,?DEF_SAVE_ALPHA},
{background_transp,?DEF_BACKGROUND_TRANSP},
{background_transp_refract,?DEF_BACKGROUND_TRANSP_REFRACT},
{lens_type,?DEF_LENS_TYPE},
{lens_ortho_scale,?DEF_LENS_ORTHO_SCALE},
{lens_angular_circular,?DEF_LENS_ANGULAR_CIRCULAR},
{lens_angular_mirrored,?DEF_LENS_ANGULAR_MIRRORED},
{lens_angular_max_angle,?DEF_LENS_ANGULAR_MAX_ANGLE},
{lens_angular_angle,?DEF_LENS_ANGULAR_ANGLE},
{bokeh_use_QMC,?DEF_USE_QMC},
{width,?DEF_WIDTH},
{aperture,?DEF_APERTURE},
{bokeh_type,?DEF_BOKEH_TYPE},
{height,?DEF_HEIGHT},
{aperture,?DEF_APERTURE},
{bokeh_bias,?DEF_BOKEH_BIAS},
{bokeh_rotation,?DEF_BOKEH_ROTATION},
{dof_distance,?DEF_DOF_DISTANCE}] ++ RenderPass.



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

Thanks, Oort!

Unfortunately it does not solve the problem :-(


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

(07-21-2016, 06:41 AM)oort Wrote: I may be wrong but I think you need to add the render pass setting in the code below: I think it would go at the bottom of the list to be in sequence.

{render_pass,?DEF_RENDER_PASS}
oort, if he wants to use all those 32 pass then store only one isn't correct. That is why I suggest for that function it fill a array of 32 passes with default value and append it to end of the previous default preferences array.

I'm going to take a look at the code.

David, is it really necessary all those 32 options for render pass? Does someone can use all of them?


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

Hello,

No idea how many will be needed, thats for the users to decide, but its the same to do 32 than to do 5 or 6 from a coding point of view I suppose?

I will try to change the code to use individual items rather than the array to see if it's better...


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

Hi,David.
How data tuple been recorded in the Preference.txt of Wings3D?
Do you tell it to us?
It might be a clue of the problem.

I installed your plug-in and run Wings3D, but not update Preference.txt
So,I tried change set_user_prefs(Attr) insted of set_prefs(Attr) in the plugin code.
Because set_prefs() function wrapped for wpaConfusedcene_pref_set().
On the other hand,set_user_prefs() function wrapped for wpa:pref_set()

As follows as experiment...
Quote:command_file(render, Attr, St) when is_list(Attr) ->
set_prefs(Attr),
set_user_prefs(Attr), %<-----------Add
do_export(export,
props(render, Attr),
[{?TAG_RENDER,true}|Attr], St);
command_file(Op, Attr, St) when is_list(Attr) ->
%% when Op =:= export; Op =:= export_selected
set_prefs(Attr),
set_user_prefs(Attr),%<-----------Add
Then,your settings have been saved to Preference.txt when quit Wings3D.
But,Still preference settings are not reflected to UserInterface for Pass option.

It is part of the data of my Preferences.txt at that time
Code:
{{wpc_yafaray,aa_filter_type},box}.
{{wpc_yafaray,aa_jitterfirst},true}.
{{wpc_yafaray,aa_minsamples},1}.
{{wpc_yafaray,aa_passes},3}.
{{wpc_yafaray,aa_pixelwidth},1.5}.
{{wpc_yafaray,aa_threshold},0.02}.
{{wpc_yafaray,ao_color},{1.0,1.0,1.0}}.
{{wpc_yafaray,ao_distance},5.0}.
{{wpc_yafaray,ao_samples},32.0}.
{{wpc_yafaray,aperture},0.0}.
{{wpc_yafaray,aperture_idx},"0.000000"}.
{{wpc_yafaray,background_color},{0.0,0.0,0.0}}.
{{wpc_yafaray,background_transp},false}.
{{wpc_yafaray,background_transp_refract},false}.
{{wpc_yafaray,bias},0.001}.
{{wpc_yafaray,bokeh_bias},uniform}.
{{wpc_yafaray,bokeh_rotation},0.0}.
{{wpc_yafaray,bokeh_type},triangle}.
{{wpc_yafaray,bokeh_use_QMC},false}.
{{wpc_yafaray,caustic_depth},10}.
{{wpc_yafaray,caustic_mix},200}.
{{wpc_yafaray,caustic_photons},900000}.
{{wpc_yafaray,caustic_radius},0.5}.
{{wpc_yafaray,clamp_rgb},true}.
{{wpc_yafaray,do_ao},false}.
{{wpc_yafaray,dof_distance},7.0}.
{{wpc_yafaray,exposure},1.4}.
{{wpc_yafaray,exr_flag_compression},compression_zip}.
{{wpc_yafaray,exr_flag_float},false}.
{{wpc_yafaray,exr_flag_zbuf},false}.
{{wpc_yafaray,gamma},2.2}.
{{wpc_yafaray,height},200}.
{{wpc_yafaray,keep_xml},false}.
{{wpc_yafaray,lens_angular_angle},90.0}.
{{wpc_yafaray,lens_angular_circular},true}.
{{wpc_yafaray,lens_angular_max_angle},90.0}.
{{wpc_yafaray,lens_angular_mirrored},false}.
{{wpc_yafaray,lens_ortho_scale},7.0}.
{{wpc_yafaray,lens_type},perspective}.
{{wpc_yafaray,lighting_method},directlighting}.
{{wpc_yafaray,options},[]}.
{{wpc_yafaray,pluginspath},"/Applications/yafaray_v3/bin/plugins"}.
{{wpc_yafaray,pm_bounces},5}.
{{wpc_yafaray,pm_caustic_mix},100}.
{{wpc_yafaray,pm_caustic_photons},500000}.
{{wpc_yafaray,pm_caustic_radius},1.0}.
{{wpc_yafaray,pm_diffuse_photons},500000}.
{{wpc_yafaray,pm_diffuse_radius},1.0}.
{{wpc_yafaray,pm_fg_bounces},3}.
{{wpc_yafaray,pm_fg_samples},100}.
{{wpc_yafaray,pm_fg_show_map},false}.
{{wpc_yafaray,pm_search},100}.
{{wpc_yafaray,pm_use_fg},true}.
{{wpc_yafaray,pt_bounces},5}.
{{wpc_yafaray,pt_caustic_depth},10}.
{{wpc_yafaray,pt_caustic_mix},100}.
{{wpc_yafaray,pt_caustic_radius},1.0}.
{{wpc_yafaray,pt_caustic_type},path}.
{{wpc_yafaray,pt_diffuse_photons},500000}.
{{wpc_yafaray,pt_samples},32}.
{{wpc_yafaray,raydepth},12}.
{{wpc_yafaray,render_format},tga}.
{{wpc_yafaray,renderer},"/Applications/yafaray_v3/bin/yafaray-xml"}.
{{wpc_yafaray,save_alpha},false}.
{{wpc_yafaray,shadow_depth},2}.
{{wpc_yafaray,sppm_bounces},4}.
{{wpc_yafaray,sppm_ire},false}.
{{wpc_yafaray,sppm_passes},1}.
{{wpc_yafaray,sppm_photons},500000}.
{{wpc_yafaray,sppm_radius},1.0}.
{{wpc_yafaray,sppm_search},100}.
{{wpc_yafaray,sppm_times},1.0}.
{{wpc_yafaray,sss_depth},15.0}.
{{wpc_yafaray,sss_photons},1000}.
{{wpc_yafaray,sss_scale},2.0}.
{{wpc_yafaray,sss_singlescatter_samples},32.0}.
{{wpc_yafaray,subdivisions},0}.
{{wpc_yafaray,threads_auto},true}.
{{wpc_yafaray,threads_number},1}.
{{wpc_yafaray,transparent_shadows},false}.
{{wpc_yafaray,use_caustics},false}.
{{wpc_yafaray,use_sss},false}.
{{wpc_yafaray,volintegr_adaptive},true}.
{{wpc_yafaray,volintegr_optimize},true}.
{{wpc_yafaray,volintegr_stepsize},0.2}.
{{wpc_yafaray,volintegr_type},none}.
{{wpc_yafaray,width},200}.
{{wpc_yafaray,{yafaray,{pass,1}}},combined}.
{{wpc_yafaray,{yafaray,{pass,2}}},diffuse}.
{{wpc_yafaray,{yafaray,{pass,3}}},shadow}.
{{wpc_yafaray,{yafaray,{pass,4}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,5}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,6}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,7}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,8}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,9}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,10}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,11}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,12}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,13}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,14}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,15}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,16}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,17}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,18}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,19}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,20}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,21}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,22}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,23}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,24}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,25}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,26}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,27}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,28}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,29}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,30}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,31}}},disabled}.
{{wpc_yafaray,{yafaray,{pass,32}}},disabled}.



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

Hello,

Unfortunately these settings should be scene-specific, and user preferences are global settings common for all scenes. Anyway thank you as your idea gives very interesting results.

I got the GUI working now by giving up on the array and setting the 32 passes as independent items. I've uploaded my latest changes to the github address above.

I'll now work on the xml export and check that the passes work in Core.


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

One thing is the user preferences that is reused for any project and other is the project values/prefs (if we can say this way) that will be remembered when reloading it.

I was thinking about the last one, because the preferences by plugin was implemented in older than v2.* by using a button in the dialogs (save default) - something that we couldn't yet enable using the new wx GUI.