render.GetLightColor

From GMod Wiki

Jump to: navigation, search
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: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Render.GetLightColor]Render.GetLightColor [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionExample taken from the bouncy ball SENT
Used onNewerClient.png
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
 
OutputN/A


Additional Notes

local lightvec = render.GetLightColor( pos )
local lightcol = Color( lightvec.x * 255, lightvec.y * 255, lightvec.z * 255 ) --this is the color
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox