I've been messing around with shaders and lighting and I'm trying to cast light onto a fence so the light projects the fence's shadow onto the wall. As of now I have only been able to achieve a rather ugly shadow casting, and the fence disappears when the player moves too far away from it. My question is, is there a way to produce higher resolution shadows through an alpha image and is there a way to fix the fence vanishing? thanks in advance if you feel like helping
I've included some screenshots and a pk3 if you need a closer look.
As I lay there gazing up at the billions of stars above my head in complete awe of creations beauty and vastness the most pressing question on my mind about the meaning of it all was, "Where in the hell is my roof?"
Several possible solutions, best for you to do would probably be upping the _lightmapscale to .125 to generate a higher resolution shadow.
However, you have to make turn those walls into a func_group entity, open entity editor and addd _lightmapscale .125 key to the func_group. That's a quick way to do it.
However, lightmaps are stretched across a surface, so a func_group that contains 3 walls, a floor and a ceiling would be considered one surface. And the higher resolution lightmap would be stretched across that surface. As you might guess that means your lightmap might not look as good as you expected.
Solution is to split the walls, floor, ceiling into smaller brushes. Then turn each brush into it's own individual func_group and assign the above mentioned _lightmapscale .125 to each func_group. Now the compiler will generate same high resolution lightmap but it will stretch it across a much smaller surface, now the shadow will have higher definition, sharper edges and then that fence might show nicely on the brushes.
Bellow is a simple example, on one screenshot i applied _lightmapscale to one single large surface, now it looks good, but the edges are still blurry. So i split the surface into 3x5 equally as big brushes and made each one a func_group like i described before. Now the shadow look really good and has some sharpness.
Also try using a light entity in that place instead of light shaders.
As for it becoming invisible at a distance, it's probably cause the "wires" the fence is made of are too thin.
Oh and i forgot something important. The shadow resolution is directly linked to the source of the shadow, alpha channel. So if you use a low resolution image the shadow will be equally as low res. So your best way of doing this is by using just one tiny fragment of that fence and then tiling it 20 or 30 times across a surface until it appears dense enough.
That way you can use a higher resolution image and get better looking shadows.
I made a simple example that will show you how I'd do it.
As you can see i only used a small portion of the entire fence. And i didn't tile it too much cause i want it to be big enough to cast proper shadows. See size of the surface is very important and if you tile it too much details become too small, and the shadow can't be cast properly.
On the screenshot i used show tris to show you how the size of the surface the shadow is being cast on affects the shadow. To the left we have two surfaces both with _lightmascale set to .125, and as you can see it doesn't look very impressive.
To the right you can see several smaller surfaces with the same _lightmapscale, now things look a lot better.
Thanks for the help, it worked great! I never knew about using smaller brushes as func_groups to achieve a higher res shadow map!
As I lay there gazing up at the billions of stars above my head in complete awe of creations beauty and vastness the most pressing question on my mind about the meaning of it all was, "Where in the hell is my roof?"