Shadow Mapping in Source

Grab your favourite IDE and tinker with the innards of game engines

Re: Shadow Mapping in Source

Postby Botolf on Fri Jun 15, 2012 10:15 am

So taking a closer look now, dumb question time!

-=Biohazard=- wrote:I know about a few people who tried it and gave up really fast, maybe because they have been spammed with errors after copy and pasting it...

Like Gary said, non-coders would probably have trouble with this - you need to understand the compiler errors you'd get if you want to fix them.

But anyway, this should be super simple to port imho. Especially considering that the materialsystem is based on the 2007 one. If that wasn't the case, there'd be a high potential for a lot of shader work to do...

Regarding the shader stuff, take the vanilla shaderlib.lib from 2007 and the keep the rest. Any compile errors should be simple to fix. For the client/server you can keep all the files and simply fix any occuring errors except for viewrender_deferred.cpp. That file is entirely different and it would make more sense to take the 2007 viewrender file and re-implement the deferred stuff, diff viewrender_deferred with the swarm viewrender file to do so efficiently.

- Regarding the shader stuff: Checked for a shaderlib.lib in my 2007 directories, nothing to be found. Okay on this front?

- viewrender_deferred.cpp: both your [src\game\client\deferred] viewrender_deferred.cpp and your [src\game\client] viewrender.cpp appear to have deferred rendering code within them, so colour me a little bit confused as to which of these files I'm supposed to be following the lead of when modifying the 2007 viewrender [src\game\client]. I figure the latter was superseded by the former, but it doesn't hurt to be sure.

- Not sure what you mean by diff, I assume it's some kind of side-by-side comparative mode for visual studio .cpps and the like? Once I get this running, I presume there are Alien Swarm-specific bits of code I'm looking to try not to duplicate here?

- How difficult would it be to port the editor menus as well? Used them briefly in the swarm mod and they're mighty handy.

Haven't got to moving files around yet, I'm being cautious and backing up anything I'm touching here (as well as getting clarification on everything dumb that comes to mind :P )
User avatar
Botolf
Regular
Regular
 
Joined: Sat Jan 16, 2010 7:38 am

Re: Shadow Mapping in Source

Postby -=Biohazard=- on Fri Jun 15, 2012 11:23 am

Botolf wrote:- Regarding the shader stuff: Checked for a shaderlib.lib in my 2007 directories, nothing to be found. Okay on this front?

src\materialsystem\shaderlib

Botolf wrote:- viewrender_deferred.cpp: both your [src\game\client\deferred] viewrender_deferred.cpp and your [src\game\client] viewrender.cpp appear to have deferred rendering code within them, so colour me a little bit confused as to which of these files I'm supposed to be following the lead of when modifying the 2007 viewrender [src\game\client]. I figure the latter was superseded by the former, but it doesn't hurt to be sure.

My viewrender.cpp should only contain the removal of *several* static keywords because I need those things in global scope to access them from my file. Firstly, copy your 2007 viewrender.cpp and name it viewrender_deferred.cpp. Then take a *fresh* viewrender.cpp from the swarm sdk, do not use mine! Now diff that file with viewrender_deferred, you mainly need to find the differences in renderview() and re-implement them, the rest can be copied more or less.

Now for an additional difficulty I recently copied and changed some generic render functions like DrawOpaqueRenderables and named it DrawOpaqueRenderablesDeferred. I did this to add a decal skip flag where possible (not even possible everywhere so they still break sometimes :smt021). Just omit all of that in my baseworldview because 2007 does not even support that flag.

Botolf wrote:- Not sure what you mean by diff, I assume it's some kind of side-by-side comparative mode for visual studio .cpps and the like? Once I get this running, I presume there are Alien Swarm-specific bits of code I'm looking to try not to duplicate here?

Your SVN client might help you with a diff comparison or an external tool like Beyond Compare would do the job.

Botolf wrote:- How difficult would it be to port the editor menus as well? Used them briefly in the swarm mod and they're mighty handy.

The lighting editor gui should run natively, you might again encounter simple compile errors caused by things like 'MAX' being 'max' in 2007.
User avatar
-=Biohazard=-
Regular
Regular
 
Joined: Mon Apr 07, 2008 11:15 am

Re: Shadow Mapping in Source

Postby Santairo on Fri Jun 15, 2012 4:39 pm

I'm really struggling to implement this into a fresh version of ASWScratch. I did everything the readme told me to do, but when I try to run it ShaderEditor seems to stuff it all up. Here's the build log:

Code: Select all
2>------ Build started: Project: client, Configuration: Debug Win32 ------
2>cl : Command line warning D9030: '/Gm' is incompatible with multiprocessing; ignoring /MP switch
2>  ShaderEditorSystem.cpp
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(232): error C2660: 'MainViewOrigin' : function does not take 0 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(233): error C2660: 'MainViewOrigin' : function does not take 0 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(238): error C2660: 'MainViewForward' : function does not take 0 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(242): error C2660: 'MainViewOrigin' : function does not take 0 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(242): error C2660: 'MainViewOrigin' : function does not take 0 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(651): error C2065: 'RENDER_GROUP_OPAQUE_BRUSH' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(652): error C2065: 'RENDER_GROUP_OPAQUE_BRUSH' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(661): error C2065: 'RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(662): error C2065: 'RENDER_GROUP_OPAQUE_ENTITY_HUGE' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(668): error C2065: 'RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(671): error C2065: 'RENDER_GROUP_OPAQUE_ENTITY_HUGE' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(672): error C2065: 'RENDER_GROUP_OPAQUE_ENTITY_HUGE' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(685): error C2039: 'm_RenderHandle' : is not a member of 'CClientRenderablesList::CEntry'
2>          d:\source\src\game\client\clientleafsystem.h(84) : see declaration of 'CClientRenderablesList::CEntry'
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(703): error C2065: 'RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(704): error C2065: 'RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(706): error C2065: 'RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(708): error C2065: 'RENDER_GROUP_OPAQUE_ENTITY_HUGE' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(709): error C2065: 'RENDER_GROUP_OPAQUE_ENTITY_HUGE' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(711): error C2065: 'RENDER_GROUP_OPAQUE_STATIC_HUGE' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(712): error C2065: 'RENDER_GROUP_OPAQUE_STATIC_HUGE' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(715): error C2065: 'RENDER_GROUP_CFG_NUM_OPAQUE_ENT_BUCKETS' : undeclared identifier
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(852): error C2660: 'IClientRenderable::DrawModel' : function does not take 1 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(861): error C2660: 'IClientRenderable::DrawModel' : function does not take 1 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(944): error C2660: 'IStaticPropMgrClient::DrawStaticProps' : function does not take 4 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(950): error C2660: 'IStaticPropMgrClient::DrawStaticProps' : function does not take 4 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1173): error C2039: 'IsTransparent' : is not a member of 'IClientRenderable'
2>          d:\source\src\public\iclientrenderable.h(82) : see declaration of 'IClientRenderable'
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1184): error C2039: 'm_RenderHandle' : is not a member of 'CClientRenderablesList::CEntry'
2>          d:\source\src\game\client\clientleafsystem.h(84) : see declaration of 'CClientRenderablesList::CEntry'
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1198): error C2039: 'm_RenderHandle' : is not a member of 'CClientRenderablesList::CEntry'
2>          d:\source\src\game\client\clientleafsystem.h(84) : see declaration of 'CClientRenderablesList::CEntry'
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1207): error C2039: 'm_RenderHandle' : is not a member of 'CClientRenderablesList::CEntry'
2>          d:\source\src\game\client\clientleafsystem.h(84) : see declaration of 'CClientRenderablesList::CEntry'
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1214): error C3861: 'swap': identifier not found
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1225): error C2039: 'm_RenderHandle' : is not a member of 'CClientRenderablesList::CEntry'
2>          d:\source\src\game\client\clientleafsystem.h(84) : see declaration of 'CClientRenderablesList::CEntry'
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1317): error C2039: 'UsesPowerOfTwoFrameBufferTexture' : is not a member of 'IClientRenderable'
2>          d:\source\src\public\iclientrenderable.h(82) : see declaration of 'IClientRenderable'
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1344): error C2660: 'IClientRenderable::DrawModel' : function does not take 1 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1465): error C2660: 'IVEngineClient::GetScreenAspectRatio' : function does not take 0 arguments
2>d:\source\src\game\client\shadereditor\shadereditorsystem.cpp(1497): error C2660: 'IClientLeafSystem::CollateViewModelRenderables' : function does not take 2 arguments
2>  SEdit_ModelRender.cpp
2>d:\source\src\game\client\shadereditor\sedit_modelrender.cpp(140): error C2065: 'RENDER_GROUP_OPAQUE_ENTITY' : undeclared identifier
2>d:\source\src\game\client\shadereditor\sedit_modelrender.cpp(283): error C2660: 'C_BaseAnimating::DrawModel' : function does not take 1 arguments
2>d:\source\src\game\client\shadereditor\sedit_modelrender.cpp(307): error C2660: 'IVEngineClient::GetScreenAspectRatio' : function does not take 0 arguments
2>  Generating Code...


I haven't modified any of the shader editor code and I'm using revision 32 from the deferred SVN.

Any help will be appreciated!
Santairo
Dumpling
Dumpling
 
Joined: Fri Jun 15, 2012 4:32 pm

Re: Shadow Mapping in Source

Postby -=Biohazard=- on Fri Jun 15, 2012 4:47 pm

Are you actually using the shadereditor files from my repo? Because those are just forced to compile for swarm atm, however yours tries to compile for 2007.

The error should be pretty self explanatory if you'd take a look at your file. You don't have SWARM_DLL defined because that aswscratch thingy prbly removed it.
User avatar
-=Biohazard=-
Regular
Regular
 
Joined: Mon Apr 07, 2008 11:15 am

Re: Shadow Mapping in Source

Postby Santairo on Fri Jun 15, 2012 6:41 pm

-=Biohazard=- wrote:Are you actually using the shadereditor files from my repo? Because those are just forced to compile for swarm atm, however yours tries to compile for 2007.

The error should be pretty self explanatory if you'd take a look at your file. You don't have SWARM_DLL defined because that aswscratch thingy prbly removed it.


Ah, of course! Completely forgot about that. Everything compiles now! Thanks for the help.
Santairo
Dumpling
Dumpling
 
Joined: Fri Jun 15, 2012 4:32 pm

Re: Shadow Mapping in Source

Postby Botolf on Fri Jun 15, 2012 9:07 pm

src\materialsystem\shaderlib

Checked this location yesterday, double-checked it now. No .lib files of any sort, let alone one named shaderlib.

My viewrender.cpp should only contain the removal of *several* static keywords because I need those things in global scope to access them from my file. Firstly, copy your 2007 viewrender.cpp and name it viewrender_deferred.cpp. Then take a *fresh* viewrender.cpp from the swarm sdk, do not use mine! Now diff that file with viewrender_deferred, you mainly need to find the differences in renderview() and re-implement them, the rest can be copied more or less.

Now for an additional difficulty I recently copied and changed some generic render functions like DrawOpaqueRenderables and named it DrawOpaqueRenderablesDeferred. I did this to add a decal skip flag where possible (not even possible everywhere so they still break sometimes :smt021). Just omit all of that in my baseworldview because 2007 does not even support that flag.

Your SVN client might help you with a diff comparison or an external tool like Beyond Compare would do the job

Alright, danke kindly. I'll probably have more dumb questions later, but I'll take what you've said and see what I can get working.

Ah, I know tortoisesvn does diff on older revisions of a file, but not sure about two separate ones. I'll take a look at Beyond Compare, thanks :D

The lighting editor gui should run natively, you might again encounter simple compile errors caused by things like 'MAX' being 'max' in 2007.

Noted.
User avatar
Botolf
Regular
Regular
 
Joined: Sat Jan 16, 2010 7:38 am

Re: Shadow Mapping in Source

Postby -=Biohazard=- on Fri Jun 15, 2012 9:23 pm

Botolf wrote:
src\materialsystem\shaderlib

Checked this location yesterday, double-checked it now. No .lib files of any sort, let alone one named shaderlib.

The project in there builds the shaderlib.lib, I guess I didn't really make that clear earlier :wink: .
User avatar
-=Biohazard=-
Regular
Regular
 
Joined: Mon Apr 07, 2008 11:15 am

Re: Shadow Mapping in Source

Postby Santairo on Fri Jun 15, 2012 9:26 pm

Botolf wrote:Ah, I know tortoisesvn does diff on older revisions of a file, but not sure about two separate ones. I'll take a look at Beyond Compare, thanks :D


You might want to check out KDiff3 since it's free.

Santairo wrote:
-=Biohazard=- wrote:Are you actually using the shadereditor files from my repo? Because those are just forced to compile for swarm atm, however yours tries to compile for 2007.

The error should be pretty self explanatory if you'd take a look at your file. You don't have SWARM_DLL defined because that aswscratch thingy prbly removed it.


Ah, of course! Completely forgot about that. Everything compiles now! Thanks for the help.


Shortly after posting this I tried out viewmodels and got some very strange results:

Image

I'll be honest, I'm not great at coding (as I proved with the whole SWARM_DLL thing.)
But I figured I may as well jump right in and give it a go.

I've gone through practically every file and compared it to the deferred code and I can't seem to track down the problem. Also, the wall on the left appears to be transparent and I can't figure that one out either... Again, any help would be appreciated.
Santairo
Dumpling
Dumpling
 
Joined: Fri Jun 15, 2012 4:32 pm

Re: Shadow Mapping in Source

Postby Botolf on Sat Jun 16, 2012 12:21 am

-=Biohazard=- wrote:The project in there builds the shaderlib.lib, I guess I didn't really make that clear earlier :wink: .

Ahhhh, derp. So I build shaderlib from the deferred mod's project, in lieu of SDK 2007's.

Santairo wrote:You might want to check out KDiff3 since it's free.

Noted, thank you.
User avatar
Botolf
Regular
Regular
 
Joined: Sat Jan 16, 2010 7:38 am

Re: Shadow Mapping in Source

Postby -=Biohazard=- on Sat Jun 16, 2012 3:36 pm

Santairo wrote:I'll be honest, I'm not great at coding (as I proved with the whole SWARM_DLL thing.)
But I figured I may as well jump right in and give it a go.

I've gone through practically every file and compared it to the deferred code and I can't seem to track down the problem. Also, the wall on the left appears to be transparent and I can't figure that one out either... Again, any help would be appreciated.

That's kinda.. random.. but chances are you're missing something simple I suppose.
Also viewmodels and stuff work fine in my (unmodifed) build for you, right? Maybe try copying the materials from my build too, some of them use deferred_brush and stuff - make sure to also use the vpk or that overridevpk startparam then.

@Botolf, I said that you should use a shaderlib.lib built from the original 2007 files (for 2007), not the other way around :wink: .
User avatar
-=Biohazard=-
Regular
Regular
 
Joined: Mon Apr 07, 2008 11:15 am

Re: Shadow Mapping in Source

Postby Santairo on Sun Jun 17, 2012 1:26 pm

-=Biohazard=- wrote:That's kinda.. random.. but chances are you're missing something simple I suppose.
Also viewmodels and stuff work fine in my (unmodifed) build for you, right? Maybe try copying the materials from my build too, some of them use deferred_brush and stuff - make sure to also use the vpk or that overridevpk startparam then.


Yeah, turns out I hadn't copied the vpk across. Everything works fine now. After compiling and messing around a bit I noticed something else though. I also tested this on your build and the same thing happens.

Image

As you can see in the picture here, by simply moving the mouse a little to the left the shadows disappear completely. This only seems to happen in this particular area of your test map and it will only happen when you're close to the orange cube, when the cube is in view and when you're viewing the cube at certain angles.
Santairo
Dumpling
Dumpling
 
Joined: Fri Jun 15, 2012 4:32 pm

Re: Shadow Mapping in Source

Postby -=Biohazard=- on Sun Jun 17, 2012 5:23 pm

It has nothing to do with the cube.

See viewrender_deferred.cpp #line 2938...

If you use the correct code it'll bug with orthogonal projections at certain light angles.
User avatar
-=Biohazard=-
Regular
Regular
 
Joined: Mon Apr 07, 2008 11:15 am

Re: Shadow Mapping in Source

Postby ScarT on Wed Jul 11, 2012 9:41 pm

Textures with $selfillum crashes for me, even in the build on the SVN.

Code: Select all
Unhandled exception at 0x0DB0EE80 (shaderapidx9.dll) in swarm.exe: 0xC0000005: Access violation reading location 0x0000000C.


It points me to line 423 in \materialsystem\swarmshaders\defpass_composite.cpp
Specifically at
pShaderAPI->SetPixelShaderConstant( 10, params[ info.iSelfIllumTint ]->GetVecValue() );

The callstack can be found here.
http://pastebin.com/t0HqjQ41
User avatar
ScarT
Senior Member
Senior Member
 
Joined: Sat Apr 02, 2005 7:33 pm
Location: Denmarkian Land

Re: Shadow Mapping in Source

Postby Ken Chan on Thu Jul 12, 2012 6:19 am

A little off-topic on deferred lighting, I've done some coding on updating the env_projectedtexture to give mappers more control of it.
1. Volumetric lighting/ Filter Size Setting from Hammer
Image
2. Real-time Volumetric
Image
(64 Planes)

Image
(128 Planes)

Give me some comments!
User avatar
Ken Chan
Regular
Regular
 
Joined: Mon Apr 09, 2012 7:16 pm
Location: Hong Kong

Re: Shadow Mapping in Source

Postby -=Biohazard=- on Thu Jul 12, 2012 12:11 pm

ScarT wrote:Textures with $selfillum crashes for me, even in the build on the SVN.

Code: Select all
Unhandled exception at 0x0DB0EE80 (shaderapidx9.dll) in swarm.exe: 0xC0000005: Access violation reading location 0x0000000C.


It points me to line 423 in \materialsystem\swarmshaders\defpass_composite.cpp
Specifically at
pShaderAPI->SetPixelShaderConstant( 10, params[ info.iSelfIllumTint ]->GetVecValue() );

The callstack can be found here.
http://pastebin.com/t0HqjQ41


Did you use it on a brush?
It looks like I forgot to copy the self illum vars to deferred_brush (only tested it on models actually...).
User avatar
-=Biohazard=-
Regular
Regular
 
Joined: Mon Apr 07, 2008 11:15 am
PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users

cron