[MAYA] My ShaderFx Uber Shader v2

triangle
Offline / Send Message
brurpo triangle
Hi folks! Decided to redo my pbr shader from the ground up following a metallness workflow.

There will be two versions, one with all parameters textures separated, and one that uses each channel of a single texture.

Also simplified a lot of things, one of them is that you no longer need a checkbox to use a texture.

This way the shader is much simpler to operate:



Another thing that I've been working on... area lights!





And its possible to mix any type of light, as far as your hardware can handle:



There are some stabilty issues that I still need to figure out. For example when adding an area light that light will flick until you change its intensity or position or refresh the viewport.

Also, I wish I could light loop a shadow map inside a custom code :(

PCF and PCSS are 4x and 16x, respectivelly, slower than calculating them in a custom code. But its impossible to loop it for all lights, just light 0.

Still need to sort opacity and translucency, as soon as I fix those things I will star releasing the shader.

Thanks!

Replies

  • shaderfx
    Offline / Send Message
    shaderfx polycounter lvl 8
    This is really awesome!
    Can't wait to try it out.
  • brurpo
    Offline / Send Message
    brurpo triangle
    Thanks Kees!

    The area light is made using a spot light because its the only light that has a rotate-able light view prj.

    So I can create an area by offsetting its position left and right, up and down with a transposed light view prj.

    None of the other lights rotate the projection on the z axis. As I control the bias inside the shader I differentiate normal spots from area spots by increasing its bias past its default value. Then the area with its cone angle and penumbra linked with a plane scale x/y. Then made a .mb from it, to add more are lights you only need to import this project, again and again.

    Yes... I know, pretty ugly.

    I noticed that shaderfx interprets maya's area light as a point light placed in that area light vertex 0 (its view prj also does not rotate).

    I guess that there is no way to get that area light vertices position right?

    Also, no way to loop the shadow map inside a custom code?

    I tryed to loop it manually, but the light index is an "int value" and no way to create an array of it and increment it in a loop, just normal ints.

    All light nodes loop normally inside a custom code (light direction, vector, etc). But shadow maps create a variable that is not found during compile, something like BBB_BBB_blablabla. If I manually assign it a light index it works normally, but only for that index.

    Sorry for all the question bombardment, again,  o:)
  • shaderfx
    Offline / Send Message
    shaderfx polycounter lvl 8
    Shadow Map:
    Can you give a code example of the shadowmap issue?
    I don't completely understand what is happening for you.
    There shouldn't be anything generated that is not available during compile time, but I might be misunderstanding the issue.

    We use shadowmap information directly also in for example the AutodeskUberShader.fx that you can load into the DX11ShaderNode.


    Area lights:
    For area lights, it might be that the Maya viewport api is not giving this information to shader plugins (like ShaderFX). I don't think I do anything specifically different for area lights in the code.

    I query the Maya API for all the light information is has, such as direction, color, etc. Whatever the API gives me, I try to bind inside the shader.

    It is possible the API doesn't provide this information for area lights.
    (It is also possible I did something wrong, of course)






  • brurpo
    Offline / Send Message
    brurpo triangle
    Thanks for your time kees! I love you!

    About the shadow map, I did a very simple custom code to show you what happens.



    As you can see by the node preview, the custom code compiles normally (float3 shadMap = SFX_TEXTURE0.Sample(SFX_SAMPLER0, uv);), but as soon as you connect it to a light loop, it throws an error: undeclared identifier "_LightShadowMap".


    And the area light:



    As you can see, it emmits a light from one of the area light vertices, not the center, that makes me think that somehow maya  API is giving you this vertex information and hoped it would be possible to query the rest, so I wouldnt need to fake it with a projection and do all those ugly things with a spot light.

    Again, thanks a lot Kees! =)
  • blukazs
    Offline / Send Message
    blukazs polycounter lvl 2
    Looks neat, can we test it? AreaLights + ScreenSpace Reflections would be the total killer :D
  • brurpo
    Offline / Send Message
    brurpo triangle
    Thanks!! Soon =)
    Unfortunately its not possible to make screen space effects such as SSR, as we dont have access to the frame buffer in shaderfx. I really wish we did =(
  • blukazs
    Offline / Send Message
    blukazs polycounter lvl 2
    brurpo said:
    Thanks!! Soon =)
    Unfortunately its not possible to make screen space effects such as SSR, as we dont have access to the frame buffer in shaderfx. I really wish we did =(
    :( What about a "Flat Mirror" shader that just flips the scene in 3d like its done in MotionBuilder? Are you able to control the shadowmap resolution? Looks like the maya native tools lock it to 4k :/ Would be great to get a "Adam" level of quality with Your shader :>
  • brurpo
    Offline / Send Message
    brurpo triangle
    Unfortunately, you also need the frame buffer to do that. Shaderfx is unaware of other objects in your scene beside the one its applyed to nor the frame buffer (nor other full screen passes for the matter, like a normal pass which also is needed to make reflections, refractions etc).

    Also not. ShadowMap is generated by maya and passed to shaderfx through the API. The resolution is locked to a max of 4096. We can do some smart filtering but thats all. Also it encompass the entire scene. So the larger the scene, larger is the area that the 4096 map needs to cover so you lose more and more shadow detail.

    Game engines generates multiple shadowmaps to remedy this. Techniques like Cascaded Shadow Maps or Parallel-Split, (asked autodesk for it if you want you can vote for it here). It works, for example, by using 4 shadow maps, a 4096, a 2048, a 1024 and a 512, using them according to the camera distance and blending between them keeping objects close to the camera with a good ammount of shadow detail. There is also raytraced shadows which can be generated very quickly in modern graphics cards that has full detail on the entire scene (but needs to be blended with PCSS for soft shadows).

    I plan to make plugins to maya API to generate these shadow maps and hopefully screen space effects. But thats very complex and I need to study it a lot. Also it needs to be done for each version of maya and that requires a lot of time, something I dont have :( So dont expect it very soon.

    Having this kind of features on the viewport would be amazing, both for pre-viz, quick prototyping and asset testing without needing to resort to marmoset or exporting to a game engine and even production, which would be so very awesome, but its not autodesk priority, the best we can do is make some noise and let them know we want that (in the end, its not a complex thing for them to do).
  • blukazs
    Offline / Send Message
    blukazs polycounter lvl 2
    @brurpo Thank You for the explanation! :) I've voted for it. Maybe they integrate stingray into maya and we'll get all the toys plus realtime GI :D For now can't wait to check your area lights :>
  • jlahham
    Offline / Send Message
    jlahham null
    Hey guys,
    I'm reaching out to almost everyone here .. I'm new to the site and I'm a CG animator looking to make a short film utilizing viewport 2.0 and the ShaderFx instead of going the full render path..it's a personal short film, and I'd love to keep the cost to a minimum... do you know of any site/service where I can buy/download ShaderFx shader libraries?
    Thank you
  • brurpo
    Offline / Send Message
    brurpo triangle
    Hi there, you can check shaderFx and  Kodde's site.
  • jlahham
    Offline / Send Message
    jlahham null
    brurpo said:
    Hi there, you can check shaderFx and  Kodde's site.
    Thank you for the pointers... another quick question... How beneficial it is for me to use the ShaderFx over the Hypershade? especially that my final output is simply a playblast out of Maya? Couldn't I practically do everything I need in Hypershade?

    Thank you
  • brurpo
    Offline / Send Message
    brurpo triangle
    No problems!
    No, shaderFx is visual programming, much more powerful then mayas viewport.

    You can create custom techniques and do lots of things that are impossible via hypershade. Things like custom shadow filtering, blending normals, blur maps, create your own procedurals and even raymarching, etc.

    Also, hypershading in the viewport will quickly become slow as hell. Maya need to actually convert everything you do in hypershade to a realtime shader and as your graph increases (like 5 nodes) maya will bend to its knees, and every update will take forever.
  • blukazs
    Offline / Send Message
    blukazs polycounter lvl 2
    I have another question, slightly off-topic, but you're the smart guy here @brurpo : D
    I assume it's not easy / possible 'cause otherwise somebody would probably already do it XD
    Is it possible to create realtime fish-eye camera distortion in realtime inside the viewport? Like PlayblastVR does? Would You be able to implement it and how much time/money would it cost ?:D
  • brurpo
    Offline / Send Message
    brurpo triangle
    Everything is possible, guerilla games put their entire engine in maya's viewport.

    Link! Check out the seventh item, "Demo: Autodesk Maya in-Engine viewport".

    Using shaderfx its the same problem as before, no framebuffer, no full screen effects.

    So you would need to go the API route, and that is beyond me, for now at least.
  • blukazs
    Offline / Send Message
    blukazs polycounter lvl 2
    OMFG Thank You, I'll have to watch the whole thing home! Thanks again for the info!
  • brurpo
    Offline / Send Message
    brurpo triangle
    HAha! No problems!

    Here is an update on the shader.


  • brurpo
    Offline / Send Message
    brurpo triangle
    Some more progress and tests. 
  • brurpo
    Offline / Send Message
    brurpo triangle
    Hey Kees! Sorry to bother, but I was checking maya docs and saw that dx11ShaderNode and GLSLShaderNode has the some uniform parameters.

    One of them is the following.

    AreaPosition0-3

              float3/4 (dx11Shader)

              vec3/4 (glslShader)

     

              Position for the four corners of an area light.


    Is it possible to query this in shaderFx, maybe inside a custom code perhaps??

    Thanks!
  • jlahham
    Offline / Send Message
    jlahham null
    Hey @brurpo will any of these shaders be available for download and testing?
  • brurpo
    Offline / Send Message
    brurpo triangle
    Very soon! Hopefully after next week. I am also preparing a mel toolbox for lots of usefull things, like exposure and environment replacement. Work is a caos and I am with a crazy freelance job on the side for comic-con, 4 days without sleep. But it should be all over next week.
  • jlahham
    Offline / Send Message
    jlahham null
    Thanks man...Good luck
  • brurpo
    Offline / Send Message
    brurpo triangle
    No problems!

    Had some time today at work and did a little update.

    Tone mapping, fuzziness, blended normals and a bit of the toolbox:

    Rock model from Megascans.

    (


  • blukazs
    Offline / Send Message
    blukazs polycounter lvl 2
    Great! Can we get it ? : >
  • shaderfx
    Offline / Send Message
    shaderfx polycounter lvl 8
    @brurpo Those arealight corners can currently not be queried inside ShaderFX. They would need to be added (had no idea they were exposed to the API to be honest!)
  • brurpo
    Offline / Send Message
    brurpo triangle
    @blukazs I think I will have the shader done by sunday!

    @shaderfx Thanks a lot for your time Kees! Can we hope for it to be added? What about that custom code shadow map error? Any ideas? 
  • brurpo
    Offline / Send Message
    brurpo triangle
    Unfortunatelly I've hit some walls and couldnt release it yet.

    But here is another update.


  • brurpo
    Offline / Send Message
    brurpo triangle
    I had a couple of hours to do the chapecoense airplane that tragically crashed and killed almost the entire chapecoense team.
    It was a sad day here.
    Due to the very short time to do it, I used this shader and made a viewport render with some minor tweaking in after effects.
    HDRI by MAC MAVE
     
  • brurpo
    Offline / Send Message
    brurpo triangle
    I've decided to change the Environment maps to Lys's GGX pre-convolved Cube Maps.

    There are several advantages, the reflection blurring is much better. There is a large gain in performance and quality when compared to gaussian blurring the reflections in the pixel shader and a huge gain in quality with the same performance when using mip mapping alone.

    The downside is having to either use Lys to do that, or manually doing it. (I recommend grabbing it, its an amazing piece of software!)



  • brurpo
    Offline / Send Message
    brurpo triangle
    And here is another test using it.


  • brurpo
    Offline / Send Message
    brurpo triangle
    Quick changing HDRI with the toolbox.


  • ddankhazi
    Hey brurpo,
    Awesome work!
    Cheers, D
  • brurpo
  • sirpiltrafus
    Looking really good. I used the previous version a few times. Works really well for skin.
    Any idea when you are releasing version 2.
  • hellobard
    Offline / Send Message
    hellobard polycounter lvl 4
    Is there any chance we can beta test this? Could really use a setup like this!
  • brurpo
    Offline / Send Message
    brurpo triangle
    Hi there! Thanks for the interest! Ive changed jobs and everything got messy, sorry for the delay, as soon as things settle I will finish this up!
Sign In or Register to comment.