From GMod Wiki
Function |
Syntax |
render.GetLightColor( Vector Position ) Where is this used? |
Description: |
Returns the colour produced by the light at the position specified. |
Returns: |
Vector |
Part of Library: |
render |
Realm: |
|
BBCode Link: |
[b][url=http://wiki.garrysmod.com/?title=Render.GetLightColor]Render.GetLightColor [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Example taken from the bouncy ball SENT |
Used on | |
Code |
function ENT:Draw()
local pos = self:GetPos()
local vel = self:GetVelocity()
render.SetMaterial( matBall )
//This gets the light color to simulate shadows on the sprite overlay
local lcolor = render.GetLightColor( pos ) * 2
lcolor.x = self.Color.r * mathx.Clamp( lcolor.x, 0, 1 )
lcolor.y = self.Color.g * mathx.Clamp( lcolor.y, 0, 1 )
lcolor.z = self.Color.b * mathx.Clamp( lcolor.z, 0, 1 )
// Fake motion blur
for i = 1, 10 do
local col = Color( lcolor.x, lcolor.y, lcolor.z, 200 / i )
render.DrawSprite( pos + vel*(i*-0.005), 32, 32, col )
end
render.DrawSprite( pos, 32, 32, lcolor )
end
|
Output | N/A |
Additional Notes
- This returns a Vector instead of a Color, to convert it to a color, use this:
local lightvec = render.GetLightColor( pos )
local lightcol = Color( lightvec.x * 255, lightvec.y * 255, lightvec.z * 255 ) --this is the color