<div dir="ltr"><div><div><div>If someone cares I manage to get cubemap capturing to work inside blender&#39;s viewport.<br><br><a href="http://blenderartists.org/forum/showthread.php?343278-GLSL-PBR-Shader-for-viewport&amp;p=3025302&amp;viewfull=1#post3025302">http://blenderartists.org/forum/showthread.php?343278-GLSL-PBR-Shader-for-viewport&amp;p=3025302&amp;viewfull=1#post3025302</a><br><br></div>If someone more experienced than me want take a look to my code and tell me if i&#39;m going wrong in some areas I would be very graful.<br><br></div>I don&#39;t have any diff file for now but I have a github : <a href="https://github.com/Hypersomniac/blender-shader">https://github.com/Hypersomniac/blender-shader</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-01-29 2:06 GMT+01:00 Brecht Van Lommel <span dir="ltr">&lt;<a href="mailto:brechtvanlommel@pandora.be" target="_blank">brechtvanlommel@pandora.be</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Clément,<br>
<br>
Thanks for you insights. It&#39;s a great overview of the trade-offs of<br>
the various methods.<br>
<br>
I agree about deferred shading, it adds limitations for artists in the<br>
shaders and lighting they can create, and it really would be a very<br>
different rendering system. It may give better performance for games,<br>
but for use cases like realtime rendered short movies (e.g. Glass<br>
Half) or Cycles previews it&#39;s not so great. There&#39;s more important<br>
things to solve before complexifying the system with deferred shading.<br>
<span class="HOEnZb"><font color="#888888"><br>
Brecht.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Fri, Jan 29, 2016 at 12:55 AM, Clément FOUCAULT<br>
&lt;<a href="mailto:foucault.clem@gmail.com">foucault.clem@gmail.com</a>&gt; wrote:<br>
&gt; About the ubershader :<br>
&gt; I don&#39;t think it&#39;s easier. The current viewport rendering is done in forward<br>
&gt; Shading and is already built to allow a wide variety of shaders. That&#39;s why<br>
&gt; my build exists. Because it was &quot;easy&quot;.<br>
&gt; Making the viewport works in deferred shading should imply another render<br>
&gt; &quot;engine&quot; (i&#39;m talking about the drop down menu on the top header) as the<br>
&gt; limitations of such method is not compatible with previewing cycles<br>
&gt; materials. It&#39;s not easier. It would be just faster to render with complex<br>
&gt; materials (but these materials are subject to limitations).<br>
&gt;<br>
&gt; Clément<br>
&gt;<br>
&gt;<br>
&gt; 2016-01-28 23:49 GMT+01:00 Hadrien Brissaud &lt;<a href="mailto:hadriscus@gmail.com">hadriscus@gmail.com</a>&gt;:<br>
&gt;&gt;<br>
&gt;&gt; Just my two cents : from a user pov having a monolithic ubershader for<br>
&gt;&gt; viewport seems fine, probably covers most uses and you make it sound like<br>
&gt;&gt; it&#39;s way easier to make. Now my use case is more like having a nice preview<br>
&gt;&gt; of actual cycles shaders (ie not necessarily super-accurate) rather than a<br>
&gt;&gt; full fledged cryengine, maybe not everyone is in the same boat.<br>
&gt;&gt;<br>
&gt;&gt; By the way thanks a lot Clément for contributing.<br>
&gt;&gt;<br>
&gt;&gt; Hadrien<br>
&gt;&gt;<br>
&gt;&gt; On 28 January 2016 at 23:37, Clément FOUCAULT &lt;<a href="mailto:foucault.clem@gmail.com">foucault.clem@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi Ton,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I don&#39;t have a design doc but I can share some thoughts about what I read<br>
&gt;&gt;&gt; on this mailing list.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Please note I am not feeling very familiar with all concepts below and I<br>
&gt;&gt;&gt; can really be misleaded. I am a 3D artist before being a coder.<br>
&gt;&gt;&gt; Also please note that I&#39;m primarily focusing on the viewport and not the<br>
&gt;&gt;&gt; game engine.<br>
&gt;&gt;&gt; Some of my notes have already been expressed by other participants.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; About deferred shading :<br>
&gt;&gt;&gt; I think it&#39;s a bad idea overall.<br>
&gt;&gt;&gt; Why? Because of the multitude and flexibility of blender&#39;s node setups we<br>
&gt;&gt;&gt; can have all sorts of bsdf inside one shader and thus having a lot of<br>
&gt;&gt;&gt; parameters.<br>
&gt;&gt;&gt; In fact the number of parameters is not fixed and we cannot pass this to<br>
&gt;&gt;&gt; the shading step unless using a gigantic G-buffer.<br>
&gt;&gt;&gt; So deferred shading would be nice ONLY if we have a static &quot;ubershader&quot;<br>
&gt;&gt;&gt; like unreal with consistent inputs. But that would mean subtracting<br>
&gt;&gt;&gt; features.<br>
&gt;&gt;&gt; Even Epic is reluctant to add anisotropic shaders because of the cost of<br>
&gt;&gt;&gt; another parameter inside the G-buffer.<br>
&gt;&gt;&gt; I know we could support both and switch between the one that fits better<br>
&gt;&gt;&gt; to the task. But in the short run I think we should try to focus only on one<br>
&gt;&gt;&gt; of these.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; About light probes :<br>
&gt;&gt;&gt; Needs to be HDR (kinda obvious). Needs to be dynamic (rendered from<br>
&gt;&gt;&gt; opengl) if not it wont be worth it to user to spend time to hit a render<br>
&gt;&gt;&gt; button and wait at least 30secs for a preview.<br>
&gt;&gt;&gt; Pre-convolving (baking) the bsdf to the cubemap can be slow even for the<br>
&gt;&gt;&gt; gpu (500ms for a 64px cubemap with diffuse brdf with average gpu). So I<br>
&gt;&gt;&gt; would prefer to have this as an option.<br>
&gt;&gt;&gt; Also we can&#39;t convolve for each Bsdf that would mean a lot of cubemaps.<br>
&gt;&gt;&gt; As I said previously, I&#39;m in favor a global cubemap which would be the<br>
&gt;&gt;&gt; result of the world node tree. This one is applied by default to all<br>
&gt;&gt;&gt; materials / objects.<br>
&gt;&gt;&gt; Then similarly to the blender internal envmap texture, we could specify a<br>
&gt;&gt;&gt; viewpoint for the object cubemap.<br>
&gt;&gt;&gt; To get accurate reflection Epic Unreal Engine correct the ray casting<br>
&gt;&gt;&gt; (who sample the cubemap) to fit a volume sphere or box. This would be useful<br>
&gt;&gt;&gt; for indoor scenes.<br>
&gt;&gt;&gt; As of now, in my branch I use Importance sampling (<br>
&gt;&gt;&gt; <a href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html" rel="noreferrer" target="_blank">http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html</a> ) because it<br>
&gt;&gt;&gt; does not need to precompute anything.<br>
&gt;&gt;&gt; The number of samples could be exposed to the user to get the most<br>
&gt;&gt;&gt; accurate reflections for render, or to lower the samples for performance<br>
&gt;&gt;&gt; reason.<br>
&gt;&gt;&gt; For diffusion i&#39;m using spherical harmonics.<br>
&gt;&gt;&gt; <a href="https://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/" rel="noreferrer" target="_blank">https://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/</a><br>
&gt;&gt;&gt; Computing them depends on the size of the map as it read each texel and<br>
&gt;&gt;&gt; the type of mapping. But it&#39;s fairly quick and require only 1sec for a<br>
&gt;&gt;&gt; 2000x1000px equirectangular envmap.<br>
&gt;&gt;&gt; Any kind of (lengthy) pre-computation should not freeze blender&#39;s UI.<br>
&gt;&gt;&gt; Pretty much like the renderers do.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; About lamps :<br>
&gt;&gt;&gt; I&#39;m already using epic&#39;s approach of area lights.<br>
&gt;&gt;&gt; Using tube lights for area (rectangular) lights as I was not able to find<br>
&gt;&gt;&gt; a correct algorithm for them.<br>
&gt;&gt;&gt; But energy conservation is not perfect for this solution and does not<br>
&gt;&gt;&gt; quite match cycles at grazing angles.<br>
&gt;&gt;&gt; We could use this paper <a href="https://www.youtube.com/watch?v=O3TG1VXx1tg" rel="noreferrer" target="_blank">https://www.youtube.com/watch?v=O3TG1VXx1tg</a> but I<br>
&gt;&gt;&gt; highly doubt the computational cost is worth it.<br>
&gt;&gt;&gt; Another technique is by Michael Drobot inside GPU Pro 5. But I did not<br>
&gt;&gt;&gt; have much success with it.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; About aligning on UE4 :<br>
&gt;&gt;&gt; Their implementation of PBR is already doable inside cycles.<br>
&gt;&gt;&gt; They just use baking to do less calculation at runtime.<br>
&gt;&gt;&gt; My branch is already using a lot of their maners.<br>
&gt;&gt;&gt; Supporting cycles shaders implies supporting UE4 shaders.<br>
&gt;&gt;&gt; If you want to talk about rendering pipeline that&#39;s another topic.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; About viewport framebuffer:<br>
&gt;&gt;&gt; We need a float framebuffer for a lots of effects. Like bloom,<br>
&gt;&gt;&gt; tone/colormapping, Quality dof.<br>
&gt;&gt;&gt; You could also render quick passes with float informations (like Z depth<br>
&gt;&gt;&gt; or world normal for instance) instead of doing a slow cycle pass.<br>
&gt;&gt;&gt; I suggested a R10_G11_B11 format but that means having a separate alpha<br>
&gt;&gt;&gt; buffer.<br>
&gt;&gt;&gt; To have a &quot;correct shading&quot;, with only the indirect light being<br>
&gt;&gt;&gt; multiplied by ambiant occlusion, we need to separate the direct light from<br>
&gt;&gt;&gt; the indirect lighting.<br>
&gt;&gt;&gt; That would mean another float buffer unfortunately.<br>
&gt;&gt;&gt; Maybe there is a way to encode everything inside a big 64bit buffer with<br>
&gt;&gt;&gt; alpha but it can get a bit complicated.<br>
&gt;&gt;&gt; I&#39;ve seen people doing these kind of things but I&#39;m not completely sure<br>
&gt;&gt;&gt; if it&#39;s worth it.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; RGBA16    R16   G16   B16   A16<br>
&gt;&gt;&gt; Direct    8bits 8bits 8bits 4bits -&gt; R9G10B9<br>
&gt;&gt;&gt; Indirect  8bits 8bits 8bits 4bits -&gt; R9G10B9<br>
&gt;&gt;&gt; Alpha     -     -     -     8bits<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I don&#39;t know if these extra bits could be enough.<br>
&gt;&gt;&gt; Also not to forget the depth buffer.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;d really like to also see ScreenSpaceLocalReflection inside the<br>
&gt;&gt;&gt; viewport but this means to have a mean to tag relevant area of the<br>
&gt;&gt;&gt; frame-buffer to blend with a reflection buffer.<br>
&gt;&gt;&gt; And it should overwrite only the indirect specular (envmap), that means<br>
&gt;&gt;&gt; basically splitting up the color buffer again and it can get pretty far.<br>
&gt;&gt;&gt; So i&#39;m not positive on this. But if someone has an idea about this that<br>
&gt;&gt;&gt; would be cool.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I can populate some design docs (at least try I&#39;ve) but as I mention<br>
&gt;&gt;&gt; earlier i&#39;m not familiar with all the opengl drawing methods and how blender<br>
&gt;&gt;&gt; handles it.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;ll be around IRC when I will have more time. I&#39;m starting a job Monday<br>
&gt;&gt;&gt; so it won&#39;t be easy for me.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I hope we can decide where to go and help each others.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thank you for your interest.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; Bf-viewport mailing list<br>
&gt;&gt;&gt; <a href="mailto:Bf-viewport@blender.org">Bf-viewport@blender.org</a><br>
&gt;&gt;&gt; <a href="http://lists.blender.org/mailman/listinfo/bf-viewport" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-viewport</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Bf-viewport mailing list<br>
&gt;&gt; <a href="mailto:Bf-viewport@blender.org">Bf-viewport@blender.org</a><br>
&gt;&gt; <a href="http://lists.blender.org/mailman/listinfo/bf-viewport" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-viewport</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Bf-viewport mailing list<br>
&gt; <a href="mailto:Bf-viewport@blender.org">Bf-viewport@blender.org</a><br>
&gt; <a href="http://lists.blender.org/mailman/listinfo/bf-viewport" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-viewport</a><br>
&gt;<br>
_______________________________________________<br>
Bf-viewport mailing list<br>
<a href="mailto:Bf-viewport@blender.org">Bf-viewport@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-viewport" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-viewport</a><br>
</div></div></blockquote></div><br></div>