Results 1 to 9 of 9

Thread: WINDOW_STYLE_DVAR_SHADER

  1. #1
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts

    WINDOW_STYLE_DVAR_SHADER

    I just discovered this. I didn't know of its existence until I saw it in COD1 (it's not used in COD2 at all, and there isn't any reference to it), so I thought I'd share:

    If you want to show a shader image in a menu file, but you only want to show it on certain conditions, what I have been doing all these years is to put in a dvartest to only show the shader when the condition is right. This lead to quite a few different itemDef assets in the same menu file. By using the WINDOW_STYLE_DVAR_SHADER as the style setting, you only have to have 1 ItemDef and then set the dvar, either in the menu action, or by GSC script. That way you can show an unlimited number of different shaders on different occasions and keep your asset count down.

    This is an example:

    Code:
    		itemDef
    		{
    			name			"soldier_image"
    			visible 		1
    			rect			0 0 270 270
    			origin			ORIGIN_TEAMIMAGE
    	 		style			WINDOW_STYLE_CVAR_SHADER
    			cvar			"ui_nation"
    			forecolor		1 1 1 1
    			backcolor		0 0 0 0.7975
    			decoration
    		}
    So, that is an ItemDef in my teams menu. I set the "ui_nation" dvar according to which team they are on:

    Code:
    	switch( game["allies"] )
    	{
    		case "american":
    			self setClientCvar( "ui_nation", "ui_mp/assets/hud@team_flags_americangerman.dds" );
    			break;
    		
    		case "british":
    			self setClientCvar( "ui_nation", "ui_mp/assets/hud@team_flags_britishgerman.dds" );
    			break;
    
    		case "russian":
    			self setClientCvar( "ui_nation", "ui_mp/assets/hud@team_flags_russiangerman.dds" );
    			break;
    	}
    NOTE - the dvar contains the full path to the file. The example above is from COD1, and so obviously as that game didn't use materials files, the path leads to the raw shader file.

    Special Note for COD2 - If you want to keep switching the shader shown, to make the ItemDef "blank", you have to set the dvar to nothing. In COD1, that's fine - if it doesn't find a shader, it wont kick off. With COD2 however, you get the checkerboard missing image shader. So, create a blank/empty IWI file and materials, and call that to "blank" it out:

    Code:
    self setClientCvar( "ui_nation", "empty" );
    Where "empty" is a 12 x 12 shader with a white alpha channel but nothing on its face (it is effectively "blank" or "empty").
    Last edited by Tally; 29th October 2014 at 10:29.

  2. The Following 2 Users Say Thank You to Tally For This Useful Post:

    filthy_freak_ (30th October 2014),kung foo man (29th October 2014)

  3. #2
    Private First Class php's Avatar
    Join Date
    Nov 2012
    Posts
    142
    Thanks
    28
    Thanked 116 Times in 59 Posts
    You would be surprised how many unused/unreferenced features there are in the CoD engine.

  4. #3
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by php View Post
    You would be surprised how many unused/unreferenced features there are in the CoD engine.
    Actually, no I wouldn't. Take the file functions we all take for granted these days. That was discovered late 2007, just before COD4 came out. Had we known about it in 2005/2006, it would have solved a lot of problems for us.

    It always takes some inquisitive person to discover these things for us. That is why it is vital that the credits to these people is preserved. Modders today don't have a clue who they are indebted to for all the things they take for granted. It is up to us who remember to keep those credits alive.

  5. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by php View Post
    You would be surprised how many unused/unreferenced features there are in the CoD engine.
    You are ofcourse referring to my rotational hud element find 5 years after the release of the game?

    Agree with tally though, nowadays most features are pretty well documented or at least quite well known
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  6. #5
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by IzNoGoD View Post
    Agree with tally though, nowadays most features are pretty well documented or at least quite well known
    I guess the only unknowns spots are the shader materials and custom player animations (without referring to the stock CoD2 joints).
    I've managed to create some custom scrolling shaders like 2 years ago, but still dont really have a clue how they are working

  7. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by serthy View Post
    I guess the only unknowns spots are the shader materials and custom player animations (without referring to the stock CoD2 joints).
    I've managed to create some custom scrolling shaders like 2 years ago, but still dont really have a clue how they are working
    The problem with the COD2 HLSL language files is that they aren't documented. So, no one knows much about them. I have been experimenting with them recently, and I found them quite easy to do once you understand the basic principles. I read a couple of online tutorials on HLSL and once I understood the basic principles, it became fairly easy to create my own technique sets.

    Another problem with the language is that there are only so many template files. This means if you don't understand HLSL and there isn't a template for what you want to do, you are pretty much stuck. But as I say, once you learn a bit of HLSL and you get to understand the structure of the COD2 HLSL file system, it becomes quite clear what you can do with them.

    The power of the COD2 HLSL language can be seen in successive COD games. All the developers had to do was program their shader needs and the basis to do it was already there. This is why COD:BO1 could do some pretty impressive approximations of FXAA a couple of years ahead of proper FXAA being implemented into graphics cards - it was the flexibility of the Programmable Graphics Pipeline built by IW for the COD2 engine. Once you see things like that, you begin to understand why IW dumped the very limited Fixed Function Graphics Pipeline of the old Quake 3 engine. It could not have possibly have stood the test of time, never mind the very bad bump mapping that the Q3 Gouraud shading engine does. Dumping that in favour of the Phong shading engine was also very much a far gone conclusion.
    Last edited by Tally; 29th October 2014 at 17:58.

  8. #7
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    another thing to mention to MENU_STYLE_DVAR_SHADER:
    - instead of an empty image you could use a dvartest + hidedvar{""}
    - you can use a server cvar and call makeCvarServerInfo() on that cvar, so global vars will be recognized as client cvars in your menus

  9. #8
    Private First Class php's Avatar
    Join Date
    Nov 2012
    Posts
    142
    Thanks
    28
    Thanked 116 Times in 59 Posts
    I was referring to a lot of things including rotational setClock hud element, but not one particular in mind.

  10. #9
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Just succesfully tested this method.

    Tiny note: in cod2 these 2 lines:
    Code:
                 style            WINDOW_STYLE_CVAR_SHADER
                cvar            "ui_nation"
    should use dvar instead of cvar, thus changing them to
    Code:
                 style            WINDOW_STYLE_DVAR_SHADER
                dvar            "ui_nation"
    works fine.

    http://classic.xfire.com/video/63145d/

    This is what's possible with it

    It's only one menu, maplist is dynamically generated from a mysql table
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  11. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (9th January 2015)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •