Resource:Dynamic lighting: Difference between revisions
(Created page with "{{Resource page}} This resource lets You create dynamic lights in MTA. It gives you a list of exported functions that You can use to create per pixel pointlights and spotlight...") |
No edit summary |
||
Line 178: | Line 178: | ||
Of course when you want to use these functions in your resources you have to include | Of course when you want to use these functions in your resources you have to include | ||
the | the dynamic_lighting resource in meta. | ||
==See Also== | ==See Also== | ||
[http://msdn.microsoft.com/en-us/library/windows/desktop/bb174697%28v=vs.85%29.aspx Light Types (Direct3D 9)] | [http://msdn.microsoft.com/en-us/library/windows/desktop/bb174697%28v=vs.85%29.aspx Light Types (Direct3D 9)] |
Revision as of 15:02, 9 June 2014
This resource lets You create dynamic lights in MTA. It gives you a list of exported functions that You can use to create per pixel pointlights and spotlights.
Overview
It is easy to use, gives a few options to create per pixel lights in gtasa.
The resource itself adds exported clientside functions:
Exported functions
createPointLight
This function creates a pixel shader pointlight.
bool exports.dynamic_lighting:createPointLight(float posX,posY,posZ,colorR,colorG,colorB,colorA,attenuation,[bool normalShadow = true])
Required Arguments
- float posX, posY, posZ: Light position in world.
- float colorR,colorG,colorB,colorA: Light RGBA color emitted by the light (0 - 1 instead of 0-255).
- float attenuation: Value specifying how the light intensity changes over distance.
Optional Arguments
- bool normalShadow: Determine if the light source should be obscured when lighting a surface on opposite angles.
Returns
The function returns true if set successfully, false otherwise.
createSpotLight
This function creates a pixel shader spotlight.
bool exports.dynamic_lighting:createSpottLight(float posX,posY,posZ,colorR,colorG,colorB,colorA,dirX,dirY,dirZ, bool isEuler,float falloff,theta,phi,attenuation,[bool normalShadowing = true])
Required Arguments
- float posX, posY, posZ: Light position in world space.
- float colorR,colorG,colorB,colorA: Light RGBA color emitted by the light (0 - 1 instead of 0-255).
- float dirX,dirY,dirZ: Direction that the light is pointing in world space. It's a vector as default.
- bool isEuler: Is the angle set as an "ZXY" euler andgle or a vector.
- float dirX,dirY,dirZ: Direction that the light is pointing in world space. It's a vector as default.
- float falloff: Decrease in illumination between a spotlight's inner cone (the angle specified by Theta) and the outer edge of the outer cone (the angle specified by Phi).
- float theta: (radians) Angle, in radians, of a spotlight's inner cone - that is, the fully illuminated spotlight cone. This value must be in the range from 0 through the value specified by Phi.
- float phi: (radians) Angle, in radians, defining the outer edge of the spotlight's outer cone. Points outside this cone are not lit by the spotlight. This value must be between 0 and pi.
- float attenuation: Value specifying how the light intensity changes over distance.
Optional Arguments
- bool normalShadow: Determine if the light source should be obscured when lighting a surface on opposite angles.
Returns
The function returns true if set successfully, false otherwise.
destroyLight
This function destroys a light element.
bool exports.dynamic_lighting:destroyLight(element lightElement)
Required Arguments
- element lightElement: A previously declaired light element.
Returns
The function returns true if set successfully, false otherwise.
setLightDirection
This function destroys a light element.
bool exports.dynamic_lighting:setLightDirection(element lightElement,float dirX,dirY,dirZ,[bool isEuler = false])
Required Arguments
- element lightElement: A previously declaired light element.
- float dirX,dirY,dirZ: Direction that the light is pointing in world space. It's a vector as default.
Optional Arguments
- bool isEuler:Is the angle set as an "ZXY" euler andgle or a vector.
Returns
The function returns true if set successfully, false otherwise.
setLightPosition
This function sets light position value for both a pointlight and a spotlight.
bool exports.dynamic_lighting:setLightPosition(element lightElement,float posX,posY,posZ)
Required Arguments
- element lightElement: A previously declaired light element.
- float posX, posY, posZ: Light position in world space.
Returns
The function returns true if set successfully, false otherwise.
setLightColor
This function sets light color value for both a pointlight and a spotlight.
bool exports.dynamic_lighting:setLightColor(element lightElement,float colorR,colorG,colorB,colorA)
Required Arguments
- element lightElement: A previously declaired light element.
- float colorR,colorG,colorB,colorA: Light RGBA color emitted by the light (0 - 1 instead of 0-255).
Returns
The function returns true if set successfully, false otherwise.
setLightAttenuation
This function sets setLightAttenuation value for both a pointlight and a spotlight.
bool exports.dynamic_lighting:setLightAttenuation(element lightElement,float attenuation)
Required Arguments
- element lightElement: A previously declaired light element.
- float attenuation: Value specifying how the light intensity changes over distance.
Returns
The function returns true if set successfully, false otherwise.
setLightFalloff
This function sets falloff value for a spotlight.
bool exports.dynamic_lighting:setLightFalloff(element lightElement,float falloff)
Required Arguments
- element lightElement: A previously declaired light element.
- float falloff (radians): Decrease in illumination between a spotlight's inner cone (the angle specified by Theta) and the outer edge of the outer cone (the angle specified by Phi).
Returns
The function returns true if set successfully, false otherwise.
setLightTheta
This function sets theta value for a spotlight.
bool exports.dynamic_lighting:setLightTheta(element lightElement,float theta)
Required Arguments
- element lightElement: A previously declaired light element.
- float theta (radians): Angle, in radians, of a spotlight's inner cone - that is, the fully illuminated spotlight cone. This value must be in the range from 0 through the value specified by Phi.
Returns
The function returns true if set successfully, false otherwise.
setLightPhi
This function sets phi value for a spotlight.
bool exports.dynamic_lighting:setLightPhi(element lightElement,float phi)
Required Arguments
- element lightElement: A previously declaired light element.
- float phi (radians): Angle, in radians, defining the outer edge of the spotlight's outer cone. Points outside this cone are not lit by the spotlight. This value must be between 0 and pi.
Returns
The function returns true if set successfully, false otherwise.
setLightNormalShadowing
Determine if the light source should be obscured when lighting a surface on opposite angles.
bool exports.dynamic_lighting:setLightNormalShadowing(element lightElement,bool normalShadow)
Required Arguments
- element lightElement: A previously declaired light element.
- bool normalShadow: Determine if the light source should be obscured when lighting a surface on opposite angles.
Returns
The function returns true if set successfully, false otherwise.
setNormalShadowingAmount
Determine global shadowing value ( for all lights).
bool exports.dynamic_lighting:setNormalShadowingAmount(element lightElement,float normalShadowAmmount)
Required Arguments
- element lightElement: A previously declaired light element.
- float normalShadowAmmount: Determine global shadowing value (1-full 0-nil).
Returns
The function returns true if set successfully, false otherwise.
setShaderForcedOn
Should the shader effect turn off when no lightsources.
bool exports.dynamic_lighting:setShaderForcedOn(bool isShaderForcedOn)
Required Arguments
- bool isShaderForcedOn: Should the shader effect turn off when no lightsources.
Returns
The function returns true if set successfully, false otherwise.
setShaderTimeOut
Should the shader effect turn off after number of seconds (when no lightsources)
bool exports.dynamic_lighting:setShaderTimeOut(bool timeOut)
Required Arguments
- bool timeOut: Should the shader effect turn off after number of seconds (when no lightsources)
Returns
The function returns true if set successfully, false otherwise.
Examples
exports.dynamic_lighting:createPointLight(0,0,5,1,0,0,1,15)
This creates a red pointlight in world position (0,0,5)
Of course when you want to use these functions in your resources you have to include the dynamic_lighting resource in meta.