Jump to content

Jedi Academy turned 20 this year! We celebrated in a ton of different ways: mod contest, server event, podcast, etc. Thank you to all who have been a part of this game for the last two decades. Check out the anniversary content!

Read more

Welcome to JKHub

This community is dedicated to the games Star Wars: Jedi Outcast (2002) and Jedi Academy (2003). We host over 3,000 mods created by passionate fans around the world, and thousands of threads of people showcasing their works in progress and asking for assistance. From mods to art to troubleshooting help, we probably have it. If we don't, request or contribute!

Get started

This game turned 20 years old this year, and it is still one of the greatest Star Wars games of all time. If you're new or returning from a long hiatus, here are the basics of getting started with Star Wars Jedi Knight Jedi Academy in 2023.

Read more

Shadowing Effects and Alpha-Shadowing


Szico VII
  • Title: Shadowing Effects and Alpha shadowing
  • Subject: How to create cool looking shadows that are well defined.
  • Written by: Szico VII
  • Tutorial written for: JK3
  • Similar concept work like in: N/A
  • Difficulty level: 4/10
  • Expected time to complete for first attempt: 10 mins
  • Prerequisites: Ability to map basic structures, create entities and to implement shaders.


You can get shadows normally in JK3 simply by design, as the engine usually calculates reasonable shadows for you. But what if you want that special effect to enhance the atmosphere, chances are, you're gonna need to do it manually. This tutorial will go over the basics of creating cool, more realistic and defined shadows, using the alpha shadowing techniques. You will end up with something like this:
gRiu7HC.gif

The Setup
First off, you'll want to find the area of your map which you want the cool shadowing on. Make sure you have a light source for the shadows, and I highly recommend it is shader-lit, with a fairly strong glow. In the example above, I have a texture of various control panels, which is emitting yellow light. This is covered by a brush with a grate texture on it. The same setup is repeated with the white light at the top, except I have used a less powerful light there and a different grate texture.

So here is what you need to do:
Create a square room and texture the ceiling and walls with ''textures/doomgiver/basic.'' Texture the floor with your light emitting shader, as shown below. If you do not have a light-emitting shader, you will need to make one. For testing purposes, you may use the shader given below. The image it refers to is just a solid 4x4pixel yellow square.

RYqwUDs.gif

Light emitting-shader: (Copyable version shown below)
 

textures/mymap/yellowglow
{
qer_editorimage textures/mymap/yellowglow
q3map_surfacelight 500
q3map_lightRGB 1.00 0.99 0.42
{
map $lightmap
}
{
map textures/mymap/yellowglow
blendFunc GL_DST_COLOR GL_ZERO
}
{
map textures/mymap/yellowglow
blendFunc GL_ONE GL_ONE
glow
rgbGen identity
}
}


Getting the grates put in:
Once this is complete, you need to add your grate texture and shader. You can simply borrow one of Raven's grate textures, (make sure it is a .tga with an alpha channel or an equivalent png) however, you will need to give it a new shader, as we are going to give it alpha shadowing. Alpha shadowing is a technique whereby light can pass through some areas of a texture but not others. Which areas it can pass through is determined by its alpha channel. Transparent areas, light will go though, not transparent areas, it won't. Without this command, light wont go through the texture at all regardless of the presense of an alpha channel.

Here is the shader -(Copyable version shown below)

 

 

 

textures/mymap/grate
{
qer_editorimage textures/imperial/grate02
surfaceparm nonopaque
surfaceparm trans
surfaceparm alphashadow
cull twosided
qer_trans 1.0
{
map textures/imperial/grate02
alphaFunc GE128
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
depthWrite
}
{
map $lightmap
rgbGen identity
blendFunc GL_DST_COLOR GL_ZERO
depthFunc equal
}
}

 


Now we are ready to apply the shader, so go back to your map and create a brush covering the entire floor space, which lines up about halfway between the floor and ceiling (You can change this for different shadow effects later,) as shown below. DON'T FORGET TO MAKE THIS A DETAIL BRUSH! (Select it and hit Ctrl+ M)

f8FttAG.gif

Now, turn this brush into a func_group. Give it the following keys and values:
Key: _castshadows
Value: 1

Key: _lightmapscale
Value: 0.1

Next, select all surfaces you want shadows to be cast onto by this particular light source (In this case, all the walls textured with the doomgiver/basic texture.) Make these brushes also into a func_group and give it the following keys and values.

Key: _recieveshadows
Value: 1

Key: _lightmapscale
Value: 0.1

Now add in a player spawn, and compile! You should get something looking as follows:
Ir6dkzU.gif

Of course, you can mess about with the light shader colours and strength, different gratings, and try moving the grating closer or further from the light source for different effects. You can also use higher _lightmapscale values on your func_groups if your map is very large and the light compile is taking ages, but never go higher than 0.99 (as 1 is the default) This will give you reduced shadow precision and quality however. For example, in the shots below, I have tried lowering the grating.
j9zbqHN.gif

You may have spotted that the shadows look a little grainy toward the bottom. Making your texture repeat less will solve this, as will adding a small ambient light or perhaps putting the light source closer to the grate, or, as shown in the shot below, reduce the strength of the light (I also changed the texture used).
vvmdYLc.gif

As a final note, if you want to add new brushes to your func_group, if you realise there is a brush you left out, simply select first the brush, and then a brush in the func_group. Right click in the 2D view, and go ''Move into Entity.'' Remember, if you want to cast shadows onto a brush which is already an entity and cannot be made into a func_group, you should just add the same keys and values as you would if it were a func_group.

And of course this will work with brushes as well as alpha shadowed textures - just follow the same principle, make the brushes you want cast shadows and voila!

But, there is one last thing. Sometimes, shadows require color, for example, when light is shining through coloured glass. For this kind of shadow, there is an extra command you must add to your shader. It is:

surfaceparm lightfilter

This uses the colors in the texture to generate the colours for the shadows, so if you had a green texture, you''d get a green shadow.

 


User Feedback

Recommended Comments

There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...