Post 2.3 Shader Enhancements

CrackaPollyCrackaPolly PVKII Team, Authorized Creator
edited February 2010 in Dev Journal
Some work being done for post 2.3
Been a long time since the last dev journal so here is something relating to post-2.3 work.

Part of our current plans for things to be done after 2.3 is to overhaul the visual. This is going to include improving some of the maps where there are areas lacking in detail as well as in model detail. I've been doing some work with the shader sdk to improve some of the shaders we use.

Firstly, originally in one the new maps for 2.3 we wanted to use a video on some geometry to perform a much more visually pleasing job of drawing a rapidly changing texture. So to facilitate this I wrote a new special entity prop_dynamic_video to allow a mapper to specify a BIK video to use as the texture of a model. While in the end we did not use this in the map, the code will remain and made it into the 2.3 patch. Basically a few things need to be taken to care when putting a video onto a model. The UV mapping of the default texture needs to fit perfectly the necessary rect that the video takes up in a way that the video is contiguous. Although it is theoretically possible to do a more complicated UV map and author the original video with all the frames keeping in mind the UV map. In this picture the reason for the green checkboard is because this model was not authored with video on it in mind and explains why the UV map needs to fit only the subrect of a whole texture that the video will be best fit to in a 2 exponential sides only textures. (Also the BIK will output the audio into the world making syncing of audio to video not an issue, and it will loop)

image

With post-2.3 I have been looking at some improvements to the character shading. In particular I have worked on implementing an improved model for rendering specular highlights. The lighting model it uses is known as the Cook-Torrance model with a Beckman Distribution for the roughness factor into the main model. I believe Orange Box is using the Blinn-Phong model. Here gives an explanation of the different lighting models http://en.wikipedia.org/wiki/Specular_highlight.

The benefits of using this lighting model is that it better approximates the specularity much better than Phong shading. The best case situations of this model are with metals and plastics, but it works great across many applications. In implementing it I also kept the support for the rim lighting term they have in Orange Box, as well as Base Texture tinting of the specularity which is useful for better simulating gold and things of that nature. I replaced the rim mask with a lightwarp mask because rim mask is unused and having a lightwarp mask is important to allowing better skin rendering approximation when you have skin and other parts of the model on the same texture which many of the player models do.

In this new lighting model there are two main parameters which affect how the specularity will look.

a. Roughness - This is a measure of how rough the material is. To keep consistent with phong for easy transfer of phong exponent texture I have this setup where black is extremely rough texel and white is extremely smooth texel.
b. Reflectance at normal incidence - This is sort of like a phong boost, but it works in a different way. As the direction of the light approaches the normal of the surface of the model it will be brighter. As this value goes up you will see overall a brighter specularity, but not at an equal distribution, light that is hitting the model close to its normal will be much brighter than light that is perpendicular to the surface normal. I represent black as 0 reflectance value and white as a 10.0 reflectance value.

The main method of using these new parameters is through a texture I call the RTNL Texture. Which just stands for Roughness/Texture Tint Mask/Reflectance at Normal/Lightwarp Mask corresponding to the RGBA channels of a texture. Here are some examples of the comparing the new lighting between no specular, and phong specularity:

image
With the heavy knight there is a drastic difference mainly because metal is one of the best case scenarios for this lighting model. Some things that are not easily seen in a picture are that with this new lighting it helps to make the texture look more gritty because I used a non-uniform roughness across the armor so that as light passes around the model you will see parts that take longer to fully specular in comparison to other parts. (Kinda hard to explain, but on the helmet you can sorta see that dirtiness in the specular) Also this comparison is missing a comparison of the chain mail part which is why it is constant in all 3 images.

image
With the archer you can see his face is rendered in a much more realistic fashion, other areas of the specularity are generally much more subtle because the roughness in this case is pretty low, but overall is brighter and in motion the specular results are much more divergent.

image
With the captain we can see the skin is also render much more realistically. Also his buttons and other gold objects produce much better specularity and use a tint mask to look more like gold.

image
With the parrot I used a special lightwarp texture to better simulate the depth of the feathers, essentially it is a high density stair stepped effect. He is also getting specularity which makes him match the lighting of the scene much more properly.

I've also done some work on another refract shader which takes into account the object geometry rather than relying on a normal map to refract with. This is useful for bottles or ice statues where the geometry needs to be refracting and there is no normal map so to speak.

Comments

  • schatzmeisterschatzmeister PVKII Team, Beta Tester
    edited 11:08PM
    Wow, amazing work!

    Will Turner: You didn't beat me. You ignored the rules of engagement. In a fair fight, I'd kill you.
    Jack Sparrow: That's not much incentive for me to fight fair, then, is it?

  • ZinuXZinuX Mutated Walrus Hamster Members, Beta Tester
    edited 11:08PM
    Nice
    dragonattacksig04.pngrage.jpg
  • SmackSmack Damn this compooter Senior
    edited 11:08PM
    The Cook-Torrance Specular Captain looks so much more virile!

    yowza!

    Very nice indeed!
    Wise Chinese proverb say "He who pays for porn has failed at life."

    image
  • PaladinPaladin Senior
    edited 11:08PM
    The Heavy Knight has now become shiny smile.gif
    2v2z7rr.jpg
  • .sverek.sverek PVKII Team, Authorized Creator
    edited 11:08PM
    Very nice to read dev blog!

    Amazing job on shaders, I didn't see much coders who can handle shaders. Thanks, great reading.
  • CrackaPollyCrackaPolly PVKII Team, Authorized Creator
    edited 11:08PM
    Oh also I recall some people were requesting things like SSAO, but originally that was what I started to work on when I got into doing shader upgrades, but it isn't possible from what I can see. SSAO requires a depth buffer at the minimum and the default depth buffer is specially setup for something relating to depth blending of particles and so it is a very short range from the camera. Tried to manually render the scene in another pass with my shader on all materials, but not possible to do on a brush geometry so it currently can't be done without some access to these things.
  • jRocketjRocket Pixel Punisher PVKII Team
    edited 11:08PM
    I think ambient occlusion can be turned on in the driver level for nvidia owners. I haven't tried it with PVKII though.
  • gubbegubbe Senior
    edited 11:08PM
    oh man that is awesome!
    Curse thee valve for holding this wonderful game back.
  • MiggogMiggog PVKII Team, Beta Tester
    edited 11:08PM
    Valve is probably just jealous of pvk graphics.

    Hot damn those Cook-torrance specular maximus 2000 effects on Heavy Knight and the captain! icon_yay.gif
    lego_sig250_v3_zps09b6104b.jpg
  • Scurvy BobScurvy Bob senior
    edited February 2010
    awesome work smile.gif keep it up guys!

    A question about 2.3:
    Why don't you just release it like you did with all the previous versions and let us play on dedicated servers or offline untill valve starts to move their asses? Well, we would be happy and could give you feedback and you could already prepare a little patch, if we find something to fix.
    This is just an idea that came to my mind, I'm not forcing you to do this. But it would definitely make the community happy and stop the frustration.

    cheers
  • CrackaPollyCrackaPolly PVKII Team, Authorized Creator
    edited February 2010
    Well I think Crazytalk is awaiting response before he decides anything of that nature. Thought it has been discussed some.
  • ZinuXZinuX Mutated Walrus Hamster Members, Beta Tester
    edited 11:08PM
    Do you mean, response in like talking back, or in an action way (you talked, but they hadn't really physically responded a.k.a. released the patch) ?

    I am worried if it is the first one.
    dragonattacksig04.pngrage.jpg
  • CrackaPollyCrackaPolly PVKII Team, Authorized Creator
    edited 11:08PM
    Here are some of the other player models in the new shader:

    image

    image


    About the patch we hope for it to be Steam released as soon as possible, but if we may end up release standalone soon if that doesn't happen. It will be good to catch bugs for a steam patch short time from it being finally released.
  • HeiHei and truly did she know the name of the Kong Senior
    edited 11:08PM
    Beautiful. This is definitely the changes that make this mod rise above every other mod stuck in the Source Engine mold; way to bring some serious glorious uniqueness.
  • RyujenRyujen Senior
    edited 11:08PM
    At last the berseker gets his Schwarzenneger-like muscles (when he was still young of course) light-speculated in all their excellence, just look at those triceps lol
  • HarHar Senior
    edited 11:08PM
    NICE
  • edited 11:08PM
    Looking forward to it! That shader looks awesome.
  • mrmongmrmong Senior
    edited February 2010
    i have some questions about the Bik video texture thing you mentioned for an idea of mine (gonna suggest a cool map idea maybe) smile.gif

    - will you be able to apply it to "vertexlitgeneric" stuff like models as well as Light mapped stuff.

    -can you move the model around that the video is playing on

    -Would a large video file cause performance issues?

    this is unrelated to my map idea but would a video texture work well as a 2d skybox? (assuming you placed another one to seal the map)
  • CrackaPollyCrackaPolly PVKII Team, Authorized Creator
    edited 11:08PM
    Its a prop_dynamic it only works with. The entity name is prop_dynamic_video in the current sdk.

    For a model there is a UV map, if you want the video to look right you have to take care with the UV map for the model because it won't be a perfect square for the video it will be some subrect of that texture that is used by the video. The rest will just be garbage data.

    I've not tested any extremely large files, I just used the valve bik to test.

    You can use a 3d skybox with a dome model with the video properly uved to the dome to use a BIK as the skybox.
  • DIFTOWDIFTOW Senior
    edited 11:08PM
    QUOTE (CrackaPolly @ Feb 1 2010, 06:06 AM) »
    Oh also I recall some people were requesting things like SSAO, but originally that was what I started to work on when I got into doing shader upgrades, but it isn't possible from what I can see. SSAO requires a depth buffer at the minimum and the default depth buffer is specially setup for something relating to depth blending of particles and so it is a very short range from the camera. Tried to manually render the scene in another pass with my shader on all materials, but not possible to do on a brush geometry so it currently can't be done without some access to these things.


    Bake Ambient Occlusion into the diffuse, lightly. Next best thing.
  • MiggogMiggog PVKII Team, Beta Tester
    edited 11:08PM
    So how long are we going to have to for these new graphical advancements?
    Are they planned to be released at the same time as man at arms and sharpshooter or sooner?
    lego_sig250_v3_zps09b6104b.jpg
  • CrackaPollyCrackaPolly PVKII Team, Authorized Creator
    edited 11:08PM
    Its gonna release with the next patch. I finally finished off allowing to enable disable usage so for those who have problems using it can revert to current player shaders when it comes, etc.
  • Brother PedroBrother Pedro Senior
    edited 11:08PM
    Sounds great, this patch is shaping up to be much bigger than I expected.
Sign In or Register to comment.