Resource:Dynamic lighting: Difference between revisions
No edit summary |
No edit summary |
||
Line 160: | Line 160: | ||
*'''bool isTrue:''' Turn on or off bump mapping. | *'''bool isTrue:''' Turn on or off bump mapping. | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
*''' | *'''int textureSize:''' The size of the input texture. | ||
*'''float normalStrength.xy:''' How bumpy should the surface be ? | *'''float normalStrength.xy:''' How bumpy should the surface be ? | ||
===Returns=== | ===Returns=== | ||
Line 169: | Line 169: | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
Set the Max distance of the light to sync and the distance on which the light starts to fade out. | Set the Max distance of the light to sync and the distance on which the light starts to fade out. | ||
<syntaxhighlight lang="lua">bool exports.dynamic_lighting:setLightsDistFade( | <syntaxhighlight lang="lua">bool exports.dynamic_lighting:setLightsDistFade(int MaxEffectFade,int MinEffectFade)</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''int MaxEffectFade:''' Set the Max distance of the light to sync.(Must be greater than MinEffectFade and lower than maxEffectRange). | ||
*''' | *'''int MinEffectFade:''' Set the distance on which the light starts to fade out. | ||
===Returns=== | ===Returns=== | ||
The function returns true if set successfully, false otherwise. | The function returns true if set successfully, false otherwise. | ||
Line 180: | Line 180: | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
Set the Max distance from the camera the shader effects are applied to. | Set the Max distance from the camera the shader effects are applied to. | ||
<syntaxhighlight lang="lua">bool exports.dynamic_lighting:setLightsEffectRange( | <syntaxhighlight lang="lua">bool exports.dynamic_lighting:setLightsEffectRange(int maxEffectRange)</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''int maxEffectRange:''' If non-zero, the shaders will be applied to textures nearer than maxDistance only. | ||
===Returns=== | ===Returns=== | ||
The function returns true if set successfully, false otherwise. | The function returns true if set successfully, false otherwise. | ||
Line 200: | Line 200: | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
Should the shader effect turn off after number of seconds (when no lightsources) | Should the shader effect turn off after number of seconds (when no lightsources) | ||
<syntaxhighlight lang="lua">bool exports.dynamic_lighting:setShaderTimeOut( | <syntaxhighlight lang="lua">bool exports.dynamic_lighting:setShaderTimeOut(int timeOut)</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''int timeOut:''' Should the shader effect turn off after number of seconds (when no lightsources) | ||
===Returns=== | |||
The function returns true if set successfully, false otherwise. | |||
</section> | |||
====setShaderNightMod==== | |||
<section name="Client" class="client" show="true"> | |||
Enable nightMod effect - requires proper manipulation of setTextureBrightness and SetShaderDayTime, also some additional shaders. | |||
<syntaxhighlight lang="lua">bool exports.dynamic_lighting:setShaderNightMod(bool enable)</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''bool enable:''' Enable or disable nightMod effect | |||
===Returns=== | |||
The function returns true if set successfully, false otherwise. | |||
</section> | |||
====setShaderDayTime==== | |||
<section name="Client" class="client" show="true"> | |||
Another additional variable to control texture colors - requires setShaderNightMod(true) | |||
<syntaxhighlight lang="lua">bool exports.dynamic_lighting:setShaderDayTime(float dayTime)</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''float dayTime:''' Another additional variable to control texture colors - requires setShaderNightMod(true) set 1 as default | |||
===Returns=== | |||
The function returns true if set successfully, false otherwise. | |||
</section> | |||
====setShaderPedDiffuse==== | |||
<section name="Client" class="client" show="true"> | |||
Enable or disable gta directional lights for ped. | |||
<syntaxhighlight lang="lua">bool exports.dynamic_lighting:setShaderPedDiffuse(bool enable)</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''bool enable:''' Enable or disable gta directional lights for ped (enabled as default) | |||
===Returns=== | ===Returns=== | ||
The function returns true if set successfully, false otherwise. | The function returns true if set successfully, false otherwise. |
Revision as of 16:12, 2 July 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. It should be considered a preview of what MTA:Eir will offer. The future solution should be more FPS friendly. Yet i see that resource as an example of what the future holds.
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.
setGenerateBumpNormals
Should the shader effect generate bump normals from texture0. Doesn't work when normal shadowing is set to false.
bool exports.dynamic_lighting:setGenerateBumpNormals(bool isTrue,[int textureSize = 512, float normalStrength.x = 1, float normalStrength.y = 1])
Required Arguments
- bool isTrue: Turn on or off bump mapping.
Optional Arguments
- int textureSize: The size of the input texture.
- float normalStrength.xy: How bumpy should the surface be ?
Returns
The function returns true if set successfully, false otherwise.
setLightsDistFade
Set the Max distance of the light to sync and the distance on which the light starts to fade out.
bool exports.dynamic_lighting:setLightsDistFade(int MaxEffectFade,int MinEffectFade)
Required Arguments
- int MaxEffectFade: Set the Max distance of the light to sync.(Must be greater than MinEffectFade and lower than maxEffectRange).
- int MinEffectFade: Set the distance on which the light starts to fade out.
Returns
The function returns true if set successfully, false otherwise.
setLightsEffectRange
Set the Max distance from the camera the shader effects are applied to.
bool exports.dynamic_lighting:setLightsEffectRange(int maxEffectRange)
Required Arguments
- int maxEffectRange: If non-zero, the shaders will be applied to textures nearer than maxDistance only.
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(int timeOut)
Required Arguments
- int timeOut: Should the shader effect turn off after number of seconds (when no lightsources)
Returns
The function returns true if set successfully, false otherwise.
setShaderNightMod
Enable nightMod effect - requires proper manipulation of setTextureBrightness and SetShaderDayTime, also some additional shaders.
bool exports.dynamic_lighting:setShaderNightMod(bool enable)
Required Arguments
- bool enable: Enable or disable nightMod effect
Returns
The function returns true if set successfully, false otherwise.
setShaderDayTime
Another additional variable to control texture colors - requires setShaderNightMod(true)
bool exports.dynamic_lighting:setShaderDayTime(float dayTime)
Required Arguments
- float dayTime: Another additional variable to control texture colors - requires setShaderNightMod(true) set 1 as default
Returns
The function returns true if set successfully, false otherwise.
setShaderPedDiffuse
Enable or disable gta directional lights for ped.
bool exports.dynamic_lighting:setShaderPedDiffuse(bool enable)
Required Arguments
- bool enable: Enable or disable gta directional lights for ped (enabled as default)
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.