Lua UnitRendering: Difference between revisions

From Spring
Jump to navigationJump to search
Jk (talk | contribs)
Flozi (talk | contribs)
→Material Table: 95.0 - new LuaUnitRendering Material keys:
Line 55: Line 55:
     ["culling" = [[Lua_ConstGL#Culling|number face]] ,]
     ["culling" = [[Lua_ConstGL#Culling|number face]] ,]
     ["shader" = [[Lua_GLSL_Api|lua_shader]] | string "3do" | string "s3o" ,]
     ["shader" = [[Lua_GLSL_Api|lua_shader]] | string "3do" | string "s3o" ,]
    <span class=note>(95.0: alias standard_shader)</span>
    ["deferred_shader" = { vertex = ..., ... } ,]
    <span class=note>(new in 95.0, alias deferred. Deferred fragment shaders must *ONLY* write to gl_FragData[i] where
      i = {0 = normals, 1 = diffuse, 2 = specular, 3 = emissive, 4 = misc})</span>


     ["texunits" = {
     ["texunits" = {
Line 60: Line 64:
                   ["enable" = boolean true ] }, ]
                   ["enable" = boolean true ] }, ]
         [ [3] = <font color=#55ee99>[[Lua_OpenGL_Api#Textures|see gl.Texture]]</font>, ]
         [ [3] = <font color=#55ee99>[[Lua_OpenGL_Api#Textures|see gl.Texture]]</font>, ]
         <font color=#55ee99>(upto [15] and supports holes in it)</font>
         <span class=note>(upto [15] and supports holes in it)</span>
       } ,]
       } ,]


Line 73: Line 77:
     ["cameraposloc" = number uniformLocation,]
     ["cameraposloc" = number uniformLocation,]
     ["camerainvloc"  = number uniformLocation,]
     ["camerainvloc"  = number uniformLocation,]
     ["sunposloc"    = number uniformLocation,] <span class=note>new in 0.83</span>
     ["sunposloc"    = number uniformLocation,] <span class=note>(new in 0.83)</span>
     ["shadowloc"      = number uniformLocation,]
     ["shadowloc"      = number uniformLocation,]
     ["shadowparamsloc" = number uniformLocation,]
     ["shadowparamsloc" = number uniformLocation,]

Revision as of 04:16, 27 December 2013

Development < Lua Scripting < Lua UnitRendering

Unit Rendering

Spring.UnitRendering.SetLODCount

 ( number unitID, int lodCount ) -> nil

Spring.UnitRendering.SetLODLength (`lod` is 1-indexed)

 ( number unitID, int lod, number lodLength ) -> nil

Spring.UnitRendering.SetLODDistance (same as SetLODLength(), but adjusted for 45deg FOV + 1024x768)

 (number unitID,  int lod, number lodDistance ) -> nil

Spring.UnitRendering.SetPieceList (displayList=nil reset to default)

 ( number unitID, int lod, int piece [, number displayList = nil ] ) -> nil

Spring.UnitRendering.GetMaterial (creates a material userdata)

 ( string MaterialType, table Material ) -> userdata Material

Spring.UnitRendering.SetMaterial

 ( number unitID, int lod, string MaterialType, userdata Material | table Material ) -> nil

Spring.UnitRendering.SetMaterialLastLOD

 ( number unitID, string MaterialType, int lastLOD ) -> nil

Spring.UnitRendering.SetMaterialDisplayLists

 ( number unitID, int lod, string MaterialType, preDisplayList, postDisplayList ) -> nil

Spring.UnitRendering.SetUnitUniform (unfinished)

 ( number unitID, string MaterialType, int lod, arg1, arg2, ... ) -> nil

Debug

Spring.UnitRendering.Debug (prints some usefull debug informations)

 ( [ number unitID ] ) -> nil

Lua's DrawXYZ-Callin

Spring.UnitRendering.SetUnitLuaDraw (enables the LuaRules' DrawUnit callin)

 ( number unitID, boolean enabled ) -> nil

Spring.UnitRendering.SetFeatureLuaDraw (enables the LuaRules' DrawFeature callin)

 ( number featureID, boolean enabled ) -> nil

MaterialTypes

"alpha"
"opaque"
"alpha_reflect"
"opaque_reflect"
"shadow"

Material UserData

none user accessible methods (yet)

Material Table

 material = {
   ["order"  = number ,]
   ["culling" = number face ,]
   ["shader" = lua_shader | string "3do" | string "s3o" ,]
   (95.0: alias standard_shader)
   ["deferred_shader" = { vertex = ..., ... } ,]
   (new in 95.0, alias deferred. Deferred fragment shaders must *ONLY* write to gl_FragData[i] where
     i = {0 = normals, 1 = diffuse, 2 = specular, 3 = emissive, 4 = misc})
   ["texunits" = {
       [ [0] = { ["tex" = see gl.Texture ,]
                 ["enable" = boolean true ] }, ]
       [ [3] = see gl.Texture, ]
       (upto [15] and supports holes in it)
     } ,]
   ["texunit0" = see gl.Texture ,]
    ...
   ["texunit7" = see gl.Texture ,]
   ["prelist"   = lua_displaylist ,]
   ["postlist"  = lua_displaylist ,]
   ["usecamera" = boolean ,]
   ["cameraloc" = number uniformLocation,]
   ["cameraposloc" = number uniformLocation,]
   ["camerainvloc"  = number uniformLocation,]
   ["sunposloc"     = number uniformLocation,] (new in 0.83)
   ["shadowloc"       = number uniformLocation,]
   ["shadowparamsloc" = number uniformLocation,]
 }