Script_mover casting shadows?


(FireFly) #1

At the moment I’m having the same problem as Ifurita is having with one of the models in his map: http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=11684&sid=b00d154fd6e42e2fbe673ef62b90c69a

Instead of hijacking his thread I decided to post a new one. In my map I have a script_mover with a model2 key pointing to a md3 model. I wanted to cast some shadows on the model with the _rs=1 and _cs=1 keys/values , but it left me with a pitch black model. After deleting those keys everything looked fine except: no shadows…

Now if you look at the churchhill in “Fueldump” you’ll notice that the tank does cast shadows.It’s also a script_mover, without the _cs & _rs keys.

In the directory where the churchhill.md3 model is located I found these files: models/mapobjects/tanks_sd/churchhill.shadow and models/mapobjects/tanks_sd/tank_shadow.tga

the tank_shadow.tga file contains the image of the tank’s shadow (inverted)

the churchhill.shadow file is nothing more than a textfile you can open in wordpad saying: “models/mapobjects/tanks_sd/shadow_tank -80 -160 160 320 192 -32”

Does anyone might have a clue how these shadow-files work and what the numbers mean?


(Detoeni) #2

You dont want that model casting a shadow. That shadow is cast on the lightgrid and worldspawn, there for it is static.

Sd’s tank has a blend shader just above the ground to fake the shadow. Im not 100% sure but the shadow file might be a leftover from where they were playing with stencil shadows.


(FireFly) #3

You dont want that model casting a shadow. That shadow is cast on the lightgrid and worldspawn, there for it is static.

You’re right, when I only add the _rs=1 key the tram looks fine and is casting a shadow on the ground, however when the tram moves, the shadow remains on the same spot. So the shadow is ‘burned’ into the lightmap and therefor remains static.

Sd’s tank has a blend shader just above the ground to fake the shadow

So this might work: creating a flat md3 model containing an image of the trams’ shadow and tag it to the tram,making sure it’s just 1 or less units above the ground…
It’s worth a try…


(Detoeni) #4

It will work, its used quite alot in ET/RTCW, next time your in game, look at your feet, the shadow blobs you see are done the same way.


(FireFly) #5

I found out that the shadow-files are not leftovers but actually work. I copied the churchhill.shadow file to the directory where my trammodel is located (ff_tramsiege.md3) and renamed it to ff_tramsiege.shadow…

below is the result:

Like I said, the shadow-file is nothing more than a textfile with this line in it: “models/mapobjects/tanks_sd/shadow_tank -80 -160 160 320 192 -32”

the ‘models/mapobjects/tanks_sd/shadow_tank’ part refers to the tga image. The first 2 numbers are y and x coordinates where the shadow is being displayed on the ground (-80=y pos, -160=x pos)

I still haven’t figured out what the other numbers are but i’m working on it…

EDIT: the third number represents the y-stretching of the shadow, the fourth number represents the x-stretching, the last number will make the shadow darker or lighter…


(Detoeni) #6
<y> <x> <y stretch> <x stretch> <?> <alpha>

that five values, also all the tanks/truck have there own shadow file.
They all have diffrent hight origins, so hows the shadow hight been set?


(Jaquboss) #7

Or you may just update your tram with flate model/brush and use similar shader …


(Detoeni) #8

This is realy nice, why, o, why is it not in the LDR?

The shadow is projected down on all surfaces that face upward, under the object ( and quite a bit higher(needs more testing)). Thats why no “z” settings, You also need a shader (shadow.shader has the shader used by the tank).

The texture needs to be a black and white 24bit tga (no alpha chanel) the last value sets the alpha levels (0 means white is value “0”, a lower value the more transparent)

not worked out value five but thats next on me list.


(mrfin) #9

nice tram


(Detoeni) #10

Got it worked out

<path/to/shader> <Y> <X> <y size> <x size> <influence> <alpha>

<Y> = Y axis off set, in game units, from model origin.
<X> = X axis off set, in game units, from model origin.
<y size> = sets texture projection size, in game units for Y axis.
<x size> = sets texture projection size, in game units for X axis.
<influence> = distance from origin, in game units that the shadow fades across.
<alpha> = sets the alpha levels (0 means white is value "0", a lower value the more transparent) 


and the shader for refrence

// model projection shadow shaders

models/mapobjects/tanks_sd/shadow_tank
{
	polygonOffset
	{
		clampmap models/mapobjects/tanks_sd/shadow_tank.tga
		blendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
		rgbGen exactVertex
	}
}

nice tram

ditto


(Chruker) #11

Nice thread. And a really nice tram model. Anyway if you go for the thing with having a shadow being painted on a piece of brush that is moved with the tram, I remember reading somewhere that if you set _rs and _cs to a value higher than 1 it will only receive/cast light on others with the same number.


(FireFly) #12
<path/to/shader> <Y> <X> <y size> <x size> <influence> <alpha> 

<Y> = Y axis off set, in game units, from model origin. 
<X> = X axis off set, in game units, from model origin. 
<y size> = sets texture projection size, in game units for Y axis. 
<x size> = sets texture projection size, in game units for X axis. 
<influence> = distance from origin, in game units that the shadow fades across. 
<alpha> = sets the alpha levels (0 means white is value "0", a lower value the more transparent) 

Nice work Detoeni, I Could not figure out what that fifth number was doing. Unfortunally I’ve had to delete the shadow in my map because it was acting weird: on some spots in the map parts of the shadow would keep disappearing, re-appering a second later. I also found out what is causing this;

the tram rail-road (receiving the shadow) is a combination of patches and brushes. Right on the spots where patchwork changes into brushwork I get the missing shadow thingy…

One solution would be to delete all the brushwork and replace them with patches, however I want to release my map today or tomorrow, so I nolonger have the time changing it. instead I will fix it for the next release, because I have to admit, those shadows are looking kinda cool :smiley:


(Detoeni) #13

One solution would be to delete all the brushwork and replace them with patches

A better one would be to convert all your track to ase models. That way the track corners(patches) wont get messed up when folks use a low “level of detail” in there game settings.


(FireFly) #14

Well, I don’t have much experience with using / creating ase-models, But there should be some information about it here in the forums…I’ll give it a shot


(Detoeni) #15

I have a small tutorial on ase here:
http://www.planetwolfenstein.com/detoeni/ase.htm

A “–subivisions” value of “4” should be good for what your doing.


(Chruker) #16

When I’m starting my Church Of Enemy-Territory and its related religion, you two are going to be the Gods Of Modeling