tag:blogger.com,1999:blog-85751383086257853042024-03-13T23:22:23.580-07:00Blend BitsiReboothttp://www.blogger.com/profile/06641590596635834490noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8575138308625785304.post-37033779324433887852017-02-05T07:52:00.000-08:002017-02-07T05:16:49.082-08:00The CutAway Shader - A free Blender add on for architectural visualisation, model cutaways and more.<a href="https://4.bp.blogspot.com/-hj2aZr2dfmM/WJUJHvuBeiI/AAAAAAAAAII/5X-RibX01P0Oq2ViAlg3pinAscAdNva-gCLcB/s1600/1020.png" imageanchor="1" style="clear: right; display: inline !important; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"></a><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-p9IAm0YtQaI/WJiOVYyn_bI/AAAAAAAAAJw/KjqxYWWAEIo_UgKHzHUEqkAs1sVZwNxHgCEw/s1600/CutAway%2BShader%2BBanner_3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="184" src="https://3.bp.blogspot.com/-p9IAm0YtQaI/WJiOVYyn_bI/AAAAAAAAAJw/KjqxYWWAEIo_UgKHzHUEqkAs1sVZwNxHgCEw/s640/CutAway%2BShader%2BBanner_3.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<a href="https://3.bp.blogspot.com/-mOKLzCgsGqk/WJUHYgRtdyI/AAAAAAAAAH0/L5JguraYR-wtx-3HbLo7OtG_7iSfUXB-QCLcB/s1600/00_rocket_cutaway.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a>
<span style="color: black;"><br /></span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="clear: right; color: black; float: right; margin-bottom: 1em; margin-left: 1em;"><a href="http://bit.ly/2gIdMVO"><img border="0" src="https://2.bp.blogspot.com/-hXYgWa61im8/WJc2zMeV1JI/AAAAAAAAAJM/BRyHJ5pCjhElpEL-x4RhjIJOY1VD9bH2ACEw/s1600/Cutaway%2BShader%2BGif2_320x180.gif" /></a></span></div>
<span style="color: black;">After 3 years in the making - I'm excited to </span>announce the alpha release of the CutAway Shader - a free addon for Blender for artists, architects, scientists and engineers.<br />
<span style="color: black;"><br />If you've ever wanted to cut away a cross section of a model, perform an architectural reveal or carry out some tricky special effects then this is the tool for you! </span><br />
<span style="color: black;"><br /></span>
<span style="color: black;">It works for still images and for animations.</span><br />
<br />
<a href="https://3.bp.blogspot.com/-mOKLzCgsGqk/WJUHYgRtdyI/AAAAAAAAAH0/L5JguraYR-wtx-3HbLo7OtG_7iSfUXB-QCLcB/s1600/00_rocket_cutaway.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" height="179" src="https://3.bp.blogspot.com/-mOKLzCgsGqk/WJUHYgRtdyI/AAAAAAAAAH0/L5JguraYR-wtx-3HbLo7OtG_7iSfUXB-QCLcB/s320/00_rocket_cutaway.PNG" width="320" /></a>The CutAway Shader can be used for:<br />
<ul>
<li><b>Model cut aways.</b></li>
<li><b>Architectural reveals.</b></li>
<li><b>Scientific and engineering images.</b></li>
<li><b>Filming through walls (without damaging or re-dressing the set).</b></li>
<li><b>Special effects (e.g. turning a winter scene into a summer scene).</b></li>
<li><b>Wire frame to solid model transitions.</b></li>
<li><b>... plus much more!</b></li>
</ul>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-mOKLzCgsGqk/WJUHYgRtdyI/AAAAAAAAAH0/L5JguraYR-wtx-3HbLo7OtG_7iSfUXB-QCLcB/s1600/00_rocket_cutaway.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><br /></a></div>
<a href="https://3.bp.blogspot.com/-f1yTS7WU7vI/WJUKF4COi_I/AAAAAAAAAIQ/O1jM4q5zKh0KNsP0dDiqElqUe23JChdSwCLcB/s1600/0520.png" imageanchor="1" style="clear: right; display: inline !important; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="180" src="https://3.bp.blogspot.com/-f1yTS7WU7vI/WJUKF4COi_I/AAAAAAAAAIQ/O1jM4q5zKh0KNsP0dDiqElqUe23JChdSwCLcB/s320/0520.png" width="320" /></a><br />
<br />
<ul>
</ul>
<a href="https://4.bp.blogspot.com/-hj2aZr2dfmM/WJUJHvuBeiI/AAAAAAAAAII/5X-RibX01P0Oq2ViAlg3pinAscAdNva-gCLcB/s1600/1020.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="180" src="https://4.bp.blogspot.com/-hj2aZr2dfmM/WJUJHvuBeiI/AAAAAAAAAII/5X-RibX01P0Oq2ViAlg3pinAscAdNva-gCLcB/s320/1020.png" width="320" /></a><br />
<h3>
<span style="color: blue;">What does it do?</span></h3>
Checkout the CutAway Shader demo reel video on YouTube<br />
<ul>
<li><a href="http://bit.ly/2gIdMVO" target="_blank"><b>CutAway Shader Demo Reel Video</b></a></li>
</ul>
<a href="https://1.bp.blogspot.com/-NpLmPI75CWY/WJUHwaPrLvI/AAAAAAAAAH4/XnQ8y1wxIhQndBNw9lrTFrTGFUXCwvD8wCLcB/s1600/02_building_cutaway.PNG" imageanchor="1" style="clear: right; display: inline !important; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" height="180" src="https://1.bp.blogspot.com/-NpLmPI75CWY/WJUHwaPrLvI/AAAAAAAAAH4/XnQ8y1wxIhQndBNw9lrTFrTGFUXCwvD8wCLcB/s320/02_building_cutaway.PNG" width="320" /></a><br />
<h3>
<span style="color: blue;">Downloading the Addon</span></h3>
<ul>
<li><span style="font-family: inherit;"><span style="color: magenta;"><b><a href="http://bit.ly/2dFKqYP" target="_blank"><span style="color: magenta;">Download Adddon(.zip) </span></a> </b></span></span><br /><span style="font-size: x-small;">(node_cutaway_shader.zip v1.2 alpha)</span><span style="font-size: x-small;"><br /></span>(This is an alpha release - so remember to save your work!)</li>
</ul>
<ul>
</ul>
<h3>
<span style="color: blue;">Installation</span></h3>
<div>
Install the addon in Blender in the usual way. </div>
<ul>
<li><a href="http://bit.ly/2kyxvJA" target="_blank"><b>Installation Instructions Video</b></a></li>
</ul>
<ul>
</ul>
<h3>
</h3>
<ul>
</ul>
<h3>
<span style="color: blue;"><div style="color: black; font-size: medium; font-weight: normal;">
or just do the following:</div>
<ul style="color: black; font-weight: normal;">
<li><span style="font-size: small;">File <span style="font-family: "courier new" , "courier" , monospace;">-> </span>Preferences <span style="font-family: "courier new" , "courier" , monospace;">-> </span>Addons Tab <span style="font-family: "courier new" , "courier" , monospace;">-> </span>Install from file <span style="font-family: "courier new" , "courier" , monospace;">-> </span>node_cutaway_shader.zip</span></li>
<li><span style="font-size: small;">File <span style="font-family: "courier new" , "courier" , monospace;">-> </span>Preferences <span style="font-family: "courier new" , "courier" , monospace;">-></span> File Tab <span style="font-family: "courier new" , "courier" , monospace;">-> </span>Check "Auto Run Python Scripts"</span></li>
</ul>
<div style="color: black; font-size: medium; font-weight: normal;">
<br /></div>
</span></h3>
<h3>
<span style="color: blue;">Video Tutorials</span></h3>
<h3>
<span style="color: blue;"><div style="font-size: medium;">
<ol style="color: black;">
<li style="color: black;"><a href="http://bit.ly/2kyxvJA" style="font-size: medium;" target="_blank"><span style="color: magenta;">Installation Instructions and Very Quick Overview Video</span></a><br /><span style="color: black; font-size: xx-small;"><span style="font-weight: normal;"><span style="font-weight: normal;"><span style="font-family: inherit; font-size: small;">How to download and install the addon - and a very quick intro on how to use the shader.</span></span><br /><span style="color: black; font-size: small; font-weight: normal;"> </span></span></span></li>
<li style="color: black; font-size: medium;"><a href="http://bit.ly/2kaqtdb" target="_blank">Architectural Reveal with the CutAway Shader: (YouTube link)</a><br /><span style="font-weight: normal;">Learn how to reveal the walls and furniture in a house - as seen in T.V design shows and documentaries.</span><br /><br /><span style="font-weight: normal;">This tutorial jumps right into it with a practical example - and assumes no knowledge of how to use the shader.</span><br /><span style="font-weight: normal;"> </span></li>
<li style="color: black; font-size: medium;"><a href="http://bit.ly/2kvQ1m5" target="_blank">CutAway Shader Controls: Overview Tutorial</a><br /><span style="font-weight: normal;">All the CutAway Shader controls are covered - showing what situations they're useful for and how to use them. It is assumed that the shader has already been installed.</span><br /><br /><span style="font-weight: normal;">This tutorial is really a compilation of 11 short videos (2 min to 10 min each) covering:</span></li>
</ol>
</div>
<div style="color: black; font-size: medium; font-weight: normal;">
<ul>
<li>A quick overview of the controls.</li>
<li>Setting up the CutAway Shader in your scene.</li>
<li>Adding cutaway planes.</li>
<li>Solidify and Rim Fill options.</li>
<li>Cutaway Shape: Rectangular and Circular.</li>
<li>Cutaway Shape: From Gray Scale Image.</li>
<li>Cutaway Shape: By editing the shape of the cutaway plane mesh.</li>
<li>Origin Control Buttons: To help with plane scaling and positioning.</li>
<li>Parenting Controls: Easily duplicate parent shaders to selected objects.</li>
<li>Auto and Manual Refresh: Viewport speedups.</li>
<li>Remove All CutAway Shaders button.<br /><br />Each 'mini' tutorial has a heading -- so scroll though the video to get to the desired section, or click on the quick links on the YouTube page.</li>
</ul>
</div>
<div style="color: black; font-size: medium; font-weight: normal;">
... More tutorials to follow</div>
<div style="color: black; font-size: medium; font-weight: normal;">
<br /></div>
</span></h3>
<h3>
<span style="color: blue;">How does it work? Executive summary</span></h3>
<div>
<ol>
<li>The Cutaway Shader is added as a material node to an existing Cycles material (or materials)<br /> </li>
<li>Objects in front of the 'green' side of the cutaway plane (that use the assigned materials) will be made fully or partially transparent.<br /> </li>
<li>A number of helpful controls are available to:<br />- Add the Cutaway Shader to multiple materials at once (parenting).<br />- Draw a rim at the cutaway cross section.<br />- Fadeout the cutaway edge<br />- Cutaway arbitrary shapes based on gray scale images, or the shape of the cutaway plane.<br /> ... plus many more features. (<a href="http://bit.ly/2kvQ1m5" target="_blank">Checkout this tutorial</a>)</li>
</ol>
</div>
<h3>
<span style="color: blue;">Some background info</span></h3>
<h4>
History: </h4>
<h3>
<span style="color: blue;"><div style="color: black; font-size: medium; font-weight: normal;">
After finishing the Open Shader language (OSL) Cycles Lens Flare shader a few years ago, I began experimenting with a few more OSL shader designs. The CutAway shader looked like it would be the quickest to finish (!!!) - so I continued with it.</div>
<div style="color: black; font-size: medium; font-weight: normal;">
<br /></div>
<div style="color: black; font-size: medium; font-weight: normal;">
I noticed with the previous Lens Flare shader release that many people did not know how to add the Blender drivers - these are needed to let the Lens Flare shader know the position of the sun (an 'Empty') in the scene. A custom 'py-node' in front of the Lens Flare OSL shader could have automated this task. (A Blender py-node is a node that runs Python custom code)</div>
<div style="color: black; font-size: medium; font-weight: normal;">
<br /></div>
<div style="color: black; font-size: medium; font-weight: normal;">
<a href="https://2.bp.blogspot.com/--mlEwTzKWyA/WJcpSCecXII/AAAAAAAAAIk/ZHLzk8lsXzo-umYZpU-PDMM1WraTRtoNQCLcB/s1600/CutawayShader%2Bannotated.PNG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://2.bp.blogspot.com/--mlEwTzKWyA/WJcpSCecXII/AAAAAAAAAIk/ZHLzk8lsXzo-umYZpU-PDMM1WraTRtoNQCLcB/s1600/CutawayShader%2Bannotated.PNG" /></a>For the CutAway shader release I decided to include a custom py-node to help automate many useful tasks (see figure to the right)<br />
<br />
For example, the py-node adds all required drivers automatically. These let the CutAway shader know:<br />
<br />
<ul>
<li>The position of the cutaway plane.<br /> </li>
<li>The rotation of the cutaway plane. </li>
</ul>
The custom py-node also:<br />
<br />
<ul>
<li>Colours the cutaway plane in the view port (red on one side and green on the other)<br /> </li>
<li>Provides parenting and duplication functions.</li>
</ul>
... and a lot of other things too.</div>
<div style="color: black; font-size: medium; font-weight: normal;">
<br /></div>
<div style="color: black; font-size: medium; font-weight: normal;">
This all took quite a lot of time!<br />
<br />
Even so, the bulk of the code was finished over two years ago - however, this was followed by the production of 12 demonstration video scenes and several tutorials.<br />
<br />
As I am kept very busy during the day project managing <a href="https://youtu.be/U05RUq5PSJA" target="_blank">this</a> (and like most people have a very busy home life too) this project has taken approximately 3 years to get to the alpha release stage.</div>
<div style="color: black; font-size: medium; font-weight: normal;">
<br /></div>
<div style="color: black; font-size: medium; font-weight: normal;">
<br /></div>
</span></h3>
<h3>
<span style="color: blue;">
Special Effects Use</span></h3>
<h3>
<span style="color: blue;"><div style="color: black; font-size: medium;">
<div style="font-weight: normal;">
<a href="http://bit.ly/2gIdMVO" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://2.bp.blogspot.com/-hXYgWa61im8/WJc2zMeV1JI/AAAAAAAAAJM/uVwbVmDFXCc74AZQFqcmT35DQk5MVkvRQCLcB/s1600/Cutaway%2BShader%2BGif2_320x180.gif" /></a>Initially I imagined the CutAway shader performing the obvious tasks - Model cross section cutaways, geological cutaways and architectural reveals. But I soon became excited about other uses the shader could be put to.</div>
<div style="font-weight: normal;">
<br /></div>
Special effect Revels: <span style="font-weight: normal;">The a shader can easily hide materials on one side of the 'cutaway plane' and (optionally) reveal materials on the other.</span><br />
<div style="font-weight: normal;">
<br /></div>
<div style="font-weight: normal;">
This type of effect can be seen in the <a href="http://bit.ly/2gIdMVO" target="_blank">demonstration video</a> in the following scenes:</div>
<div style="font-weight: normal;">
</div>
<ul>
<li><span style="font-weight: normal;">Winter Forest <span style="font-family: "courier new" , "courier" , monospace;">-> </span>Summer Forrest scene.</span></li>
<li><span style="font-weight: normal;">Ivy growing on statue scene.<span style="font-family: "courier new" , "courier" , monospace;"> </span></span></li>
<li><span style="font-weight: normal;">Magic stairway reveal scene.</span></li>
<li><span style="font-weight: normal;">Island forest <span style="font-family: "courier new" , "courier" , monospace;">-></span> Island city scene.</span></li>
<li><span style="font-weight: normal;">Filming through set walls (see full video)<br /> </span></li>
</ul>
<div style="font-weight: normal;">
</div>
<span style="font-weight: normal;">These 'special effect' examples can easily be extended to many additional scenarios:</span><br />
<br />
<ul>
<li><span style="font-weight: normal;">Revealing car tire tracks in the snow, or in the desert, or on a road.</span></li>
<li><span style="font-weight: normal;">Casting shadows in laser lights shining on a mist.</span></li>
<li><span style="font-weight: normal;">Animated characters 'morphing' from one costume set to another (super hero style)</span></li>
<li><span style="font-weight: normal;">Cat scan style cutaway sections.</span></li>
<li><span style="font-weight: normal;">Easily Cutting holes to let the light into a scene (without affecting the mesh or U.V wrappings)</span></li>
<li><span style="font-weight: normal;">... etc</span></li>
</ul>
<br />
<div style="font-weight: normal;">
Another interesting use for the CutAway Shader is related to the 3D pipeline work flow. The shader makes it easy to 'punch' any arbitrary shaped hole through scene elements without affecting the base mesh or U.V mapping. If a client wants to move or add an window to a scene at the last minute - none of the existing mesh or U.V work has to be re-worked. The shader will create the new hole with the desired shape and additional geometry (or existing windows etc) can be moved into place.</div>
<div style="font-weight: normal;">
<br /></div>
<div style="font-weight: normal;">
If the pipeline involves mesh assets the are frozen (or scene dressings that are locked) then the shader offers a new method of hiding (cutting away) assets that are blocking the camera view. This can be achieved without actually moving assets or redressing the scene.</div>
<div style="font-weight: normal;">
<br /></div>
<div style="font-weight: normal;">
This concept extends to 'filming' through set walls - without affecting a set's internal lighting setup, as the shader can be configured to only cutaway 'camera rays'. (i.e. we can look through 'solid' walls without light leaking into or out of the set!)<br />
<br />
Filming through sets can be useful for when the desired framing and depth of field results in a lens size that forces the camera to be placed outside the walls of a small set (e.g. a small bedroom, or small space capsule).</div>
<div style="font-weight: normal;">
<br /></div>
<div style="font-weight: normal;">
So, the possibilities for the Cutaway Shader are surprisingly large for such a simple concept!</div>
<div style="font-weight: normal;">
<br /></div>
<div style="font-weight: normal;">
Give it a try!</div>
<div style="font-weight: normal;">
<br /></div>
<div style="font-weight: normal;">
<span style="font-weight: normal;">Let me know what you think in the comments below - or e.mail: </span>iReboot42 at gmail dot com.</div>
</div>
</span></h3>
Please note:<br />
<br />
<ul>
<li>This is an alpha release - so please save your work first. </li>
<li>There are a few 'non-standard' features related to the parenting controls of the shader, These allow the CutAway Shader node to be automatically replicated among selected objects in the scene. Child copies of the parent node are added to the material nodes of selected objects (i.e this feature will alter material nodes in your scene).</li>
</ul>
<h3>
<span style="color: blue;">Future Work</span></h3>
<div>
There are many features that could be added to the shader - along with some optimisations. I would like to look at micro displacement of shaded points in the drawn 'rim' to improve this effect.<br />
<br />
Cheers<br />
<br />
Dylan</div>
iReboothttp://www.blogger.com/profile/06641590596635834490noreply@blogger.com28tag:blogger.com,1999:blog-8575138308625785304.post-37054040401386573222013-06-13T07:27:00.002-07:002013-06-13T07:27:14.435-07:00<h2>
<span style="color: blue;">LensFlare Tutorial Part 3 of 4: Blender Lens Flare: Automatic Masking </span></h2>
<div>
<span style="color: blue;"><br /></span></div>
<div>
I have just posted a new tutorial on how to achieve automated masking of the lens flare using Blenders compositor.</div>
<div>
<br /></div>
<div>
Automated masking of lens flares can be very useful for complex scenes -- such as in a forrest - where many randomly placed branches may block a lens flare.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-eOqHbalrVvE/UbnWZq6DPAI/AAAAAAAAAGs/WNfLum_dDMk/s1600/0021.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="360" src="http://1.bp.blogspot.com/-eOqHbalrVvE/UbnWZq6DPAI/AAAAAAAAAGs/WNfLum_dDMk/s640/0021.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<b><u><span style="color: blue;">Here is an introduction animation showing the automated masking in action:</span></u></b></div>
<div>
<b><u><br /></u></b></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/s0k6vbWmhO0?feature=player_embedded' frameborder='0'></iframe></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<b><u><span style="color: blue;">Here is the tutorial.</span></u></b></div>
<div>
<br /></div>
<div>
It's a little long - weighing in at just over 60mins -- but it has been put together to allow a non-expert to create a scene using the lens flare shader from scratch. Links in the info section below the video allow advanced users to skip ahead.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/2leKfFhsa6o?feature=player_embedded' frameborder='0'></iframe></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<b><u><span style="color: blue;">Here's the Automated Masking Node Setup</span></u></b></div>
<div>
<br /></div>
<div>
The actual node set up is reasonably simple - as can be seen from the noodle below.</div>
<div>
The general idea works as follows:</div>
<div>
<ol>
<li>Solid 3D objects in the scene that should block a lens flare are given a Pass Index.<br />The IndexOB render-pass is enabled in the RenderLayer(s) for these objects.<br /></li>
<li>A small emission source (e.g an icosphere) is placed on it's own RenderLayer.<br />The emission source is parented to the empty that defines the position of the lens flare bloom.<br /></li>
<li>The emission source output image, from its RenderLayer is Multiplied by the output of an IDMask. The IDMask index is set to match the Pass Index from above.<br /><br />a) Flare Blocked: When the emission source is behind a 'solid' 3D objects (white) mask -- then its bright white image passes through the Multiply node. (i.e. 1 x 1 = 1 = small white dot)<br /><br />b) Flare Not Blocked: If he emission source is not behind a white mask -- then it does not appear at the out put of the Multiply node. (i.e. 1 x 0 = 0 = totally black image)<br /></li>
<li>The output of the Multiply node is fed into a Dilate node. This will turn the small white dot from 3a into a fully white image that is the size of the render image.<br /><br />a) Flare Blocked: Output = fully white image.<br />b) Flare not Blocked: Output = fully black image.<br /><br />(In earlier version of this noodle - various blur functions were used to spread the dot 'gating signal' to cover the whole image.<br /></li>
<li>The output of the Dilate node is inverted.<br /><br />a) Flare Blocked: Output = fully black image.<br />b) Flare not Blocked: Output = fully white image.<br /><br />Hence this signal can be fed directly to the Fac input off the ADD color mixer that mixes the output from the lens flare render layer with the output from the general 3D scene render layer.</li>
</ol>
</div>
<div>
<br /></div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-CIQTApDl5BY/UbnK_dUTf1I/AAAAAAAAAGc/Ki4ojwSDEBY/s1600/automated+lensflare+masking.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="390" src="http://4.bp.blogspot.com/-CIQTApDl5BY/UbnK_dUTf1I/AAAAAAAAAGc/Ki4ojwSDEBY/s640/automated+lensflare+masking.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Automated Lens Flare Masking Node Setup (click to enlarge)</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
The main reason that the video is so long is that it takes a while to go through the steps (for newer users) that allow all the render layers to be setup and the drivers to be added to the shaders.</div>
<div>
<br /></div>
<div>
There are many more way's to achieve this automated masking effect I'm sure - so it will be interesting to see what people come up with.</div>
<div>
<br /></div>
<div>
This latest invocation is fair;y simple -- and very fast. It does appear to be very 'binary' however. It mostly seems to block - or not block.<br /><br />Some of the earlers methods that used blur nodes etc were very good at quickly 'fading out' the lens flare as it passed behind objects (such as tree branches or plane wings).</div>
<div>
<br /></div>
<div>
Some tuning can be made with the masking sensitivity however by changing the emission brightness of the source (as seen in the video).</div>
<div>
<br /></div>
<div>
<b><u><span style="color: blue;">Draw Backs</span></u></b></div>
<div>
<b><u><br /></u></b></div>
<div>
The compositing method as described above has a key drawback in that once the lens flare bloom moves off the screen (along with its special masking emission source), the compositor can no longer be used to manage the masking -- as it cannot process off screen images.</div>
<div>
<br /></div>
<div>
There are work around for this - such as adding another special emission light source on the 'Masking' Render layer that can be 'keyed' by hand to get the flare into the desired visible state. The lens flare shader's Intensity input itself may also be 'keyed' in this case.</div>
<div>
<br /></div>
<div>
<b><u><span style="color: blue;">The Future</span></u></b></div>
<div>
<b><u><span style="color: blue;"><br /></span></u></b></div>
<div>
I would like to investigate the use of the OSL 'trace' function to determine if any 3D scene objects are occluding the ray from the camera to the 'light source'. I did try this when porting/developing the shader - but without initial success. It <i>should</i> be possible though - so hopefilly in the future -- extra compositing nodes and render layers will not be required.</div>
<div>
<br /></div>
<div>
Until then however -- this nifty trick seems to work well.</div>
<div>
<br /></div>
<div>
Also in the future - it would be good to see if a Python add on, or a Pynode, could be used to automate the set up of the lens flare render layers camera plane creation and parenting. Again -- this should be quite do-able - but will have to wait for some development time ;-)</div>
iReboothttp://www.blogger.com/profile/06641590596635834490noreply@blogger.com0tag:blogger.com,1999:blog-8575138308625785304.post-49511362901381006522013-05-20T10:34:00.000-07:002013-05-24T16:55:20.918-07:00<div>
<br /></div>
<h2>
<span style="color: blue; font-size: large;">Lens-flare Shader for Blender Cycles with real time preview</span></h2>
<div>
I have been using Blender for several years and have recently started to learn OSL - Open Shader Language.<br />
<br />
As a first project I embarked upon creating a lens-flare shader for Blender. In the process I came across a lens-flare shader, written for the Renderman language by <a href="http://www.larrygritz.com/arman/shaders/lensflare.sl" target="_blank">Larry Gritz & Tony Apodaca</a>.<br />
<br />
I decided to try and port this to OSL - and to my surprise after a day of tinkering it worked! Along the way I added a few features, such as user definable images for lens-flare elements and have got to a point where the shader can now be released. Details about how to download and use this shader are given below - along with video tutorial links.<br />
<br />
<br />
Before proceeding, a big thanks to the original authors of the shader, Larry Gritz for his work in making the Open Shader Language available to the world and the Blender developers for creating such a great tool.<br />
<br />
In the process of learning OSL (an on-going process) I found the following blogs / links extremely helpful.<br />
<ul>
<li><a href="http://www.openshading.com/" target="_blank">Open Shading</a> web site by Thomas Dinges.<br />A great way to learn how to start with OSL and Blender.</li>
<li><a href="http://blenderthings.blogspot.com.au/" target="_blank">Small Blender Things</a> - a fantastic site for OSL code implemented for Blender.</li>
<li><a href="https://github.com/imageworks/OpenShadingLanguage/blob/master/src/doc/osl-languagespec.pdf" target="_blank">The Open Shading Language Specification</a>. An essential tool.</li>
</ul>
<br /></div>
<div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-D4yUvkfboag/UZoybXr_PkI/AAAAAAAAAFk/dZRbq50kWGs/s1600/Blender+Screen+Capture.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="343" src="http://3.bp.blogspot.com/-D4yUvkfboag/UZoybXr_PkI/AAAAAAAAAFk/dZRbq50kWGs/s1600/Blender+Screen+Capture.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Screenshot showing the lens- flare shader node set up, real time 3D preview, and positioning control.<br />
Drivers are used to link the position control Empty to the shaders "LightPosition" input.</td></tr>
</tbody></table>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<h3>
<span style="color: blue; font-size: small;"><u>Lens-flare Shader Features:</u></span></h3>
<ul>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Real time 3D viewport preview.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Shader output may be connected directly to a Material's "Surface" </span><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">node connection (easy node setup).</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Lens-flare light source position co-ordinates may be set by the user.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Highly customisable Bloom, Starburst, Rainbow, Disk, RIng,Blot and Hole elements.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Number of spots, and the distribution of spot type, may be varied by the user.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Optional user definable images for all lens-flare elements (new feature).</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Full control to mix between synthesised lens-flare and user image based lens flare.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Lens flare elements may be drawn in GIMP - Photoshop - Downloaded - or other.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Easy color tinting.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Simple random color variation user settings.</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">Automatic or user definable aspect ratio setting (e.g. for anamorphic lens-flare).</span></li>
<li><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">An Extensive selection of Color outputs allow all of the lens flare elements </span><span style="background-color: #f6f6f6; color: #333333; font-family: arial, sans-serif; font-size: 13px; line-height: 17px;">to be further proceed in the node editor if desired.</span></li>
</ul>
<br />
<h3>
<span style="color: blue; font-size: small;"><u><b>Shader Set up:</b></u></span></h3>
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-nKnjoAKTnWg/UZo1MgAdj0I/AAAAAAAAAF8/6nGKE14vKRk/s1600/setup.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="235" src="http://1.bp.blogspot.com/-nKnjoAKTnWg/UZo1MgAdj0I/AAAAAAAAAF8/6nGKE14vKRk/s1600/setup.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The lens-flare is created by applying the shader to a plane<br />
parented in front of the camera. An "Empty" is used to define the <br />
position of the flare's light source.</td></tr>
</tbody></table>
<div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-bNgtCVOv6eY/UZoyes2Fk9I/AAAAAAAAAFs/Q6VaEwFnH1U/s1600/Shader+Capture.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="640" src="http://1.bp.blogspot.com/-bNgtCVOv6eY/UZoyes2Fk9I/AAAAAAAAAFs/Q6VaEwFnH1U/s1600/Shader+Capture.png" width="404" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The image above shows the simple shader node set up <br />
for the lens-flare plane material. The "Light Source Empty" position is fed to the <br />
shader using Drivers to set the x,y and z inputs of Value nodes.</td></tr>
</tbody></table>
</div>
<div>
<h3>
<b><span style="color: blue; font-size: small;"><u>Video Tutorials</u></span></b></h3>
Two of the planned four tutorial videos have been completed. Follow the links to see an overview of the lens-flare shader features - anda tutorial on how to set up a scene with this shader.<br />
<ul>
<li><a href="http://youtu.be/Whbq8H6Ltvk" target="_blank">LensFlare Tutorial Part 1 of 4: Blender Real TIme Lens Flare Shader Introduction. </a></li>
<li><a href="http://youtu.be/mf69t-hKxVk" target="_blank">LensFlare Tutorial: Part 2 of 4: How To Set Up a LensFlare Shader in Blender.</a></li>
</ul>
Part's 2 and 4 are yet to be completed - but will go over additional composition features - such as automated masking of the flare as it passes behind objects. (Download the .blend file or look at the node 'noodle' below if you want to try this before the videos are completed).<br />
<h3>
<span style="color: blue; font-size: small;"><u>Download an Example Blend file and LensFlare Shader File (lensflare1v1.osl) </u></span></h3>
<div>
An example .blend file with an:</div>
<div>
<ul>
<li>Example scene</li>
<li>lensflare1v1.osl shader </li>
<li>Sample user defined shader textures</li>
<li>Masking composite node setup</li>
</ul>
<div>
is available from <a href="http://www.blendswap.com/blends/view/68257" target="_blank">Blendswap here.</a></div>
</div>
<div>
<br />
<h3>
<span style="color: blue; font-size: small;"><u>Blender Artists Link</u></span></h3>
<br />
<ul>
<li><a href="http://blenderartists.org/forum/showthread.php?292861-Lens-flare-Shader-for-Cycles-with-real-time-preview" target="_blank">There is a lens-flare BA thread here</a></li>
</ul>
<div>
<br /></div>
</div>
<h3>
<span style="color: blue; font-size: small;"><u>Get a copy of the Shader here!</u></span></h3>
<ul>
<li>Download a copy of the code below as <b>lensflare1v1.osl</b> - and save into the same directory as your .blend file.</li>
<li>Load the file as a script in the materials node editor - and connect directly to the Material output node of a plane parented to the front of a camera. Follow the video tutorials for more information.</li>
</ul>
<div>
<br /></div>
<div>
<br /></div>
<script src="https://gist.github.com/iReboot/d4f4769bffdba082075a.js"></script>
<br />
<div>
<br /></div>
<div>
<h3>
<span style="color: blue; font-size: small;"><u>Automated masking of the flare</u></span> </h3>
</div>
<div>
This is the subject of an upcoming video - however if you want the Node<br />
Noodle - either download the .blend file from Blendswap (see above) or copy the node setting below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-oYnWWCT9K1E/UZpd9q2IShI/AAAAAAAAAGM/B2a53rndZtQ/s1600/noodle.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-oYnWWCT9K1E/UZpd9q2IShI/AAAAAAAAAGM/B2a53rndZtQ/s1600/noodle.png" /></a></div>
<br />
<br />
Note: An additional lensflare plane with its own shader is needed in front of the camera for this to work)</div>
<div>
<br /></div>
<div>
<h3>
<span style="color: blue; font-size: small;"><u>Finally</u></span></h3>
</div>
</div>
I hope to see your example scenes and tutorials on the web :-)iReboothttp://www.blogger.com/profile/06641590596635834490noreply@blogger.com6