Thread: [Tutorial] Advanced Shadows

Results 1 to 3 of 3
  1. #1
    Administrator Hezus's Avatar  
    Manager
    Join Date
    Aug 2001
    Location
    The Netherlands
    Posts
    9,045

    [Tutorial] Advanced Shadows

    As a follow-up to my Advanced Lighting tutorial, I'd like to cover shadows in this one! Note that we'll be using the latest ZHTL.fgd and the SC SDK compile tools. Even with high-res textures, hi-res models and well tweaked lighting, there is a thing that makes Goldsource looks like it does: generated shadows. Take a look at the following screenshot.

    Click image for larger version. 

Name:	20180215164803_1.jpg 
Views:	113 
Size:	102.6 KB 
ID:	18013

    The reason why shadows look so aweful is the lightmap. The lightmap calculates the sharpness of lights and shadows and this is something you can't really change. The engine is not made to handle smaller lightmaps. However there are some tricks you can use to make things look more realistic.

    Part 1: Scaling it down
    As said, the lightmap cannot be changed but the size of the texture can. Scaling it down to 0,5 or 0,25 will greatly improve the shadows, as shown in the next screenshot.
    Click image for larger version. 

Name:	20180215163816_1.png 
Views:	90 
Size:	199.1 KB 
ID:	18014

    Alas, this trick comes with a price. 2 actually.

    Problem 1: Tiny textures
    Scaling leaves you with smaller textures, which we don't really want. A solution to this is to create high-res copies of the texture you are using. Let's say your original texture is 128x128 pixels and you're planning on scaling it down to 0,5. Extract the texture from the WAD and scale it up to 256x256 in your favourite image editor and put it back into the WAD (using Wally) with a different name. You can even go as high as 512x512 if you plan on scaling it to 0,25. 512x512 is the maximum Goldsource can handle. Now use this new texture you created whereever you want to have scaled down textures for better shadows and use the regular versions for places where clear shadows are not that important.

    Problem 2: Performance
    By lowering the scale of the texture you also increase the wpoly by a great deal. Using the 0,5 or 0,25 scale everywhere will do horrible things to your map's performance and compile times. So pick your battles! Use the trick only on surfaces where light and shadow effects are important.

    To show you the effect of the scaling and the performance issues, here's are some different settings:

    Scale: 1,00 / Wpoly: 56 ------- Scale: 0,50 / Wpoly: 111 ------ Scale: 0,25 / Wpoly: 345 ------ Scale: 0,125 / Wpoly: 605
    Click image for larger version. 

Name:	20180215164803_1.jpg 
Views:	113 
Size:	102.6 KB 
ID:	18013 Click image for larger version. 

Name:	20180215165002_1.jpg 
Views:	76 
Size:	111.9 KB 
ID:	18010 Click image for larger version. 

Name:	20180215165100_1.jpg 
Views:	78 
Size:	118.2 KB 
ID:	18011 Click image for larger version. 

Name:	20180215170356_1.jpg 
Views:	110 
Size:	135.5 KB 
ID:	18012

    As you can see shadows start to look quite realistic around 0,125 but the wpoly goes through the roof. 0,5 still is quite acceptable and 0,25 should be used very sparingly.

    In the next post I'll show you how to tweak your shadows to make them look even better.
    Last edited by Hezus; 16-02-2018 at 03:47 AM.

  2. #2
    Administrator Hezus's Avatar  
    Manager
    Join Date
    Aug 2001
    Location
    The Netherlands
    Posts
    9,045

    Re: [Tutorial] Advanced Shadows

    Part 2: Tweaking VRAD
    To make your shadows even better you can apply certain settings to VRAD in the compile process.

    Command: -extra
    Explanation: This will enable a render technique which will oversample lighting and shadow effects, making it look better.

    Command: -blur
    Explanation: typical for Goldsource are the jagged edges of the shadows. You can make them less apparent by blurring the shadows a little. This is 1,5 by default in the SC SDK tools.

    scale 0,25 / blur 1.0 ------- vs ------- scale 0,25 - blur 2.0
    Click image for larger version. 

Name:	20180215165100_1.jpg 
Views:	84 
Size:	118.2 KB 
ID:	18015 Click image for larger version. 

Name:	20180215171043_1.jpg 
Views:	91 
Size:	125.2 KB 
ID:	18016

    Command: -smooth
    Explanation: Smoothes lighting and shadows adjacent to eachother at an angle (such as cyclinders). This is on by default in SC SDK tools. A value of 50 is enough in most cases.
    Click image for larger version. 

Name:	al05.jpg 
Views:	97 
Size:	46.9 KB 
ID:	18017
    Last edited by Hezus; 15-02-2018 at 01:30 PM.

  3. #3
    Registered User ToTac's Avatar
    Join Date
    Nov 2016
    Location
    The Void
    Posts
    9

    Re: [Tutorial] Advanced Shadows

    Very useful, thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •