diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 00000000..8980b8c4 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,277 @@ +YafaRay-E (Experimental) Change Log (current version at the top, oldest at the bottom) + +Note: this CHANGELOG file only shows the YafaRay-E releases and changes, not the official stable YafaRay changes. + +For more information about releases and changes see: https://github.com/DavidBluecame/Blender-Exporter/releases + +Important: read the README file for installation instructions and important information about YafaRay + + +Yafaray-E v2.1.1 (2016-02-06) for Blender 2.76b: +------------------------------------------------ +Note: there has been important changes and bug fixes in this version. They have solved some long-standing issues but perhaps they could cause new issues and unexpected results, so we have to keep an eye on them. + +* IMPORTANT: Fix for incorrect IBL lighting in World Background Texture when set to Angular. See: http://www.yafaray.org/node/714 + +* IMPORTANT: Adjustment to the automatic intersection/shadow bias calculation formula to avoid black artifacts in the scenes with fine details. However, now we can get again some black dots in some scenes again. For now, no good solution at hand (any good solution would require fundamental changes to the engine and probably slow down the renders in a significant amount). However, I hope to have found a better balance now. See: http://blenderartists.org/forum/showthread.php?389385-YafaRay-E-(Experimental)-v2-0-2-builds-Windows-Linux-and-Mac-OSX-for-Blender-2-76b&p=3004974&viewfull=1#post3004974 + +* IMPORTANT: Fix for black dots (alpha=0) sometimes when using Mitchell/Lanzcos filters. It's not clear what is the best way of solving this problem. This fix is the one that makes more sense but could cause new issues, we have to keep an eye on this. See: http://www.yafaray.org/node/712 + +* Fixed Black artifacts in World Background Textures. See: http://www.yafaray.org/node/714 + +* Fixed regression error in v2.1.0 when using Area Lights. See: http://www.yafaray.org/node/713 + +* Fixed World Preview not updating correctly. This is probably caused by Blender itself, I had to use the same workaround I used in the past to fix the material preview updating problem + +* Fixed crash when using textures with Normal or Window coordinates (which are view dependent) along with Caustic Photons. However, we have to consider that Photons are supposed to be view-independent, but when using textures with Window or Normal coordinates (which are view dependant), then the Photons WILL also be view dependant as well! So, using textures with "tricks" like Normal or Windows coordinates can cause low frequency noise in animations with Photons. This would not be a problem, but the price for using such "tricks" in renders. + +* Fixed python error when selecting an image texture before with no image opened yet. + +* "Final" changes to the Material Preview Advanced Controls: + - Added Dynamic Camera Rotation & Zoom. + - Changes to ensure the preview object is centered and rotation keeps it always in the centre. + - Changes to keep the scale/proportions of custom preview objects + - Added AA Passes control for progressively refining the material rendering + - Splitted the Light power and Light Color controls in two: Key Light power control and Fill Lights power control + - Removed PosX,PosZ controls as considered unnecessary and complicating the interface. + - Removed Texture scale/offset controls as they could cause confusion with the actual texture scale/offset parameters + +Important note: YafaRay only supports *one* scene in the .blend file. If you have more than one scene, it could cause unexpected results and problems in the new Material Preview Controls. + + +Yafaray-E v2.1.0 (2016-01-31) for Blender 2.76b: +------------------------------------------------ + +- Added Normal Coordinates for textures, so you can use a gradient texture mapped to normal coordinates to simulate, for example, some cloth materials (see http://yafaray.org/node/188 ) +- Fixed some crashes when changing Material/Texture settings +- Increased max limit for Sample Multiplier Factor from 2.0 to 4.0 so more steep exponential increase of samples can be done for every pass. Be aware that the number of samples will grow very fast in every pass if the factor is above 1.5. + +- Advanced Controls for Material/Texture Preview + As requested in http://yafaray.org/node/699 I've made some changes to allow fine-grained control of the Material and Texture Preview window. + + Some videos explaining the new feature: + + * First tests (outdated): https://www.youtube.com/watch?v=AFWcHgufkBw + * Latest video with all features: https://www.youtube.com/watch?v=jBgzqZFQ3Y8 + + The new features are: + + * Ability to change key light incident angle, so we can place the terminator area on the preview object.: new parameter added to rotate the lights in the Preview window around the preview object. That should allow to set the lights in different angles to look the material under different light conditions + * Ability to focus in the observer's terminator area: added parameters to displace the preview object up/down, left/right as well as to scale the preview object. This way, the terminator area can be better explored in detail + * Ability to change light power in the material previsualisation window: added a power factor parameter for the lights and another parameter to set the color of the lights themselves to experiment with different lighting conditions on the material + * Ability to change previsualisation object size: with the parameter to scale the object plus added parameters to scale/displace the texture as well in the preview + * Rendering an object from the scene as a previsualisation object: added a parameter to select an arbitrary object from the blend scene as preview object. + * Background selection: added a parameter to select the desired background: "checker" is the default, "none" is a white background and "world" would be the blend scene world definition. Selecting "world" would allow a more realistic and customized material preview, but it will probably be noisier and slower (depending on the samples selected in the World definition) + + +Yafaray-E v2.0.2 (2016-01-26) for Blender 2.76b: +------------------------------------------------ +- Fixed crash when Blend materials were used and their components were also blend, which had some component materials missing +- Max value for the dark noise factor parameter expanded to 1.0 to allow even darker areas to have better AA sampling +- Fix for Oren Nayar to avoid generating white/black dots when used together with bump mapping +- Fix for black dots using HDRI spherical and Coated Glossy + + +Yafaray-E v2.0.1 (2016-01-05) for Blender 2.76b: +------------------------------------------------ +- Fixed Instances not working in v2.0.0 (regression) + + +Yafaray-E v2.0.0 (2016-01-01) for Blender 2.76b: +------------------------------------------------ +- STRUCTURAL CHANGES to implement Render Passes. The Passes are especially intended for Direct Light and Photon Mapping integrators. Some passes may not work (or work incorrectly) in other integrators. +- STRUCTURAL CHANGES to implement Render Views (Stereo3D / MultiView) +- STRUCTURAL CHANGES to implement a (hopefully) improved more automatic and reliable Shadow Bias and Intersection Bias, based on triangle size and coordinates positions. +- New Noise Control parameters, including a new clamping function to reduce noise at the cost of reducing physical accuracy and realism. +- RAM optimization options for JPG,PNG,TGA and TIFF textures. Using "optimized" (by default now) will reduce RAM usage for those textures in approx. 70%. The "optimized" option is lossless (except in TIFF 16bit). There is a "compressed" option that is lossy but allows an extra reduction of approx. 20% in RAM usage. +- Support for exporting in MultiLayer EXR files, that can be opened in Blender as well. +- XML rendering now supports an option to save partially rendered images every "x" seconds, probably useful when creaiting external GUIs to the XML interface. +- Ability to select what "internal" YafaRay Render Pass has to be mapped to an "external" Render Pass. This provides a lot of power and flexibility when generating Render Passes. +- Object ID/Material ID passes, with option of automatic ID color pass. +- Object ID Masking and Material ID masking (objects only, objects+shadows, shadows only) +- Debug passes and UV debug pass available to be able to find mesh/mapping/texturing problems at the same time as rendering the scene. +- Samplerate pass, to apply post-processing filters to the noisier parts of the render. +- Added dispersive caustics to SPPM. +- Changes to dispersion in rough glass. +- Removal of entire Qt interface. As far as we know it was old, unmaintained and probably useless anyway. +- Fix (although horrible) for the Bidirectional integrator generating black renders with some types of lights. +- A few speed improvements, I don't expect a significant change but I hope they help a bit, especially in 64bit systems. +- Fixes to the material preview to be correctly refreshed after any changes to the material properties. + + + +Yafaray-E v1.1.0 (2015-11-06) for Blender 2.76: +----------------------------------------------- +- Changes to the Core code and build files to enable building for Mac OSX 64bit (v10.6 or higher), based on the excellent work from Jens Verwiebe. Thank you very much, Jens!! + +- Added a new "Resampled Floor" parameter to the Adaptative AA calculations, to increase the noise reduction performance. The idea is that if the amount of resampled pixels go below that "floor" value during a certain pass, the AA threshold is automatically decreased in 10% for the next pass. More information: http://yafaray.org/node/690 + +- Blend materials can now be selected using drop down menus. This feature has been ported from povmaniaco's The Bounty fork of YafaRay. Thanks, povmaniaco!! + +- Added a new texture sampling parameter in Blender Exporter to control the type of interpolation in the image texture. Options will be: bilinear (default), bicubic or none. See: http://www.yafaray.org/community/forum/viewtopic.php?f=22&t=5121 + +- Added a per-material parameter to control reception of shadows. Now it's possible to select if a material should receive shadows from other objects (as default) or not. See: http://yafaray.org/node/687 + +- Minor changes for existing material visibility feature to improve (just a tiny bit) performance. + + + +Yafaray-E v1.0.0 (2015-10-13) for Blender 2.76: +----------------------------------------------- +Note: from v1.0.0 I will no longer use the suffix "beta", as all YafaRay-Experimental versions are inherently betas ;-). I will use for version scheme: "Major.Minor.Bugfix". Major will be very important and structural changes with possible API breakage, Minor will be new and modified functionality without API breakage, Bugfix will be small changes and bugfixes. + +- IMPORTANT CHANGES to Color Management and Color Pipeline Linear Workflow: http://www.yafaray.org/node/670 + +Initial prototype to try to fix the (apparently broken) YafaRay color pipeline workflow and to replace the simple gamma input/output correction with a proper sRGB decoding/coding in non-HDR files. + +More information here: http://www.yafaray.org/node/670 + +So, I've prepared a YafaRay prototype that fixes the next issues: + +* Improved Blender Color Space integration. +* The "simple" gamma correction has been replaced by Color Spaces: + - LinearRGB Linear values, no gamma correction + - sRGB sRGB encoding/decoding + - XYZ XYZ (very experimental) support + - Raw_Manual_Gamma Raw linear values that allow to set a simple gamma output correction manually + +* Fixed: Double application of input gamma to the Blender Color picker. So now scenes will look brighter in general, but they should also look more realistic with less tweaking. +* Gamma input correction no longer used. The color picker floating point color values will be considered already linear and no conversion applied to them. +* For textures, added specific per-texture Color Space and gamma parameters. +* The color values exported to the XML file will be encoded acording to Blender Output Device Color Space setting. +* In yafaray-xml, new commandline option added: "-ics" or "--input-color-space" that allows to select how to interpret the XML color values. By default, for backwards compatibility, color values will be read as "LinearRGB", but using "-ics sRGB", the color values will be interpreted as sRGB. This setting does *not* affect the textures, as they have already per-texture specific color space/gamma parameters. +* Fixed: when exporting to file there was an error in Blender while reopening it to be shown in the Blender image view. + + +Several bug tracker entries are supposed to be fixed with this change: +* Color pipeline bug: http://www.yafaray.org/node/670 +* Linear output forced on every scene: http://www.yafaray.org/node/603 +* Gamma 1.80 input on linux: http://www.yafaray.org/node/604 +* Forward compatibility with Blender Color Management: http://www.yafaray.org/node/547 +* Gamma correction performed on EXR files: http://www.yafaray.org/node/549 + + + +- IMPORTANT CHANGES to Volumetrics for proper raytracing of volumes: + +Problems with volumes and transparent objects have been reported in the bug tracker several times: +http://yafaray.org/node/289 +http://yafaray.org/node/666 + +The problem was that Volumes were not really included in the raytracing process, so they were not reflected nor refracted. Now Volumes have been included in the raytracing process, so they can be refracted and reflected as any other objects. This is a significant change that could cause new issues, so please let us know about any problems in YafaRay bug tracker. + +Now, if there are no parameters set in the XML for transparent background or transparent refracted background, their default values will be "false" and not "true" as until now. This will avoid confusion due to the new way "transparent refracted background" works, not rendering the background at all so volumes rendered against a transparent background do not carry "remains" of the background with them. + +- Fix for attenuation when using 2 or more volumetric objects: http://www.yafaray.org/node/332 + +- Fix for error message "Index out of bounds in pdf1D_t" when spotlights with falloff > 0.70 and photons were used: http://www.yafaray.org/node/681 + +- Fix for Alpha Premultiply broken in Blender exporter: http://www.yafaray.org/node/682 Now the "Premultiply Alpha" option is back in the Exporter, but only when Export to file or to xml is selected. Premultiply will now be forced to true when exporting into Blender. + +- Fix for some YafaRay camera panels incorrectly appearing in LuxRender! http://www.luxrender.net/forum/viewtopic.php?f=16&t=12405&sid=14e5a712bb33cbdee95c65fb1920ad38&start=20 +https://github.com/DavidBluecame/Blender-Exporter/commit/70138b7ec2c2aa3f94d3c820babc10d12af6f943 + + + +Yafaray-E v0.1.99-beta4c (2015-07-29) for Blender 2.75 RC: +---------------------------------------------------------- +Note: builds were not created for this version, as it was only used for limited-scale testing. However, the changes made in this version remain in newer Releases and builds. + +More info about the discussion and changes: http://www.yafaray.org/node/662 + +- Fix for issue where Final Gather uses non-IBL background in glass: http://www.yafaray.org/node/572 + +- Fix for white dots in Path Tracer integrator: http://www.yafaray.org/node/662 + +- Fix for bump mapping artifacts: http://www.yafaray.org/node/660 +WARNING: I've made significant changes to the bump mapping when using image textures, trying to improve it and get results more similar to Blender, but it could cause new issues so enough testing should be done to make sure bump/normal mapping still works correctly. + +- Improvements to the noise fireflies in Rough Glass: http://www.yafaray.org/node/663 + +- New parameter to enable/disable lights. In the XML, into each "light" section you can add: + or + +- Ability to control per-light shadow casting. In blender exporter this is in the new "advanced settings" at the very bottom of the light panel. In the xml file, you can add this to the "light" sections: + or + +- New per-material "visibility" enum parameter that can have the following values: + +'normal' (default): Normal - Normal visibility - visible casting shadows. +'no_shadows': No shadows - visible but not casting shadows. +'shadow_only': Shadows only - invisible but casting shadows. +'invisible': Invisible: totally invisible material. + +This new parameter is at the bottom of the material panel, in the new advanced settings. In XML it would be something like, in the material section, for example: + + + + + +Yafaray-E v0.1.99-beta4 (2015-06-20) for Blender 2.75 RC: +--------------------------------------------------------- + +- Changes to the blend material "component" material1,material2 handling: http://www.yafaray.org/node/546 + +In previous versions if you created or deleted materials in the .blend file, sometimes all the material components of the blend materials changed or dissapeared randomly. To avoid it, now the materials are referenced by name using strings. You cannot use dropdown menus anymore to select the blend submaterials, and you have to be careful now not to rename the materials used by "blend" materials. However, with the new system if you create or delete other materials it will not affect the blend material1,material2 assignments. + +Increased the level of detail in the YafaRay Log, so if there are any problems with missing components in blend materials it should be easy to spot and correct by reading the YafaRay Log. + +WARNING: this change breaks backwards compatibility. When opening a .blend created with an older version of YafaRay the blend material components will be "upgraded" to the new system, but the"blend" materials in a blend made with the new version could behave wrongly if you open it with an older version. + +- New advanced parameters for fine control of Shadow Bias/Min Ray Dist if the automatic calculation is not good enough. Please give us feedback about it in the forum: http://www.yafaray.org/community/forum/viewtopic.php?f=23&t=5084 + +- Fix for caustics noise coming from Non-IBL background in Photon Mapping. Now the background will only be used for Caustics if IBL is enabled and (if there is a caustics parameter available in the background settings) if caustics is enabled in the background. + +- Background "power" parameters relocated to places where they make more sense. They were hidden and only visible when IBL was enabled, but most of the times the power parameter affects the background rendering even if IBL is disabled. + + + +Yafaray-E v0.1.99-beta3 (2015-05-02) for Blender 2.74.5 (up to Blender builbots for 2015-05-02): +------------------------------------------------------------------------------------------------ +Blender made a change to their API in their development branch 2.74.4 to include MultiView. That change caused YafaRay to render black images despite being working fine. + +Very kindly Jens Verwiebe sent us the fix for Blender Exporter so YafaRay can work again with Blender 2.74.4. This fix is not a full integration in the new MultiView functionality, it just allows YafaRay to work again with Blender. + +More changes in this beta3 version: + +- Fix for -NAN results in the Bidirectional integrator when using Architectural, Angular and Ortho cameras. See: http://www.yafaray.org/node/538 + +- Fix for problem with Rough Glass too bright when dispersion is enabled. See: http://www.yafaray.org/node/642 + +- Extended Texture Mapping system, allowing using textures to map additional properties in materials, to be able to create either more realistic or more exotic materials and reduce the dependency on the "blend" material. More information in: http://www.yafaray.org/community/forum/viewtopic.php?f=22&t=5091 + +Important note: when using some of the new mappings, the renders may slow down. I'm not sure whether it's because of the additional calculations (very likely) or if it's something we can optimize further in the future. In any case, it should only be noticeable when using the new mappings, and I think it's worth the ability to create new materials now. + +The new texture mappings in addition to the existing ones are: + - Diffuse Reflection Amount in Shiny Diffuse, Glossy and Coated Glossy materials + - Sigma factor for Oren Nayar in Shiny Diffuse, Glossy and Coated Glossy materials + - Filter color in Glass and Rough Glass. + - IOR refractive factor in Glass and Rough Glass. The texture amounts are added to the IOR of the material. + - IOR refractive factor for the Fresnel in Shiny Diffuse and Coated Glossy materials. + - Roughness factor in Rough Glass material. + - Exponent factor in Glossy and Coated Glossy materials + - Mirror amount in Coated Glossy materials. + - Mirror Color in Coated Glossy Materials + +Also added a (non-texture) mirror amount slider in the Coated Glossy material + +Unfortunately due to Blender API limitations, in some of the new texture sliders, the "tooltip" information that appears when hovering the mouse over the slider, can be misleading and not represent the actual function of that slider. However, I took care in setting the description correctly so just by looking at the slider itself you can see what does it map. + + + +Yafaray-E v0.1.99-beta2 (2015-04-18) for Blender 2.74: +------------------------------------------------------- +- New Clay Material, with a small correction since the previous beta1 +- Fix for bad NaN normals that happened sometimes. +- Calculate automatically Shadow Bias and Minimum Ray Dist depending on the scene size. This is to avoid black artifacts when resizing the objects. However as it's a fundamental change that affects everything, perhaps some new artifacts could appear in the images now and further fine tuning needed in this new formula. Please give us feedback about it in the forum: +http://www.yafaray.org/community/forum/viewtopic.php?f=23&t=5084 + + + +Yafaray-E v0.1.99-beta1 (2015-04-11) for Blender 2.74: +------------------------------------------------------ +Based on the official stable YafaRay v0.1.5 git version + +- New Clay Material system, more powerful and flexible +- Texture mapping of Sigma factor in Shiny Diffuse/Oren Nayar +- Fix for Negated colors in Musgrave/Voronoi textures mapped to diffuse color. diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..66364dec --- /dev/null +++ b/INSTALL @@ -0,0 +1,21 @@ +To install YafaRay-E (Experimental) into Blender: + +Don't use the Blender from the distro repositories. Download the Blender official builds from: +https://www.blender.org/download/ + +Once Blender is installed, locate the folder where it was installed. The paths given below are just examples, but they will probably be different in your system. + +Copy this entire folder "yafaray" to (for example): + - in Linux 64bit, for example: "$HOME/blender-2.74-linux-glibc211-x86_64/2.74/scripts/addons" folder. + - in Windows 64bit, for example: "C:\Program Files\Blender Foundation\Blender\2.74\scripts\addons" folder. + +After it, start Blender, go to User Preferences, AddOns and try to enable Render:YafaRay. Once (hopefully) enabled you should see it in the list of renderers. + +* Important: the YafaRay-E Linux 32bit build requires a processor with SSE/SSE2 instructions. Any non-ancient processor should have them... + +If you have any issues: + +* Check that you have copied the "yafaray" folder into the correct Blender addons folder. +* Check that you have downloaded the appropiate YafaRay build for your Operating System and Blender build (32/64 bit) +* Check that you are using the official Blender build from www.blender.org and it's a version supported by YafaRay (see CHANGELOG) +* If you still have problems, please ask for help in the yafaRay.org forums or post a bug report in http://www.yafaray.org/development/bugtracker/yafaray diff --git a/README b/README index e1673287..cffdbb3b 100644 --- a/README +++ b/README @@ -1,22 +1,53 @@ -Yafaray 0.1.5 exporter for Blender 2.7: +DESCRIPTION +----------- +YafaRay is a free open-source montecarlo raytracing engine released under the LGPL 2.1 license. Raytracing is a rendering technique for generating realistic images by tracing the path of light through a 3D scene. -For the latest exporter updates check: +For more information, see: http://www.yafaray.org + + +YafaRay-E (Experimental) is an unofficial testing/unstable branch for fixes and new features, maintained by David Bluecame. Some of these fixes and features could be eventually accepted into the official/stable YafaRay, while others may end up rejected or implemented in a different way. + +*WARNING*: YafaRay-E contains EXPERIMENTAL CHANGES AND FEATURES, so it's recommended not to use it for production scenes. This application is provided as is, and no guarantee is given that this code will preform in the desired way. + +IMPORTANT: current LIMITATIONS of YafaRay: +* YafaRay only supports *one* version of YafaRay installed in the system. This limitation also affects installations of multiple "forks" of YafaRay, even if they have different names. +If you have a black window when rendering: + - Make sure that YafaRay is correctly installed in the appropiate place + - Make sure there are no other YafaRay versions/forks installed. + +* YafaRay only supports *one* scene in the .blend file. If you have more than one scene, it could cause unexpected results and problems in the new Material Preview Controls. + +Please post bugreports and feature requests here: +http://www.yafaray.org/development/bugtracker/yafaray + + +RELEASES +-------- + +YafaRay-E (Experimental) releases can be found here: +https://github.com/DavidBluecame/Blender-Exporter/releases + +YafaRay-E latest source code: +* Core code: https://github.com/DavidBluecame/Core +* Blender Exporter: https://github.com/DavidBluecame/Blender-Exporter + +More information about the changes in each YafaRay-E version see the file CHANGELOG + + + +For the official YafaRay latest exporter updates check: https://github.com/YafaRay/Blender-Exporter and for the latest Yafaray builds (including exporter files too) -check for builds on graphicall.org: +check for builds here: -http://www.graphicall.org/yafaray +* http://www.yafaray.org/download +* http://www.graphicall.org/yafaray or look into this forum post for other platform builds: - -http://www.yafaray.org/community/forum/viewtopic.php?f=16&t=3520 - http://www.yafaray.org/community/forum/viewforum.php?f=12 -Download and extract the exporter files and folders to the 'Blender/2.7/scripts/addons/yafaray' directory. - Please post bugreports and feature requests here: http://www.yafaray.org/development/bugtracker/yafaray diff --git a/__init__.py b/__init__.py index 0d27b5a3..09eb8fa8 100644 --- a/__init__.py +++ b/__init__.py @@ -34,9 +34,9 @@ "author": "Shuvro Sarker, Kim Skoglund (Kerbox), Pedro Alcaide (povmaniaco)," "Paulo Gomes (tuga3d), Michele Castigliego (subcomandante)," "Bert Buchholz, Rodrigo Placencia (DarkTide)," - "Alexander Smirnov (Exvion), Olaf Arnold (olaf)", - "version": (0, 1, 5, 'Stable'), - "blender": (2, 6, 3), + "Alexander Smirnov (Exvion), Olaf Arnold (olaf), David Bluecame", + "version": ('Experimental', 2, 1, 1), + "blender": (2, 7, 6), "location": "Info Header > Engine dropdown menu", "wiki_url": "http://www.yafaray.org/community/forum", "tracker_url": "http://www.yafaray.org/development/bugtracker/yafaray", @@ -46,20 +46,34 @@ # Preload needed libraries # Loading order of the dlls is sensible please do not alter it if sys.platform == 'win32': - for file in os.listdir(BIN_PATH): - # load dll's from a MSVC installation - if file in {'yafaraycore.dll'}: - dllArray = ['zlib1', 'iconv', 'zlib', 'libpng15', 'libxml2', 'yafaraycore', 'yafarayplugin'] - break - # load dll's from a MinGW installation - else: - dllArray = ['zlib1', 'libxml2-2', 'libgcc_s_sjlj-1', 'Half', 'Iex', 'IlmThread', 'IlmImf', 'libjpeg-8', \ - 'libpng14', 'libtiff-3', 'libfreetype-6', 'libyafaraycore', 'libyafarayplugin'] + if sys.maxsize == 2**63 - 1: # Windows 64bit system + for file in os.listdir(BIN_PATH): + # load dll's from a MSVC installation + if file in {'yafaraycore.dll'}: + dllArray = ['zlib1', 'iconv', 'zlib', 'libpng15', 'libxml2', 'yafaraycore', 'yafarayplugin'] + break + # load dll's from a MinGW64 installation + else: + dllArray = ['libwinpthread-1', 'libgcc_s_seh-1', 'libstdc++-6', 'libiconv-2', 'libzlib1', 'libxml2-2', 'libHalf', 'libIex', 'libImath', 'libIlmThread', 'libIlmImf', 'libjpeg-8', 'libpng16', 'libtiff-5', 'libbz2-1', 'libfreetype-6', 'libyafaraycore', 'libyafarayplugin'] + + else: # Windows 32bit system + for file in os.listdir(BIN_PATH): + # load dll's from a MSVC installation + if file in {'yafaraycore.dll'}: + dllArray = ['zlib1', 'iconv', 'zlib', 'libpng15', 'libxml2', 'yafaraycore', 'yafarayplugin'] + break + # load dll's from a MinGW32 installation + else: + dllArray = ['libwinpthread-1', 'libgcc_s_sjlj-1', 'libstdc++-6', 'libiconv-2', 'libzlib1', 'libxml2-2', 'libHalf', 'libIex', 'libImath', 'libIlmThread', 'libIlmImf', 'libjpeg-8', 'libpng16', 'libtiff-5', 'libbz2-1', 'libfreetype-6', 'libyafaraycore', 'libyafarayplugin'] elif sys.platform == 'darwin': dllArray = ['libyafaraycore.dylib', 'libyafarayplugin.dylib'] else: - dllArray = ['libyafaraycore.so', 'libyafarayplugin.so'] + if sys.maxsize == 2**63 - 1: # Linux 64bit system + dllArray = ['libHalf.so.6.0.0', 'libIex.so.6.0.0', 'libImath.so.6.0.0', 'libIlmThread.so.6.0.0', 'libIlmImf.so.6.0.0', 'libpython3.4m.so.1.0', 'libjpeg.so.62.0.0', 'libz.so.1.2.3.4', 'libpng12.so.0.44.0', 'libtiff.so.4.3.3', 'libfreetype.so.6.6.0', 'libyafaraycore.so', 'libyafarayplugin.so'] + + else: # Linux 32bit system + dllArray = ['libHalf.so.6.0.0', 'libIex.so.6.0.0', 'libImath.so.6.0.0', 'libIlmThread.so.6.0.0', 'libIlmImf.so.6.0.0', 'libpython3.4m.so.1.0', 'libjpeg.so.62.0.0', 'libz.so.1.2.3.4', 'libpng12.so.0.44.0', 'libtiff.so.4.3.3', 'libfreetype.so.6.6.0', 'libyafaraycore.so', 'libyafarayplugin.so'] for dll in dllArray: try: @@ -90,6 +104,14 @@ def load_handler(dummy): # converts old files, where propertie yaf_tex_type wasn't defined print("Load Handler: Convert Yafaray texture \"{0}\" with texture type: \"{1}\" to \"{2}\"".format(tex.name, tex.yaf_tex_type, tex.type)) tex.yaf_tex_type = tex.type + for mat in bpy.data.materials: + if mat is not None: + # from old scenes, convert old blend material Enum properties into the new string properties + if mat.mat_type == "blend": + if not mat.is_property_set("material1name") or not mat.material1name: + mat.material1name = mat.material1 + if not mat.is_property_set("material2name") or not mat.material2name: + mat.material2name = mat.material2 # convert image output file type setting from blender to yafaray's file type setting on file load, so that both are the same... if bpy.context.scene.render.image_settings.file_format is not bpy.context.scene.img_output: bpy.context.scene.img_output = bpy.context.scene.render.image_settings.file_format diff --git a/io/yaf_export.py b/io/yaf_export.py old mode 100644 new mode 100755 index 8360dc9a..5b301945 --- a/io/yaf_export.py +++ b/io/yaf_export.py @@ -19,6 +19,7 @@ # #TODO: Use Blender enumerators if any +import copy import bpy import os import threading @@ -73,18 +74,29 @@ def exportScene(self): self.exportMaterials() self.yaf_object.setScene(self.scene) self.exportObjects() - self.yaf_object.createCamera() - self.yaf_world.exportWorld(self.scene) + self.yaf_object.createCameras() + + if self.is_preview and bpy.data.scenes[0].yafaray.preview.enable and bpy.data.scenes[0].yafaray.preview.previewBackground == "world": + self.yaf_world.exportWorld(bpy.data.scenes[0]) + else: + self.yaf_world.exportWorld(self.scene) def exportTexture(self, obj): # First export the textures of the materials type 'blend' for mat_slot in [m for m in obj.material_slots if m.material is not None]: if mat_slot.material.mat_type == 'blend': + blendmat_error = False + try: + mat1 = bpy.data.materials[mat_slot.material.material1name] + except: + self.yi.printWarning("Exporter: Problem with blend material:\"{0}\". Could not find the first material:\"{1}\"".format(mat_slot.material.name,mat_slot.material.material1name)) + blendmat_error = True try: - mat1 = bpy.data.materials[mat_slot.material.material1] - mat2 = bpy.data.materials[mat_slot.material.material2] + mat2 = bpy.data.materials[mat_slot.material.material2name] except: - self.yi.printWarning("Exporter: Problem with blend material {0}. Could not find one of the two blended materials".format(mat_slot.material.name)) + self.yi.printWarning("Exporter: Problem with blend material:\"{0}\". Could not find the second material:\"{1}\"".format(mat_slot.material.name,mat_slot.material.material2name)) + blendmat_error = True + if blendmat_error: continue for bm in [mat1, mat2]: for blendtex in [bt for bt in bm.texture_slots if (bt and bt.texture and bt.use)]: @@ -181,31 +193,43 @@ def exportObjects(self): self.yaf_object.writeObject(obj) def handleBlendMat(self, mat): + blendmat_error = False try: - mat1 = bpy.data.materials[mat.material1] - mat2 = bpy.data.materials[mat.material2] + mat1 = bpy.data.materials[mat.material1name] except: - self.yi.printWarning("Exporter: Problem with blend material {0}. Could not find one of the two blended materials".format(mat.name)) - return + self.yi.printWarning("Exporter: Problem with blend material:\"{0}\". Could not find the first material:\"{1}\"".format(mat.name,mat.material1name)) + blendmat_error = True + try: + mat2 = bpy.data.materials[mat.material2name] + except: + self.yi.printWarning("Exporter: Problem with blend material:\"{0}\". Could not find the second material:\"{1}\"".format(mat.name,mat.material2name)) + blendmat_error = True + if blendmat_error: + return blendmat_error if mat1.name == mat2.name: - self.yi.printWarning("Exporter: Problem with blend material {0}. {1} and {2} to blend are the same materials".format(mat.name, mat1.name, mat2.name)) - return + self.yi.printWarning("Exporter: Problem with blend material \"{0}\". \"{1}\" and \"{2}\" to blend are the same materials".format(mat.name, mat1.name, mat2.name)) if mat1.mat_type == 'blend': - self.handleBlendMat(mat1) + blendmat_error = self.handleBlendMat(mat1) + if blendmat_error: + return + elif mat1 not in self.materials: self.materials.add(mat1) - self.yaf_material.writeMaterial(mat1) + self.yaf_material.writeMaterial(mat1, self.scene) if mat2.mat_type == 'blend': - self.handleBlendMat(mat2) + blendmat_error = self.handleBlendMat(mat2) + if blendmat_error: + return + elif mat2 not in self.materials: self.materials.add(mat2) - self.yaf_material.writeMaterial(mat2) + self.yaf_material.writeMaterial(mat2, self.scene) if mat not in self.materials: self.materials.add(mat) - self.yaf_material.writeMaterial(mat) + self.yaf_material.writeMaterial(mat, self.scene) def exportMaterials(self): self.yi.printInfo("Exporter: Processing Materials...") @@ -214,19 +238,23 @@ def exportMaterials(self): # create a default shiny diffuse material -> it will be assigned, if object has no material(s) self.yi.paramsClearAll() self.yi.paramsSetString("type", "shinydiffusemat") - self.yi.paramsSetColor("color", 0.8, 0.8, 0.8) + if self.scene.gs_clay_render: + cCol = self.scene.gs_clay_col + else: + cCol = (0.8, 0.8, 0.8) + self.yi.paramsSetColor("color", cCol[0], cCol[1], cCol[2]) self.yi.printInfo("Exporter: Creating Material \"defaultMat\"") ymat = self.yi.createMaterial("defaultMat") self.materialMap["default"] = ymat - # create a shiny diffuse material for "Clay Render" option in general settings - self.yi.paramsClearAll() - self.yi.paramsSetString("type", "shinydiffusemat") - cCol = self.scene.gs_clay_col - self.yi.paramsSetColor("color", cCol[0], cCol[1], cCol[2]) - self.yi.printInfo("Exporter: Creating Material \"clayMat\"") - cmat = self.yi.createMaterial("clayMat") - self.materialMap["clay"] = cmat + # Obsolete: create a shiny diffuse material for "Clay Render" option in general settings + #self.yi.paramsClearAll() + #self.yi.paramsSetString("type", "shinydiffusemat") + #cCol = self.scene.gs_clay_col + #self.yi.paramsSetColor("color", cCol[0], cCol[1], cCol[2]) + #self.yi.printInfo("Exporter: Creating Material \"clayMat\"") + #cmat = self.yi.createMaterial("clayMat") + #self.materialMap["clay"] = cmat for obj in self.scene.objects: for mat_slot in obj.material_slots: @@ -241,7 +269,7 @@ def exportMaterial(self, material): self.handleBlendMat(material) else: self.materials.add(material) - self.yaf_material.writeMaterial(material, self.is_preview) + self.yaf_material.writeMaterial(material, self.scene, self.is_preview) def decideOutputFileName(self, output_path, filetype): @@ -295,12 +323,15 @@ def update(self, data, scene): if scene.gs_type_render == "file": self.setInterface(yafrayinterface.yafrayInterface_t()) - self.yi.setInputGamma(scene.gs_gamma_input, True) + self.yi.startScene() + yaf_scene.exportRenderPassesSettings(self.yi, self.scene) + self.yi.setupRenderPasses() + self.yi.setInputColorSpace("LinearRGB", 1.0) #When rendering into Blender, color picker floating point data is already linear (linearized by Blender) self.outputFile, self.output, self.file_type = self.decideOutputFileName(fp, scene.img_output) self.yi.paramsClearAll() self.yi.paramsSetString("type", self.file_type) + self.yi.paramsSetBool("img_multilayer", scene.img_multilayer) self.yi.paramsSetBool("alpha_channel", render.image_settings.color_mode == "RGBA") - self.yi.paramsSetBool("z_channel", scene.gs_z_channel) self.yi.paramsSetInt("width", self.resX) self.yi.paramsSetInt("height", self.resY) self.ih = self.yi.createImageHandler("outFile") @@ -308,17 +339,38 @@ def update(self, data, scene): elif scene.gs_type_render == "xml": self.setInterface(yafrayinterface.xmlInterface_t()) - self.yi.setInputGamma(scene.gs_gamma_input, True) self.outputFile, self.output, self.file_type = self.decideOutputFileName(fp, 'XML') + self.yi.setOutfile(self.outputFile) + self.yi.startScene() + yaf_scene.exportRenderPassesSettings(self.yi, self.scene) + self.yi.setupRenderPasses() + + input_color_values_color_space = "sRGB" + input_color_values_gamma = 1.0 + + if scene.display_settings.display_device == "sRGB": + input_color_values_color_space = "sRGB" + + elif scene.display_settings.display_device == "XYZ": + input_color_values_color_space = "XYZ" + + elif scene.display_settings.display_device == "None": + input_color_values_color_space = "Raw_Manual_Gamma" + input_color_values_gamma = scene.gs_gamma #We only use the selected gamma if the output device is set to "None" + + self.yi.setInputColorSpace("LinearRGB", 1.0) #Values from Blender, color picker floating point data are already linear (linearized by Blender) + self.yi.setXMLColorSpace(input_color_values_color_space, input_color_values_gamma) #To set the XML interface to write the XML values with the correction included for the selected color space (and gamma if applicable) + self.yi.paramsClearAll() self.co = yafrayinterface.imageOutput_t() - self.yi.setOutfile(self.outputFile) else: self.setInterface(yafrayinterface.yafrayInterface_t()) - self.yi.setInputGamma(scene.gs_gamma_input, True) + self.yi.startScene() + yaf_scene.exportRenderPassesSettings(self.yi, self.scene) + self.yi.setupRenderPasses() + self.yi.setInputColorSpace("LinearRGB", 1.0) #When rendering into Blender, color picker floating point data is already linear (linearized by Blender) - self.yi.startScene() self.exportScene() self.yaf_integrator.exportIntegrator(self.scene) self.yaf_integrator.exportVolumeIntegrator(self.scene) @@ -329,19 +381,17 @@ def update(self, data, scene): # callback to render scene def render(self, scene): self.bl_use_postprocess = False + self.scene = scene if scene.gs_type_render == "file": self.yi.printInfo("Exporter: Rendering to file {0}".format(self.outputFile)) self.update_stats("YafaRay Rendering:", "Rendering to {0}".format(self.outputFile)) self.yi.render(self.co) result = self.begin_result(0, 0, self.resX, self.resY) - lay = result.layers[0] if bpy.app.version < (2, 74, 4 ) else result.layers[0].passes[0] + lay = result.layers[0] #if bpy.app.version < (2, 74, 4 ) else result.layers[0].passes[0] #FIXME? - # exr format has z-buffer included, so no need to load '_zbuffer' - file - if scene.gs_z_channel and not scene.img_output == 'OPEN_EXR': - lay.load_from_file("{0}_zbuffer.{1}".format(self.output, self.file_type)) - else: - lay.load_from_file(self.outputFile) + lay.load_from_file(self.outputFile) + #lay.passes["Depth"].load_from_file("{0} (Depth).{1}".format(self.output, self.file_type)) #FIXME? Unfortunately I cannot find a way to load the exported images back to the appropiate passes in Blender. Blender probably needs to improve their API to allow per-pass loading of files. Also, Blender does not allow opening multi layer EXR files with this function. self.end_result(result) @@ -362,37 +412,79 @@ def progressCallback(command, *args): self.update_progress(self.prog) def drawAreaCallback(*args): - x, y, w, h, tile = args + x, y, w, h, view_number, tiles = args res = self.begin_result(x, y, w, h) + try: l = res.layers[0] if bpy.app.version < (2, 74, 4 ): - l.rect, l.passes[0].rect = tile + l.rect, l.passes[0].rect = tiles else: - if self.is_preview: - l.passes[0].rect = tile[0] + if scene.render.use_multiview: + #due to Blender limitations while drawing the tiles, I cannot use the view names properly and I have to repeat the currently drawing tile into all views so it shows correctly. Maybe there is a better way? + for view_number,view in enumerate(scene.render.views): + if view.use and not (scene.render.views_format == "STEREO_3D" and view.name != "left" and view.name != "right"): + view_suffix = '.'+scene.render.views[view_number].name + + for tile in tiles: + view_name, tile_name, tile_bitmap = tile + try: + l.passes[tile_name+view_suffix].rect = tile_bitmap + except: + print("Exporter: Exception while rendering in drawAreaCallback function:") + traceback.print_exc() + else: - l.passes[0].rect, l.passes[1].rect = tile - + for tile in tiles: + view_name, tile_name, tile_bitmap = tile + try: + l.passes[tile_name].rect = tile_bitmap + except: + print("Exporter: Exception while rendering in drawAreaCallback function:") + traceback.print_exc() + self.end_result(res) except: print("Exporter: Exception while rendering in drawAreaCallback function:") traceback.print_exc() - def flushCallback(*args): - w, h, tile = args + w, h, view_number, tiles = args res = self.begin_result(0, 0, w, h) + try: l = res.layers[0] if bpy.app.version < (2, 74, 4 ): - l.rect, l.passes[0].rect = tile + l.rect, l.passes[0].rect = tiles else: - if self.is_preview: - l.passes[0].rect = tile[0] - else: - l.passes[0].rect, l.passes[1].rect = tile + for tile in tiles: + view_name, tile_name, tile_bitmap = tile + if scene.render.use_multiview: + if view_name == "": #In case we use Render 3D vierpowrt with Views enabled, it will copy the result to all views + for view_number,view in enumerate(scene.render.views): + if view.use and not (scene.render.views_format == "STEREO_3D" and view.name != "left" and view.name != "right"): + full_tile_name = tile_name + "." + view.name + try: + l.passes[full_tile_name].rect = tile_bitmap + except: + print("Exporter: Exception while rendering in flushCallback function:") + traceback.print_exc() + else: + if scene.render.views[view_name].use and not (scene.render.views_format == "STEREO_3D" and view_name != "left" and view_name != "right"): + full_tile_name = tile_name + "." + view_name + try: + l.passes[full_tile_name].rect = tile_bitmap + except: + print("Exporter: Exception while rendering in flushCallback function:") + traceback.print_exc() + else: + full_tile_name = tile_name + try: + l.passes[full_tile_name].rect = tile_bitmap + except: + print("Exporter: Exception while rendering in flushCallback function:") + traceback.print_exc() self.end_result(res) diff --git a/io/yaf_integrator.py b/io/yaf_integrator.py index 76ea177a..16e89853 100644 --- a/io/yaf_integrator.py +++ b/io/yaf_integrator.py @@ -18,6 +18,7 @@ # +import bpy class yafIntegrator: def __init__(self, interface): @@ -35,12 +36,20 @@ def exportIntegrator(self, scene): yi.paramsSetBool("bg_transp_refract", False) yi.paramsSetInt("raydepth", scene.gs_ray_depth) + if scene.name == "preview" and bpy.data.scenes[0].yafaray.preview.enable: + yi.paramsSetInt("raydepth", bpy.data.scenes[0].yafaray.preview.previewRayDepth) yi.paramsSetInt("shadowDepth", scene.gs_shadow_depth) yi.paramsSetBool("transpShad", scene.gs_transp_shad) light_type = scene.intg_light_method yi.printInfo("Exporting Integrator: {0}".format(light_type)) + yi.paramsSetBool("do_AO", scene.intg_use_AO) + yi.paramsSetInt("AO_samples", scene.intg_AO_samples) + yi.paramsSetFloat("AO_distance", scene.intg_AO_distance) + c = scene.intg_AO_color + yi.paramsSetColor("AO_color", c[0], c[1], c[2]) + if light_type == "Direct Lighting": yi.paramsSetString("type", "directlighting") @@ -51,14 +60,6 @@ def exportIntegrator(self, scene): yi.paramsSetInt("caustic_mix", scene.intg_caustic_mix) yi.paramsSetInt("caustic_depth", scene.intg_caustic_depth) yi.paramsSetFloat("caustic_radius", scene.intg_caustic_radius) - - yi.paramsSetBool("do_AO", scene.intg_use_AO) - - if scene.intg_use_AO: - yi.paramsSetInt("AO_samples", scene.intg_AO_samples) - yi.paramsSetFloat("AO_distance", scene.intg_AO_distance) - c = scene.intg_AO_color - yi.paramsSetColor("AO_color", c[0], c[1], c[2]) elif light_type == "Photon Mapping": yi.paramsSetString("type", "photonmapping") diff --git a/io/yaf_light.py b/io/yaf_light.py index af1bc351..1384bcfe 100644 --- a/io/yaf_light.py +++ b/io/yaf_light.py @@ -20,9 +20,18 @@ import os from mathutils import Vector +import mathutils +import bpy from math import degrees, pi, sin, cos from bpy.path import abspath +def multiplyMatrix4x4Vector4(matrix, vector): + result = mathutils.Vector((0.0, 0.0, 0.0, 0.0)) + for i in range(4): + result[i] = vector * matrix[i] # use reverse vector multiply order, API changed with rev. 38674 + + return result + class yafLight: def __init__(self, interface, preview): self.yi = interface @@ -86,16 +95,35 @@ def createLight(self, yi, lamp_object, matrix=None): if name == "Lamp": pos = (-6, -4, 8, 1.0) power = 5 + if bpy.data.scenes[0].yafaray.preview.enable: + power *= bpy.data.scenes[0].yafaray.preview.fillLightPowerFactor + color = bpy.data.scenes[0].yafaray.preview.fillLightColor + elif name == "Lamp.001": pos = (6, -6, -2, 1.0) power = 6 + if bpy.data.scenes[0].yafaray.preview.enable: + power *= bpy.data.scenes[0].yafaray.preview.fillLightPowerFactor + color = bpy.data.scenes[0].yafaray.preview.fillLightColor + elif name == "Lamp.002": pos = (-2.9123109, -7.270790733, 4.439187765, 1.0) to = (-0.0062182024121284485, 0.6771485209465027, 1.8015732765197754, 1.0) power = 5 + if bpy.data.scenes[0].yafaray.preview.enable: + power *= bpy.data.scenes[0].yafaray.preview.keyLightPowerFactor + color = bpy.data.scenes[0].yafaray.preview.keyLightColor + elif name == "Lamp.008": lampType = "sun" power = 0.8 + if bpy.data.scenes[0].yafaray.preview.enable: + power *= bpy.data.scenes[0].yafaray.preview.keyLightPowerFactor + color = bpy.data.scenes[0].yafaray.preview.keyLightColor + + if bpy.data.scenes[0].yafaray.preview.enable: + matrix2 = mathutils.Matrix.Rotation(bpy.data.scenes[0].yafaray.preview.lightRotZ, 4, 'Z') + pos = multiplyMatrix4x4Vector4(matrix2, mathutils.Vector((pos[0], pos[1], pos[2], pos[3]))) yi.paramsClearAll() @@ -105,6 +133,9 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsClearAll() yi.paramsSetColor("color", color[0], color[1], color[2]) # color for spherelight and area light geometry yi.paramsSetString("type", "light_mat") + power_sphere = power / lamp.yaf_sphere_radius + yi.paramsSetFloat("power", power_sphere) + self.lightMat = self.yi.createMaterial(name) self.yi.paramsClearAll() #yi.paramsSetBool("light_enabled", lamp.light_enabled) @@ -119,6 +150,7 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsSetInt("samples", lamp.yaf_samples) yi.paramsSetFloat("radius", lamp.yaf_sphere_radius) yi.paramsSetBool("light_enabled", lamp.light_enabled) + yi.paramsSetBool("cast_shadows", lamp.cast_shadows) elif lampType == "spot": if self.preview and name == "Lamp.002": @@ -138,6 +170,7 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsSetBool("photon_only", lamp.photon_only) yi.paramsSetInt("samples", lamp.yaf_samples) yi.paramsSetBool("light_enabled", lamp.light_enabled) + yi.paramsSetBool("cast_shadows", lamp.cast_shadows) elif lampType == "sun": yi.paramsSetString("type", "sunlight") @@ -145,6 +178,7 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsSetFloat("angle", lamp.angle) yi.paramsSetPoint("direction", direct[0], direct[1], direct[2]) yi.paramsSetBool("light_enabled", lamp.light_enabled) + yi.paramsSetBool("cast_shadows", lamp.cast_shadows) elif lampType == "directional": yi.paramsSetString("type", "directional") @@ -154,6 +188,7 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsSetFloat("radius", lamp.shadow_soft_size) yi.paramsSetPoint("from", pos[0], pos[1], pos[2]) yi.paramsSetBool("light_enabled", lamp.light_enabled) + yi.paramsSetBool("cast_shadows", lamp.cast_shadows) elif lampType == "ies": yi.paramsSetString("type", "ieslight") @@ -166,6 +201,7 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsSetInt("samples", lamp.yaf_samples) yi.paramsSetBool("soft_shadows", lamp.ies_soft_shadows) yi.paramsSetBool("light_enabled", lamp.light_enabled) + yi.paramsSetBool("cast_shadows", lamp.cast_shadows) elif lampType == "area": sizeX = lamp.size @@ -210,6 +246,7 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsSetPoint("point1", corner1[0], corner1[1], corner1[2]) yi.paramsSetPoint("point2", corner3[0], corner3[1], corner3[2]) yi.paramsSetBool("light_enabled", lamp.light_enabled) + yi.paramsSetBool("cast_shadows", lamp.cast_shadows) if lampType not in {"sun", "directional"}: # "from" is not used for sunlight and infinite directional light @@ -223,6 +260,7 @@ def createLight(self, yi, lamp_object, matrix=None): yi.paramsSetColor("color", color[0], color[1], color[2]) yi.paramsSetFloat("power", power) yi.paramsSetBool("light_enabled", lamp.light_enabled) + yi.paramsSetBool("cast_shadows", lamp.cast_shadows) yi.createLight(name) return True diff --git a/io/yaf_material.py b/io/yaf_material.py index 1fcdfc1d..2d474505 100644 --- a/io/yaf_material.py +++ b/io/yaf_material.py @@ -191,13 +191,8 @@ def writeMappingNode(self, name, texname, mtex): mappingCoords = switchMappingCoords.get(mtex.mapping, 'plain') yi.paramsSetString("mapping", mappingCoords) + yi.paramsSetPoint("scale", mtex.scale[0], mtex.scale[1], mtex.scale[2]) yi.paramsSetPoint("offset", mtex.offset[0], mtex.offset[1], mtex.offset[2]) - if self.preview: # check if it is a texture preview render - mtex_X = mtex.scale[0] * 8.998 # tex preview fix: scale X value of tex size for the stretched Plane Mesh in preview scene - mtex_Z = mtex.scale[2] * 0.00001 # and for Z value of texture size also... - yi.paramsSetPoint("scale", mtex_X, mtex.scale[1], mtex_Z) - else: - yi.paramsSetPoint("scale", mtex.scale[0], mtex.scale[1], mtex.scale[2]) if mtex.use_map_normal: # || mtex->maptoneg & MAP_NORM ) # scale up the normal factor, it resembles @@ -205,12 +200,14 @@ def writeMappingNode(self, name, texname, mtex): nf = mtex.normal_factor * 2 yi.paramsSetFloat("bump_strength", nf) - def writeGlassShader(self, mat, rough): + def writeGlassShader(self, mat, scene, rough): # mat : is an instance of material yi = self.yi yi.paramsClearAll() + yi.paramsSetInt("mat_pass_index", mat.pass_index) + if rough: # create bool property "rough" yi.paramsSetString("type", "rough_glass") yi.paramsSetFloat("alpha", mat.refr_roughness) # added refraction roughness for roughglass material @@ -218,10 +215,14 @@ def writeGlassShader(self, mat, rough): yi.paramsSetString("type", "glass") yi.paramsSetFloat("IOR", mat.IOR_refraction) # added IOR for refraction - filt_col = mat.filter_color + if scene.gs_clay_render and not mat.clay_exclude: + filt_col = (1.0, 1.0, 1.0) + abs_col = (1.0, 1.0, 1.0) + else: + filt_col = mat.filter_color + abs_col = mat.absorption mir_col = mat.glass_mir_col tfilt = mat.glass_transmit - abs_col = mat.absorption yi.paramsSetColor("filter_color", filt_col[0], filt_col[1], filt_col[2]) yi.paramsSetColor("mirror_color", mir_col[0], mir_col[1], mir_col[2]) @@ -231,10 +232,15 @@ def writeGlassShader(self, mat, rough): yi.paramsSetFloat("absorption_dist", mat.absorption_dist) yi.paramsSetFloat("dispersion_power", mat.dispersion_power) yi.paramsSetBool("fake_shadows", mat.fake_shadows) + yi.paramsSetString("visibility", mat.visibility) + yi.paramsSetBool("receive_shadows", mat.receive_shadows) mcolRoot = '' # fcolRoot = '' /* UNUSED */ bumpRoot = '' + filterColorRoot = '' + IORRoot = '' + roughnessRoot = '' i = 0 used_textures = self.getUsedTextures(mat) @@ -251,6 +257,18 @@ def writeGlassShader(self, mat, rough): if self.writeTexLayer(lname, mappername, bumpRoot, mtex, mtex.use_map_normal, [0], mtex.normal_factor): used = True bumpRoot = lname + lname = "filter_color_layer%x" % i + if self.writeTexLayer(lname, mappername, filterColorRoot, mtex, mtex.use_map_color_reflection, filt_col, mtex.reflection_color_factor): + used = True + filterColorRoot = lname + lname = "IOR_layer%x" % i + if self.writeTexLayer(lname, mappername, IORRoot, mtex, mtex.use_map_warp, [0], mtex.warp_factor): + used = True + IORRoot = lname + lname = "roughness_layer%x" % i + if self.writeTexLayer(lname, mappername, roughnessRoot, mtex, mtex.use_map_hardness, [0], mtex.hardness_factor): + used = True + roughnessRoot = lname if used: self.writeMappingNode(mappername, mtex.texture.name, mtex) i += 1 @@ -260,13 +278,20 @@ def writeGlassShader(self, mat, rough): yi.paramsSetString("mirror_color_shader", mcolRoot) if len(bumpRoot) > 0: yi.paramsSetString("bump_shader", bumpRoot) - + if len(filterColorRoot) > 0: + yi.paramsSetString("filter_color_shader", filterColorRoot) + if len(IORRoot) > 0: + yi.paramsSetString("IOR_shader", IORRoot) + if len(roughnessRoot) > 0: + yi.paramsSetString("roughness_shader", roughnessRoot) return yi.createMaterial(self.namehash(mat)) - def writeGlossyShader(self, mat, coated): # mat : instance of material class + def writeGlossyShader(self, mat, scene, coated): # mat : instance of material class yi = self.yi yi.paramsClearAll() + yi.paramsSetInt("mat_pass_index", mat.pass_index) + if coated: # create bool property yi.paramsSetString("type", "coated_glossy") yi.paramsSetFloat("IOR", mat.IOR_reflection) # IOR for reflection @@ -274,8 +299,10 @@ def writeGlossyShader(self, mat, coated): # mat : instance of material class yi.paramsSetColor("mirror_color", mir_col[0], mir_col[1], mir_col[2]) else: yi.paramsSetString("type", "glossy") + mir_col = mat.diffuse_color diffuse_color = mat.diffuse_color + bSpecr = mat.specular_reflect color = mat.glossy_color yi.paramsSetColor("diffuse_color", diffuse_color[0], diffuse_color[1], diffuse_color[2]) @@ -287,12 +314,21 @@ def writeGlossyShader(self, mat, coated): # mat : instance of material class yi.paramsSetBool("anisotropic", mat.anisotropic) yi.paramsSetFloat("exp_u", mat.exp_u) yi.paramsSetFloat("exp_v", mat.exp_v) + yi.paramsSetFloat("specular_reflect", bSpecr) + yi.paramsSetString("visibility", mat.visibility) + yi.paramsSetBool("receive_shadows", mat.receive_shadows) diffRoot = '' # mcolRoot = '' /* UNUSED */ glossRoot = '' glRefRoot = '' bumpRoot = '' + sigmaOrenRoot = '' + exponentRoot = '' + IORRoot = '' + diffReflectRoot = '' + mirrorRoot = '' + mcolRoot = '' i = 0 used_textures = self.getUsedTextures(mat) @@ -317,6 +353,32 @@ def writeGlossyShader(self, mat, coated): # mat : instance of material class if self.writeTexLayer(lname, mappername, bumpRoot, mtex, mtex.use_map_normal, [0], mtex.normal_factor): used = True bumpRoot = lname + lname = "sigma_oren_layer%x" % i + if self.writeTexLayer(lname, mappername, sigmaOrenRoot, mtex, mtex.use_map_hardness, [0], mtex.hardness_factor): + used = True + sigmaOrenRoot = lname + lname = "exponent_layer%x" % i + if self.writeTexLayer(lname, mappername, exponentRoot, mtex, mtex.use_map_ambient, [0], mtex.ambient_factor): + used = True + exponentRoot = lname + lname = "IOR_layer%x" % i + if self.writeTexLayer(lname, mappername, IORRoot, mtex, mtex.use_map_warp, [0], mtex.warp_factor): + used = True + IORRoot = lname + lname = "diff_refl_layer%x" % i + if self.writeTexLayer(lname, mappername, diffReflectRoot, mtex, mtex.use_map_diffuse, [0], mtex.diffuse_factor): + used = True + diffReflectRoot = lname + lname = "mircol_layer%x" % i + if self.writeTexLayer(lname, mappername, mcolRoot, mtex, mtex.use_map_mirror, mir_col, mtex.mirror_factor): + used = True + mcolRoot = lname + lname = "mirr_layer%x" % i + if self.writeTexLayer(lname, mappername, mirrorRoot, mtex, mtex.use_map_raymir, [bSpecr], mtex.raymir_factor): + used = True + mirrorRoot = lname + + if used: self.writeMappingNode(mappername, mtex.texture.name, mtex) i += 1 @@ -330,27 +392,52 @@ def writeGlossyShader(self, mat, coated): # mat : instance of material class yi.paramsSetString("glossy_reflect_shader", glRefRoot) if len(bumpRoot) > 0: yi.paramsSetString("bump_shader", bumpRoot) - + if len(sigmaOrenRoot) > 0: + yi.paramsSetString("sigma_oren_shader", sigmaOrenRoot) + if len(exponentRoot) > 0: + yi.paramsSetString("exponent_shader", exponentRoot) + if len(IORRoot) > 0: + yi.paramsSetString("IOR_shader", IORRoot) + if len(diffReflectRoot) > 0: + yi.paramsSetString("diffuse_refl_shader", diffReflectRoot) + if len(mcolRoot) > 0: + yi.paramsSetString("mirror_color_shader", mcolRoot) + if len(mirrorRoot) > 0: + yi.paramsSetString("mirror_shader", mirrorRoot) + if mat.brdf_type == "oren-nayar": # oren-nayar fix for glossy yi.paramsSetString("diffuse_brdf", "Oren-Nayar") yi.paramsSetFloat("sigma", mat.sigma) return yi.createMaterial(self.namehash(mat)) - def writeShinyDiffuseShader(self, mat): + + def writeShinyDiffuseShader(self, mat, scene): yi = self.yi yi.paramsClearAll() + yi.paramsSetInt("mat_pass_index", mat.pass_index) + yi.paramsSetString("type", "shinydiffusemat") bCol = mat.diffuse_color mirCol = mat.mirror_color bSpecr = mat.specular_reflect + bDiffRefl = mat.diffuse_reflect bTransp = mat.transparency bTransl = mat.translucency bTransmit = mat.transmit_filter bEmit = mat.emit + if scene.gs_clay_render and not mat.clay_exclude: + bCol = scene.gs_clay_col + bSpecr = 0.0 + bEmit = 0.0 + bDiffRefl = 1.0 + if not scene.gs_clay_render_keep_transparency: + bTransp = 0.0 + bTransl = 0.0 + if self.preview: if mat.name.startswith("checker"): bEmit = 2.50 @@ -364,6 +451,9 @@ def writeShinyDiffuseShader(self, mat): translRoot = '' mirrorRoot = '' bumpRoot = '' + sigmaOrenRoot = '' + diffReflectRoot = '' + IORRoot = '' for mtex in used_textures: if not mtex.texture: @@ -371,35 +461,59 @@ def writeShinyDiffuseShader(self, mat): used = False mappername = "map%x" % i - lname = "diff_layer%x" % i - if self.writeTexLayer(lname, mappername, diffRoot, mtex, mtex.use_map_color_diffuse, bCol, mtex.diffuse_color_factor): - used = True - diffRoot = lname - - lname = "mircol_layer%x" % i - if self.writeTexLayer(lname, mappername, mcolRoot, mtex, mtex.use_map_mirror, mirCol, mtex.mirror_factor): - used = True - mcolRoot = lname - - lname = "transp_layer%x" % i - if self.writeTexLayer(lname, mappername, transpRoot, mtex, mtex.use_map_alpha, [bTransp], mtex.alpha_factor): - used = True - transpRoot = lname - - lname = "translu_layer%x" % i - if self.writeTexLayer(lname, mappername, translRoot, mtex, mtex.use_map_translucency, [bTransl], mtex.translucency_factor): - used = True - translRoot = lname - - lname = "mirr_layer%x" % i - if self.writeTexLayer(lname, mappername, mirrorRoot, mtex, mtex.use_map_raymir, [bSpecr], mtex.raymir_factor): - used = True - mirrorRoot = lname - - lname = "bump_layer%x" % i - if self.writeTexLayer(lname, mappername, bumpRoot, mtex, mtex.use_map_normal, [0], mtex.normal_factor): - used = True - bumpRoot = lname + if mat.clay_exclude or not scene.gs_clay_render: + lname = "diff_layer%x" % i + if self.writeTexLayer(lname, mappername, diffRoot, mtex, mtex.use_map_color_diffuse, bCol, mtex.diffuse_color_factor): + used = True + diffRoot = lname + + if mat.clay_exclude or not scene.gs_clay_render: + lname = "mircol_layer%x" % i + if self.writeTexLayer(lname, mappername, mcolRoot, mtex, mtex.use_map_mirror, mirCol, mtex.mirror_factor): + used = True + mcolRoot = lname + + if mat.clay_exclude or scene.gs_clay_render_keep_transparency or not scene.gs_clay_render: + lname = "transp_layer%x" % i + if self.writeTexLayer(lname, mappername, transpRoot, mtex, mtex.use_map_alpha, [bTransp], mtex.alpha_factor): + used = True + transpRoot = lname + + if mat.clay_exclude or scene.gs_clay_render_keep_transparency or not scene.gs_clay_render: + lname = "translu_layer%x" % i + if self.writeTexLayer(lname, mappername, translRoot, mtex, mtex.use_map_translucency, [bTransl], mtex.translucency_factor): + used = True + translRoot = lname + + if mat.clay_exclude or not scene.gs_clay_render: + lname = "mirr_layer%x" % i + if self.writeTexLayer(lname, mappername, mirrorRoot, mtex, mtex.use_map_raymir, [bSpecr], mtex.raymir_factor): + used = True + mirrorRoot = lname + + if mat.clay_exclude or scene.gs_clay_render_keep_normals or not scene.gs_clay_render: + lname = "bump_layer%x" % i + if self.writeTexLayer(lname, mappername, bumpRoot, mtex, mtex.use_map_normal, [0], mtex.normal_factor): + used = True + bumpRoot = lname + + if mat.clay_exclude or scene.gs_clay_render_keep_normals or not scene.gs_clay_render: + lname = "sigma_oren_layer%x" % i + if self.writeTexLayer(lname, mappername, sigmaOrenRoot, mtex, mtex.use_map_hardness, [0], mtex.hardness_factor): + used = True + sigmaOrenRoot = lname + + if mat.clay_exclude or not scene.gs_clay_render: + lname = "diff_refl_layer%x" % i + if self.writeTexLayer(lname, mappername, diffReflectRoot, mtex, mtex.use_map_diffuse, [0], mtex.diffuse_factor): + used = True + diffReflectRoot = lname + + if mat.clay_exclude or not scene.gs_clay_render: + lname = "IOR_layer%x" % i + if self.writeTexLayer(lname, mappername, IORRoot, mtex, mtex.use_map_warp, [0], mtex.warp_factor): + used = True + IORRoot = lname if used: self.writeMappingNode(mappername, mtex.texture.name, mtex) @@ -418,11 +532,17 @@ def writeShinyDiffuseShader(self, mat): yi.paramsSetString("mirror_shader", mirrorRoot) if len(bumpRoot) > 0: yi.paramsSetString("bump_shader", bumpRoot) + if len(sigmaOrenRoot) > 0: + yi.paramsSetString("sigma_oren_shader", sigmaOrenRoot) + if len(diffReflectRoot) > 0: + yi.paramsSetString("diffuse_refl_shader", diffReflectRoot) + if len(IORRoot) > 0: + yi.paramsSetString("IOR_shader", IORRoot) yi.paramsSetColor("color", bCol[0], bCol[1], bCol[2]) yi.paramsSetFloat("transparency", bTransp) yi.paramsSetFloat("translucency", bTransl) - yi.paramsSetFloat("diffuse_reflect", mat.diffuse_reflect) + yi.paramsSetFloat("diffuse_reflect", bDiffRefl) yi.paramsSetFloat("emit", bEmit) yi.paramsSetFloat("transmit_filter", bTransmit) @@ -430,21 +550,27 @@ def writeShinyDiffuseShader(self, mat): yi.paramsSetColor("mirror_color", mirCol[0], mirCol[1], mirCol[2]) yi.paramsSetBool("fresnel_effect", mat.fresnel_effect) yi.paramsSetFloat("IOR", mat.IOR_reflection) # added IOR for reflection - - if mat.brdf_type == "oren-nayar": # oren-nayar fix for shinydiffuse + yi.paramsSetString("visibility", mat.visibility) + yi.paramsSetBool("receive_shadows", mat.receive_shadows) + + if scene.gs_clay_render and not mat.clay_exclude: + if scene.gs_clay_oren_nayar: + yi.paramsSetString("diffuse_brdf", "oren_nayar") + yi.paramsSetFloat("sigma", scene.gs_clay_sigma) + elif mat.brdf_type == "oren-nayar": # oren-nayar fix for shinydiffuse yi.paramsSetString("diffuse_brdf", "oren_nayar") yi.paramsSetFloat("sigma", mat.sigma) return yi.createMaterial(self.namehash(mat)) - def writeBlendShader(self, mat): + def writeBlendShader(self, mat, scene): yi = self.yi yi.paramsClearAll() - yi.printInfo("Exporter: Blend material with: [" + mat.material1 + "] [" + mat.material2 + "]") + yi.printInfo("Exporter: Blend material with: [" + mat.material1name + "] [" + mat.material2name + "]") yi.paramsSetString("type", "blend_mat") - yi.paramsSetString("material1", self.namehash(bpy.data.materials[mat.material1])) - yi.paramsSetString("material2", self.namehash(bpy.data.materials[mat.material2])) + yi.paramsSetString("material1", self.namehash(bpy.data.materials[mat.material1name])) + yi.paramsSetString("material2", self.namehash(bpy.data.materials[mat.material2name])) i = 0 @@ -475,39 +601,46 @@ def writeBlendShader(self, mat): else: yi.paramsSetFloat("blend_value", mat.blend_value) + yi.paramsSetString("visibility", mat.visibility) + yi.paramsSetBool("receive_shadows", mat.receive_shadows) + return yi.createMaterial(self.namehash(mat)) - def writeMatteShader(self, mat): + def writeMatteShader(self, mat, scene): yi = self.yi yi.paramsClearAll() yi.paramsSetString("type", "shadow_mat") return yi.createMaterial(self.namehash(mat)) - def writeNullMat(self, mat): + def writeNullMat(self, mat, scene): yi = self.yi yi.paramsClearAll() yi.paramsSetString("type", "null") return yi.createMaterial(self.namehash(mat)) - def writeMaterial(self, mat, preview=False): + def writeMaterial(self, mat, scene, preview=False): self.preview = preview self.yi.printInfo("Exporter: Creating Material: \"" + self.namehash(mat) + "\"") ymat = None if mat.name == "y_null": - ymat = self.writeNullMat(mat) + ymat = self.writeNullMat(mat, scene) + elif scene.gs_clay_render and not mat.clay_exclude and not (scene.gs_clay_render_keep_transparency and mat.mat_type == "glass"): + ymat = self.writeShinyDiffuseShader(mat, scene) elif mat.mat_type == "glass": - ymat = self.writeGlassShader(mat, False) + ymat = self.writeGlassShader(mat, scene, False) elif mat.mat_type == "rough_glass": - ymat = self.writeGlassShader(mat, True) + ymat = self.writeGlassShader(mat, scene, True) elif mat.mat_type == "glossy": - ymat = self.writeGlossyShader(mat, False) + ymat = self.writeGlossyShader(mat, scene, False) elif mat.mat_type == "coated_glossy": - ymat = self.writeGlossyShader(mat, True) + ymat = self.writeGlossyShader(mat, scene, True) elif mat.mat_type == "shinydiffusemat": - ymat = self.writeShinyDiffuseShader(mat) + ymat = self.writeShinyDiffuseShader(mat, scene) elif mat.mat_type == "blend": - ymat = self.writeBlendShader(mat) + ymat = self.writeBlendShader(mat, scene) #FIXME: in the new Clay render two limitations: + #We cannot yet keep transparency in Blend objects. If that's needed to test a scene, better to exclude that particular material from the Clay + #We cannot exclude just the blended material from the Clay render, the individual materials that are used to make the blend also have to be excluded else: - ymat = self.writeNullMat(mat) + ymat = self.writeNullMat(mat, scene) self.materialMap[mat] = ymat diff --git a/io/yaf_object.py b/io/yaf_object.py index b7fda920..358af818 100644 --- a/io/yaf_object.py +++ b/io/yaf_object.py @@ -43,115 +43,147 @@ def setScene(self, scene): self.scene = scene - def createCamera(self): + def createCameras(self): yi = self.yi - yi.printInfo("Exporting Camera") - - camera = self.scene.camera + yi.printInfo("Exporting Cameras") + render = self.scene.render + + class CameraData: + def __init__ (self, camera, camera_name, view_name): + self.camera = camera + self.camera_name = camera_name + self.view_name = view_name + + cameras = [] + + if bpy.types.YAFA_RENDER.useViewToRender or not render.use_multiview: + cameras.append(CameraData(self.scene.camera, "cam", "")) + else: + camera_base_name = self.scene.camera.name.rsplit('_',1)[0] - if bpy.types.YAFA_RENDER.useViewToRender and bpy.types.YAFA_RENDER.viewMatrix: - # use the view matrix to calculate the inverted transformed - # points cam pos (0,0,0), front (0,0,1) and up (0,1,0) - # view matrix works like the opengl view part of the - # projection matrix, i.e. transforms everything so camera is - # at 0,0,0 looking towards 0,0,1 (y axis being up) + for view in render.views: + if view.use and not (render.views_format == "STEREO_3D" and view.name != "left" and view.name != "right"): + cameras.append(CameraData(self.scene.objects[camera_base_name+view.camera_suffix], camera_base_name+view.camera_suffix, view.name)) - m = bpy.types.YAFA_RENDER.viewMatrix - # m.transpose() --> not needed anymore: matrix indexing changed with Blender rev.42816 - inv = m.inverted() + for cam in cameras: + if bpy.types.YAFA_RENDER.useViewToRender and bpy.types.YAFA_RENDER.viewMatrix: + # use the view matrix to calculate the inverted transformed + # points cam pos (0,0,0), front (0,0,1) and up (0,1,0) + # view matrix works like the opengl view part of the + # projection matrix, i.e. transforms everything so camera is + # at 0,0,0 looking towards 0,0,1 (y axis being up) - pos = multiplyMatrix4x4Vector4(inv, mathutils.Vector((0, 0, 0, 1))) - aboveCam = multiplyMatrix4x4Vector4(inv, mathutils.Vector((0, 1, 0, 1))) - frontCam = multiplyMatrix4x4Vector4(inv, mathutils.Vector((0, 0, 1, 1))) + m = bpy.types.YAFA_RENDER.viewMatrix + # m.transpose() --> not needed anymore: matrix indexing changed with Blender rev.42816 + inv = m.inverted() - dir = frontCam - pos - up = aboveCam + pos = multiplyMatrix4x4Vector4(inv, mathutils.Vector((0, 0, 0, 1))) + aboveCam = multiplyMatrix4x4Vector4(inv, mathutils.Vector((0, 1, 0, 1))) + frontCam = multiplyMatrix4x4Vector4(inv, mathutils.Vector((0, 0, 1, 1))) - else: - # get cam worldspace transformation matrix, e.g. if cam is parented matrix_local does not work - matrix = camera.matrix_world.copy() - # matrix indexing (row, colums) changed in Blender rev.42816, for explanation see also: - # http://wiki.blender.org/index.php/User:TrumanBlending/Matrix_Indexing - pos = matrix.col[3] - dir = matrix.col[2] - up = pos + matrix.col[1] + dir = frontCam - pos + up = aboveCam - to = pos - dir + else: + # get cam worldspace transformation matrix, e.g. if cam is parented matrix_local does not work + matrix = cam.camera.matrix_world.copy() + # matrix indexing (row, colums) changed in Blender rev.42816, for explanation see also: + # http://wiki.blender.org/index.php/User:TrumanBlending/Matrix_Indexing + pos = matrix.col[3] + dir = matrix.col[2] + up = pos + matrix.col[1] - x = int(render.resolution_x * render.resolution_percentage * 0.01) - y = int(render.resolution_y * render.resolution_percentage * 0.01) + to = pos - dir - yi.paramsClearAll() + x = int(render.resolution_x * render.resolution_percentage * 0.01) + y = int(render.resolution_y * render.resolution_percentage * 0.01) - if bpy.types.YAFA_RENDER.useViewToRender: - yi.paramsSetString("type", "perspective") - yi.paramsSetFloat("focal", 0.7) - bpy.types.YAFA_RENDER.useViewToRender = False + yi.paramsClearAll() - else: - camera = camera.data - camType = camera.camera_type - - yi.paramsSetString("type", camType) - - if camera.use_clipping: - yi.paramsSetFloat("nearClip", camera.clip_start) - yi.paramsSetFloat("farClip", camera.clip_end) - - if camType == "orthographic": - yi.paramsSetFloat("scale", camera.ortho_scale) - - elif camType in {"perspective", "architect"}: - # Blenders GSOC 2011 project "tomato branch" merged into trunk. - # Check for sensor settings and use them in yafaray exporter also. - if camera.sensor_fit == 'AUTO': - horizontal_fit = (x > y) - sensor_size = camera.sensor_width - elif camera.sensor_fit == 'HORIZONTAL': - horizontal_fit = True - sensor_size = camera.sensor_width - else: - horizontal_fit = False - sensor_size = camera.sensor_height + if bpy.types.YAFA_RENDER.useViewToRender: + yi.paramsSetString("type", "perspective") + yi.paramsSetFloat("focal", 0.7) + bpy.types.YAFA_RENDER.useViewToRender = False - if horizontal_fit: - f_aspect = 1.0 - else: - f_aspect = x / y + else: + camera = cam.camera.data + camType = camera.camera_type + + yi.paramsSetString("type", camType) + + if camera.use_clipping: + yi.paramsSetFloat("nearClip", camera.clip_start) + yi.paramsSetFloat("farClip", camera.clip_end) + + if camType == "orthographic": + yi.paramsSetFloat("scale", camera.ortho_scale) + + elif camType in {"perspective", "architect"}: + # Blenders GSOC 2011 project "tomato branch" merged into trunk. + # Check for sensor settings and use them in yafaray exporter also. + if camera.sensor_fit == 'AUTO': + horizontal_fit = (x > y) + sensor_size = camera.sensor_width + elif camera.sensor_fit == 'HORIZONTAL': + horizontal_fit = True + sensor_size = camera.sensor_width + else: + horizontal_fit = False + sensor_size = camera.sensor_height - yi.paramsSetFloat("focal", camera.lens / (f_aspect * sensor_size)) + if horizontal_fit: + f_aspect = 1.0 + else: + f_aspect = x / y - # DOF params, only valid for real camera - # use DOF object distance if present or fixed DOF - if camera.dof_object is not None: - # use DOF object distance - dist = (pos.xyz - camera.dof_object.location.xyz).length - dof_distance = dist - else: - # use fixed DOF distance - dof_distance = camera.dof_distance + yi.paramsSetFloat("focal", camera.lens / (f_aspect * sensor_size)) - yi.paramsSetFloat("dof_distance", dof_distance) - yi.paramsSetFloat("aperture", camera.aperture) - # bokeh params - yi.paramsSetString("bokeh_type", camera.bokeh_type) - yi.paramsSetFloat("bokeh_rotation", camera.bokeh_rotation) + # DOF params, only valid for real camera + # use DOF object distance if present or fixed DOF + if camera.dof_object is not None: + # use DOF object distance + dist = (pos.xyz - camera.dof_object.location.xyz).length + dof_distance = dist + else: + # use fixed DOF distance + dof_distance = camera.dof_distance + + yi.paramsSetFloat("dof_distance", dof_distance) + yi.paramsSetFloat("aperture", camera.aperture) + # bokeh params + yi.paramsSetString("bokeh_type", camera.bokeh_type) + yi.paramsSetFloat("bokeh_rotation", camera.bokeh_rotation) + + elif camType == "angular": + yi.paramsSetBool("circular", camera.circular) + yi.paramsSetBool("mirrored", camera.mirrored) + yi.paramsSetFloat("max_angle", camera.max_angle) + yi.paramsSetFloat("angle", camera.angular_angle) + + yi.paramsSetInt("resx", x) + yi.paramsSetInt("resy", y) + + if self.is_preview and bpy.data.scenes[0].yafaray.preview.enable: + + #incl = bpy.data.scenes[0].yafaray.preview.camRotIncl + #azi = bpy.data.scenes[0].yafaray.preview.camRotAzi + rot = bpy.data.scenes[0].yafaray.preview.camRot + dist = bpy.data.scenes[0].yafaray.preview.camDist - elif camType == "angular": - yi.paramsSetBool("circular", camera.circular) - yi.paramsSetBool("mirrored", camera.mirrored) - yi.paramsSetFloat("max_angle", camera.max_angle) - yi.paramsSetFloat("angle", camera.angular_angle) + #pos = (dist*math.sin(incl)*math.cos(azi), dist*math.sin(incl)*math.sin(azi), dist*math.cos(incl)) + #up = (math.sin(rotZ), 0, math.cos(rotZ)) + pos = (-dist*rot[0], -dist*rot[2], -dist*rot[1]) + up = (0,0,1) + to = (0,0,0) - yi.paramsSetInt("resx", x) - yi.paramsSetInt("resy", y) + yi.paramsSetPoint("from", pos[0], pos[1], pos[2]) + yi.paramsSetPoint("up", up[0], up[1], up[2]) + yi.paramsSetPoint("to", to[0], to[1], to[2]) + yi.paramsSetString("view_name", cam.view_name) + yi.createCamera(cam.camera_name) - yi.paramsSetPoint("from", pos[0], pos[1], pos[2]) - yi.paramsSetPoint("up", up[0], up[1], up[2]) - yi.paramsSetPoint("to", to[0], to[1], to[2]) - yi.createCamera("cam") def getBBCorners(self, object): bb = object.bound_box # look bpy.types.Object if there is any problem @@ -196,7 +228,13 @@ def writeObject(self, obj, matrix=None): self.writeParticleStrands(obj, matrix) else: # The rest of the object types - self.writeMesh(obj, matrix) + if self.is_preview and bpy.data.scenes[0].yafaray.preview.enable: + if "checkers" in obj.name and bpy.data.scenes[0].yafaray.preview.previewBackground == "checker": + self.writeMesh(obj, matrix) + elif "checkers" not in obj.name: + self.writeMesh(obj, matrix) + else: + self.writeMesh(obj, matrix) def writeInstanceBase(self, obj): @@ -207,7 +245,10 @@ def writeInstanceBase(self, obj): obType = 512 # Create this geometry object as a base object for instances - self.writeGeometry(ID, obj, None, obType) # We want the vertices in object space + self.yi.paramsClearAll() + self.yi.paramsSetInt("obj_pass_index", obj.pass_index) + + self.writeGeometry(ID, obj, None, obj.pass_index, obType) # We want the vertices in object space return ID @@ -230,8 +271,29 @@ def writeMesh(self, obj, matrix): # Generate unique object ID ID = self.yi.getNextFreeID() - - self.writeGeometry(ID, obj, matrix) # obType in 0, default, the object is rendered + + self.yi.paramsClearAll() + self.yi.paramsSetInt("obj_pass_index", obj.pass_index) + + if self.is_preview and bpy.data.scenes[0].yafaray.preview.enable and "preview" in obj.name: + ymat = self.materialMap[obj.active_material] + + if bpy.data.scenes[0].yafaray.preview.previewObject != "" and bpy.data.scenes[0].objects[bpy.data.scenes[0].yafaray.preview.previewObject].type=="MESH": + customObj = bpy.data.scenes[0].objects[bpy.data.scenes[0].yafaray.preview.previewObject] + previewMatrix = customObj.matrix_world.copy() + previewMatrix[0][3]=0 + previewMatrix[1][3]=0 + previewMatrix[2][3]=0 + self.writeGeometry(ID, customObj, previewMatrix, obj.pass_index, 0, ymat) + else: + previewMatrix = obj.matrix_world.copy() + previewMatrix[0][3]=0 + previewMatrix[1][3]=0 + previewMatrix[2][3]=0 + + self.writeGeometry(ID, obj, previewMatrix, obj.pass_index) + else: + self.writeGeometry(ID, obj, matrix, obj.pass_index) # obType in 0, default, the object is rendered def writeBGPortal(self, obj, matrix): @@ -241,6 +303,7 @@ def writeBGPortal(self, obj, matrix): ID = self.yi.getNextFreeID() self.yi.paramsClearAll() + self.yi.paramsSetInt("obj_pass_index", obj.pass_index) self.yi.paramsSetString("type", "bgPortalLight") self.yi.paramsSetFloat("power", obj.bgp_power) self.yi.paramsSetInt("samples", obj.bgp_samples) @@ -252,7 +315,7 @@ def writeBGPortal(self, obj, matrix): obType = 256 # Makes object invisible to the renderer (doesn't enter the kdtree) - self.writeGeometry(ID, obj, matrix, obType) + self.writeGeometry(ID, obj, matrix, obj.pass_index, obType) def writeMeshLight(self, obj, matrix): @@ -265,6 +328,7 @@ def writeMeshLight(self, obj, matrix): ml_matname += obj.name + "." + str(obj.__hash__()) self.yi.paramsClearAll() + self.yi.paramsSetInt("obj_pass_index", obj.pass_index) self.yi.paramsSetString("type", "light_mat") self.yi.paramsSetBool("double_sided", obj.ml_double_sided) c = obj.ml_color @@ -276,6 +340,7 @@ def writeMeshLight(self, obj, matrix): # Export mesh light self.yi.paramsClearAll() + self.yi.paramsSetInt("obj_pass_index", obj.pass_index) self.yi.paramsSetString("type", "meshlight") self.yi.paramsSetBool("double_sided", obj.ml_double_sided) c = obj.ml_color @@ -285,7 +350,7 @@ def writeMeshLight(self, obj, matrix): self.yi.paramsSetInt("object", ID) self.yi.createLight(obj.name) - self.writeGeometry(ID, obj, matrix, 0, ml_mat) # obType in 0, default, the object is rendered + self.writeGeometry(ID, obj, matrix, obj.pass_index, 0, ml_mat) # obType in 0, default, the object is rendered def writeVolumeObject(self, obj, matrix): @@ -296,6 +361,7 @@ def writeVolumeObject(self, obj, matrix): # me_materials = me.materials /* UNUSED */ yi.paramsClearAll() + yi.paramsSetInt("obj_pass_index", obj.pass_index) if obj.vol_region == 'ExpDensity Volume': yi.paramsSetString("type", "ExpDensityVolume") @@ -345,7 +411,7 @@ def writeVolumeObject(self, obj, matrix): yi.createVolumeRegion("VR.{0}-{1}".format(obj.name, str(obj.__hash__()))) bpy.data.meshes.remove(mesh) - def writeGeometry(self, ID, obj, matrix, obType=0, oMat=None): + def writeGeometry(self, ID, obj, matrix, pass_index, obType=0, oMat=None): mesh = obj.to_mesh(self.scene, True, 'RENDER') isSmooth = False @@ -406,11 +472,22 @@ def writeGeometry(self, ID, obj, matrix, obType=0, oMat=None): # Transform the mesh after orcos have been stored and only if matrix exists if matrix is not None: mesh.transform(matrix) + + if self.is_preview: + if("checker" in obj.name): + matrix2 = mathutils.Matrix.Scale(4, 4) + mesh.transform(matrix2) + elif bpy.data.scenes[0].yafaray.preview.enable: + matrix2 = mathutils.Matrix.Scale(bpy.data.scenes[0].yafaray.preview.objScale, 4) + mesh.transform(matrix2) + matrix2 = mathutils.Matrix.Rotation(bpy.data.scenes[0].yafaray.preview.rotZ, 4, 'Z') + mesh.transform(matrix2) + pass self.yi.paramsClearAll() self.yi.startGeometry() - self.yi.startTriMesh(ID, len(mesh.vertices), len(getattr(mesh, face_attr)), hasOrco, hasUV, obType) + self.yi.startTriMesh(ID, len(mesh.vertices), len(getattr(mesh, face_attr)), hasOrco, hasUV, obType, pass_index) for ind, v in enumerate(mesh.vertices): if hasOrco: @@ -467,9 +544,9 @@ def getFaceMaterial(self, meshMats, matIndex, matSlots): ymaterial = self.materialMap["default"] - if self.scene.gs_clay_render: - ymaterial = self.materialMap["clay"] - elif len(meshMats) and meshMats[matIndex]: + #if self.scene.gs_clay_render: + # ymaterial = self.materialMap["clay"] + if len(meshMats) and meshMats[matIndex]: mat = meshMats[matIndex] if mat in self.materialMap: ymaterial = self.materialMap[mat] diff --git a/io/yaf_scene.py b/io/yaf_scene.py old mode 100644 new mode 100755 index 3dc25ff0..26edff1a --- a/io/yaf_scene.py +++ b/io/yaf_scene.py @@ -18,6 +18,7 @@ # +import bpy def computeSceneSize(render): sizeX = int(render.resolution_x * render.resolution_percentage * 0.01) @@ -79,7 +80,20 @@ def exportAA(yi, scene): yi.paramsSetFloat("AA_pixelwidth", scene.AA_pixelwidth) yi.paramsSetFloat("AA_threshold", scene.AA_threshold) yi.paramsSetString("filter_type", scene.AA_filter_type) - yi.paramsSetInt("AA_resampled_floor", scene.AA_resampled_floor) + yi.paramsSetFloat("AA_resampled_floor", scene.yafaray.noise_control.resampled_floor) + yi.paramsSetFloat("AA_sample_multiplier_factor", scene.yafaray.noise_control.sample_multiplier_factor) + yi.paramsSetFloat("AA_light_sample_multiplier_factor", scene.yafaray.noise_control.light_sample_multiplier_factor) + yi.paramsSetFloat("AA_indirect_sample_multiplier_factor", scene.yafaray.noise_control.indirect_sample_multiplier_factor) + yi.paramsSetBool("AA_detect_color_noise", scene.yafaray.noise_control.detect_color_noise) + yi.paramsSetFloat("AA_dark_threshold_factor", scene.yafaray.noise_control.dark_threshold_factor) + yi.paramsSetInt("AA_variance_edge_size", scene.yafaray.noise_control.variance_edge_size) + yi.paramsSetInt("AA_variance_pixels", scene.yafaray.noise_control.variance_pixels) + yi.paramsSetFloat("AA_clamp_samples", scene.yafaray.noise_control.clamp_samples) + yi.paramsSetFloat("AA_clamp_indirect", scene.yafaray.noise_control.clamp_indirect) + + if scene.name == "preview" and bpy.data.scenes[0].yafaray.preview.enable: + yi.paramsSetInt("AA_passes", bpy.data.scenes[0].yafaray.preview.previewAApasses) + yi.paramsSetFloat("AA_threshold", 0.01) def exportRenderSettings(yi, scene): @@ -93,7 +107,37 @@ def exportRenderSettings(yi, scene): yi.paramsSetString("integrator_name", "default") yi.paramsSetString("volintegrator_name", "volintegr") - yi.paramsSetFloat("gamma", scene.gs_gamma) + output_device_color_space = "LinearRGB" + output_device_gamma = 1.0 + + if scene.gs_type_render == "file" or scene.gs_type_render == "xml": + output_device_color_space = "sRGB" + + if scene.img_output == "OPEN_EXR" or scene.img_output == "HDR": #If the output file is a HDR/EXR file, we force the render output to Linear + output_device_color_space = "LinearRGB" + + elif scene.display_settings.display_device == "sRGB": + output_device_color_space = "sRGB" + + elif scene.display_settings.display_device == "XYZ": + output_device_color_space = "XYZ" + + elif scene.display_settings.display_device == "None": + output_device_color_space = "Raw_Manual_Gamma" + output_device_gamma = scene.gs_gamma #We only use the selected gamma if the output device is set to "None" + + else: #Render into Blender + output_device_color_space = "LinearRGB" #Blender expects a linear output from YafaRay + + if scene.display_settings.display_device == "sRGB" or scene.display_settings.display_device == "XYZ" or scene.display_settings.display_device == "Rec709": + output_device_color_space = "LinearRGB" #If we render into Blender, YafaRay generates linear output and Blender does the conversion to the color space + + elif scene.display_settings.display_device == "None": + output_device_color_space = "Raw_Manual_Gamma" + output_device_gamma = scene.gs_gamma #We only use the selected gamma if the output device is set to "None" + + yi.paramsSetString("color_space", output_device_color_space) + yi.paramsSetFloat("gamma", output_device_gamma) exportAA(yi, scene) @@ -108,17 +152,18 @@ def exportRenderSettings(yi, scene): yi.paramsSetInt("width", sizeX) yi.paramsSetInt("height", sizeY) - yi.paramsSetBool("clamp_rgb", scene.gs_clamp_rgb) yi.paramsSetBool("show_sam_pix", scene.gs_show_sam_pix) - yi.paramsSetBool("premult", scene.gs_premult) - yi.paramsSetInt("tile_size", scene.gs_tile_size) - yi.paramsSetString("tiles_order", scene.gs_tile_order) + if scene.name == "preview" and bpy.data.scenes[0].yafaray.preview.enable: + yi.paramsSetBool("show_sam_pix", False) - yi.paramsSetBool("z_channel", scene.gs_z_channel) + if scene.gs_type_render == "file" or scene.gs_type_render == "xml": + yi.paramsSetBool("premult", scene.gs_premult) + else: + yi.paramsSetBool("premult", True) #We force alpha premultiply when rendering into Blender as it expects premultiplied input - if scene.gs_type_render == "into_blender": - yi.paramsSetBool("normalize_z_channel", False) + yi.paramsSetInt("tile_size", scene.gs_tile_size) + yi.paramsSetString("tiles_order", scene.gs_tile_order) yi.paramsSetBool("drawParams", scene.gs_draw_params) yi.paramsSetString("customString", scene.gs_custom_string) @@ -129,3 +174,166 @@ def exportRenderSettings(yi, scene): yi.paramsSetInt("threads", scene.gs_threads) yi.paramsSetString("background_name", "world_background") + + yi.paramsSetBool("adv_auto_shadow_bias_enabled", scene.adv_auto_shadow_bias_enabled) + yi.paramsSetFloat("adv_shadow_bias_value", scene.adv_shadow_bias_value) + yi.paramsSetBool("adv_auto_min_raydist_enabled", scene.adv_auto_min_raydist_enabled) + yi.paramsSetFloat("adv_min_raydist_value", scene.adv_min_raydist_value) + + +def exportRenderPassesSettings(yi, scene): + yi.printInfo("Exporting Render Passes settings") + + yi.paramsSetBool("pass_enable", scene.yafaray.passes.pass_enable) + + yi.paramsSetInt("pass_mask_obj_index", scene.yafaray.passes.pass_mask_obj_index) + yi.paramsSetInt("pass_mask_mat_index", scene.yafaray.passes.pass_mask_mat_index) + yi.paramsSetBool("pass_mask_invert", scene.yafaray.passes.pass_mask_invert) + yi.paramsSetBool("pass_mask_only", scene.yafaray.passes.pass_mask_only) + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_z: + yi.paramsSetString("pass_Depth", scene.yafaray.passes.pass_Depth) + else: + yi.paramsSetString("pass_Depth", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_vector: + yi.paramsSetString("pass_Vector", scene.yafaray.passes.pass_Vector) + else: + yi.paramsSetString("pass_Vector", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_normal: + yi.paramsSetString("pass_Normal", scene.yafaray.passes.pass_Normal) + else: + yi.paramsSetString("pass_Normal", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_uv: + yi.paramsSetString("pass_UV", scene.yafaray.passes.pass_UV) + else: + yi.paramsSetString("pass_UV", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_color: + yi.paramsSetString("pass_Color", scene.yafaray.passes.pass_Color) + else: + yi.paramsSetString("pass_Color", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_emit: + yi.paramsSetString("pass_Emit", scene.yafaray.passes.pass_Emit) + else: + yi.paramsSetString("pass_Emit", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_mist: + yi.paramsSetString("pass_Mist", scene.yafaray.passes.pass_Mist) + else: + yi.paramsSetString("pass_Mist", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_diffuse: + yi.paramsSetString("pass_Diffuse", scene.yafaray.passes.pass_Diffuse) + else: + yi.paramsSetString("pass_Diffuse", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_specular: + yi.paramsSetString("pass_Spec", scene.yafaray.passes.pass_Spec) + else: + yi.paramsSetString("pass_Spec", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_ambient_occlusion: + yi.paramsSetString("pass_AO", scene.yafaray.passes.pass_AO) + else: + yi.paramsSetString("pass_AO", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_environment: + yi.paramsSetString("pass_Env", scene.yafaray.passes.pass_Env) + else: + yi.paramsSetString("pass_Env", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_indirect: + yi.paramsSetString("pass_Indirect", scene.yafaray.passes.pass_Indirect) + else: + yi.paramsSetString("pass_Indirect", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_shadow: + yi.paramsSetString("pass_Shadow", scene.yafaray.passes.pass_Shadow) + else: + yi.paramsSetString("pass_Shadow", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_reflection: + yi.paramsSetString("pass_Reflect", scene.yafaray.passes.pass_Reflect) + else: + yi.paramsSetString("pass_Reflect", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_refraction: + yi.paramsSetString("pass_Refract", scene.yafaray.passes.pass_Refract) + else: + yi.paramsSetString("pass_Refract", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_object_index: + yi.paramsSetString("pass_IndexOB", scene.yafaray.passes.pass_IndexOB) + else: + yi.paramsSetString("pass_IndexOB", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_material_index: + yi.paramsSetString("pass_IndexMA", scene.yafaray.passes.pass_IndexMA) + else: + yi.paramsSetString("pass_IndexMA", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_diffuse_direct: + yi.paramsSetString("pass_DiffDir", scene.yafaray.passes.pass_DiffDir) + else: + yi.paramsSetString("pass_DiffDir", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_diffuse_indirect: + yi.paramsSetString("pass_DiffInd", scene.yafaray.passes.pass_DiffInd) + else: + yi.paramsSetString("pass_DiffInd", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_diffuse_color: + yi.paramsSetString("pass_DiffCol", scene.yafaray.passes.pass_DiffCol) + else: + yi.paramsSetString("pass_DiffCol", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_glossy_direct: + yi.paramsSetString("pass_GlossDir", scene.yafaray.passes.pass_GlossDir) + else: + yi.paramsSetString("pass_GlossDir", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_glossy_indirect: + yi.paramsSetString("pass_GlossInd", scene.yafaray.passes.pass_GlossInd) + else: + yi.paramsSetString("pass_GlossInd", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_glossy_color: + yi.paramsSetString("pass_GlossCol", scene.yafaray.passes.pass_GlossCol) + else: + yi.paramsSetString("pass_GlossCol", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_transmission_direct: + yi.paramsSetString("pass_TransDir", scene.yafaray.passes.pass_TransDir) + else: + yi.paramsSetString("pass_TransDir", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_transmission_indirect: + yi.paramsSetString("pass_TransInd", scene.yafaray.passes.pass_TransInd) + else: + yi.paramsSetString("pass_TransInd", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_transmission_color: + yi.paramsSetString("pass_TransCol", scene.yafaray.passes.pass_TransCol) + else: + yi.paramsSetString("pass_TransCol", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_subsurface_direct: + yi.paramsSetString("pass_SubsurfaceDir", scene.yafaray.passes.pass_SubsurfaceDir) + else: + yi.paramsSetString("pass_SubsurfaceDir", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_subsurface_indirect: + yi.paramsSetString("pass_SubsurfaceInd", scene.yafaray.passes.pass_SubsurfaceInd) + else: + yi.paramsSetString("pass_SubsurfaceInd", "disabled") + + if scene.yafaray.passes.pass_enable and scene.render.layers[0].use_pass_subsurface_color: + yi.paramsSetString("pass_SubsurfaceCol", scene.yafaray.passes.pass_SubsurfaceCol) + else: + yi.paramsSetString("pass_SubsurfaceCol", "disabled") + + diff --git a/io/yaf_texture.py b/io/yaf_texture.py old mode 100644 new mode 100755 index aaa8820c..b925eaa6 --- a/io/yaf_texture.py +++ b/io/yaf_texture.py @@ -306,17 +306,42 @@ def writeTexture(self, scene, tex): image_tex = os.path.realpath(image_tex) image_tex = os.path.normpath(image_tex) - yi.printInfo("Exporter: Creating Texture: '{0}' type {1}: {2}".format(name, tex.yaf_tex_type, image_tex)) - yi.paramsSetString("type", "image") yi.paramsSetString("filename", image_tex) yi.paramsSetBool("use_alpha", tex.yaf_use_alpha) yi.paramsSetBool("calc_alpha", tex.use_calculate_alpha) yi.paramsSetBool("normalmap", tex.yaf_is_normal_map) - yi.paramsSetFloat("gamma", scene.gs_gamma_input) + yi.paramsSetString("fileformat", fileformat.upper()) + + texture_color_space = "sRGB" + texture_gamma = 1.0 + + if tex.image.colorspace_settings.name == "sRGB" or tex.image.colorspace_settings.name == "VD16": + texture_color_space = "sRGB" + + elif tex.image.colorspace_settings.name == "XYZ": + texture_color_space = "XYZ" + + elif tex.image.colorspace_settings.name == "Linear" or tex.image.colorspace_settings.name == "Linear ACES" or tex.image.colorspace_settings.name == "Non-Color": + texture_color_space = "LinearRGB" + + elif tex.image.colorspace_settings.name == "Raw": + texture_color_space = "Raw_Manual_Gamma" + texture_gamma = tex.yaf_gamma_input #We only use the selected gamma if the color space is set to "Raw" + + yi.paramsSetString("color_space", texture_color_space) + yi.paramsSetFloat("gamma", texture_gamma) + + if tex.yaf_tex_optimization == "default": + texture_optimization = scene.gs_tex_optimization + else: + texture_optimization = tex.yaf_tex_optimization + + yi.printInfo("Exporter: Creating Texture: '{0}' type {1}: {2}. Texture Color Space: '{3}', gamma={4}. Texture optimization='{5}'".format(name, tex.yaf_tex_type, image_tex, texture_color_space, texture_gamma, texture_optimization)) yi.paramsSetString("interpolate", tex.yaf_tex_interpolate) + yi.paramsSetString("texture_optimization", texture_optimization) # repeat repeat_x = 1 diff --git a/io/yaf_world.py b/io/yaf_world.py old mode 100644 new mode 100755 index 67c02b36..0dbedbec --- a/io/yaf_world.py +++ b/io/yaf_world.py @@ -76,6 +76,25 @@ def exportWorld(self, scene): interpolate = 'bilinear' # yi.paramsSetString("interpolate", interpolate) + + texture_color_space = "sRGB" + texture_gamma = 1.0 + + if worldTex.image.colorspace_settings.name == "sRGB" or worldTex.image.colorspace_settings.name == "VD16": + texture_color_space = "sRGB" + + elif worldTex.image.colorspace_settings.name == "XYZ": + texture_color_space = "XYZ" + + elif worldTex.image.colorspace_settings.name == "Linear" or worldTex.image.colorspace_settings.name == "Linear ACES" or worldTex.image.colorspace_settings.name == "Non-Color": + texture_color_space = "LinearRGB" + + elif worldTex.image.colorspace_settings.name == "Raw": + texture_color_space = "Raw_manualGamma" + texture_gamma = worldTex.yaf_gamma_input #We only use the selected gamma if the color space is set to "Raw" + + yi.paramsSetString("color_space", texture_color_space) + yi.paramsSetFloat("gamma", texture_gamma) yi.createTexture("world_texture") diff --git a/prop/yaf_light.py b/prop/yaf_light.py index 03c51fca..de86b878 100644 --- a/prop/yaf_light.py +++ b/prop/yaf_light.py @@ -139,6 +139,11 @@ def register(): name="Light enabled", description="Enable/Disable light", default=True) + + Lamp.cast_shadows = BoolProperty( + name="Cast shadows", + description="Enable casting shadows. This is the normal and expected behavior. Disable it only for special cases!", + default=True) def unregister(): del Lamp.lamp_type @@ -156,3 +161,4 @@ def unregister(): del Lamp.yaf_samples del Lamp.yaf_show_dist_clip del Lamp.light_enabled + del Lamp.cast_shadows diff --git a/prop/yaf_material.py b/prop/yaf_material.py index fb6c24a2..b9e13be4 100644 --- a/prop/yaf_material.py +++ b/prop/yaf_material.py @@ -27,14 +27,14 @@ Material = bpy.types.Material - +# This code is irrelevant after the change in the blend material to convert it from EnumProperty to StringProperty. I'm keeping this as a reference in case a better solution can be found for the blend material component materials references def items_mat1(self, context): a = [] for mat in [m for m in bpy.data.materials if m.name not in self.name]: a.append((mat.name, mat.name, "First blend material")) return(a) - +# This code is irrelevant after the change in the blend material to convert it from EnumProperty to StringProperty. I'm keeping this as a reference in case a better solution can be found for the blend material component materials references def items_mat2(self, context): a = [] for mat in [m for m in bpy.data.materials if m.name not in self.name]: @@ -42,7 +42,7 @@ def items_mat2(self, context): return(a) def update_preview(self, context): - bpy.data.materials[0].preview_render_type = bpy.data.materials[0].preview_render_type + context.material.preview_render_type = context.material.preview_render_type def register(): @@ -239,6 +239,11 @@ def register(): description="Let light straight through for shadow calculation. Not to be used with dispersion", default=False) + Material.clay_exclude = BoolProperty( + update=update_preview, name="Exclude from Clay render", + description="Exclude from Clay render mode: this material will be rendered normally even in Clay render mode", + default=False) + Material.blend_value = FloatProperty( update=update_preview, name="Blend value", description="The mixing balance: 0 -> only material 1, 1.0 -> only material 2", @@ -265,6 +270,7 @@ def register(): description="", default=False) + #Deprecated blend material component Enum references, only to keep compatibility with old scenes Material.material1 = EnumProperty( update=update_preview, name="Material one", description="First blend material", @@ -275,6 +281,32 @@ def register(): description="Second blend material", items=items_mat2) + #New blend material component String references, when opening old scenes it should copy the old Enum Property materials to the new String Properties + Material.material1name = StringProperty( + update=update_preview, name="Material one", + description="First blend material") + #, get=get_blend_mat1_old_scenes) + + Material.material2name = StringProperty( + update=update_preview, name="Material two", + description="Second blend material") + #, get=get_blend_mat2_old_scenes) + + Material.visibility = EnumProperty( + update=update_preview, name="Visibility", + items=( + ('invisible', "Invisible", "Totally invisible"), + ('shadow_only', "Shadows only", "Invisible but casting shadows"), + ('no_shadows', "No shadows", "Visible but not casting shadows"), + ('normal', "Normal", "Normal visibility - visible casting shadows"), + + ), + default='normal') + + Material.receive_shadows = BoolProperty( + update=update_preview, name="Receive Shadows", + description="If this parameter is set to false, the material will not receive shadows from other objects", + default=True) def unregister(): del Material.mat_type @@ -302,9 +334,14 @@ def unregister(): del Material.dispersion_power del Material.refr_roughness del Material.fake_shadows + del Material.clay_exclude del Material.blend_value del Material.sigma del Material.rough del Material.coated del Material.material1 del Material.material2 + del Material.material1name + del Material.material2name + del Material.visibility + del Material.receive_shadows diff --git a/prop/yaf_object.py b/prop/yaf_object.py index fcd59739..8a859c78 100644 --- a/prop/yaf_object.py +++ b/prop/yaf_object.py @@ -23,7 +23,8 @@ FloatProperty, IntProperty, BoolProperty, - EnumProperty) + EnumProperty, + StringProperty) Object = bpy.types.Object diff --git a/prop/yaf_scene.py b/prop/yaf_scene.py index f0463aab..77a96d44 100644 --- a/prop/yaf_scene.py +++ b/prop/yaf_scene.py @@ -18,6 +18,7 @@ # +import math import bpy from sys import platform from bpy.props import (IntProperty, @@ -25,10 +26,17 @@ FloatVectorProperty, EnumProperty, BoolProperty, - StringProperty) + StringProperty, + PointerProperty, + CollectionProperty) Scene = bpy.types.Scene +def update_preview(self, context): + if hasattr(context, "material"): + context.material.preview_render_type = context.material.preview_render_type + elif len(bpy.data.materials) > 0: + bpy.data.materials[0].preview_render_type = bpy.data.materials[0].preview_render_type # set fileformat for image saving on same format as in YafaRay, both have default PNG def call_update_fileformat(self, context): @@ -36,17 +44,540 @@ def call_update_fileformat(self, context): render = scene.render if scene.img_output is not render.image_settings.file_format: render.image_settings.file_format = scene.img_output - if render.image_settings.file_format == "OPEN_EXR" and scene.gs_z_channel: - render.image_settings.use_zbuffer = True +class YafaRayProperties(bpy.types.PropertyGroup): + pass + +class YafaRayNoiseControlProperties(bpy.types.PropertyGroup): + resampled_floor = FloatProperty( + name="Resampled floor (%)", + description=("Noise reduction: when resampled pixels go below this value (% of total pixels)," + " the AA threshold will automatically decrease before the next pass"), + min=0.0, max=100.0, precision=1, + default=0.0) -def register(): - # Default Gamma values for Windows = 2.2, for Linux and MacOS = 1.8 - if platform == "win32": - gamma = 2.20 - else: - gamma = 1.80 + sample_multiplier_factor = FloatProperty( + name="AA sample multiplier factor", + description="Factor to increase the AA samples multiplier for next AA pass", + min=1.0, max=4.0, precision=2, + default=1.0) + + light_sample_multiplier_factor = FloatProperty( + name="Light sample multiplier factor", + description="Factor to increase the light samples multiplier for next AA pass", + min=1.0, max=4.0, precision=2, + default=1.0) + + indirect_sample_multiplier_factor = FloatProperty( + name="Indirect sample multiplier factor", + description="Factor to increase the indirect samples (FG for example) multiplier for next AA pass", + min=1.0, max=4.0, precision=2, + default=1.0) + + detect_color_noise = BoolProperty( + name="Color noise detection", + description="Detect noise in RGB components in addidion to pixel brightness", + default=False) + + dark_threshold_factor = FloatProperty( + name="Dark areas noise detection factor", + description=("Factor used to reduce the AA threshold in dark areas." + " It will reduce noise in dark areas, but noise in bright areas will take longer"), + min=0.0, max=1.0, precision=3, + default=0.0) + + variance_edge_size = IntProperty( + name="Variance window", + description="Window edge size for variance noise detection", + min=4, max=20, + default=10) + + variance_pixels = IntProperty( + name="Variance threshold", + description="Threshold (in pixels) for variance noise detection. 0 disables variance detection", + min=0, max=10, + default=0) + + clamp_samples = FloatProperty( + name="Clamp samples", + description="Clamp RGB values in all samples, less noise but less realism. 0.0 disables clamping", + min=0.0, precision=1, + default=0.0) + + clamp_indirect = FloatProperty( + name="Clamp indirect", + description="Clamp RGB values in the indirect light, less noise but less realism. 0.0 disables clamping", + min=0.0, precision=1, + default=0.0) + + +class YafaRayRenderPassesProperties(bpy.types.PropertyGroup): + pass_enable = BoolProperty( + name="Enable render passes", + default=False) + + pass_mask_obj_index = IntProperty( + name="Mask Object Index", + description="Object index used for masking in the Mask render passes", + min=0, + default=0) + + pass_mask_mat_index = IntProperty( + name="Mask Material Index", + description="Material index used for masking in the Mask render passes", + min=0, + default=0) + + pass_mask_invert = BoolProperty( + name="Invert Mask selection", + description="Property to mask-in or mask-out the desired objects/materials in the Mask render passes", + default=False) + + pass_mask_only = BoolProperty( + name="Mask Only", + description="Property to show the mask only instead of the masked rendered image", + default=False) + + + #The numbers here MUST NEVER CHANGE to keep backwards compatibility with older scenes. The numbers do not need to match the Core internal pass numbers. + #The matching between these properties and the YafaRay Core internal passes is done via the first string, for example 'z-depth-abs'. They must match the list of strings for internal passes in the Core: include/core_api/color.h + + renderPassItemsDisabled=sorted(( + ('disabled', "Disabled", "Disable this pass", 999999), + ), key=lambda index: index[1]) + + renderPassItemsBasic=sorted(( + ('combined', "Basic: Combined image", "Basic: Combined standard image", 0), + ('diffuse', "Basic: Diffuse", "Basic: Diffuse materials", 1), + ('diffuse-noshadow', "Basic: Diffuse (no shadows)", "Basic: Diffuse materials (without shadows)", 2), + ('shadow', "Basic: Shadow", "Basic: Shadows", 3), + ('env', "Basic: Environment", "Basic: Environmental light", 4), + ('indirect', "Basic: Indirect", "Basic: Indirect light (all, including caustics and diffuse)", 5), + ('emit', "Basic: Emit", "Basic: Objects emitting light", 6), + ('reflect', "Basic: Reflection", "Basic: Reflections (all, including perfect and glossy)", 7), + ('refract', "Basic: Refraction", "Basic: Refractions (all, including perfect and sampled)", 8), + ('mist', "Basic: Mist", "Basic: Mist", 9), + ), key=lambda index: index[1]) + + renderPassItemsDepth=sorted(( + ('z-depth-abs', "Z-Depth (absolute)", "Z-Depth (absolute values)", 101), + ('z-depth-norm', "Z-Depth (normalized)", "Z-Depth (normalized values)", 102), + ), key=lambda index: index[1]) + + renderPassItemsIndex=sorted(( + ('obj-index-abs', "Index-Object (absolute)", "Index-Object: Grayscale value = obj.index in the object properties (absolute values)", 201), + ('obj-index-norm', "Index-Object (normalized)", "Index-Object: Grayscale value = obj.index in the object properties (normalized values)", 202), + ('obj-index-auto', "Index-Object (auto)", "Index-Object: A color automatically generated for each object", 203), + ('obj-index-mask', "Index-Object Mask", "Index-Object: Masking object based on obj.index.mask setting", 204), + ('obj-index-mask-shadow', "Index-Object Mask Shadow", "Index-Object: Masking object shadow based on obj.index.mask setting", 205), + ('obj-index-mask-all', "Index-Object Mask All (Object+Shadow)", "Index-Object: Masking object+shadow based on obj.index.mask setting", 206), + ('mat-index-abs', "Index-Material (absolute)", "Index-Material: Grayscale value = mat.index in the material properties (absolute values)", 207), + ('mat-index-norm', "Index-Material (normalized)", "Index-Material: Grayscale value = mat.index in the material properties (normalized values)", 208), + ('mat-index-auto', "Index-Material (auto)", "Index-Material: A color automatically generated for each material", 209), + ('mat-index-mask', "Index-Material Mask", "Index-Material: Masking material based on mat.index.mask setting", 210), + ('mat-index-mask-shadow', "Index-Material Mask Shadow", "Index-Material: Masking material shadow based on mat.index.mask setting", 211), + ('mat-index-mask-all', "Index-Material Mask All (Object+Shadow)", "Index-Material: Masking material+shadow based on mat.index.mask setting", 212) + ), key=lambda index: index[1]) + + renderPassItemsDebug=sorted(( + ('debug-aa-samples', "Debug: AA sample count", "Debug: Adaptative AA sample count (estimation), normalized", 301), + ('debug-uv', "Debug: UV", "Debug: UV coordinates (black for objects with no UV mapping)", 302), + ('debug-dsdv', "Debug: dSdV", "Debug: shading dSdV", 303), + ('debug-dsdu', "Debug: dSdU", "Debug: shading dSdU", 304), + ('debug-dpdv', "Debug: dPdV", "Debug: surface dPdV", 305), + ('debug-dpdu', "Debug: dPdU", "Debug: surface dPdU", 306), + ('debug-nv', "Debug: NV", "Debug - surface NV", 307), + ('debug-nu', "Debug: NU", "Debug - surface NU", 308), + ('debug-normal-geom', "Debug: Normals (geometric)", "Normals (geometric, no smoothness)", 309), + ('debug-normal-smooth', "Debug: Normals (smooth)", "Normals (including smoothness)", 310), + ), key=lambda index: index[1]) + + renderInternalPassAdvanced=sorted(( + ('adv-reflect', "Adv: Reflection ", "Advanced: Reflections (perfect only)", 401), + ('adv-refract', "Adv: Refraction", "Advanced: Refractions (perfect only)", 402), + ('adv-radiance', "Adv: Photon Radiance map", "Advanced: Radiance map (only for photon mapping)", 403), + ('adv-volume-transmittance', "Adv: Volume Transmittance", "Advanced: Volume Transmittance", 404), + ('adv-volume-integration', "Adv: Volume integration", "Advanced: Volume integration", 405), + ('adv-diffuse-indirect', "Adv: Diffuse Indirect", "Advanced: Diffuse Indirect light", 406), + ('adv-diffuse-color', "Adv: Diffuse color", "Advanced: Diffuse color", 407), + ('adv-glossy', "Adv: Glossy", "Advanced: Glossy materials", 408), + ('adv-glossy-indirect', "Adv: Glossy Indirect", "Advanced: Glossy Indirect light", 409), + ('adv-glossy-color', "Adv: Glossy color", "Advanced: Glossy color", 410), + ('adv-trans', "Adv: Transmissive", "Advanced: Transmissive materials", 411), + ('adv-trans-indirect', "Adv: Trans.Indirect", "Advanced: Transmissive Indirect light", 412), + ('adv-trans-color', "Adv: Trans.color", "Advanced: Transmissive color", 413), + ('adv-subsurface', "Adv: SubSurface", "Advanced: SubSurface materials", 414), + ('adv-subsurface-indirect', "Adv: SubSurf.Indirect", "Advanced: SubSurface Indirect light", 415), + ('adv-subsurface-color', "Adv: SubSurf.color", "Advanced: SubSurface color", 416), + ('adv-indirect', "Adv: Indirect", "Adv: Indirect light (depends on the integrator but usually caustics only)", 417), + ('adv-surface-integration', "Adv: Surface Integration", "Advanced: Surface Integration", 418), + ), key=lambda index: index[1]) + + renderPassItemsAO=sorted(( + ('ao', "AO", "Ambient Occlusion", 501), + ('ao-clay', "AO clay", "Ambient Occlusion (clay)", 502), + ), key=lambda index: index[1]) + + renderPassAllItems = sorted(renderPassItemsBasic+renderInternalPassAdvanced+renderPassItemsIndex+renderPassItemsDebug+renderPassItemsDepth+renderPassItemsAO, key=lambda index: index[1]) + + #This property is not currently used by YafaRay Core, as the combined external pass is always using the internal combined pass. + pass_Combined = EnumProperty( + name="Combined", #RGBA (4 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassItemsDisabled + ), + default="disabled") + + pass_Depth = EnumProperty( + name="Depth", #Gray (1 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassItemsDepth + ), + default="z-depth-norm") + + pass_Vector = EnumProperty( + name="Vector", #RGBA (4 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="obj-index-auto") + + pass_Normal = EnumProperty( + name="Normal", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="debug-normal-smooth") + + pass_UV = EnumProperty( + name="UV", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="debug-uv") + + pass_Color = EnumProperty( + name="Color", #RGBA (4 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="mat-index-auto") + + pass_Emit = EnumProperty( + name="Emit", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="emit") + + pass_Mist = EnumProperty( + name="Mist", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="mist") + + pass_Diffuse = EnumProperty( + name="Diffuse", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="diffuse") + + pass_Spec = EnumProperty( + name="Spec", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-reflect") + + pass_AO = EnumProperty( + name="AO", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassItemsAO + ), + default="ao") + + pass_Env = EnumProperty( + name="Env", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="env") + + pass_Indirect = EnumProperty( + name="Indirect", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="indirect") + + pass_Shadow = EnumProperty( + name="Shadow", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="shadow") + pass_Reflect = EnumProperty( + name="Reflect", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="reflect") + + pass_Refract = EnumProperty( + name="Refract", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="refract") + + pass_IndexOB = EnumProperty( + name="Object Index", #Gray (1 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassItemsIndex + ), + default="obj-index-norm") + + pass_IndexMA = EnumProperty( + name="Material Index", #Gray (1 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassItemsIndex + ), + default="mat-index-norm") + + pass_DiffDir = EnumProperty( + name="Diff Dir", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="diffuse") + + pass_DiffInd = EnumProperty( + name="Diff Ind", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-diffuse-indirect") + + pass_DiffCol = EnumProperty( + name="Diff Col", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-diffuse-color") + + pass_GlossDir = EnumProperty( + name="Gloss Dir", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-glossy") + + pass_GlossInd = EnumProperty( + name="Gloss Ind", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-glossy-indirect") + + pass_GlossCol = EnumProperty( + name="Gloss Col", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-glossy-color") + + pass_TransDir = EnumProperty( + name="Trans Dir", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-trans") + + pass_TransInd = EnumProperty( + name="Trans Ind", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-trans-indirect") + + pass_TransCol = EnumProperty( + name="Trans Col", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-trans-color") + + pass_SubsurfaceDir = EnumProperty( + name="SubSurface Dir", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-subsurface") + + pass_SubsurfaceInd = EnumProperty( + name="SubSurface Ind", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-subsurface-indirect") + + pass_SubsurfaceCol = EnumProperty( + name="SubSurface Col", #RGB (3 x float) + description="Select the type of image you want to be displayed in this pass", + items=(renderPassAllItems + ), + default="adv-subsurface-color") + +class YafaRayMaterialPreviewControlProperties(bpy.types.PropertyGroup): + + enable = BoolProperty( + update=update_preview, + name="Material Preview Controls enabled", + description="Enable/Disable material preview controls", + default=False) + + objScale = FloatProperty( + update=update_preview, + name="objScale", + description=("Material Preview object scaling factor"), + min=0.0, #max=10.0, + precision=2, step=10, + default=1.0) + + rotZ = FloatProperty( + update=update_preview, + name="rotZ", + description=("Material Preview object rotation Z axis"), + precision=1, step=1000, + #min=math.radians(-360), max=math.radians(360), + subtype="ANGLE", unit="ROTATION", + default=0.0) + + lightRotZ = FloatProperty( + update=update_preview, + name="lightRotZ", + description=("Material Preview light rotation Z axis"), + precision=1, step=1000, + #min=math.radians(-360), max=math.radians(360), + subtype="ANGLE", unit="ROTATION", + default=0.0) + + keyLightPowerFactor = FloatProperty( + update=update_preview, + name="keyLightPowerFactor", + description=("Material Preview power factor for the key light"), + min=0.0, max=10.0, precision=2, step=10, + default=1.0) + + fillLightPowerFactor = FloatProperty( + update=update_preview, + name="lightPowerFactor", + description=("Material Preview power factor for the fill lights"), + min=0.0, max=10.0, precision=2, step=10, + default=0.5) + + keyLightColor = FloatVectorProperty( + update=update_preview, + name="keyLightColor", + description=("Material Preview color for key light"), + subtype='COLOR', + step=1, precision=2, + min=0.0, max=1.0, + soft_min=0.0, soft_max=1.0, + default=(1.0, 1.0, 1.0)) + + fillLightColor = FloatVectorProperty( + update=update_preview, + name="fillLightColor", + description=("Material Preview color for fill lights"), + subtype='COLOR', + step=1, precision=2, + min=0.0, max=1.0, + soft_min=0.0, soft_max=1.0, + default=(1.0, 1.0, 1.0)) + + previewRayDepth = IntProperty( + update=update_preview, + name="previewRayDepth", + description=("Material Preview max ray depth, set higher for better (slower) glass preview"), + min=0, max=20, default=2) + + previewAApasses = IntProperty( + update=update_preview, + name="previewAApasses", + description=("Material Preview AA passes, set higher for better (slower) preview"), + min=1, max=20, default=1) + + previewBackground = EnumProperty( + update=update_preview, + name="previewBackground", + description=("Material Preview background type"), + items=( + ('none', "None", "No background", 0), + ('checker', "Checker", "Checker background (default)", 1), + ('world', "Scene World", "Scene world background (can be slow!)", 2) + ), + default="checker") + + previewObject = StringProperty( + update=update_preview, + name="previewObject", + description=("Material Preview custom object to be shown, if empty will use default preview objects"), + default="") + + camDist = FloatProperty( + update=update_preview, + name="camDist", + description=("Material Preview Camera distance to object"), + min=0.1, max=22.0, precision=2, step=100, + default=12.0) + + camRot = FloatVectorProperty( + update=update_preview, + name="camRot", + description=("Material Preview camera rotation"), + subtype='DIRECTION', + #step=10, precision=3, + #min=-1.0, max=1.0, + default=(0.0, 0.0, 1.0) + ) + + class OBJECT_OT_CamRotReset(bpy.types.Operator): + """ Reset camera rotation/zoom to initial values. """ + bl_idname = "preview.camrotreset" + bl_label = "reset camera rotation/distance values to defaults" + country = bpy.props.StringProperty() + + def execute(self, context): + bpy.data.scenes[0].yafaray.preview.camRot = (0,0,1) + bpy.data.scenes[0].yafaray.preview.camDist = 12 + return{'FINISHED'} + + class OBJECT_OT_CamZoomIn(bpy.types.Operator): + """ Camera zoom in (reduces distance between camera and object) """ + bl_idname = "preview.camzoomin" + bl_label = "reset camera rotation/distance values to defaults" + country = bpy.props.StringProperty() + + def execute(self, context): + bpy.data.scenes[0].yafaray.preview.camDist -= 0.5; + return{'FINISHED'} + + class OBJECT_OT_CamZoomOut(bpy.types.Operator): + """ Camera zoom out (increases distance between camera and object) """ + bl_idname = "preview.camzoomout" + bl_label = "reset camera rotation/distance values to defaults" + country = bpy.props.StringProperty() + + def execute(self, context): + bpy.data.scenes[0].yafaray.preview.camDist += 0.5; + return{'FINISHED'} + + +def register(): ########### YafaRays general settings properties ############# Scene.gs_ray_depth = IntProperty( name="Ray depth", @@ -67,12 +598,12 @@ def register(): name="Gamma", description="Gamma correction applied to final output, inverse correction " "of textures and colors is performed", - min=0, max=5, default= 1.0) #gamma) + min=0, max=5, default= 1.0) Scene.gs_gamma_input = FloatProperty( name="Gamma input", description="Gamma correction applied to input", - min=0, max=5, default=gamma) + min=0, max=5, default=1.0) Scene.gs_tile_size = IntProperty( name="Tile size", @@ -98,13 +629,37 @@ def register(): description="Override all materials with a white diffuse material", default=False) + Scene.gs_clay_render_keep_transparency = BoolProperty( + name="Keep transparency", + description="Keep transparency during clay render", + default=False) + + Scene.gs_clay_render_keep_normals = BoolProperty( + name="Keep normal/bump maps", + description="Keep normal and bump maps during clay render", + default=False) + + Scene.gs_clay_oren_nayar = BoolProperty( + name="Oren-Nayar", + description="Use Oren-Nayar shader for a more realistic diffuse clay render", + default=True) + + Scene.gs_clay_sigma = FloatProperty( + name="Sigma", + description="Roughness of the clay surfaces when rendering with Clay-Oren Nayar", + min=0.0, max=1.0, + step=1, precision=5, + soft_min=0.0, soft_max=1.0, + default=0.30000) + + # added clay color property Scene.gs_clay_col = FloatVectorProperty( name="Clay color", description="Color of clay render material", subtype='COLOR', min=0.0, max=1.0, - default=(0.8, 0.8, 0.8)) + default=(0.5, 0.5, 0.5)) Scene.gs_mask_render = BoolProperty( name="Render mask", @@ -126,6 +681,26 @@ def register(): description="Materials refract the background as transparent", default=True) + Scene.adv_auto_shadow_bias_enabled = BoolProperty( + name="Shadow Bias Automatic", + description="Shadow Bias Automatic Calculation (recommended). Disable ONLY if artifacts or black dots due to bad self-shadowing, otherwise LEAVE THIS ENABLED FOR NORMAL SCENES", + default=True) + + Scene.adv_shadow_bias_value = FloatProperty( + name="Shadow Bias Factor", + description="Shadow Bias (default 0.0005). Change ONLY if artifacts or black dots due to bad self-shadowing. Increasing this value can led to artifacts and incorrect renders", + min=0.00000001, max=10000, default=0.0005) + + Scene.adv_auto_min_raydist_enabled = BoolProperty( + name="Min Ray Dist Automatic", + description="Min Ray Dist Automatic Calculation (recommended), based on the Shadow Bias factor. Disable ONLY if artifacts or light leaks due to bad ray intersections, otherwise LEAVE THIS ENABLED FOR NORMAL SCENES", + default=True) + + Scene.adv_min_raydist_value = FloatProperty( + name="Min Ray Dist Factor", + description="Min Ray Dist (default 0.00005). Change ONLY if artifacts or light leaks due to bad ray intersections. Increasing this value can led to artifacts and incorrect renders", + min=0.00000001, max=10000, default=0.00005) + Scene.gs_custom_string = StringProperty( name="Custom string", description="Custom string will be added to the info bar, " @@ -142,21 +717,11 @@ def register(): description="Compute transparent shadows", default=False) - Scene.gs_clamp_rgb = BoolProperty( - name="Clamp RGB", - description="Reduce the color's brightness to a low dynamic range", - default=False) - Scene.gs_show_sam_pix = BoolProperty( name="Show sample pixels", description="Masks pixels marked for resampling during adaptive passes", default=True) - - Scene.gs_z_channel = BoolProperty( - name="Render depth map", - description="Render depth map (Z-Buffer)", - default=False) - + Scene.gs_verbose = BoolProperty( name="Log info to console", description="Print YafaRay engine log messages in console window", @@ -172,6 +737,16 @@ def register(): ), default='into_blender') + Scene.gs_tex_optimization = EnumProperty( + name="Textures optimization", + description="Textures optimization to reduce RAM usage, can be overriden by per-texture setting", + items=( + ('compressed', "Compressed", "Lossy color compression, some color/transparency details will be lost, more RAM improvement"), + ('optimized', "Optimized", "Lossless optimization, good RAM improvement"), + ('none', "None", "No optimization, lossless and faster but high RAM usage") + ), + default='optimized') + ######### YafaRays own image output property ############ Scene.img_output = EnumProperty( name="Image File Type", @@ -186,6 +761,11 @@ def register(): ), default='PNG', update=call_update_fileformat) + Scene.img_multilayer = BoolProperty( + name="MultiLayer", + description="Enable MultiLayer image export, only available in certain formats as EXR", + default=False) + ########### YafaRays integrator properties ############# Scene.intg_light_method = EnumProperty( name="Lighting Method", @@ -355,7 +935,7 @@ def register(): min=0.0, default=1.0) - ######### YafaRays anti-aliasing properties ########### + ######### YafaRays anti-aliasing/noise properties ########### Scene.AA_min_samples = IntProperty( name="Samples", description="Number of samples for first AA pass", @@ -381,13 +961,6 @@ def register(): min=0.0, max=1.0, precision=4, default=0.05) - Scene.AA_resampled_floor = IntProperty( - name="Resampled floor", - description=("For better noise reduction, if the amount of resampled pixels go below this value," - " the AA threshold will automatically decrease before the next pass"), - min=0, - default=0) - Scene.AA_pixelwidth = FloatProperty( name="Pixelwidth", description="AA filter size", @@ -403,7 +976,18 @@ def register(): ('lanczos', "Lanczos", "AA filter type") ), default="gauss") + + bpy.utils.register_class(YafaRayProperties) + bpy.types.Scene.yafaray = PointerProperty(type=YafaRayProperties) + + bpy.utils.register_class(YafaRayRenderPassesProperties) + YafaRayProperties.passes = PointerProperty(type=YafaRayRenderPassesProperties) + + bpy.utils.register_class(YafaRayNoiseControlProperties) + YafaRayProperties.noise_control = PointerProperty(type=YafaRayNoiseControlProperties) + bpy.utils.register_class(YafaRayMaterialPreviewControlProperties) + YafaRayProperties.preview = PointerProperty(type=YafaRayMaterialPreviewControlProperties) def unregister(): Scene.gs_ray_depth @@ -415,21 +999,29 @@ def unregister(): Scene.gs_tile_order Scene.gs_auto_threads Scene.gs_clay_render + Scene.gs_clay_render_keep_transparency + Scene.gs_clay_render_keep_normals + Scene.gs_clay_oren_nayar + Scene.gs_clay_sigma Scene.gs_clay_col Scene.gs_mask_render Scene.gs_draw_params Scene.bg_transp Scene.bg_transp_refract + Scene.adv_auto_shadow_bias_enabled + Scene.adv_shadow_bias_value + Scene.adv_auto_min_raydist_enabled + Scene.adv_min_raydist_value Scene.gs_custom_string Scene.gs_premult Scene.gs_transp_shad - Scene.gs_clamp_rgb Scene.gs_show_sam_pix - Scene.gs_z_channel Scene.gs_verbose Scene.gs_type_render + Scene.gs_tex_optimization Scene.img_output + Scene.img_multilayer Scene.intg_light_method Scene.intg_use_caustics @@ -465,4 +1057,8 @@ def unregister(): Scene.AA_threshold Scene.AA_pixelwidth Scene.AA_filter_type - Scene.AA_resampled_floor + + bpy.utils.unregister_class(YafaRayNoiseControlProperties) + bpy.utils.unregister_class(YafaRayRenderPassesProperties) + bpy.utils.unregister_class(YafaRayMaterialPreviewControlProperties) + bpy.utils.unregister_class(YafaRayProperties) diff --git a/prop/yaf_texture.py b/prop/yaf_texture.py old mode 100644 new mode 100755 index e3cd0dbd..e131388a --- a/prop/yaf_texture.py +++ b/prop/yaf_texture.py @@ -20,7 +20,8 @@ import bpy from bpy.props import (EnumProperty, - BoolProperty) + BoolProperty, + FloatProperty) Texture = bpy.types.Texture @@ -61,6 +62,11 @@ def register(): name="Use alpha image info", description="Use alpha values for image mapping", default=False) + + Texture.yaf_gamma_input = FloatProperty( + name="Gamma input", + description="Gamma correction applied to input texture", + min=0, max=5, default=1.0) Texture.yaf_tex_interpolate = EnumProperty( name="Interpolation", @@ -70,10 +76,22 @@ def register(): ('none', "No interpolation", "") ), default='bilinear') - + + Texture.yaf_tex_optimization = EnumProperty( + name="Optimization", + description="Texture optimization to reduce RAM usage", + items=( + ('compressed', "Compressed", "Lossy color compression, some color/transparency details will be lost, more RAM improvement"), + ('optimized', "Optimized", "Lossless optimization, good RAM improvement"), + ('none', "None", "No optimization, lossless and faster but high RAM usage"), + ('default', "Default", "Use global texture optimization setting from the Render tab") + ), + default='default') def unregister(): Texture.yaf_tex_type Texture.yaf_is_normal_map Texture.yaf_use_alpha + Texture.yaf_gamma_input Texture.yaf_tex_interpolate + Texture.yaf_tex_optimization diff --git a/prop/yaf_world.py b/prop/yaf_world.py index 2cc73fa8..a5211725 100644 --- a/prop/yaf_world.py +++ b/prop/yaf_world.py @@ -27,11 +27,14 @@ World = bpy.types.World +def update_preview(self, context): + context.world.use_sky_paper = context.world.use_sky_paper + def register(): ########### YafaRays world background properties ############# World.bg_type = EnumProperty( - name="Background", + update=update_preview, name="Background", items=( ('Gradient', "Gradient", "Gradient background"), ('Texture', "Texture", "Textured background"), @@ -42,7 +45,7 @@ def register(): default="Single Color") World.bg_color_space = EnumProperty( - name="Color space", + update=update_preview, name="Color space", items=( ('CIE (E)', "CIE (E)", "Select color space model"), ('CIE (D50)', "CIE (D50)", "Select color space model"), @@ -54,7 +57,7 @@ def register(): ## povman test: create a list of YafaRay mapping modes ########## # World.yaf_mapworld_type = EnumProperty( - name="Mapping Type", + update=update_preview, name="Mapping Type", items=( ('SPHERE', "Spherical", "Spherical mapping"), ('ANGMAP', "Angular", "Angular mapping") @@ -63,111 +66,111 @@ def register(): ########## end test ######################## World.bg_zenith_color = FloatVectorProperty( - name="Zenith color", + update=update_preview, name="Zenith color", description="Zenith color", subtype='COLOR', min=0.0, max=1.0, default=(0.57, 0.65, 1.0)) World.bg_horizon_color = FloatVectorProperty( - name="Horizon color", + update=update_preview, name="Horizon color", description="Horizon color", subtype='COLOR', min=0.0, max=1.0, default=(1.0, 1.0, 0.5)) World.bg_zenith_ground_color = FloatVectorProperty( - name="Zenith ground color", + update=update_preview, name="Zenith ground color", description="Zenith ground color", subtype='COLOR', min=0.0, max=1.0, default=(1.0, 0.9, 0.8)) World.bg_horizon_ground_color = FloatVectorProperty( - name="Horizon ground color", + update=update_preview, name="Horizon ground color", description="Horizon ground color", subtype='COLOR', min=0.0, max=1.0, default=(0.8, 0.6, 0.3)) World.bg_single_color = FloatVectorProperty( - name="Background color", + update=update_preview, name="Background color", description="Background color", subtype='COLOR', min=0.0, max=1.0, default=(0.7, 0.7, 0.7)) World.bg_use_ibl = BoolProperty( - name="Use IBL", + update=update_preview, name="Use IBL", description="Use the background as the light source for your image", default=False) World.bg_with_caustic = BoolProperty( - name="Caustic photons", + update=update_preview, name="Caustic photons", description="Allow background light to shoot caustic photons", default=True) World.bg_with_diffuse = BoolProperty( - name="Diffuse photons", + update=update_preview, name="Diffuse photons", description="Allow background light to shoot diffuse photons", default=True) World.bg_ibl_samples = IntProperty( - name="IBL Samples", + update=update_preview, name="IBL Samples", description="Number of samples for direct lighting from background", min=1, max=512, default=16) World.bg_rotation = FloatProperty( - name="Rotation", + update=update_preview, name="Rotation", description="Rotation offset of background texture", min=0.0, max=360.0, default=0.0) World.bg_turbidity = FloatProperty( - name="Turbidity", + update=update_preview, name="Turbidity", description="Turbidity of the atmosphere", min=1.0, max=20.0, default=2.0) World.bg_ds_turbidity = FloatProperty( # Darktides turbidity has different values - name="Turbidity", + update=update_preview, name="Turbidity", description="Turbidity of the atmosphere", min=2.0, max=12.0, default=2.0) World.bg_a_var = FloatProperty( - name="Brightness of horizon gradient", + update=update_preview, name="Brightness of horizon gradient", description="Darkening or brightening towards horizon", min=0.0, max=10.0, default=1.0) World.bg_b_var = FloatProperty( - name="Luminance of horizon", + update=update_preview, name="Luminance of horizon", description="Luminance gradient near the horizon", min=0.0, max=10.0, default=1.0) World.bg_c_var = FloatProperty( - name="Solar region intensity", + update=update_preview, name="Solar region intensity", description="Relative intensity of circumsolar region", min=0.0, max=10.0, default=1.0) World.bg_d_var = FloatProperty( - name="Width of circumsolor region", + update=update_preview, name="Width of circumsolor region", description="Width of circumsolar region", min=0.0, max=10.0, default=1.0) World.bg_e_var = FloatProperty( - name="Backscattered light", + update=update_preview, name="Backscattered light", description="Relative backscattered light", min=0.0, max=10.0, default=1.0) World.bg_from = FloatVectorProperty( - name="Set sun position", + update=update_preview, name="Set sun position", description="Set the position of the sun", subtype='DIRECTION', step=10, precision=3, @@ -175,69 +178,69 @@ def register(): default=(1.0, 1.0, 1.0)) World.bg_add_sun = BoolProperty( - name="Add sun", + update=update_preview, name="Add sun", description="Add a real sun light", default=False) World.bg_sun_power = FloatProperty( - name="Sunlight power", + update=update_preview, name="Sunlight power", description="Sunlight power", min=0.0, max=10.0, default=1.0) World.bg_background_light = BoolProperty( - name="Add skylight", + update=update_preview, name="Add skylight", description="Add skylight", default=False) World.bg_light_samples = IntProperty( - name="Samples", + update=update_preview, name="Samples", description="Set skylight and sunlight samples", min=1, max=512, default=16) World.bg_dsaltitude = FloatProperty( - name="Altitude", + update=update_preview, name="Altitude", description="Moves the sky dome above or below the camera position", min=-1.0, max=2.0, default=0.0) World.bg_dsnight = BoolProperty( - name="Night", + update=update_preview, name="Night", description="Activate experimental night mode", default=False) World.bg_dsbright = FloatProperty( - name="Sky brightness", + update=update_preview, name="Sky brightness", description="Brightness of the sky", min=0.0, max=10.0, default=1.0) World.bg_power = FloatProperty( - name="Skylight power", + update=update_preview, name="Skylight power", description="Multiplier for background color", min=0.0, default=1.0) World.bg_exposure = FloatProperty( - name="Exposure", + update=update_preview, name="Exposure", description="Exposure correction for the sky (0 = no correction)", min=0.0, max=10.0, default=1.0) World.bg_clamp_rgb = BoolProperty( - name="Clamp RGB", + update=update_preview, name="Clamp RGB", description="Clamp RGB values", default=False) World.bg_gamma_enc = BoolProperty( - name="Gamma encoding", + update=update_preview, name="Gamma encoding", description="Apply gamma encoding to the sky", default=True) ########### YafaRays volume integrator properties ############# World.v_int_type = EnumProperty( - name="Volume integrator", + update=update_preview, name="Volume integrator", description="Set the volume integrator", items=( ('None', "None", ""), @@ -247,43 +250,43 @@ def register(): default='None') World.v_int_step_size = FloatProperty( - name="Step size", + update=update_preview, name="Step size", description="Precision of volumetric rendering (in Blender units)", min=0.0, max=100.0, precision=3, default=1.000) World.v_int_adaptive = BoolProperty( - name="Adaptive", + update=update_preview, name="Adaptive", description="Optimizes stepping calculations for NoiseVolumes", default=False) World.v_int_optimize = BoolProperty( - name="Optimize", + update=update_preview, name="Optimize", description="Precomputing attenuation in the entire volume at a 3d grid of points", default=False) World.v_int_attgridres = IntProperty( - name="Att. grid resolution", + update=update_preview, name="Att. grid resolution", description="Optimization attenuation grid resolution", min=1, max=50, default=1) # ??? not sure about the following properties ??? World.v_int_scale = FloatProperty( - name="Sigma T", + update=update_preview, name="Sigma T", min=0.0, precision=3, description="", default=0.100) World.v_int_alpha = FloatProperty( - name="Alpha", + update=update_preview, name="Alpha", min=0.0, precision=3, description="", default=0.500) World.v_int_dsturbidity = FloatProperty( - name="Turbidity", + update=update_preview, name="Turbidity", description="", default=3.0) diff --git a/ui/__init__.py b/ui/__init__.py index 8f6e52c0..8271381c 100644 --- a/ui/__init__.py +++ b/ui/__init__.py @@ -26,6 +26,8 @@ from . import properties_yaf_strand from . import properties_yaf_object from . import properties_yaf_light +from . import properties_yaf_scene +from . import properties_yaf_layer_passes from bl_ui import properties_object as properties_object for member in dir(properties_object): # add all "object" panels from blender @@ -63,12 +65,16 @@ pass del properties_data_speaker -# YafaRay did not display the Scene panels anymore, due to addition of COMPAT_ENGINES to them from bl_ui import properties_scene as properties_scene for member in dir(properties_scene): - subclass = getattr(properties_scene, member) - try: - subclass.COMPAT_ENGINES.add('YAFA_RENDER') - except: - pass + + if member != "SCENE_PT_color_management": #YafaRay Color management panel is customized in properties_yaf_scene. + #FIXME: The customized YafaRay panel appears at the end of the Blender scene tab panels, I don't know how to rearrange the panels to keep YafaRay color management in the same place as Blender Color Management panel was. + + subclass = getattr(properties_scene, member) + try: + subclass.COMPAT_ENGINES.add('YAFA_RENDER') + except: + pass + del properties_scene diff --git a/ui/properties_yaf_AA_settings.py b/ui/properties_yaf_AA_settings.py index 250dd9a7..0c59a36d 100644 --- a/ui/properties_yaf_AA_settings.py +++ b/ui/properties_yaf_AA_settings.py @@ -26,13 +26,20 @@ class YAF_PT_AA_settings(RenderButtonsPanel, Panel): - bl_label = "Anti-Aliasing" + bl_label = "Anti-Aliasing / Noise control" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): scene = context.scene layout = self.layout + split = layout.split() + col = split.column() + col.prop(scene.yafaray.noise_control, "clamp_samples") + col = split.column() + col.prop(scene.yafaray.noise_control, "clamp_indirect") + split = layout.split() col = split.column() col.prop(scene, "AA_filter_type") @@ -50,9 +57,30 @@ def draw(self, context): spp.prop(scene, "AA_passes") sub.prop(scene, "AA_inc_samples") sub.prop(scene, "AA_threshold") - if scene.intg_light_method != "SPPM": - sub.prop(scene, "AA_resampled_floor") + row = layout.row() + row.enabled = False + + if scene.AA_passes > 1 and scene.intg_light_method != "SPPM": + row.enabled = True + + row.prop(scene.yafaray.noise_control, "detect_color_noise") + + row = layout.row() + row.enabled = False + + if scene.AA_passes > 1 and scene.intg_light_method != "SPPM": + row.enabled = True + + col = row.column() + col.prop(scene.yafaray.noise_control, "dark_threshold_factor") + col.prop(scene.yafaray.noise_control, "sample_multiplier_factor") + col.prop(scene.yafaray.noise_control, "light_sample_multiplier_factor") + col.prop(scene.yafaray.noise_control, "indirect_sample_multiplier_factor") + col = row.column() + col.prop(scene.yafaray.noise_control, "resampled_floor") + col.prop(scene.yafaray.noise_control, "variance_edge_size") + col.prop(scene.yafaray.noise_control, "variance_pixels") if __name__ == "__main__": # only for live edit. import bpy diff --git a/ui/properties_yaf_general_settings.py b/ui/properties_yaf_general_settings.py old mode 100644 new mode 100755 index b043d672..8dd2785a --- a/ui/properties_yaf_general_settings.py +++ b/ui/properties_yaf_general_settings.py @@ -28,6 +28,8 @@ class YAFARAY_MT_presets_render(Menu): bl_label = "Yafaray Render Presets" + COMPAT_ENGINES = {'YAFA_RENDER'} + preset_subdir = "render" preset_operator = "script.execute_preset" draw = yafaray_presets.Yafaray_Menu.draw_preset @@ -35,6 +37,7 @@ class YAFARAY_MT_presets_render(Menu): class YAF_PT_general_settings(RenderButtonsPanel, Panel): bl_label = "General Settings" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): layout = self.layout @@ -51,7 +54,6 @@ def draw(self, context): split = layout.split(percentage=0.58) col = split.column() col.prop(scene, "gs_ray_depth") - col.prop(scene, "gs_gamma") col.prop(scene, "gs_type_render") sub = col.column() sub.enabled = scene.gs_type_render == "into_blender" @@ -61,7 +63,7 @@ def draw(self, context): sub = col.column() sub.enabled = scene.gs_transp_shad sub.prop(scene, "gs_shadow_depth") - col.prop(scene, "gs_gamma_input") + #col.prop(scene, "gs_gamma_input") #No longer needed sub = col.column() sub.enabled = scene.gs_auto_threads == False sub.prop(scene, "gs_threads") @@ -73,19 +75,18 @@ def draw(self, context): split = layout.split() col = split.column() - col.prop(scene, "gs_clay_render", toggle=True) - col.prop(scene, "gs_z_channel", toggle=True) + col.prop(scene, "gs_tex_optimization") + + split = layout.split() + col = split.column() col.prop(scene, "gs_transp_shad", toggle=True) col.prop(scene, "gs_draw_params", toggle=True) - col.prop(scene, "gs_clamp_rgb", toggle=True) + col.prop(scene, "gs_verbose", toggle=True) col = split.column() - if scene.gs_clay_render: - col.prop(scene, "gs_clay_col", text="") col.prop(scene, "gs_auto_threads", toggle=True) col.prop(scene, "gs_show_sam_pix", toggle=True) col.prop(render, "use_instances", text="Use instances", toggle=True) - col.prop(scene, "gs_verbose", toggle=True) split = layout.split(percentage=0.5) col = split.column() @@ -100,6 +101,36 @@ def draw(self, context): col.prop(scene, "gs_custom_string") +class YAFARAY_MT_clay_render(RenderButtonsPanel, Panel): + bl_label = "Clay Render Settings" + COMPAT_ENGINES = {'YAFA_RENDER'} + + def draw(self, context): + layout = self.layout + scene = context.scene + render = scene.render + + row = layout.row(align=True) + split = layout.split(percentage=0.5) + col = split.column() + col.prop(scene, "gs_clay_render", toggle=True) + if scene.gs_clay_render: + col = split.column() + col.prop(scene, "gs_clay_col", text="") + layout.separator() + split = layout.split() + col = split.column() + col.prop(scene, "gs_clay_oren_nayar") + if scene.gs_clay_oren_nayar: + col = split.column() + col.prop(scene, "gs_clay_sigma") + col = layout.column() + col.prop(scene, "gs_clay_render_keep_transparency") + #col = split.column() + col.prop(scene, "gs_clay_render_keep_normals") + + + if __name__ == "__main__": # only for live edit. import bpy bpy.utils.register_module(__name__) diff --git a/ui/properties_yaf_integrator.py b/ui/properties_yaf_integrator.py index 23d4efe6..917067fc 100644 --- a/ui/properties_yaf_integrator.py +++ b/ui/properties_yaf_integrator.py @@ -27,6 +27,7 @@ class YAF_PT_render(RenderButtonsPanel, Panel): bl_label = "Integrator" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): layout = self.layout diff --git a/ui/properties_yaf_layer_passes.py b/ui/properties_yaf_layer_passes.py new file mode 100755 index 00000000..b1787b53 --- /dev/null +++ b/ui/properties_yaf_layer_passes.py @@ -0,0 +1,319 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from bpy.types import Panel +from bl_ui.properties_render_layer import RenderLayerButtonsPanel + +RenderLayerButtonsPanel.COMPAT_ENGINES = {'YAFA_RENDER'} + + +class YAFRENDER_PT_layers(RenderLayerButtonsPanel, Panel): + bl_label = "Layers" + COMPAT_ENGINES = {'YAFA_RENDER'} +# bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + + scene = context.scene + rd = scene.render + + row = layout.row() + if bpy.app.version < (2, 65, 3 ): + row.template_list(rd, "layers", rd.layers, "active_index", rows=2) + else: + row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2) + + col = row.column(align=True) + col.operator("scene.render_layer_add", icon='ZOOMIN', text="") + col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="") + + row = layout.row() + rl = rd.layers.active + row.prop(rl, "name") + row.prop(rd, "use_single_layer", text="", icon_only=True) + + split = layout.split() + + col = split.column() + col.prop(scene, "layers", text="Scene") + # TODO: Implement material override + #col.prop(rl, "material_override", text="Material") + + col = split.column() + # TODO: Implement render layers + #col.prop(rl, "layers", text="Layer") + +class YAFRENDER_PT_layer_passes(RenderLayerButtonsPanel, Panel): + bl_label = "Render Passes" + COMPAT_ENGINES = {'YAFA_RENDER'} + + def draw_header(self, context): + scene = context.scene + self.layout.prop(scene.yafaray.passes, "pass_enable", text="") + + def draw(self, context): + layout = self.layout + + scene = context.scene + rd = scene.render + rl = rd.layers.active + + if scene.yafaray.passes.pass_enable: + + row = layout.row() #(align=True) + row = layout.row() #(align=True) + row.prop(rl, "use_pass_z") #, "Z-depth") + if scene.render.layers[0].use_pass_z: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Depth", "") + + row = layout.row() + row.prop(rl, "use_pass_vector") + if scene.render.layers[0].use_pass_vector: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Vector", "") + + row = layout.row() + row.prop(rl, "use_pass_normal") + if scene.render.layers[0].use_pass_normal: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Normal", "") + + row = layout.row() + row.prop(rl, "use_pass_uv") + if scene.render.layers[0].use_pass_uv: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_UV", "") + + row = layout.row() + row.prop(rl, "use_pass_color") + if scene.render.layers[0].use_pass_color: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Color", "") + + row = layout.row() + row.prop(rl, "use_pass_emit") + if scene.render.layers[0].use_pass_emit: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Emit", "") + + row = layout.row() + row.prop(rl, "use_pass_mist") + if scene.render.layers[0].use_pass_mist: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Mist", "") + + row = layout.row() + row.prop(rl, "use_pass_diffuse") + if scene.render.layers[0].use_pass_diffuse: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Diffuse", "") + + row = layout.row() + row.prop(rl, "use_pass_specular") + if scene.render.layers[0].use_pass_specular: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Spec", "") + + row = layout.row() + row.prop(rl, "use_pass_ambient_occlusion") + if scene.render.layers[0].use_pass_ambient_occlusion: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_AO", "") + row = layout.row() + col = row.column() + col.prop(scene, "intg_AO_color") + col.prop(scene, "intg_AO_samples") + col.prop(scene, "intg_AO_distance") + + row = layout.row() + row.prop(rl, "use_pass_environment") + if scene.render.layers[0].use_pass_environment: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Env", "") + + row = layout.row() + row.prop(rl, "use_pass_indirect") + if scene.render.layers[0].use_pass_indirect: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Indirect", "") + + row = layout.row() + row.prop(rl, "use_pass_shadow") + if scene.render.layers[0].use_pass_shadow: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Shadow", "") + + row = layout.row() + row.prop(rl, "use_pass_reflection") + if scene.render.layers[0].use_pass_reflection: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Reflect", "") + + row = layout.row() + row.prop(rl, "use_pass_refraction") + if scene.render.layers[0].use_pass_refraction: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_Refract", "") + + row = layout.row() + row.prop(rl, "use_pass_object_index") + if scene.render.layers[0].use_pass_object_index: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_IndexOB", "") + + row = layout.row() + row.prop(rl, "use_pass_material_index") + if scene.render.layers[0].use_pass_material_index: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_IndexMA", "") + + row = layout.row() + row.prop(rl, "use_pass_diffuse_direct") + if scene.render.layers[0].use_pass_diffuse_direct: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_DiffDir", "") + + row = layout.row() + row.prop(rl, "use_pass_diffuse_indirect") + if scene.render.layers[0].use_pass_diffuse_indirect: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_DiffInd", "") + + row = layout.row() + row.prop(rl, "use_pass_diffuse_color") + if scene.render.layers[0].use_pass_diffuse_color: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_DiffCol", "") + + row = layout.row() + row.prop(rl, "use_pass_glossy_direct") + if scene.render.layers[0].use_pass_glossy_direct: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_GlossDir", "") + + row = layout.row() + row.prop(rl, "use_pass_glossy_indirect") + if scene.render.layers[0].use_pass_glossy_indirect: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_GlossInd", "") + + row = layout.row() + row.prop(rl, "use_pass_glossy_color") + if scene.render.layers[0].use_pass_glossy_color: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_GlossCol", "") + + row = layout.row() + row.prop(rl, "use_pass_transmission_direct") + if scene.render.layers[0].use_pass_transmission_direct: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_TransDir", "") + + row = layout.row() + row.prop(rl, "use_pass_transmission_indirect") + if scene.render.layers[0].use_pass_transmission_indirect: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_TransInd", "") + + row = layout.row() + row.prop(rl, "use_pass_transmission_color") + if scene.render.layers[0].use_pass_transmission_color: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_TransCol", "") + + row = layout.row() + row.prop(rl, "use_pass_subsurface_direct") + if scene.render.layers[0].use_pass_subsurface_direct: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_SubsurfaceDir", "") + + row = layout.row() + row.prop(rl, "use_pass_subsurface_indirect") + if scene.render.layers[0].use_pass_subsurface_indirect: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_SubsurfaceInd", "") + + row = layout.row() + row.prop(rl, "use_pass_subsurface_color") + if scene.render.layers[0].use_pass_subsurface_color: + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_SubsurfaceCol", "") + + row = layout.row() + row.prop(scene.yafaray.passes, "pass_mask_obj_index") + + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_mask_mat_index") + + row = layout.row() + row.prop(scene.yafaray.passes, "pass_mask_invert") + + sub = row.column(align=True) + sub.prop(scene.yafaray.passes, "pass_mask_only") + + +class YAFRENDER_PT_views(RenderLayerButtonsPanel, Panel): + bl_label = "Views" + COMPAT_ENGINES = {'YAFA_RENDER'} + + def draw_header(self, context): + rd = context.scene.render + self.layout.prop(rd, "use_multiview", text="") + + def draw(self, context): + layout = self.layout + + scene = context.scene + rd = scene.render + rv = rd.views.active + + if rd.use_multiview: + layout.active = rd.use_multiview + basic_stereo = rd.views_format == 'STEREO_3D' + + row = layout.row() + row.prop(rd, "views_format", expand=True) + + if basic_stereo: + row = layout.row() + row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "stereo_views", rd.views, "active_index", rows=2) + + row = layout.row() + row.label(text="File Suffix:") + row.prop(rv, "file_suffix", text="") + + else: + row = layout.row() + row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "views", rd.views, "active_index", rows=2) + + col = row.column(align=True) + col.operator("scene.render_view_add", icon='ZOOMIN', text="") + col.operator("scene.render_view_remove", icon='ZOOMOUT', text="") + + row = layout.row() + row.label(text="Camera Suffix:") + row.prop(rv, "camera_suffix", text="") + +if __name__ == "__main__": # only for live edit. + import bpy + bpy.utils.register_module(__name__) diff --git a/ui/properties_yaf_light.py b/ui/properties_yaf_light.py index 17e6f91c..2d548bc0 100644 --- a/ui/properties_yaf_light.py +++ b/ui/properties_yaf_light.py @@ -162,6 +162,19 @@ def draw(self, context): col.label(text="") col.prop(lamp, "shadow_buffer_clip_end", text=" Clip End") +class YAF_PT_lamp_advanced(DataButtonsPanel, Panel): + bl_label = "Advanced settings" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'YAFA_RENDER'} + + def draw(self, context): + layout = self.layout + lamp = context.lamp + + split = layout.split() + col = split.column() + layout.row().prop(lamp, "cast_shadows") + if __name__ == "__main__": # only for live edit. import bpy diff --git a/ui/properties_yaf_material.py b/ui/properties_yaf_material.py old mode 100644 new mode 100755 index 48a11586..911f881d --- a/ui/properties_yaf_material.py +++ b/ui/properties_yaf_material.py @@ -28,6 +28,22 @@ MaterialButtonsPanel.COMPAT_ENGINES = {'YAFA_RENDER'} +def blend_one_draw(layout, mat): + try: + layout.prop_search(mat, "material1name", bpy.data, "materials") + except: + return False + + return True + +def blend_two_draw(layout, mat): + try: + layout.prop_search(mat, "material2name", bpy.data, "materials") + except: + return False + return True + + class MaterialTypePanel(MaterialButtonsPanel): COMPAT_ENGINES = {'YAFA_RENDER'} @@ -95,14 +111,84 @@ def draw(self, context): if yaf_mat: layout.separator() layout.prop(yaf_mat, "mat_type") + layout.row().prop(yaf_mat, "clay_exclude") class YAF_MATERIAL_PT_preview(MaterialButtonsPanel, Panel): bl_label = "Preview" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): self.layout.template_preview(context.material) +class YAF_PT_preview_controls(MaterialButtonsPanel, Panel): + bl_label = "Preview Controls" + COMPAT_ENGINES = {'YAFA_RENDER'} + #bl_options = {'DEFAULT_CLOSED'} + + def draw_header(self, context): + scene = context.scene + self.layout.prop(context.scene.yafaray.preview, "enable", text="") + + def draw(self, context): + if context.scene.yafaray.preview.enable: + layout = self.layout + yaf_mat = active_node_mat(context.material) + split = layout.split() + col = split.column() + col.label("Preview dynamic rotation/zoom") + split = layout.split() + col = split.column() + col.prop(context.scene.yafaray.preview, "camRot", text="") + col = split.column() + row = col.row() + row.operator("preview.camzoomout", text='Zoom Out', icon='ZOOM_OUT') + col2 = row.column() + col2.operator("preview.camzoomin", text='Zoom In', icon='ZOOM_IN') + row = col.row() + row.label("") + row = col.row() + row.operator("preview.camrotreset", text='Reset dynamic rotation/zoom') + split = layout.split() + col = split.column() + col.label("Preview object control") + split = layout.split() + col = split.column() + col.prop(context.scene.yafaray.preview, "objScale", text="Scale") + col = split.column() + col.prop(context.scene.yafaray.preview, "rotZ", text="Z Rotation") + col = split.column() + col.prop_search(context.scene.yafaray.preview, "previewObject", bpy.data, "objects", text="") + split = layout.split() + col = split.column() + col.label("Preview lights control") + col = split.column() + col.prop(context.scene.yafaray.preview, "lightRotZ", text="lights Z Rotation") + split = layout.split() + col = split.column() + col.label("Key light:") + col = split.column() + col.prop(context.scene.yafaray.preview, "keyLightPowerFactor", text="Power factor") + col = split.column() + col.prop(context.scene.yafaray.preview, "keyLightColor", text="") + split = layout.split() + col = split.column() + col.label("Fill lights:") + col = split.column() + col.prop(context.scene.yafaray.preview, "fillLightPowerFactor", text="Power factor") + col = split.column() + col.prop(context.scene.yafaray.preview, "fillLightColor", text="") + split = layout.split() + col = split.column() + col.label("Preview scene control") + split = layout.split() + col = split.column() + col.prop(context.scene.yafaray.preview, "previewRayDepth", text="Ray Depth") + col = split.column() + col.prop(context.scene.yafaray.preview, "previewAApasses", text="AA samples") + col = split.column() + col.prop(context.scene.yafaray.preview, "previewBackground", text="") + def draw_generator(ior_n): def draw(self, context): @@ -134,6 +220,7 @@ def draw(self, context): class YAF_MT_presets_ior_list(Menu): bl_label = "Glass" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): sl = self.layout @@ -143,6 +230,7 @@ def draw(self, context): class YAF_PT_shinydiffuse_diffuse(MaterialTypePanel, Panel): bl_label = "Diffuse reflection" + COMPAT_ENGINES = {'YAFA_RENDER'} material_type = 'shinydiffusemat' def draw(self, context): @@ -177,6 +265,7 @@ def draw(self, context): class YAF_PT_shinydiffuse_specular(MaterialTypePanel, Panel): bl_label = "Specular reflection" + COMPAT_ENGINES = {'YAFA_RENDER'} material_type = 'shinydiffusemat' def draw(self, context): @@ -198,6 +287,7 @@ def draw(self, context): class YAF_PT_glossy_diffuse(MaterialTypePanel, Panel): bl_label = "Diffuse reflection" + COMPAT_ENGINES = {'YAFA_RENDER'} material_type = 'glossy', 'coated_glossy' def draw(self, context): @@ -220,6 +310,7 @@ def draw(self, context): class YAF_PT_glossy_specular(MaterialTypePanel, Panel): bl_label = "Specular reflection" + COMPAT_ENGINES = {'YAFA_RENDER'} material_type = 'glossy', 'coated_glossy' def draw(self, context): @@ -255,10 +346,12 @@ def draw(self, context): col.label(text="Fresnel reflection:") col.prop(yaf_mat, "IOR_reflection") col.label() + layout.row().prop(yaf_mat, "specular_reflect", slider=True) class YAF_PT_glass_real(MaterialTypePanel, Panel): bl_label = "Real glass settings" + COMPAT_ENGINES = {'YAFA_RENDER'} material_type = 'glass', 'rough_glass' def draw(self, context): @@ -290,6 +383,7 @@ def draw(self, context): class YAF_PT_glass_fake(MaterialTypePanel, Panel): bl_label = "Fake glass settings" + COMPAT_ENGINES = {'YAFA_RENDER'} material_type = 'glass', 'rough_glass' def draw(self, context): @@ -307,6 +401,7 @@ def draw(self, context): class YAF_PT_blend_(MaterialTypePanel, Panel): bl_label = "Blend material settings" + COMPAT_ENGINES = {'YAFA_RENDER'} material_type = 'blend' def draw(self, context): @@ -322,15 +417,39 @@ def draw(self, context): box = layout.box() box.label(text="Choose the two materials you wish to blend.") - split = box.split() - col = split.column() - col.label(text="Material one:") - col.prop(yaf_mat, "material1", text="") + #old blend material Enum properties - deprecated + #split = box.split() + #col = split.column() + #col.label(text="Material one:") + #col.prop(yaf_mat, "material1", text="") + + #col = split.column() + #col.label(text="Material two:") + #col.prop(yaf_mat, "material2", text="") + + blend_one_draw(layout, yaf_mat) + blend_two_draw(layout, yaf_mat) + + +class YAF_PT_advanced(MaterialButtonsPanel, Panel): + bl_label = "Advanced settings" + COMPAT_ENGINES = {'YAFA_RENDER'} + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + yaf_mat = active_node_mat(context.material) + + layout.prop(yaf_mat, "pass_index") + + split = layout.split() col = split.column() - col.label(text="Material two:") - col.prop(yaf_mat, "material2", text="") + layout.row().prop(yaf_mat, "visibility") + split = layout.split() + col = split.column() + layout.row().prop(yaf_mat, "receive_shadows") if __name__ == "__main__": # only for live edit. diff --git a/ui/properties_yaf_object.py b/ui/properties_yaf_object.py index 7cbdd6c5..100c5f6d 100644 --- a/ui/properties_yaf_object.py +++ b/ui/properties_yaf_object.py @@ -78,6 +78,7 @@ def draw(self, context): col.prop(ob, "vol_cover") col.prop(ob, "vol_density") + #layout.prop(ob, "pass_index") #no need for this, there is a pass_index field by default in the object properties panel, but just in case I'm leaving this here. if __name__ == "__main__": # only for live edit. import bpy diff --git a/ui/properties_yaf_render.py b/ui/properties_yaf_render.py old mode 100644 new mode 100755 index 0d6d9a14..cb3b9b79 --- a/ui/properties_yaf_render.py +++ b/ui/properties_yaf_render.py @@ -27,6 +27,7 @@ class YAFRENDER_PT_render(RenderButtonsPanel, Panel): bl_label = "Render" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): @@ -39,46 +40,9 @@ def draw(self, context): layout.row().operator("render.render_view", text="Render 3D View", icon='VIEW3D') layout.prop(rd, "display_mode", text="Display") - -class YAFRENDER_PT_layers(RenderButtonsPanel, Panel): - bl_label = "Layers" - bl_options = {'DEFAULT_CLOSED'} - - def draw(self, context): - layout = self.layout - - scene = context.scene - rd = scene.render - - row = layout.row() - if bpy.app.version < (2, 65, 3 ): - row.template_list(rd, "layers", rd.layers, "active_index", rows=2) - else: - row.template_list("RENDERLAYER_UL_renderlayers", "", rd, "layers", rd.layers, "active_index", rows=2) - - col = row.column(align=True) - col.operator("scene.render_layer_add", icon='ZOOMIN', text="") - col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="") - - row = layout.row() - rl = rd.layers.active - row.prop(rl, "name") - row.prop(rd, "use_single_layer", text="", icon_only=True) - - split = layout.split() - - col = split.column() - col.prop(scene, "layers", text="Scene") - # TODO: Implement material override - #col.prop(rl, "material_override", text="Material") - - col = split.column() - # TODO: Implement render layers - #col.prop(rl, "layers", text="Layer") - - class YAFRENDER_PT_dimensions(RenderButtonsPanel, Panel): bl_label = "Dimensions" + COMPAT_ENGINES = {'YAFA_RENDER'} bl_options = {'DEFAULT_CLOSED'} def draw(self, context): @@ -121,6 +85,7 @@ def draw(self, context): class YAFRENDER_PT_output(RenderButtonsPanel, Panel): bl_label = "Output" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): layout = self.layout @@ -137,9 +102,47 @@ def draw(self, context): col = split.column() col.row().prop(image_settings, "color_mode", text="Color", expand=True) + if sc.img_output == "OPEN_EXR": + split = layout.split() + split.prop(sc, "img_multilayer") + + if sc.img_output == "OPEN_EXR" or sc.img_output == "HDR": #If the output file is a HDR/EXR file, we force the render output to Linear + pass + elif sc.gs_type_render == "file" or sc.gs_type_render == "xml": + split = layout.split(percentage=0.6) + col = split.column() + col.prop(sc.display_settings, "display_device") + + if sc.display_settings.display_device == "None": + col = split.column() + col.prop(sc, "gs_gamma", text = "Gamma") + + if sc.display_settings.display_device == "sRGB": + pass + elif sc.display_settings.display_device == "None": + pass + elif sc.display_settings.display_device == "XYZ": + row = layout.row(align=True) + row.label(text="YafaRay 'XYZ' support is experimental and may not give the expected results", icon="ERROR") + else: + row = layout.row(align=True) + row.label(text="YafaRay doesn't support '" + sc.display_settings.display_device + "', assuming sRGB", icon="ERROR") + + if sc.gs_type_render == "file" or sc.gs_type_render == "xml": + split = layout.split(percentage=0.6) + col = split.column() + col.prop(sc, "gs_premult", text = "Premultiply Alpha") + if sc.img_output == "OPEN_EXR" and not sc.gs_premult: + row = layout.row(align=True) + row.label(text="Typically you should enable Premultiply in EXR files", icon="INFO") + if sc.img_output == "PNG" and sc.gs_premult: + row = layout.row(align=True) + row.label(text="Typically you should disable Premultiply in PNG files", icon="INFO") + class YAFRENDER_PT_post_processing(RenderButtonsPanel, Panel): bl_label = "Post Processing" + COMPAT_ENGINES = {'YAFA_RENDER'} bl_options = {'DEFAULT_CLOSED'} def draw(self, context): @@ -157,14 +160,40 @@ def draw(self, context): col.prop(rd, "dither_intensity", text="Dither", slider=True) -class YAF_PT_convert(RenderButtonsPanel, Panel): +class YAFRENDER_PT_convert(RenderButtonsPanel, Panel): bl_label = "Convert old YafaRay Settings" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): layout = self.layout layout.column().operator("data.convert_yafaray_properties", text="Convert data from 2.4x") +class YAFRENDER_PT_advanced(RenderButtonsPanel, Panel): + bl_label = "Advanced Settings - only for experts" + COMPAT_ENGINES = {'YAFA_RENDER'} + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + scene = context.scene + layout = self.layout + split = layout.split() + col = split.column() + col.prop(scene, "adv_auto_shadow_bias_enabled") + if not scene.adv_auto_shadow_bias_enabled: + col = split.column() + sub = col.column() + sub.prop(scene, "adv_shadow_bias_value") + + split = layout.split() + col = split.column() + col.prop(scene, "adv_auto_min_raydist_enabled") + if not scene.adv_auto_min_raydist_enabled: + col = split.column() + sub = col.column() + sub.prop(scene, "adv_min_raydist_value") + + if __name__ == "__main__": # only for live edit. import bpy bpy.utils.register_module(__name__) diff --git a/ui/properties_yaf_scene.py b/ui/properties_yaf_scene.py new file mode 100644 index 00000000..71abc501 --- /dev/null +++ b/ui/properties_yaf_scene.py @@ -0,0 +1,59 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# + +import bpy +from yafaray.ot import yafaray_presets +from bl_ui.properties_scene import SceneButtonsPanel +from bpy.types import Panel, Menu + +class YAF_PT_color_management(SceneButtonsPanel, Panel): + bl_label = "Color Management" + COMPAT_ENGINES = {'YAFA_RENDER'} + + def draw(self, context): + layout = self.layout + + scene = context.scene + + col = layout.column() + col.label(text="Display:") + col.prop(scene.display_settings, "display_device") + + if scene.display_settings.display_device == "sRGB": + pass + elif scene.display_settings.display_device == "None": + row = layout.row(align=True) + row.prop(scene, "gs_gamma", text = "Display device output gamma") + elif scene.display_settings.display_device == "XYZ": + row = layout.row(align=True) + row.label(text="YafaRay 'XYZ' support is experimental and may not give the expected results", icon="ERROR") + else: + row = layout.row(align=True) + row.label(text="YafaRay doesn't support '" + scene.display_settings.display_device + "', assuming sRGB", icon="ERROR") + + col = layout.column() + col.separator() + col.label(text="Render:") + col.template_colormanaged_view_settings(scene, "view_settings") + + +if __name__ == "__main__": # only for live edit. + import bpy + bpy.utils.register_module(__name__) diff --git a/ui/properties_yaf_texture.py b/ui/properties_yaf_texture.py old mode 100644 new mode 100755 index c45b40ee..d6080219 --- a/ui/properties_yaf_texture.py +++ b/ui/properties_yaf_texture.py @@ -135,6 +135,74 @@ def draw(self, context): if context.space_data.texture_context == 'BRUSH': layout.prop(tex, "use_preview_alpha") +class YAF_PT_preview_texture_controls(YAF_TextureButtonsPanel, Panel): + bl_label = "Preview Controls" + COMPAT_ENGINES = {'YAFA_RENDER'} + #bl_options = {'DEFAULT_CLOSED'} + + def draw_header(self, context): + scene = context.scene + self.layout.prop(context.scene.yafaray.preview, "enable", text="") + + def draw(self, context): + if context.scene.yafaray.preview.enable: + layout = self.layout + yaf_mat = active_node_mat(context.material) + split = layout.split() + col = split.column() + col.label("Preview dynamic rotation/zoom") + split = layout.split() + col = split.column() + col.prop(context.scene.yafaray.preview, "camRot", text="") + col = split.column() + row = col.row() + row.operator("preview.camzoomout", text='Zoom Out', icon='ZOOM_OUT') + col2 = row.column() + col2.operator("preview.camzoomin", text='Zoom In', icon='ZOOM_IN') + row = col.row() + row.label("") + row = col.row() + row.operator("preview.camrotreset", text='Reset dynamic rotation/zoom') + split = layout.split() + col = split.column() + col.label("Preview object control") + split = layout.split() + col = split.column() + col.prop(context.scene.yafaray.preview, "objScale", text="Scale") + col = split.column() + col.prop(context.scene.yafaray.preview, "rotZ", text="Z Rotation") + col = split.column() + col.prop_search(context.scene.yafaray.preview, "previewObject", bpy.data, "objects", text="") + split = layout.split() + col = split.column() + col.label("Preview lights control") + col = split.column() + col.prop(context.scene.yafaray.preview, "lightRotZ", text="lights Z Rotation") + split = layout.split() + col = split.column() + col.label("Key light:") + col = split.column() + col.prop(context.scene.yafaray.preview, "keyLightPowerFactor", text="Power factor") + col = split.column() + col.prop(context.scene.yafaray.preview, "keyLightColor", text="") + split = layout.split() + col = split.column() + col.label("Fill lights:") + col = split.column() + col.prop(context.scene.yafaray.preview, "fillLightPowerFactor", text="Power factor") + col = split.column() + col.prop(context.scene.yafaray.preview, "fillLightColor", text="") + split = layout.split() + col = split.column() + col.label("Preview scene control") + split = layout.split() + col = split.column() + col.prop(context.scene.yafaray.preview, "previewRayDepth", text="Ray Depth") + col = split.column() + col.prop(context.scene.yafaray.preview, "previewAApasses", text="AA samples") + col = split.column() + col.prop(context.scene.yafaray.preview, "previewBackground", text="") + class YAF_TextureSlotPanel(YAF_TextureButtonsPanel): COMPAT_ENGINES = {'YAFA_RENDER'} @@ -259,6 +327,29 @@ def draw(self, context): tex = context.texture layout.template_image(tex, "image", tex.image_user) + if hasattr(tex.image,"colorspace_settings"): + if tex.image.colorspace_settings.name == "sRGB" or tex.image.colorspace_settings.name == "Linear" or tex.image.colorspace_settings.name == "Non-Color": + pass + + elif tex.image.colorspace_settings.name == "XYZ": + row = layout.row(align=True) + row.label(text="YafaRay 'XYZ' support is experimental and may not give the expected results", icon="ERROR") + + elif tex.image.colorspace_settings.name == "Linear ACES": + row = layout.row(align=True) + row.label(text="YafaRay doesn't support '" + tex.image.colorspace_settings.name + "', assuming linear RGB", icon="ERROR") + + elif tex.image.colorspace_settings.name == "Raw": + row = layout.row(align=True) + row.prop(tex, "yaf_gamma_input", text="Texture gamma input correction") + + else: + row = layout.row(align=True) + row.label(text="YafaRay doesn't support '" + tex.image.colorspace_settings.name + "', assuming sRGB", icon="ERROR") + + row = layout.row(align=True) + row.label(text="Note: for bump/normal maps, textures are always considered Linear", icon="INFO") + class YAF_TEXTURE_PT_image_sampling(YAF_TextureTypePanel, Panel): bl_label = "Image Sampling" @@ -281,10 +372,10 @@ def draw(self, context): row.prop(tex, "use_calculate_alpha", text="Calculate Alpha") layout.prop(tex, "use_flip_axis", text="Flip X/Y Axis") layout.prop(tex, "yaf_tex_interpolate") - else: row.prop(tex, "use_interpolation", text="Use image background interpolation") #row.prop(tex, "use_calculate_alpha", text="Calculate Alpha") + layout.prop(tex, "yaf_tex_optimization") class YAF_TEXTURE_PT_image_mapping(YAF_TextureTypePanel, Panel): @@ -571,6 +662,7 @@ def factor_but(layout, toggle, factor, name): shaderNodes = dict() shaderNodes["Bump"] = ["use_map_normal", "normal_factor", "Bump"] shaderNodes["MirrorAmount"] = ["use_map_raymir", "raymir_factor", "Mirror Amount"] + shaderNodes["SigmaOren"] = ["use_map_hardness", "hardness_factor", "Sigma Amount for Oren Nayar"] shaderNodes["MirrorColor"] = ["use_map_mirror", "mirror_factor", "Mirror Color"] shaderNodes["DiffuseColor"] = ["use_map_color_diffuse", "diffuse_color_factor", "Diffuse Color"] shaderNodes["GlossyColor"] = ["use_map_color_spec", "specular_color_factor", "Glossy Color"] @@ -578,13 +670,18 @@ def factor_but(layout, toggle, factor, name): shaderNodes["Transparency"] = ["use_map_alpha", "alpha_factor", "Transparency"] shaderNodes["Translucency"] = ["use_map_translucency", "translucency_factor", "Translucency"] shaderNodes["BlendAmount"] = ["use_map_diffuse", "diffuse_factor", "Blending Amount"] - + shaderNodes["DiffuseReflection"] = ["use_map_diffuse", "diffuse_factor", "Diffuse reflection Amount"] + shaderNodes["FilterColor"] = ["use_map_color_reflection", "reflection_color_factor", "Filter Color Amount"] + shaderNodes["IORAmount"] = ["use_map_warp", "warp_factor", "IOR Amount (added to material IOR)"] + shaderNodes["RoughnessAmount"] = ["use_map_hardness", "hardness_factor", "Roughness amount"] + shaderNodes["ExponentAmount"] = ["use_map_ambient", "ambient_factor", "Glossy Exponent amount"] + materialShaderNodes = dict() - materialShaderNodes["glass"] = ["Bump", "MirrorColor"] - materialShaderNodes["rough_glass"] = ["Bump", "MirrorColor"] - materialShaderNodes["glossy"] = ["DiffuseColor", "GlossyColor", "GlossyAmount", "Bump"] - materialShaderNodes["coated_glossy"] = ["DiffuseColor", "GlossyColor", "GlossyAmount", "Bump"] - materialShaderNodes["shinydiffusemat"] = ["DiffuseColor", "MirrorAmount", "MirrorColor", "Transparency", "Translucency", "Bump"] + materialShaderNodes["glass"] = ["FilterColor", "MirrorColor", "IORAmount", "Bump"] + materialShaderNodes["rough_glass"] = ["RoughnessAmount", "FilterColor", "MirrorColor", "IORAmount", "Bump"] + materialShaderNodes["glossy"] = ["DiffuseColor", "DiffuseReflection", "SigmaOren", "GlossyColor", "GlossyAmount", "ExponentAmount", "Bump"] + materialShaderNodes["coated_glossy"] = ["DiffuseColor", "DiffuseReflection", "SigmaOren", "GlossyColor", "GlossyAmount", "ExponentAmount", "MirrorAmount", "MirrorColor", "IORAmount", "Bump"] + materialShaderNodes["shinydiffusemat"] = ["DiffuseColor", "DiffuseReflection", "SigmaOren", "MirrorAmount", "MirrorColor", "IORAmount", "Transparency", "Translucency", "Bump"] materialShaderNodes["blend"] = ["BlendAmount"] if isinstance(idblock, Material): diff --git a/ui/properties_yaf_volume_integrator.py b/ui/properties_yaf_volume_integrator.py index e44b7e1d..34108d16 100644 --- a/ui/properties_yaf_volume_integrator.py +++ b/ui/properties_yaf_volume_integrator.py @@ -27,6 +27,7 @@ class YAF_PT_vol_integrator(WorldButtonsPanel, Panel): bl_label = "YafaRay Volume Integrator" + COMPAT_ENGINES = {'YAFA_RENDER'} def draw(self, context): layout = self.layout diff --git a/ui/properties_yaf_world.py b/ui/properties_yaf_world.py old mode 100644 new mode 100755 index e87dab89..d39c524e --- a/ui/properties_yaf_world.py +++ b/ui/properties_yaf_world.py @@ -36,6 +36,7 @@ class YAFWORLD_PT_world(WorldButtonsPanel, Panel): bl_label = "Background Settings" + COMPAT_ENGINES = {'YAFA_RENDER'} ibl = True def draw(self, context): @@ -78,6 +79,26 @@ def draw(self, context): if tex.yaf_tex_type == "IMAGE": # it allows to change the used image # layout.template_image(tex, "image", tex.image_user, compact=True) + + if tex.image.colorspace_settings.name == "sRGB" or tex.image.colorspace_settings.name == "Linear" or tex.image.colorspace_settings.name == "Non-Color": + pass + + elif tex.image.colorspace_settings.name == "XYZ": + row = layout.row(align=True) + row.label(text="YafaRay 'XYZ' support is experimental and may not give the expected results", icon="ERROR") + + elif tex.image.colorspace_settings.name == "Linear ACES": + row = layout.row(align=True) + row.label(text="YafaRay doesn't support '" + tex.image.colorspace_settings.name + "', assuming linear RGB", icon="ERROR") + + elif tex.image.colorspace_settings.name == "Raw": + row = layout.row(align=True) + row.prop(tex, "yaf_gamma_input", text="Texture gamma input correction") + + else: + row = layout.row(align=True) + row.label(text="YafaRay doesn't support '" + tex.image.colorspace_settings.name + "', assuming sRGB", icon="ERROR") + # else: # TODO: create message about not allow texture type