Talk:Env projectedtexture

From Valve Developer Community
Revision as of 21:15, 23 December 2009 by Wilsonc (talk | contribs) (PCF fix?)

Jump to: navigation, search

PCF fix?

I'd heard that changing the attenuation would "fix" some of the issues with the flickery grainy filters around the shadows, and I tried to mess around with the attenuation values but it looked like it was either turning them totally black or fading them out, which didn't really help with the problem. After a bit of experimenting (I made ConVars for a lot of the variables in struct FlashlightState_t ), I found that by changing the "m_flShadowFilterSize" from 3.0f to 1.0f it made the ugly graininess less obvious on the edges of shadows, and it's so far the best solution I've found for fixing it. --Wilsonc 03:09, 30 October 2009 (UTC)

Obviously the way to remove them completely would be to set the filter size to 0, but as you've probably seen it looks awful. The way to solve this would be to employ a different filtering method (maybe VSM - this would also help with some of the biasing problems) in the flashlight shader header (src\materialsystem\stdshaders\common_flashlight_fxc.h), but even though I've been able to successfully compile a modified shader DLL, the game just won't accept it somehow and continues using the default shader. In my opinion, however, there are far greater problems than the shadow map anti aliasing, for example the fact that the light attenuates based on the position of the camera rather than the position of the projector itself. --Hamish 11:40, 31 October 2009 (UTC)


You can sort of hide the attenuation problems by setting the FarZ to something really high (like 2048 instead of the default 700 or whatever). I've also noticed that depth-bias could be changed just by changing a few variables, and the shadows no longer look all blobby and are more defined, however any changing the depth-bias to anything below 4 resulted in ugly artifacts. I also noticed that you could enable projected textures on viewmodels just by changing ShouldReceiveProjectedTextures() in baseviewmodel_shared.h to return true. It's funny how all those graphic intensive mods are always hyping their awesome shadows and boast about how they can achieve awesome graphics even though they're just changing a few lines of code :P --Wilsonc 21:15, 23 December 2009 (UTC)

Mysterious Inputs

*; target <entity> : Specify a new <target_desination> entity.
*; cameraspace <bool> : See above keyvalues.
*; LightOnlyTarget <bool> : See above keyvalues. : {bug|Non-functional.}}
*; LightWorld <bool> : See above keyvalues. : {bug|Cannot be re-enabled.}}
*; EnableShadows <bool> : See above keyvalues.
*; Ambient <float>
*; SpotlightTexture <VTF/string> :A VTF file (not VMT), relative to /models.

These inputs are not specified in base.fgd ... have they been removed? I've commented them out of the article for now. --Beeswax 16:09, 13 Apr 2008 (PDT)

They've never been in the FGD, but they are all in the source code. --TomEdwards 01:22, 14 Apr 2008 (PDT)
Thought it might be something like that ... thanks. I did try (in EP2) to test by firing the SpotlightTexture from a custom logic_auto output but I couldn't get it to work ... Any tips would be appreciated as this seems like the most exciting feature. --Beeswax 07:11, 14 Apr 2008 (PDT)
Make sure you're point it to a VTF, not a VMT. --TomEdwards 09:05, 14 Apr 2008 (PDT)
Yeah I read that in the article. Have you ever got it working ? --Beeswax 17:56, 14 Apr 2008 (PDT)
I've never not had it work... --TomEdwards 04:31, 15 Apr 2008 (PDT)

Player Parenting

How do you parent this entity to the Player? I tried various Targetname tokens (!player, etc) as parentname but it didn't like any of them ... --Beeswax 07:11, 14 Apr 2008 (PDT)

You need to enable the camera space value, I think. Never actually tried it myself. --TomEdwards 09:05, 14 Apr 2008 (PDT)
Use SetParent on the players ViewModel. Pseudo-code: ply.FlashLight:SetParent(ply:GetViewModel())

Light attenuation?

Seems there is also ways to change the Light's constant values and such, while hidden in the .cpp file. Yet you'll need a coder to help bring em out, and appear in hammer, and be accepted in game, however it seems that this entity also has these values built in as well.--Gear 01:00, 9 Aug 2008 (PDT)

Moving Object Parenting

How do you make this entity parented to a moving object ? There's a parent field, but it doesn't follow the moving object at all. The light just stay where it was turned on, and never follow it's parent until it is turned off and on again (then it appears at the same level than its parent, but don't move). --NykO18 15:38, 28 Aug 2008 (PDT)

I have updated the article with several bug fixes including the one for this particular problem. As of now, you can only parent this entity in a mod that incorporates these fixes. Yatar 19:49, 7 Nov 2008 (PST)
Parenting is broken again somehow. I've tested this with just a base fix of all the code presented to test. So for now I'm going to place this here until one of us figures out how to re-fix it.
By default, this entity's position only gets updated when it gets turned on. Thus, parenting does not work. To fix this, open c_env_projectedtexture.cpp and in line 225, comment out 3 lines like this:
    //	if ( bForceUpdate == false )
    //	{
    		g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true );
    //	}
In line 233 in the Simulate function, change the argument false to true like this:
    UpdateLight( true );

--Gear 20:57, 14 Jan 2009 (PST)

Setting r_flashlightscissor to 0

I'm not sure how to go about doing this, as it's not included in the SDK, in c_hl2mp_player.cpp I tried adding:

 DLL_IMPORT ConVar *r_flashlightscissor;

Below other ConVar definitions on line 54 and 55 and then in the class's constructor I added:

 r_flashlightscissor->SetValue( 0 );

However this doesn't compile, what am I missing and how can I fix this? -- Sicolet 17:31, 26 Nov 2008 (PST)

The problem is that it is a cheat, and therefore needs to tell Source to turn it on and initiate every time a map is loaded. I managed to get around this by loading another Dll's settings much like you did, but our coder also did a "Fuck you Source" in the code. I'll ask him how he managed to do it in the code.--Gear 16:59, 15 Dec 2008 (PST)
ConVar *r_flashlightscissor = cvar->FindVar( "r_flashlightscissor" );
r_flashlightscissor->SetValue( 0 ); You can thank some of the guys on the Steam Powered forums for this.--1/4 Life 15:33, 12 Jan 2009 (PST)

Configurable Values for number of lights?

The article has this:

m_nMaxDepthTextureShadows = YOUR_CHOSEN_MAX; //with your number

So, I figured i could make it configurable based on a ConVar so i could set it without compiling code for easy performance testing, and to determine how many lights is too many.

so I did this:

ConVar max_projected_lights( "max_projected_lights", "1" );

and this later on:

m_nMaxDepthTextureShadows = max_projected_lights.GetInt();

but there's a problem. first of all, I'm seeing a warning message "too many shadow maps this frame" just when the map loads.

I didn't think that was a huge problem, but then the player flashlight has weird behavior of projecting the result of the projection of one of the env_projectedtexture in the level. for example, i have a creature in front of an env_projectedtexture, then i click on my flashlight (while in a different part of the level) and i'm seeing the shadow of the creature in my flashlight.

This doesn't happen when I hard code an integer value for m_nMaxDepthTextureShadows. vecima 02:52, 30 March 2009 (UTC)

You're working with the init() function, which sounds very much like something called only once. You'll need your convar to execute a callback function that changes m_nMaxDepthTextureShadows whenever it's called. --TomEdwards 21:10, 30 March 2009 (UTC)
I might not have been clear. I don't want to change the number of allowed lights on the fly, I just want a number that is decided in the config file, so when the game starts up it uses that number. I didn't define the ConVar in the Init(), I just called it's GetInt(). vecima 04:23, 31 March 2009 (UTC)
If you want to save a cvar's value to save you'll need to give it the FCVAR_ARCHIVE flag. Beyond that, I don't know... --TomEdwards 18:23, 31 March 2009 (UTC)
I tried both FCVAR_ARCHIVE and FCVAR_REPLICATED and had the same problem both times. I guess it's not a big deal, but one of the things I was thinking of doing was making a mod codebase with entirely configurable values for those who don't code. for now I'll just use a set value. thanks anyhow. vecima 03:46, 6 April 2009 (UTC)
Be careful on setting the number of lights in a single map, oddly this value effects Render Targets by a large amount. 20 would be reasonable.--Gear 09:02, 6 April 2009 (UTC)