• Tired of low quality and ugly dynamic shadows?
    103 replies, posted
Hi! Let's learn how to do shadows PROPERLY. (I'm betting a few of you are already aware of this, but I've seen a number of shots with terrible shadows - I'm here to help them!) Let's get started! First, unless you actually want them, disable source's default shadows with r_shadowcolor 255 255 255. Now - let's roll with two very important values: mat_depthbias_shadowmap 0.00001 (default 0.005) and mat_slopescaledepthbias_shadowmap 2 (default 16) [B]BEFORE[/B] [quote][img]https://files.catbox.moe/xjsro2.jpg[/img][/quote] [B]AFTER[/B] [quote][img]https://files.catbox.moe/946sjy.jpg[/img][/quote] These two values control the margin for error when casting shadows - to put it simply, lowering these values reduces the distance it takes for a shadow to begin to cast from something. Set depthbias_shadowmap 0.00001 a little lower higher if you can pull it off without any noticeable artifacting loss, as super low numbers do cause small artifacting! (but nothing that a good editor couldn't take out.) r_projectedtexture_filter is an especially useful cvar, as it controls the filter / blur level on the shadows. A high value will cause the shadow to be very blurry, whilst low values will make it sharper - and more pixelated, if you use a value too low. [B]The edges of shadows are and always will be grainy at high filter sizes, there is no way to fix this! Thank nvidia for bitching at Valve years ago, so nobody can get smooth shadow edges.[/B] [B]r_projectedtexture_filter 20[/B] [quote][img]https://files.catbox.moe/y3qh5o.jpg[/img][/quote] [B]r_projectedtexture_filter 3[/B] [quote][img]https://files.catbox.moe/rkeulm.jpg[/img][/quote] [B]r_projectedtexture_filter 1[/B] [quote][img]https://files.catbox.moe/y02tmc.jpg[/img][/quote] [B]r_projectedtexture_filter 0.2[/B] [quote][img]https://files.catbox.moe/pi2awm.jpg[/img][/quote] [B]r_projectedtexture_filter 0[/B] [quote][img]https://files.catbox.moe/0t3807.jpg[/img][/quote] Finally, the most, MOST important cvar OF THEM ALL! [B]r_flashlightdepthres[/B] If you've noticed, the shadows in the previous 4 pictures are far sharper than what you would come to expect of your lamps. This is the cvar responsible for controlling how detailed the shadows are. The default value for this is 1024, meaning the shadowmap would be rendered as a 1024x1024 texture. On very good computers, you can reach up to 8192, though with significant frame loss - nice for final pictures, but not practical for playing everyday gmod with. [B]Always change this value at the main menu, changing it ingame could cause problems.[/B] Good shadowmap resolutions that most should be able to cope with are 2048 and 4096, and remember to modify r_projectedtexture_filter accordingly. (0.2 for 4096 and 0.5 for 2048 if you want the shadows to be as sharp as possible without appearing pixelated) [b]Everything after this point is considered NULL and VOID with the changes to the Lamp STool coming Garry's Mod 13. These are now all things you can do with lamps.[/b] Now, most people are comfortable working with lamps - and they are the most reliable choice if you want to modify your lamps coloring. However, there are also situations where the flashlight would come in handy, as it has many advantages which a lamp doesn't. FIRST OF ALL, to lock the flashlight into a single position, use r_flashlightlockposition 1. You can change the nearz and farz of your flashlight, meaning how near to you the light begins, and how far away before it ends. Use this to place your scene inside of the nearz and farz, as it will optimize shadowmapping MASSIVELY. r_flashlightnear (default 4) r_flashlightfar (default 750) [B]r_flashlightnear 16 r_flashlightfar 500[/B] [quote][img]https://files.catbox.moe/98qvov.jpg[/img][/quote] [B]r_flashlightnear 512 r_flashlightfar 1512[/B] [quote][img]https://files.catbox.moe/qyuout.jpg[/img] [img]https://files.catbox.moe/pr0kdw.jpg[/img][/quote] While you're setting this up, you can get the handy little box showing you where the nearz and farz are with this cvar! r_flashlightdrawfrustum 1 If you want your flashlight to stay consistantly bright, no matter what distance you're at (this is especially useful for situations where you want a nice looking sunlight) then simply change r_flashlightconstant to a high value, like 100. (default 0) One of the big advantages flashlights have over lamps, is you can modify their FoV. This changes how wide or narrow the flashlight casts. For example, you may want a light source very near to the scene, but you want it to light up as much as possible - set the FoV high. If you're looking for narrow, distant spotlights or sunlights, then use a narrow FoV. r_flashlightfov (default 45) [U]These pictures have adjusted nearz and farz settings as well![/U] [B]r_flashlightfov 130[/B] [quote][img]https://files.catbox.moe/n31gph.jpg[/img] [img]https://files.catbox.moe/dw9xwh.jpg[/img] [img]https://files.catbox.moe/5b7bzk.jpg[/img] [img]https://files.catbox.moe/qxav72.jpg[/img] [img]https://files.catbox.moe/3oup85.jpg[/img] [img]https://files.catbox.moe/2uix8e.jpg[/img][/quote] [B]r_flashlightfov 15[/B] [quote][img]https://files.catbox.moe/pett3j.jpg[/img] [img]https://files.catbox.moe/wtaw7w.jpg[/img] [img]https://files.catbox.moe/jkjazj.jpg[/img] [img]https://files.catbox.moe/habuzd.jpg[/img][/quote] Of course, the one advantage that lamps will have over flashlights is their ability to be colored and moved around a little more easily.. but that's about it. Hopefully this will help any of you screenshotters with getting nice looking shadows!
Well fuck and I thought I knew everything about source shadows. Awesome man.
This is extremely useful
I never knew about this. Will take a while to write it all down and remember it.
You wouldn't know how to enable them when source refuses to turn them on would you? :P
[QUOTE=wraithcat;31476638]You wouldn't know how to enable them when source refuses to turn them on would you? :P[/QUOTE] If you really cannot get them working under any circumstances, your computer likely just isn't strong enough to do them reliably.
[QUOTE=Darkomni;31476726]If you really cannot get them working under any circumstances, your computer likely just isn't strong enough to do them reliably.[/QUOTE] Nah, it's just source being bitchy about nvidia's brand new TMbuggy optimus technology :P. Just wondered if you knew of a way to force them.
Very useful, but i can't do it, fucking motherboard video card... also, Bookmarked
BRB FAPPING TO THREAD
And my dads internet is a ass and blocks all the pics, but never the less useful information, thanks. [editline]2nd August 2011[/editline] pictures work now. Extremely useful.
These cvars have been in gmod for a while now, I'm actually genuinely surprised that so few people knew about them until now.
[QUOTE=Darkomni;31480550]These cvars have been in gmod for a while now, I'm actually genuinely surprised that so few people knew about them until now.[/QUOTE] It's about who uses what. It's not like garry specifically tells us when he adds stuff like this, most of the people who pay attention to such things have no use for them, while most of us in screenshots have little interest in looking into the code. I'll have to write these down and try them out next time I start up gmod.
This will change everything.
guys don't write them down create an autoexec.cfg in your garrysmod/garrysmod/cfg folder and put them in that, I for example have this (from an old HQ .cfg for TF2 with the new shit added): [code] cl_burninggibs 1 cl_detaildist 2400 cl_detailfade 0 cl_maxrenderable_dist 6000 cl_new_impact_effects 1 cl_ragdoll_collide 1 cl_smooth 1 cl_threaded_bone_setup 1 cl_threaded_client_leaf_system 1 dsp_enhance_stereo 1 lod_TransitionDist 6400 mat_aaquality 8 mat_antialiasing 16 mat_antialinis 16 mat_bumpmap 1 mat_clipz 0 mat_hdr_tonemapscale 16 mat_motion_blur_forward_enabled 1 mat_picmip -1 mat_queue_mode 2 mat_specular 1 mp_usehwmmodels 1 mp_usehwmvcds 1 r_fastzreject 1 r_lod 0 r_threaded_client_shadow_manager 1 r_threaded_particles 1 r_threaded_renderables 1 r_waterforceexpensive 1 snd_mixahead 1 jpeg_quality 100 mat_mipmaptextures 0 mat_slopescaledepthbias_shadowmap 2 mat_depthbias_shadowmap 0.00001 r_projectedtexture_filter 0 r_flashlightdepthres 4096 [/code] obviously for the FoV ones you should write them down because I doubt you'll keep using the same FOV
[QUOTE=Taggart;31481547]guys don't write them down create an autoexec.cfg in your garrysmod/garrysmod/cfg folder and put them in that, I for example have this (from an old HQ .cfg for TF2 with the new shit added): [code] cl_burninggibs 1 cl_detaildist 2400 cl_detailfade 0 cl_maxrenderable_dist 6000 cl_new_impact_effects 1 cl_ragdoll_collide 1 cl_smooth 1 cl_threaded_bone_setup 1 cl_threaded_client_leaf_system 1 dsp_enhance_stereo 1 lod_TransitionDist 6400 mat_aaquality 8 mat_antialiasing 16 mat_antialinis 16 mat_bumpmap 1 mat_clipz 0 mat_hdr_tonemapscale 16 mat_motion_blur_forward_enabled 1 mat_picmip -1 mat_queue_mode 2 mat_specular 1 mp_usehwmmodels 1 mp_usehwmvcds 1 r_fastzreject 1 r_lod 0 r_threaded_client_shadow_manager 1 r_threaded_particles 1 r_threaded_renderables 1 r_waterforceexpensive 1 snd_mixahead 1 jpeg_quality 100 mat_mipmaptextures 0 mat_slopescaledepthbias_shadowmap 2 mat_depthbias_shadowmap 0.00001 r_projectedtexture_filter 0 r_flashlightdepthres 4096 [/code] obviously for the FoV ones you should write them down because I doubt you'll keep using the same FOV[/QUOTE] You shouldn't necessarily need r_projectedtexture_filter 0, you may want to change the value according to the scenario.
of course, but I personally find that 0 works in pretty much all cases for me
Could you rehost those pictures maybe?
So is this something from console command?
Wow, that's amazing! I'm gonna be bookmarkin' this page, I really hated how grainy the shadows got when I tried to do lighting for some of my pictures. This is gonna be a real life-saver.
Very cool, I didn't know half of this.
Bookmarked
You're awesome. And one question: Do these changes reset? Or they stay this way until changed?
Thank you very much for this.
Deserves a sticky, or at least.. the information should be added to the sticky.
I had no idea that Source could look this good.
[QUOTE=DarKSunrise;31523352]I had no idea that Source could look this good.[/QUOTE] It doesn't.
Very awesome, thanks, wish i knew this from day 1 of posing
[QUOTE=Taggart;31481547]guys don't write them down create an autoexec.cfg in your garrysmod/garrysmod/cfg folder and put them in that, I for example have this (from an old HQ .cfg for TF2 with the new shit added): [code] cl_burninggibs 1 cl_detaildist 2400 cl_detailfade 0 cl_maxrenderable_dist 6000 cl_new_impact_effects 1 cl_ragdoll_collide 1 cl_smooth 1 cl_threaded_bone_setup 1 cl_threaded_client_leaf_system 1 dsp_enhance_stereo 1 lod_TransitionDist 6400 mat_aaquality 8 mat_antialiasing 16 mat_antialinis 16 mat_bumpmap 1 mat_clipz 0 mat_hdr_tonemapscale 16 mat_motion_blur_forward_enabled 1 mat_picmip -1 mat_queue_mode 2 mat_specular 1 mp_usehwmmodels 1 mp_usehwmvcds 1 r_fastzreject 1 r_lod 0 r_threaded_client_shadow_manager 1 r_threaded_particles 1 r_threaded_renderables 1 r_waterforceexpensive 1 snd_mixahead 1 jpeg_quality 100 mat_mipmaptextures 0 mat_slopescaledepthbias_shadowmap 2 mat_depthbias_shadowmap 0.00001 r_projectedtexture_filter 0 r_flashlightdepthres 4096 [/code] obviously for the FoV ones you should write them down because I doubt you'll keep using the same FOV[/QUOTE] FYI, this config doesn't work in multiplayer. You'll crash after playing for a few minutes.
[QUOTE=UnknownDude;31534972]FYI, this config doesn't work in multiplayer. You'll crash after playing for a few minutes.[/QUOTE] I know, which is why the best course of action is to create your own, not copy-paste that though then again some of those commands could be useful (but their stability is in question)
Glad to know you're all finding the tutorial of use, <3
Sorry, you need to Log In to post a reply to this thread.