Transparent Texture Shadows

Tutorial collection, comprehensive listings on main site.

Transparent Texture Shadows

Postby Tutorial on Wed Feb 11, 2009 9:59 pm

category
Texture Creation

description
Allowing transparent textures to project shadows, for example a wire fence.

keywords
texture, transparent, shadows, -textureshadows, alpha, channel, prop.

In this tutorial you will learn how you can make the opaque parts of a transparent texture on a model cast shadows.

You may be wondering "What does alpha mean?" Alpha - or more specifically the alpha channel, is what defines transparency in an image. For example, glass textures have an alpha channel that makes them transparent.

For example: a fence
Image

The fence's grating has an alpha channel that allows you to see through it. This is great for visual looks like looking through it, but source has no idea what to do about lighting for the alpha channel for props, and it simply uses the collision model as a shadow reference. This would be okay, but it looks really unrealistic when a light is near it.

Image

In the days of the HL2 Source engine and the HL2:EP1 engine you had to make a grating yourself, by taking a blocklight texture and cutting it out. Nobody ever wanted to do this because it was pointless and very time consuming (And the shadows looked blocky)

Then came the Orangebox engine, and at first, we could use projectedtextures to create our dynamic lights, but then nVidia complained about the shadows from these entities and resulted in nVidia users getting these nasty grainy-edged shadows. Yes, they were dynamic (And partially better than what i'm about to teach you about), but they are really bad looking.

Skip forward to now, where we have learned that the light compiler (vrad) now has an option to allow the alpha channel to allow light through. That command? -TextureShadows.

This command, combined with -StaticPropPolys, can allow your alpha channels to create shadows. This is better than before, but there are still some flaws. These shadows are lightmap shadows, so they cannot be moved and thus, are static.

But if you're using a static prop you shouldn't care anyways.

Anyways, you may be wondering "Alright, this sounds cool, how do I accomplish this?".

Basic requirements

Orangebox /Source 2009 Engine Game (Half-Life 2 Episode 2 or Left 4 Dead)

Prop with texture that has alpha channel (In this case we'll be using a fence model)

Step 1 - Create a lights.rad file

First of all, go into notepad and copy this
Code: Select all
lights/fluorescentcool001a   189 231 232 350
lights/fluorescentcool001b   236 255 182 350
lights/fluorescentcool002a   189 231 232 400
lights/fluorescentcool002b   236 255 182 400
lights/fluorescentcool003a   189 231 232 300
lights/fluorescentwarm001a   239 216 193 350
lights/fluorescentwarm002a   239 216 193 400
lights/fluorescentwhite001a   245 245 245 350
lights/fluorescentwhite002a   245 245 245 400


lights/hazzardred001a      228 37 0 300
lights/hazzardyellow001a   250 215 74 300

lights/HIDcool001a      145 222 172 650
lights/HIDcool001b      205 232 255 650
lights/HIDwarm001a      255 201 116 650

lights/white001         250 240 205 100
lights/white002         189 233 247 425
lights/white003         232 246 190 350
lights/white004         170 228 247 425
lights/white005         234 235 220 375
lights/white006         234 235 220 100

lights/blue001         166 180 196 200 166 180 196 100
lights/blue002         141 176 203 200 141 176 203 100
lights/red001         63 1 1 200 63 1 1 100

lights/white001_nochop   250 240 205 100
lights/white002_nochop   189 233 247 425
lights/white003_nochop   232 246 190 350
lights/white004_nochop   170 228 247 425
lights/white005_nochop   234 235 220 375
lights/white006_nochop   234 235 220 100

lights/incandescentcool001a   235 235 235 300
lights/incandescentwarm001a   250 226 129 300


glass/glassscreen001a      172 192 161 225
glass/glasspipe001f      214 72 44 200
glass/glassscreen001c      172 192 161 225
glass/glassscreen001d      211 187 134 225
glass/glassblock001a      70 194 209 200
composite/citadelfloor001a   103 143 203 200
props/tvscreen006a      196 0 0 200
shadertest/gooinglass      149 49 15 50

glass/glasswindow002e      189 233 247 425
glass/glasswindow035a      145 222 172 100

dev/DEV_INTERIORLIGHT02B   151 176 204 225

plaster/plasterwall029h      189 223 227 125
building_template/Building_Trainstation_Template001d   230 230 200 65
building_template/Building_Trainstation_Template001e   230 230 200 150
building_template/Building_Trainstation_window002d   230 230 200 300
building_template/Building_Trainstation_window002e   230 230 200 300

lights/physgunlight   189 231 232 20

noshadow tree_deciduous_01a_branches.vmt
noshadow tree_deciduous_01a_leaves.vmt
noshadow tree_deciduous_01a_lod.vmt
noshadow tree_deciduous_01a_lod-leaves.vmt

forcetextureshadow props_foliage/tree_dead01.mdl
forcetextureshadow props_foliage/tree_dead02.mdl
forcetextureshadow props_foliage/tree_dead03.mdl
forcetextureshadow props_foliage/tree_dead04.mdl
forcetextureshadow props_foliage/tree_dry01.mdl
forcetextureshadow props_foliage/tree_dry02.mdl
forcetextureshadow props_foliage/tree_pine_large.mdl
forcetextureshadow props_foliage/tree_pine04.mdl
forcetextureshadow props_foliage/tree_pine05.mdl
forcetextureshadow props_foliage/tree_pine06.mdl
forcetextureshadow props_foliage/tree_deciduous_01a.mdl
forcetextureshadow props_foliage/tree_deciduous_02a.mdl
forcetextureshadow props_wasteland/interior_fence001a.mdl
forcetextureshadow props_wasteland/interior_fence001b.mdl
forcetextureshadow props_wasteland/interior_fence001c.mdl
forcetextureshadow props_wasteland/interior_fence001d.mdl
forcetextureshadow props_wasteland/interior_fence001e.mdl
forcetextureshadow props_wasteland/interior_fence001g.mdl
forcetextureshadow props_wasteland/interior_fence002a.mdl
forcetextureshadow props_wasteland/interior_fence002b.mdl
forcetextureshadow props_wasteland/interior_fence002c.mdl
forcetextureshadow props_wasteland/interior_fence002d.mdl
forcetextureshadow props_wasteland/interior_fence002e.mdl
forcetextureshadow props_wasteland/interior_fence002f.mdl
forcetextureshadow props_wasteland/interior_fence003a.mdl
forcetextureshadow props_wasteland/interior_fence003b.mdl
forcetextureshadow props_wasteland/interior_fence003d.mdl
forcetextureshadow props_wasteland/interior_fence003e.mdl
forcetextureshadow props_wasteland/interior_fence003f.mdl
forcetextureshadow props_wasteland/interior_fence004a.mdl
forcetextureshadow props_wasteland/interior_fence004b.mdl
forcetextureshadow props_forest/fence_barb_256.mdl
forcetextureshadow props_forest/fence_barb_512.mdl
forcetextureshadow props_forest/fence_border_128.mdl
forcetextureshadow props_forest/fence_border_256.mdl
forcetextureshadow props_forest/fence_border_512.mdl
forcetextureshadow props_forest/fence_trail_128.mdl
forcetextureshadow props_forest/fence_trail_256.mdl
forcetextureshadow props_forest/fence_trail_512.mdl
forcetextureshadow props_wasteland/exterior_fence_notbarbed002a.mdl
forcetextureshadow props_wasteland/exterior_fence_notbarbed002b.mdl
forcetextureshadow props_wasteland/exterior_fence_notbarbed002c.mdl
forcetextureshadow props_wasteland/exterior_fence_notbarbed002d.mdl
forcetextureshadow props_wasteland/exterior_fence_notbarbed002e.mdl
forcetextureshadow props_wasteland/exterior_fence_notbarbed002f.mdl
forcetextureshadow props_wasteland/exterior_fence001a.mdl
forcetextureshadow props_wasteland/exterior_fence001b.mdl
forcetextureshadow props_wasteland/exterior_fence002a.mdl
forcetextureshadow props_wasteland/exterior_fence002b.mdl
forcetextureshadow props_wasteland/exterior_fence002c.mdl
forcetextureshadow props_wasteland/exterior_fence002d.mdl
forcetextureshadow props_wasteland/exterior_fence002e.mdl
forcetextureshadow props_wasteland/exterior_fence003a.mdl
forcetextureshadow props_wasteland/exterior_fence003b.mdl
forcetextureshadow props_foliage/fern01.mdl
forcetextureshadow props_foliage/ferns01.mdl
forcetextureshadow props_foliage/ferns02.mdl
forcetextureshadow props_foliage/ferns03.mdl
forcetextureshadow props_forest/fern01.mdl
forcetextureshadow props_forest/fern01lg.mdl
forcetextureshadow props_c17/fence03a.mdl


This is Episode 2's lights file. It tells what textures give off light, and at the bottom, tells which models create shadows from their alpha channel.

You should add in your own models if they have an alpha channel if you want to. Simply create a new line and put in "forcetextureshadow" (without quotes) and then the path to your model (without the models part, so if you had "ep2/models/props_lol/lolball.mdl" you would put in "props_lol/lolball.mdl")

Save this file as lights.rad (not lights.rad.txt, make sure of this) in your Episode 2 / left 4 dead directory (c:\program files\steam\steamapps\username\Half Life 2 Episode 2\ep2\ or c:\program files\steam\steamapps\common\left4dead\l4d\)

Step 2 - Placing models and fulfilling requirements

Now, the fun part. Place your models you added into the list (or the ones that are already on the list) into your map. (For the sake of this tutorial, i'm using the one i added into the lights.rad file for everyone, models/props_c17/fence03a.mdl.)These models must be prop_static!. After you've placed your models where you want them, make sure there's a nearby light source. Having no light is pointless, and it strains your processor to compile what you can't even see.

Once you've done this, set the lightmaps around your fence/model down very low (2 is what seems to work the best, 4 is the minimum requirement). This will allow you to see the shadows, since they are fairly faint.

Step 3 - Compiling

Now that you've done this, it's time to compile! Press F9 and go to the button that says "Expert..."
Now you'll see a list of things like $bsp_exe and such. Click on $light_exe.

Now in the parameters section on the right, select all text there and replace it with the following
Code: Select all
-StaticPropPolys -TextureShadows -game $gamedir $path\$file


And that's it! You're now ready to compile. Press "Go!" from the box (DO NOT SWITCH BACK TO NORMAL MODE) And after a compile (It may take a lot longer because it's very processor intensive) you'll hopefully have pretty shadows.

Image

- Jimmy422
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Re: Transparent Texture Shadows

Postby srredfire on Wed Feb 11, 2009 10:31 pm

Friggin hot. Great tutorial. Definitely gonna give it a go.
User avatar
srredfire
Veteran
Veteran
 
Joined: Sat Jul 22, 2006 10:44 pm

Re: Transparent Texture Shadows

Postby Avager on Wed Feb 11, 2009 10:36 pm

Really great tutorial !
More shadows more candy for eyes :) .

But I've got a question, it wont create some problems when a person starts running through area with such shadows ? The shadows on his models would look...weird, aren't they ?
Avager
Member
Member
 
Joined: Mon May 26, 2008 10:56 pm

Re: Transparent Texture Shadows

Postby Spike on Wed Feb 11, 2009 10:46 pm

Lol Just when I ask about getting good tree shadows and you show me this :D
Last edited by Spike on Wed Feb 11, 2009 11:01 pm, edited 1 time in total.
User avatar
Spike
May Contain Skills
May Contain Skills
 
Joined: Wed Sep 17, 2008 7:10 pm

Re: Transparent Texture Shadows

Postby Jeeves on Wed Feb 11, 2009 10:56 pm

Quality tutorial.
Undue Punishment : 'An experimental FP Fighting game with stealth elements. ' -- TBD
Torn : 'A First Person RTS ' -- In Development as of 03/2014
Jeeves
Regular
Regular
 
Joined: Mon Sep 01, 2008 9:53 pm

Re: Transparent Texture Shadows

Postby Spike on Wed Feb 11, 2009 11:56 pm

I've done exacly the same thing on this tutorial, but when I load the map it's all fullbright. If I write mat_fullbright 0 on console it's sill fullbright. What have I done wrong?

nvm, got it working
User avatar
Spike
May Contain Skills
May Contain Skills
 
Joined: Wed Sep 17, 2008 7:10 pm

Re: Transparent Texture Shadows

Postby Jimmy422 on Thu Feb 12, 2009 1:37 am

Whoa, got published, sweet.
Image
User avatar
Jimmy422
Regular
Regular
 
Joined: Sat Sep 15, 2007 2:59 pm

Re: Transparent Texture Shadows

Postby Jimmy422 on Thu Feb 12, 2009 1:39 am

Avager wrote:Really great tutorial !
More shadows more candy for eyes :) .

But I've got a question, it wont create some problems when a person starts running through area with such shadows ? The shadows on his models would look...weird, aren't they ?

They look fine actually. VALVe uses this a lot on Episode 2 maps, just check out some of the shadows from the trees or the silo map background, you'll notice it.

Just noticed there's a typo on the description of this :(
"In this tutorial you will ealrn how you can make the opaque parts of a transparent texture on a model cast shadows."
Image
User avatar
Jimmy422
Regular
Regular
 
Joined: Sat Sep 15, 2007 2:59 pm

Re: Transparent Texture Shadows

Postby serpent666 on Thu Feb 12, 2009 2:42 am

bloody nice dude, this will make a great addition to my left 4 dead campaign in the future XD
Image
User avatar
serpent666
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Thu Apr 07, 2005 1:03 pm
Location: Perth , Western Australia

Re: Transparent Texture Shadows

Postby Blink on Thu Feb 12, 2009 9:16 am

Jimmy422 wrote:"In this tutorial you will ealrn how you can make the opaque parts of a transparent texture on a model cast shadows."


My bad :-D
User avatar
Blink
Cool 'n that
Cool 'n that
 
Joined: Fri Oct 08, 2004 4:16 pm
Location: UK

Re: Transparent Texture Shadows

Postby korge on Thu Feb 12, 2009 5:23 pm

Ths tutorial is awesome.
zombie@computer wrote:Thank god the government knows best.
User avatar
korge
Pheropod
Pheropod
 
Joined: Fri Dec 28, 2007 4:16 pm

Re: Transparent Texture Shadows

Postby FlynT on Thu Feb 12, 2009 8:17 pm

This Tutorial is of course awesome, its another great option to push the overall quality of a Map or Level! What brings me to a further question. If you look at the last Image from above you see that the Shadow is really hard, that doesn't look really realistic. So my question is, could it be possible to tune the shadow to something transparent, modification of the Alpha Channel or something else like that?

Again thanks for the clear an simple Tutorial, you rock ;)
Image
*Ahhrr, my Nipples they Hurt, they Hurt when i twist them*
User avatar
FlynT
Been Here A While
Been Here A While
 
Joined: Sun Jun 15, 2008 2:59 am
Location: Germany

Re: Transparent Texture Shadows

Postby Jimmy422 on Fri Feb 13, 2009 12:59 am

FlynT wrote:This Tutorial is of course awesome, its another great option to push the overall quality of a Map or Level! What brings me to a further question. If you look at the last Image from above you see that the Shadow is really hard, that doesn't look really realistic. So my question is, could it be possible to tune the shadow to something transparent, modification of the Alpha Channel or something else like that?

Again thanks for the clear an simple Tutorial, you rock ;)

I thought the hard shadows were more realistic, but i guess not. I was using a lightmap scale of 1 in that, so that's probably why.

Lower lightmaps should fix it.
Image
User avatar
Jimmy422
Regular
Regular
 
Joined: Sat Sep 15, 2007 2:59 pm

Re: Transparent Texture Shadows

Postby korge on Fri Feb 13, 2009 3:07 am

Jimmy422 wrote:Lower lightmaps should fix it.


I agree. I bet 2 would almost be perfect if you are trying to go for a noticeable shadow anyways.
zombie@computer wrote:Thank god the government knows best.
User avatar
korge
Pheropod
Pheropod
 
Joined: Fri Dec 28, 2007 4:16 pm

Re: Transparent Texture Shadows

Postby MrTwoVideoCards on Fri Feb 13, 2009 5:22 am

User avatar
MrTwoVideoCards
Monothetic
 
Joined: Thu Aug 02, 2007 11:18 am
Location: IN YOUR SOUL
Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users

cron