Specular Lighting in Lua Script?

Specular Lighting and Script Hook Toggle?
Title says most of it.

Well, I was coming here to ask if anyone knew of a way to post render a model to add a second layer to it, much like how weapons in CoD MW Looked like on the ground, and similar to this.

It’s part of a large script project im working on where as player models are lit up, and glowed around, and I want to add this cartoony kind of shading to the models via renderx module or something.

Similar to this kind of lighting:

http://developer.nvidia.com/dev_content/cg/cg_examples/images/bump_dot3x2_diffuse_specular.jpg

Where as bright spots are really accentuated, giving a kind of plastic-look to the models on TOP of their already existant materials under. Even better If i could be taught how to animate a material or a link to a tutorial, so it would ‘pass’ over the body, making it look more like a sweep of light passing over the bodies constantly on the ‘over-shiny top-material’ Now I know this will be very expensive rendering the model potentially 3 or 4 times over, for each player model, but I’m willing to take the performance hit for now.

You can probably create the highlights with Valve’s phong shader. Other effects will need a custom shader.

The real question would be, a download location for the phong shader, because I lost it a while ago, and how to actually invoke that shader onto the model via a console command trigger to be used in my script.

EDIT:

On a side note, is there a way to put a bunch of hooks into a big hook togglable via a console command, such as the code below, but modified to toggle a whole script on and off.



local togglescript = true
concommand.Add("toggle_outline_script", function()
    togglescript= not togglescript
    if togglescript then
        hook.Remove("Think", "toggle_outline_script")
    else
        hook.Add("Think", "toggle_outline_script", <Huge Hook Name Here>)
    end
end)


Maybe there is an easier way, idk. Any help is appreciated.

One more small thing, do stencil buffers not like 3d skyboxes? It seems to have a strange effect on my script where it duplicates part of the stencil strangely, its not a huge problem, just wondering.

This is what my huge stencil script does so far, modified and based off of the modules code that the OP has so graciously given to help with the outlining, and the engine lighting override for just players.
This script project is 99.98% purely for educational purposes just so you know.

http://img294.imageshack.us/img294/3572/50889664.png

It’s been over 12 hours and no reply, I really need help with at least the hooking lua script to toggle it.

A cleaner way to do the toggling would be to keep the line
togglescript = not togglescript
And in each hook add
if togglescript the return end
At the top.

Semi off topic: Can you show how it affects the skybox?

Thank you so much, did a bit of editing, and viola! It toggles via a key. Thank you very much!
Cept this little error pops up for it now… obvious, and yet not on how to fix it, help would be appreciated. That or I will also search for an answer to it.

http://img820.imageshack.us/img820/8961/70015468.png

As for the 3d skybox conflictions with the script, here’s a picture of what it looks like, only when you are in a 3d skybox enabled map it does this, i think its a renderx module issue, but regardless you wanted to see, so this is what it looks like when I pan the view up and down.

http://img824.imageshack.us/img824/3118/16661569.jpg

http://img809.imageshack.us/img809/1615/49643471.jpg

http://img816.imageshack.us/img816/9871/60876627.jpg

(Note: It doesn’t always show up at every angle that I look at the players with, and its not as big of a deal as it seems, but a fix would be nice, but there’s no telling how long that would take…)

http://img815.imageshack.us/img815/3306/59848305.jpg

I found this as well.

http://wiki.garrysmod.com/?title=Stencil I will try using it for my reasearch.