Home Technical Talk

TGA Physically Based Lighting CGFX Shader for Maya Viewport

2

Replies

  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Thanks [HP].
    It's my favorite area when it comes to CG. Not that hard to tell huh?
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    A small update on the PBL shader to v0.3.1.

    From 0.3 to 0.3.1:
    -Added Emissive Texture feature.


    PBL_Emissive_animation.gif

    You can grab the shader here:
    http://www.kostas.se/?p=30
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Another small update on the PBL shader to v0.3.2.

    From 0.3.1 to 0.3.2:
    -Added transparency support. Use the albedo texture alpha channel.


    You can grab the shader here:
    http://www.kostas.se/?p=30
  • wailingmonkey
    Options
    Offline / Send Message
    sweet work, kodde! :)
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    sweet work, kodde! :)

    Thanks mate. Was no biggie. These were mainly requests by my students who frequently use this shader.
  • poopsterspappy
    Options
    Offline / Send Message
    poopsterspappy polycounter lvl 7
    Kodde,



    Love the Shaders . Thanks a million !!!
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Thanks poopsterpappy. Glad you like it.

    I've been a bit lazy to update this thread. The latest iteration is 0.3.3.1. Anyone using older is really recommended to update as there's a major flaw (fuck up on my part) concerning normal maps prior to 0.3.3.1 Here's an extract with the change log since the last update I posted here.

    From 0.3.3 to 0.3.3.1
    -Bug fix, Normal Map multiplier was at 1.5x prior to this version. Now default is 1.0x.
    -Normal Multiplier added as a slider.
    -Scrapped idea of running two parallell shaders. Will just continue to use just the newer "multiplier sliders version".

    From 0.3.2.1 to 0.3.3:
    -Added a version of the shader with "multiplier sliders" for the Albedo texture, Roughness texture, Substance texture and Cube Map texture.

    From 0.3.2 to 0.3.2.1:
    -Retroactively added bug-fixes in Change Log between 0.2.2 -> 0.3 for clarity reasons.


    As always, you can get the shader here:
    http://www.kostas.se/?p=30
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Hello,Kotas.Great work.I am just getting into the whole real time shader thing.I would really like to try these wonderfulicious shaders but I am kinda torn between the TGA Physically Based shader and the KoddeShader 2.0.Both seem awesome but the TGA seems more recent than koddeshader so does that mean it gives better results?I wanna try these shaders out on human characters and environment work.Never knew there were real time shaders in Maya,that means render time will be very fast compared to shaders like Lambert,Blinn,sss shaders.

    Can these shaders work with Mental Ray,software renderer or only with the Hardware or viewport 2.0 renderer?

    Nice to know there is someone making stuff for Maya.3dsmax always gets all the cool stuff. Keep up the great work.
  • gilesruscoe
    Options
    Offline / Send Message
    gilesruscoe polycounter lvl 10
    Hey, im trying to get the shader working in maya 2012 but the CGFX shader node just appears pink, even when i add textures into the file slots. I think i'm doing something extremely wrong? The CGFX plugin is loaded, i've created the cgfxshader render node in hypershade and have applied it to my mesh. I'm using highquality viewport (hardware). Any advice? Cheers!
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    melviso> Both work fine, it's mostly two different shading principles. They use a bit different textures. The KoddeShader 2.0 uses the more traditional kind, the kind you will find more tutorials and material concerning. The TGA PBL shader uses Physically Based Lighting oriented textures instead, a newer way of shading real time afaik. Adopted by a few studios that I know of and probably a few more that I don't know of. If you haven't tried PBL then it could be a nice experience for you to give it a go. I actually find it easier to work with once you get familiar with it. You use one less texture with PBL and you get a few parameters for free regarding fresnel.

    gilesruscoe> ATI-card? I'm afraid none of my CGFX shaders work with ATI afaik. This seems to be a common problem with all the CGFX shaders for Maya that I know of.
  • gilesruscoe
    Options
    Offline / Send Message
    gilesruscoe polycounter lvl 10
    Ah yeap, using ATI card. Great, another thing to add to my long list of maya/ati compatibility issues :P Time to replace my card :(
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks for clearing that up,kodde.I will try out PBL then.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    gilesrusco> :(

    melviso> Np. Just ask in this thread if you have any questions and I will try to help. Read post #2 in this thread for more info on how these textures work.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    New version out, 0.3.4.

    From 0.3.3.1 to 0.3.4
    -Now features energy conservation between ambient and reflective amount. I.e. If a sampled point is reflecting a lot of light, it won't also add a lot of ambient light and vice versa. Thanks for helping me with this Niklas.


    As always, you can get the shader here:
    http://www.kostas.se/?p=30
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Checked out the link to the post.Its a little different from the maps I am used to but will definitely try it.High time I start paying attention to 3d realtime.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    I'm cross posting here, but I posted a big cube map pack today which most people using this shader will find useful. Check it out.

    http://www.polycount.com/forum/showthread.php?p=1544773
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    New version out, 0.3.4.1.

    From 0.3.4 to 0.3.4.1
    -Bug fix, ambient light is now properly gamma corrected.


    As always, you can get the shader here:
    http://www.kostas.se/?p=30
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    New version out, 0.3.5

    From 0.3.4.1 to 0.3.5
    -Energy conservation between diffuse and specular materials.
    -Implemented Kelemen Szirmay Kalos visibility model.
    -Adjusted blinn-phong normalization to better approximation.
    -Raised max specular power to take advantage of our logarithmic encoding.
    -Adapted max specular to work with common cubemap blurring levels.


    As always, you can get the shader here:
    http://www.kostas.se/?p=30
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    New version out since a while back, 0.3.5.1

    From 0.3.5 to 0.3.5.1
    -Roughness now properly gamma correct for reflections.
    -Minor improvement in mip-map selection formula for reflections.

    As always, you can get the shader here:
    http://www.kostas.se/?p=30
  • Randomself
    Options
    Offline / Send Message
    Randomself polycounter lvl 14
    Heya Kodde, just wondering what are your thoughts on efficient workflows to author textures for physically based shaders. I've been testing out painting them interactively using artisan in Maya, it feels kinda unwieldy though.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    It's not that different from authoring any other textures in my opinion. The substance texture is pretty simple, mostly filling areas with solid colors, use the cheat sheet as a baseline reference. Of course you can add variations in there for certain effects, but mostly not needed. You're left to painting the Albedo and the Roughness. Albedo is the color of your material, you don't want to paint light information in there. That doesn't mean you shouldn't add color varations, grime, dirt, scratches, etc. The roughness is a texture to define the surface structure. Is it all smooth? Rough? Any Scratches? Dents? Bumps? This map will help break up the reflections/specularity.

    Beyond these textures your normal map and ambient occlusion remain the same.

    The cube map needs to have pre-blurred mip levels to work properly with this shader as the roughness texture will change how the specular AND reflections turn out. I.e. will they be sharp? blurred? narrow? wide? intense? etc. The pre-blurred mips is needed to be able to differ from sharp/blurred reflections.
  • fatihG_
    Options
    Offline / Send Message
    fatihG_ polycounter lvl 14
    Hey Kodde,

    Havent tested this yet, but was just wondering how things work in relation to dielectric vs conducting materials. Dielectric Materials always have a white specular while conducting have coloured speculars.
    It looks ok in the various materials examples, but since the highlights on the metals are so bright, they are essentially white as well. So I figured I should ask anyway.
    So does Physically correct shaders take care of this, and what exactly controls the metalness of the surface?

    The main reason I am asking this is because I tend to hue shift my specular maps of dielectrics by 180 degrees, so that the specular highlights are always white. But this heavily depends on what it is adding with. If it is a simple light cast on a sphere, obviously one half will be lit, so the specular can be added to the diffuse. But if you are using cubemaps on that same sphere and you want to retain that dielectricness of your material you should multiply the cubemap by the specular map, so the hues are correct.
    But the issue here is that the unlit parts of the sphere will be black. So the hue shifted specular map will be added to black, showing the wrong colors where essentially the cubemap reflections will be. Though the cubemap reflections would render properly on the lit half.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    bb0x> You are right about the metals in the examples. I should have gone for a milder specular highlight. Anyway, the substance is the controlling part for coloring the specularity and reflections. The cheat sheet image bundled with the shader has some lookup color values for substance. You can tell that all the materials there have some form of color tint.

    The reason for the metals in my example showing mostly white specularity is since the colors cap out at 1.0 1.0 1.0. Sadly I can't do any post processing in the Maya viewport, otherwise it could be cool to try and adapt to the values on the screen.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    New version out with a smaller update, 0.3.5.2, reflections have been improved.

    From 0.3.5.1 to 0.3.5.2
    -Reflection fresnel is now affected by Roughness.

    As always, you can get the shader here:
    http://www.kostas.se/?p=30
  • System
    Options
    Offline / Send Message
    System admin
    looks pretty good, takes some tweaking and the g/s values are a little bit different than what Im used to.

    Is there anyway to get rid of that horrid mipping? Is that a maya thing?
    kostas_pbl.jpg
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Which mipping are you referring to?
    Are you using .dds with mip-maps or some uncompressed format? Maya's realtime resampling tends to give quite blurred out results at distance.

    When it comes to the cube maps usage those mips are explicitly controlled by the shader to get the blurred/sharp reflections feature, i.e. they don't work like mip-maps usualy do in the sense that they shift levels depending on the view distance. So a trade of with the blurred/sharp feature is that you can get issues on reflective surfaces at certain distances.
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    If I remember correctly, we did fix up the mip mapping in Maya 2013.5 so it shouldn't be so blurry anymore. If you have access to that version, let me know if that helps.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    shaderfx> Cool. I'll check it out. Feels like I've been living under a rock, I had missed that 2013.5 was official out. Downloading it as we speak.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    New version out with a smaller update, 0.3.6, new Cube Rotation feature and switched profile for transparency technique.

    From 0.3.5.2 to 0.3.6
    -New "Cube Rotation" feature which allows you to easily rotate the cube map around the Maya Y axis with a slider.
    -Switched the gp4vp/gp4fp to vp40/fp40 profiles for the TransparencyUsingAlbedoAlpha technique as I was having some issues with the gp4vp/gp4fp profile. Let me know if you have problems with this change.

    As always, you can get the shader here:
    http://www.kostas.se/?p=30
  • DInusty
    Options
    Offline / Send Message
    DInusty polycounter lvl 17
    thanks for updating :) do you have any new examples you can post? pretty awesome.
  • DInusty
    Options
    Offline / Send Message
    DInusty polycounter lvl 17
    would it be too complicated to make a 2 material blend with these? would be nice for ground break up using things like height maps and threshold controls to blend between two of these physically based materials :)
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Frozan> Thanks. I'm afraid I don't have any new examples, at least not that are my own. Most people I know who use this shader(mainly my students) use it as an intermediary format for their game projects where they use PBL shading. When it comes to portfolio renders many resort to Marmoset instead. Kind of hard to compete with a commercial dedicated render engine. Too many things missing in Maya to even begin to compete. Shadows for instance.

    It would be possible to make a blend, but quite some work for a quite narrow case. Especially considering that this shader is no longer editable in Mental Mill where it was originally created but now has to be edited by hand. It's not the easiest code to read or work with :)

    May I ask what you are using the shader for? :)
  • DInusty
    Options
    Offline / Send Message
    DInusty polycounter lvl 17
    thanks for the quick response. im just looking for a good answer to being able to make a scene that uses physical based lighting.

    As an environment artist it really helps to be able to do 2 or 3 blend materials to get nice break up on the ground or even long stretches of walls. either with a mask that blends between them or a height map exposing one material to another via vertex paint.

    I'm mainly looking for a solution to the fact that I don't have PBL at home. i guess the new skyshop in the free version of unity. might have to look into this a bit more.

    Thanks again your work is much appreciated! :)
  • Rapante
    Options
    Offline / Send Message
    Rapante polygon
    Hey guys, might be a stupid question, but which version of Mental Mill are you using? I tried downloading the latest they have in the nVidia ARC forum but unfortunately that one gives me a trojan warning of my virus scanner (ESET's NOD32).
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Nice.
    I didn't know that 1.2 was out in the open since MM has been discontinued. I'm running the 1.2 here which I got from Ruediger. Didn't have any trojan issues. The installer on the ARC forums and the one I have seem to be identical
  • pior
    Options
    Offline / Send Message
    pior grand marshal polycounter
    Hi again Kodde -

    I was wondering if you have more example screenshots of your shader being used at its full potential on complex assets by any chance? I am sure that it provides great results (I was in awe when I first tried your skin shader hence I am sure this one delivers too !!) but it would be nice to see something in context.

    The reason why I am asking this is because I feel like games using this very accurate description of physical materials tend to have a certain common look to them (MGS5 being the obvious example) and I wonder what exactly causes this. Seeing more examples of the tech in action might clarify why and how this happens !
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Hey pior. Thanks for the confidence.

    Like I've mentioned above, to my knowledge the shader is being used mostly as an intermediary format for my students game projects at school where they work with their own 3D game engines that use physically based lighting. I can't vouch for all of their games using this shading bugfree and to it's full potential as these are student projects and they are learning as they go along. Here's one of their later games created by one student group, and the same groups ongoing project which is due at the end of next week. There's loads of other projects as well.

    Other than the examples on my webpage there's not that many new "portfolio" piece examples as lately most of my students go for marmoset which I fully understand. There are a few older examples which I'm not sure if you've seen though. I generally don't produce complete game assets myself. Even less frequently now that I'm moving on to Technical Artist Teacher.


    Here's some more examples(older):

    [size=+1]Beretta pm 12, Oskar St
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Kodde,I wanted to ask if the TGA shader supports shadows in maya 2013.5 bc I do understand it doesn't work with shadows in the viewport 2.0 in maya 2013 version.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    melviso> No I'm afraid not. I'm not sure if it's possible at all with CGFX-shaders in Maya? Autodesk did add their own DX11 Material shader node in 2013.5(?) and obviously they get the same shadow possibilities with this shader as the rest of their shaders, so it should be possible to get real-time shadows in a similar manner. Maybe if you have a look at their shader code or something.

    This does give me a good incentive to learn writing shaders by hand since I know that shadows "should" be possible :)
  • pior
    Options
    Offline / Send Message
    pior grand marshal polycounter
    Thank you so much for the screenshots ! Some of them seem to have that quality I was referring to - especially the yellow tank top and the gun with the mushroom growth. Can't wait to try it!
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    Hey guys,

    Regarding shaders, I do not think this is possible in the old CGFX plugin of Maya unless you change its code and re-compile the plugin.

    However, Maya itself, in viewport 2.0, is definitely capable of doing shadows in cgfx (as well as DX11 as you mentioned).

    For DX11 we just happen to build the functionality into the DX11ShaderNode.
    I am not sure why this was never done in the CGFX plugin. Perhaps it was not a priority at the time since this plugin is already quite old.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    shaderfx> Thanks for confirming this. In other words, it should be possible for an end user to get shadows with a custom made HLSL shader if you use the DX11ShaderNode right?
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    Yup absolutely.

    You can take a look inside the AutodeskUberShader.fx we provide to see the shadow code.

    In short you need to add the shadow map textures and matrix with the correct semantic and then it is a matter of correctly sampling the shadow map that Maya provides.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    That sounds awesome Kees. Need to check this out tonight
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    So only hlsl shaders can work with shadows in Maya's viewport 2.0?Is DX 11 ubershader a hlsl shader?I do remember seeing the viewport 2.0 demo for Maya 2011,using the deux ex character,I think the demo instructor mentioned it was a hlsl shader and it supported shadows,if I remember correctly.

    I am wondering if what shaderfx is saying will only work in Maya 2013.5 or it's possible in earlier versions of Maya.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    The DX11 shader was introduced first in 2013.5 afaik, so that would probably be a No.
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    Hi melviso,

    Maya's default materials (like phong, blinn, etc) work with shadows in both OpenGL and DX11 also.

    So that shows you that CGFX could also work with shadows, because they all use the same internal VP 2.0 system.

    However you are right in saying that at this point in time, only HLSL shaders used in the DX11ShaderNode can use shadows because we never updated the CGFX plugin to support the same shadows in VP 2.
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks for answering my question.
    Just found this article on how physical based lighting shaders can achieve realistic results easier.This approach was used for the newly released game:Remember Me.
    http://www.fxguide.com/featured/game-environments-parta-remember-me-rendering/

    I am going to try the tga shader even if it doesn't support shadows.It would be nice to see what I can come up with.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Thanks for sharing that link :)
2
Sign In or Register to comment.