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:


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.


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")
        hook.Add("Think", "toggle_outline_script", <Huge Hook Name Here>)

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.


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.


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.




(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…)


I found this as well.

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