diff --git a/Sources/iron/RenderPath.hx b/Sources/iron/RenderPath.hx index 49c229df..d4e01434 100644 --- a/Sources/iron/RenderPath.hx +++ b/Sources/iron/RenderPath.hx @@ -24,7 +24,7 @@ class RenderPath { public var currentTarget:RenderTarget = null; public var currentCube:Bool; public var currentFace:Int; - public var currentLampIndex = 0; + public var currentLightIndex = 0; public var currentW:Int; public var currentH:Int; public var currentD:Int; @@ -50,12 +50,12 @@ class RenderPath { public var depthToRenderTarget:Map = new Map(); // Used by render path nodes for branch functions - public function lampCastShadow() { - return getLamp(currentLampIndex).data.raw.cast_shadow; + public function lightCastShadow() { + return getLight(currentLightIndex).data.raw.cast_shadow; } - public function lampIsSun() { - return getLamp(currentLampIndex).data.raw.type == "sun"; + public function lightIsSun() { + return getLight(currentLightIndex).data.raw.type == "sun"; } #if (rp_gi != "Off") @@ -77,7 +77,7 @@ class RenderPath { public function new() {} - inline public function getLamp(index:Int) { return Scene.active.lamps.length > 0 ? Scene.active.lamps[index] : null; } + inline public function getLight(index:Int) { return Scene.active.lights.length > 0 ? Scene.active.lights[index] : null; } public function renderFrame(g:Graphics) { if (!ready || paused || iron.App.w() == 0 || iron.App.h() == 0) return; @@ -109,8 +109,8 @@ class RenderPath { currentFace = -1; meshesSorted = false; - currentLampIndex = 0; - for (l in Scene.active.lamps) if (l.visible) l.buildMatrices(Scene.active.camera); + currentLightIndex = 0; + for (l in Scene.active.lights) if (l.visible) l.buildMatrices(Scene.active.camera); commands(); } @@ -233,29 +233,29 @@ class RenderPath { } public function drawMeshes(context:String) { - var lamp = getLamp(currentLampIndex); - if (lamp != null && !lamp.visible) { + var light = getLight(currentLightIndex); + if (light != null && !light.visible) { // Pass draw atleast once to fill geometry buffers - if (currentLampIndex > 0) return; + if (currentLightIndex > 0) return; } var isShadows = context == shadowsContext; if (isShadows) { - // Disabled shadow casting for this lamp - if (lamp == null || !lamp.data.raw.cast_shadow) return; + // Disabled shadow casting for this light + if (light == null || !light.data.raw.cast_shadow) return; } // Single face attached // TODO: draw first cube-face last, otherwise some opengl drivers glitch - if (currentFace >= 0 && lamp != null) lamp.setCubeFace(5 - currentFace, Scene.active.camera); + if (currentFace >= 0 && light != null) light.setCubeFace(5 - currentFace, Scene.active.camera); var g = currentG; var drawn = false; #if arm_csm - if (isShadows && lamp.data.raw.type == "sun") { + if (isShadows && light.data.raw.type == "sun") { var step = currentH; // Atlas with tiles on x axis - for (i in 0...LampObject.cascadeCount) { - lamp.setCascade(Scene.active.camera, i); + for (i in 0...LightObject.cascadeCount) { + light.setCascade(Scene.active.camera, i); // g.viewport(0, currentH - (i + 1) * step, step, step); g.viewport(i * step, 0, step, step); submitDraw(context); @@ -279,7 +279,7 @@ class RenderPath { @:access(iron.object.MeshObject) function submitDraw(context:String) { - var lamp = getLamp(currentLampIndex); + var light = getLight(currentLightIndex); var g = currentG; MeshObject.lastPipeline = null; @@ -294,10 +294,10 @@ class RenderPath { } #if arm_batch - Scene.active.meshBatch.render(g, context, Scene.active.camera, lamp, bindParams); + Scene.active.meshBatch.render(g, context, Scene.active.camera, light, bindParams); #else for (m in Scene.active.meshes) { - m.render(g, context, Scene.active.camera, lamp, bindParams); + m.render(g, context, Scene.active.camera, light, bindParams); } #end } @@ -329,7 +329,7 @@ class RenderPath { public function drawRects(context:String) { if (ConstData.rectVB == null) ConstData.createRectData(); var g = currentG; - var lamp = getLamp(currentLampIndex); + var light = getLight(currentLightIndex); // Unique materials var mats:Array = []; @@ -422,8 +422,8 @@ class RenderPath { getRectContexts(mat, context, materialContexts, shaderContexts); g.setPipeline(mat.shader.getContext(context).pipeState); - Uniforms.setContextConstants(g, shaderContexts[0], Scene.active.camera, lamp, bindParams); - Uniforms.setObjectConstants(g, shaderContexts[0], null, Scene.active.camera, lamp); + Uniforms.setContextConstants(g, shaderContexts[0], Scene.active.camera, light, bindParams); + Uniforms.setObjectConstants(g, shaderContexts[0], null, Scene.active.camera, light); Uniforms.setMaterialConstants(g, shaderContexts[0], materialContexts[0]); g.drawIndexedVertices(); } @@ -437,9 +437,9 @@ class RenderPath { public function drawDecals(context:String) { if (ConstData.boxVB == null) ConstData.createBoxData(); var g = currentG; - var lamp = getLamp(currentLampIndex); + var light = getLight(currentLightIndex); for (decal in Scene.active.decals) { - decal.render(g, context, Scene.active.camera, lamp, bindParams); + decal.render(g, context, Scene.active.camera, light, bindParams); } end(g); } @@ -450,11 +450,11 @@ class RenderPath { // var gp = Scene.active.greasePencil; // if (gp == null) return; // var g = currentG; - // var lamp = getLamp(currentLampIndex); + // var light = getLight(currentLightIndex); // var context = GreasePencilData.getContext(con); // g.setPipeline(context.pipeState); - // Uniforms.setContextConstants(g, context, Scene.active.camera, lamp, null); - // Uniforms.setObjectConstants(g, context, null, Scene.active.camera, lamp); + // Uniforms.setContextConstants(g, context, Scene.active.camera, light, null); + // Uniforms.setObjectConstants(g, context, null, Scene.active.camera, light); // // Draw layers // for (layer in gp.layers) { // // Next frame @@ -495,9 +495,9 @@ class RenderPath { if (cc.context == null) return; // World data not specified var g = currentG; g.setPipeline(cc.context.pipeState); - var lamp = getLamp(currentLampIndex); - Uniforms.setContextConstants(g, cc.context, Scene.active.camera, lamp, bindParams); - Uniforms.setObjectConstants(g, cc.context, null, Scene.active.camera, lamp); // External hosek + var light = getLight(currentLightIndex); + Uniforms.setContextConstants(g, cc.context, Scene.active.camera, light, bindParams); + Uniforms.setObjectConstants(g, cc.context, null, Scene.active.camera, light); // External hosek #if arm_deinterleaved g.setVertexBuffers(ConstData.skydomeVB); #else @@ -508,11 +508,11 @@ class RenderPath { end(g); } - public function drawLampVolume(handle:String) { + public function drawLightVolume(handle:String) { var vb:VertexBuffer = null; var ib:IndexBuffer = null; - var lamp = getLamp(currentLampIndex); - var type = lamp.data.raw.type; + var light = getLight(currentLightIndex); + var type = light.data.raw.type; if (type == "point" || type == "area") { // Sphere if (ConstData.sphereVB == null) ConstData.createSphereData(); vb = ConstData.sphereVB; @@ -530,8 +530,8 @@ class RenderPath { var cc:CachedShaderContext = cachedShaderContexts.get(handle); var g = currentG; g.setPipeline(cc.context.pipeState); - Uniforms.setContextConstants(g, cc.context, Scene.active.camera, lamp, bindParams); - Uniforms.setObjectConstants(g, cc.context, null, Scene.active.camera, lamp); + Uniforms.setContextConstants(g, cc.context, Scene.active.camera, light, bindParams); + Uniforms.setObjectConstants(g, cc.context, null, Scene.active.camera, light); g.setVertexBuffer(vb); g.setIndexBuffer(ib); g.drawIndexedVertices(); @@ -550,9 +550,9 @@ class RenderPath { if (ConstData.screenAlignedVB == null) ConstData.createScreenAlignedData(); var g = currentG; g.setPipeline(cc.context.pipeState); - var lamp = getLamp(currentLampIndex); - Uniforms.setContextConstants(g, cc.context, Scene.active.camera, lamp, bindParams); - Uniforms.setObjectConstants(g, cc.context, null, Scene.active.camera, lamp); + var light = getLight(currentLightIndex); + Uniforms.setContextConstants(g, cc.context, Scene.active.camera, light, bindParams); + Uniforms.setObjectConstants(g, cc.context, null, Scene.active.camera, light); g.setVertexBuffer(ConstData.screenAlignedVB); g.setIndexBuffer(ConstData.screenAlignedIB); g.drawIndexedVertices(); diff --git a/Sources/iron/Scene.hx b/Sources/iron/Scene.hx index 0a02153a..ae5a0ef2 100644 --- a/Sources/iron/Scene.hx +++ b/Sources/iron/Scene.hx @@ -26,7 +26,7 @@ class Scene { public var sceneStream:SceneStream = null; #end public var meshes:Array; - public var lamps:Array; + public var lights:Array; public var cameras:Array; public var speakers:Array; public var decals:Array; @@ -51,7 +51,7 @@ class Scene { sceneStream = new SceneStream(); #end meshes = []; - lamps = []; + lights = []; cameras = []; speakers = []; decals = []; @@ -99,7 +99,7 @@ class Scene { if (meshBatch != null) meshBatch.remove(); #end for (o in meshes) o.remove(); - for (o in lamps) o.remove(); + for (o in lights) o.remove(); for (o in cameras) o.remove(); for (o in speakers) o.remove(); for (o in decals) o.remove(); @@ -189,8 +189,8 @@ class Scene { return null; } - public function getLamp(name:String):LampObject { - for (l in lamps) if (l.name == name) return l; + public function getLight(name:String):LightObject { + for (l in lights) if (l.name == name) return l; return null; } @@ -215,8 +215,8 @@ class Scene { return object; } - public function addLampObject(data:LampData, parent:Object = null):LampObject { - var object = new LampObject(data); + public function addLightObject(data:LightData, parent:Object = null):LightObject { + var object = new LightObject(data); parent != null ? parent.addChild(object) : root.addChild(object); return object; } @@ -369,9 +369,9 @@ class Scene { returnObject(object, o, done); }); } - else if (o.type == "lamp_object") { - Data.getLamp(sceneName, o.data_ref, function(b:LampData) { - var object = addLampObject(b, parent); + else if (o.type == "light_object") { + Data.getLight(sceneName, o.data_ref, function(b:LightData) { + var object = addLightObject(b, parent); returnObject(object, o, done); }); } diff --git a/Sources/iron/data/Data.hx b/Sources/iron/data/Data.hx index a5abf3e5..448a3f6b 100644 --- a/Sources/iron/data/Data.hx +++ b/Sources/iron/data/Data.hx @@ -7,7 +7,7 @@ class Data { public static var cachedSceneRaws:Map = new Map(); public static var cachedMeshes:Map = new Map(); - public static var cachedLamps:Map = new Map(); + public static var cachedLights:Map = new Map(); public static var cachedCameras:Map = new Map(); public static var cachedMaterials:Map = new Map(); public static var cachedParticles:Map = new Map(); @@ -35,7 +35,7 @@ class Data { for (c in cachedShaders) c.delete(); cachedShaders = new Map(); cachedSceneRaws = new Map(); - cachedLamps = new Map(); + cachedLights = new Map(); cachedCameras = new Map(); cachedMaterials = new Map(); cachedParticles = new Map(); @@ -59,7 +59,7 @@ class Data { public static function clearSceneData() { cachedSceneRaws = new Map(); cachedMeshes = new Map(); // Delete data - cachedLamps = new Map(); + cachedLights = new Map(); cachedMaterials = new Map(); cachedCameras = new Map(); cachedParticles = new Map(); @@ -96,20 +96,20 @@ class Data { cachedMeshes.remove(handle); } - static var loadingLamps:MapVoid>> = new Map(); - public static function getLamp(file:String, name:String, done:LampData->Void) { - var cached = cachedLamps.get(file + name); + static var loadingLights:MapVoid>> = new Map(); + public static function getLight(file:String, name:String, done:LightData->Void) { + var cached = cachedLights.get(file + name); if (cached != null) { done(cached); return; } - var loading = loadingLamps.get(file + name); + var loading = loadingLights.get(file + name); if (loading != null) { loading.push(done); return; } - loadingLamps.set(file + name, [done]); + loadingLights.set(file + name, [done]); - LampData.parse(file, name, function(b:LampData) { - cachedLamps.set(file + name, b); - for (f in loadingLamps.get(file + name)) f(b); - loadingLamps.remove(file + name); + LightData.parse(file, name, function(b:LightData) { + cachedLights.set(file + name, b); + for (f in loadingLights.get(file + name)) f(b); + loadingLights.remove(file + name); }); } @@ -327,7 +327,7 @@ class Data { return null; } - public static function getLampRawByName(datas:Array, name:String):TLampData { + public static function getLightRawByName(datas:Array, name:String):TLightData { if (name == "") return datas[0]; for (dat in datas) if (dat.name == name) return dat; return null; diff --git a/Sources/iron/data/LampData.hx b/Sources/iron/data/LightData.hx similarity index 67% rename from Sources/iron/data/LampData.hx rename to Sources/iron/data/LightData.hx index b409a31c..2d4dbe73 100644 --- a/Sources/iron/data/LampData.hx +++ b/Sources/iron/data/LightData.hx @@ -3,14 +3,14 @@ package iron.data; import iron.math.Mat4; import iron.data.SceneFormat; -class LampData extends Data { +class LightData extends Data { public var name:String; - public var raw:TLampData; + public var raw:TLightData; public var colorTexture:kha.Image = null; - public function new(raw:TLampData, done:LampData->Void) { + public function new(raw:TLightData, done:LightData->Void) { super(); this.raw = raw; @@ -35,14 +35,14 @@ class LampData extends Data { } } - public static function parse(name:String, id:String, done:LampData->Void) { + public static function parse(name:String, id:String, done:LightData->Void) { Data.getSceneRaw(name, function(format:TSceneFormat) { - var raw:TLampData = Data.getLampRawByName(format.lamp_datas, id); + var raw:TLightData = Data.getLightRawByName(format.light_datas, id); if (raw == null) { - trace('Lamp data "$id" not found!'); + trace('Light data "$id" not found!'); done(null); } - new LampData(raw, done); + new LightData(raw, done); }); } } diff --git a/Sources/iron/data/MeshBatch.hx b/Sources/iron/data/MeshBatch.hx index 76e59d1f..f74caa02 100644 --- a/Sources/iron/data/MeshBatch.hx +++ b/Sources/iron/data/MeshBatch.hx @@ -9,7 +9,7 @@ import kha.graphics4.VertexStructure; import kha.graphics4.VertexData; import kha.graphics4.Graphics; import iron.object.CameraObject; -import iron.object.LampObject; +import iron.object.LightObject; import iron.object.MeshObject; import iron.object.Uniforms; import iron.data.MaterialData; @@ -58,7 +58,7 @@ class MeshBatch { else nonBatched.remove(m); } - public function render(g:Graphics, context:String, camera:CameraObject, lamp:LampObject, bindParams:Array) { + public function render(g:Graphics, context:String, camera:CameraObject, light:LightObject, bindParams:Array) { for (b in buckets) { @@ -74,14 +74,14 @@ class MeshBatch { // #end g.setIndexBuffer(b.indexBuffer); - Uniforms.setContextConstants(g, scontext, camera, lamp, bindParams); + Uniforms.setContextConstants(g, scontext, camera, light, bindParams); RenderPath.sortMeshesDistance(b.meshes, camera); for (m in b.meshes) { if (!m.visible) continue; // Skip render if object is hidden - if (m.cullMesh(context, camera, lamp)) continue; + if (m.cullMesh(context, camera, light)) continue; // Get context var materialContexts:Array = []; @@ -91,7 +91,7 @@ class MeshBatch { m.transform.update(); // Render mesh - Uniforms.setObjectConstants(g, scontext, m, camera, lamp); + Uniforms.setObjectConstants(g, scontext, m, camera, light); Uniforms.setMaterialConstants(g, scontext, materialContexts[0]); g.drawIndexedVertices(m.data.start, m.data.count); @@ -112,7 +112,7 @@ class MeshBatch { } for (m in nonBatched) { - m.render(g, context, camera, lamp, bindParams); + m.render(g, context, camera, light, bindParams); #if arm_debug if (m.culled) RenderPath.culled++; diff --git a/Sources/iron/data/SceneFormat.hx b/Sources/iron/data/SceneFormat.hx index da64a41e..f12a3ff9 100644 --- a/Sources/iron/data/SceneFormat.hx +++ b/Sources/iron/data/SceneFormat.hx @@ -7,7 +7,7 @@ import kha.arrays.Uint32Array; typedef TSceneFormat = { @:optional var name:String; @:optional var mesh_datas:Array; - @:optional var lamp_datas:Array; + @:optional var light_datas:Array; @:optional var camera_datas:Array; @:optional var camera_ref:String; // Active camera @:optional var material_datas:Array; @@ -59,7 +59,7 @@ typedef TIndexArray = { var material:Int; } -typedef TLampData = { +typedef TLightData = { var name:String; var type:String; // Sun, point, spot var color:Float32Array; @@ -73,9 +73,9 @@ typedef TLampData = { @:optional var shadowmap_cube:Null; // Omni shadows for point @:optional var spot_size:Null; @:optional var spot_blend:Null; - @:optional var lamp_size:Null; // Shadow soft size + @:optional var light_size:Null; // Shadow soft size @:optional var color_texture:String; // Image reference - @:optional var size:Null; // Area lamp + @:optional var size:Null; // Area light @:optional var size_y:Null; } @@ -315,7 +315,7 @@ typedef TParticleReference = { } typedef TObj = { - var type:String; // object, mesh_object, lamp_object, camera_object, speaker_object, decal_object + var type:String; // object, mesh_object, light_object, camera_object, speaker_object, decal_object var name:String; var data_ref:String; var transform:TTransform; diff --git a/Sources/iron/object/DecalObject.hx b/Sources/iron/object/DecalObject.hx index cb7ee2bb..d3c9dea7 100644 --- a/Sources/iron/object/DecalObject.hx +++ b/Sources/iron/object/DecalObject.hx @@ -24,7 +24,7 @@ class DecalObject extends Object { } // Called before rendering decal in render path - public function render(g:Graphics, context:String, camera:CameraObject, lamp:LampObject, bindParams:Array) { + public function render(g:Graphics, context:String, camera:CameraObject, light:LightObject, bindParams:Array) { // Check context skip if (material.raw.skip_context != null && @@ -45,8 +45,8 @@ class DecalObject extends Object { g.setPipeline(shaderContext.pipeState); - Uniforms.setContextConstants(g, shaderContext, camera, lamp, bindParams); - Uniforms.setObjectConstants(g, shaderContext, this, camera, lamp); + Uniforms.setContextConstants(g, shaderContext, camera, light, bindParams); + Uniforms.setObjectConstants(g, shaderContext, this, camera, light); Uniforms.setMaterialConstants(g, shaderContext, materialContext); g.setVertexBuffer(ConstData.boxVB); diff --git a/Sources/iron/object/LampObject.hx b/Sources/iron/object/LightObject.hx similarity index 95% rename from Sources/iron/object/LampObject.hx rename to Sources/iron/object/LightObject.hx index 836c4a8d..6e8c7271 100644 --- a/Sources/iron/object/LampObject.hx +++ b/Sources/iron/object/LightObject.hx @@ -3,11 +3,11 @@ package iron.object; import iron.math.Mat4; import iron.math.Vec4; import iron.math.Quat; -import iron.data.LampData; +import iron.data.LightData; import iron.object.CameraObject.FrustumPlane; import iron.Scene; -class LampObject extends Object { +class LightObject extends Object { public static var cascadeCount = 1; public static var cascadeSplitFactor = 0.8; @@ -21,7 +21,7 @@ class LampObject extends Object { var camSlicedP:Mat4 = null; #end - public var data:LampData; + public var data:LightData; public var V:Mat4 = Mat4.identity(); public var P:Mat4 = null; @@ -30,7 +30,7 @@ class LampObject extends Object { public var frustumPlanes:Array = null; static var corners:Array = null; - public function new(data:LampData) { + public function new(data:LightData) { super(); this.data = data; @@ -52,11 +52,11 @@ class LampObject extends Object { P = Mat4.persp(fov, 1, data.raw.near_plane, data.raw.far_plane); } - Scene.active.lamps.push(this); + Scene.active.lights.push(this); } public override function remove() { - if (Scene.active != null) Scene.active.lamps.remove(this); + if (Scene.active != null) Scene.active.lights.remove(this); super.remove(); } @@ -121,7 +121,7 @@ class LampObject extends Object { } m.multmat(camSlicedP[cascade]); #else - if (camSlicedP == null) { // Fit to lamp far plane + if (camSlicedP == null) { // Fit to light far plane var fov = camera.data.raw.fov; var near = data.raw.near_plane; var far = data.raw.far_plane; @@ -296,5 +296,5 @@ class LampObject extends Object { public inline function up():Vec4 { return new Vec4(V._01, V._11, V._21); } public inline function look():Vec4 { return new Vec4(V._02, V._12, V._22); } - public override function toString():String { return "Lamp Object " + name; } + public override function toString():String { return "Light Object " + name; } } diff --git a/Sources/iron/object/MeshObject.hx b/Sources/iron/object/MeshObject.hx index df55c4e6..acbc088d 100644 --- a/Sources/iron/object/MeshObject.hx +++ b/Sources/iron/object/MeshObject.hx @@ -131,7 +131,7 @@ class MeshObject extends Object { return setCulled(isShadow, false); } - function cullMesh(context:String, camera:CameraObject, lamp:LampObject):Bool { + function cullMesh(context:String, camera:CameraObject, light:LightObject):Bool { if (camera == null) return false; if (camera.data.raw.frustum_culling && frustumCulling) { @@ -144,11 +144,11 @@ class MeshObject extends Object { #end if (context == "voxel") radiusScale *= 100; var isShadow = context == RenderPath.shadowsContext; - var frustumPlanes = isShadow ? lamp.frustumPlanes : camera.frustumPlanes; + var frustumPlanes = isShadow ? light.frustumPlanes : camera.frustumPlanes; - if (isShadow && lamp.data.raw.type != "sun") { // Non-sun lamp bounds intersect camera frustum - lamp.transform.radius = lamp.data.raw.far_plane; - if (!CameraObject.sphereInFrustum(camera.frustumPlanes, lamp.transform)) { + if (isShadow && light.data.raw.type != "sun") { // Non-sun light bounds intersect camera frustum + light.transform.radius = light.data.raw.far_plane; + if (!CameraObject.sphereInFrustum(camera.frustumPlanes, light.transform)) { return setCulled(isShadow, true); } } @@ -207,11 +207,11 @@ class MeshObject extends Object { } static var lastPipeline:kha.graphics4.PipelineState = null; - public function render(g:Graphics, context:String, camera:CameraObject, lamp:LampObject, bindParams:Array) { + public function render(g:Graphics, context:String, camera:CameraObject, light:LightObject, bindParams:Array) { if (data == null || !data.geom.ready) return; // Data not yet streamed if (!visible) return; // Skip render if object is hidden - if (cullMesh(context, camera, lamp)) return; + if (cullMesh(context, camera, light)) return; var meshContext = raw != null ? RenderPath.meshContext == context : false; #if arm_particles if (raw != null && raw.is_particle && particleOwner == null) return; // Instancing not yet set-up by particle system owner @@ -285,9 +285,9 @@ class MeshObject extends Object { if (scontext.pipeState != lastPipeline) { g.setPipeline(scontext.pipeState); lastPipeline = scontext.pipeState; - Uniforms.setContextConstants(g, scontext, camera, lamp, bindParams); + Uniforms.setContextConstants(g, scontext, camera, light, bindParams); } - Uniforms.setObjectConstants(g, scontext, this, camera, lamp); + Uniforms.setObjectConstants(g, scontext, this, camera, light); if (materialContexts.length > mi) { Uniforms.setMaterialConstants(g, scontext, materialContexts[mi]); } diff --git a/Sources/iron/object/Uniforms.hx b/Sources/iron/object/Uniforms.hx index 0444847e..740c07be 100644 --- a/Sources/iron/object/Uniforms.hx +++ b/Sources/iron/object/Uniforms.hx @@ -12,7 +12,7 @@ import iron.math.Quat; import iron.math.Mat3; import iron.math.Mat4; import iron.data.WorldData; -import iron.data.LampData; +import iron.data.LightData; import iron.data.MaterialData; import iron.data.ShaderData; import iron.data.SceneFormat; @@ -49,11 +49,11 @@ class Uniforms { public static var externalFloatsLinks:ArrayMaterialData->String->kha.arrays.Float32Array> = null; public static var externalIntLinks:ArrayMaterialData->String->Null> = null; - public static function setContextConstants(g:Graphics, context:ShaderContext, camera:CameraObject, lamp:LampObject, bindParams:Array) { + public static function setContextConstants(g:Graphics, context:ShaderContext, camera:CameraObject, light:LightObject, bindParams:Array) { if (context.raw.constants != null) { for (i in 0...context.raw.constants.length) { var c = context.raw.constants[i]; - setContextConstant(g, camera, lamp, context.constants[i], c); + setContextConstant(g, camera, light, context.constants[i], c); } } @@ -112,9 +112,9 @@ class Uniforms { g.setTexture(context.textureUnits[j], Scene.active.embedded.get('noise256.png')); g.setTextureParameters(context.textureUnits[j], TextureAddressing.Repeat, TextureAddressing.Repeat, TextureFilter.LinearFilter, TextureFilter.LinearFilter, MipMapFilter.NoMipFilter); } - else if (tulink == "_lampColorTexture") { - if (lamp != null) { - g.setTexture(context.textureUnits[j], lamp.data.colorTexture); + else if (tulink == "_lightColorTexture") { + if (light != null) { + g.setTexture(context.textureUnits[j], light.data.colorTexture); g.setTextureParameters(context.textureUnits[j], TextureAddressing.Repeat, TextureAddressing.Repeat, TextureFilter.LinearFilter, TextureFilter.LinearFilter, MipMapFilter.NoMipFilter); } } @@ -135,11 +135,11 @@ class Uniforms { } } - public static function setObjectConstants(g:Graphics, context:ShaderContext, object:Object, camera:CameraObject, lamp:LampObject) { + public static function setObjectConstants(g:Graphics, context:ShaderContext, object:Object, camera:CameraObject, light:LightObject) { if (context.raw.constants != null) { for (i in 0...context.raw.constants.length) { var c = context.raw.constants[i]; - setObjectConstant(g, object, camera, lamp, context.constants[i], c); + setObjectConstant(g, object, camera, light, context.constants[i], c); } } @@ -228,7 +228,7 @@ class Uniforms { } } - static function setContextConstant(g:Graphics, camera:CameraObject, lamp:LampObject, + static function setContextConstant(g:Graphics, camera:CameraObject, light:LightObject, location:ConstantLocation, c:TShaderConstant):Bool { if (c.link == null) return true; @@ -290,26 +290,26 @@ class Uniforms { helpMat.multmat(camera.P); m = helpMat; } - else if (c.link == "_lampViewProjectionMatrix") { - if (lamp != null) { - m = lamp.VP; + else if (c.link == "_lightViewProjectionMatrix") { + if (light != null) { + m = light.VP; } } - else if (c.link == "_biasLampViewProjectionMatrix") { - if (lamp != null) { - helpMat.setFrom(lamp.VP); + else if (c.link == "_biasLightViewProjectionMatrix") { + if (light != null) { + helpMat.setFrom(light.VP); helpMat.multmat(biasMat); m = helpMat; } } - else if (c.link == "_lampVolumeWorldViewProjectionMatrix") { - if (lamp != null) { - var tr = lamp.transform; - var type = lamp.data.raw.type; + else if (c.link == "_lightVolumeWorldViewProjectionMatrix") { + if (light != null) { + var tr = light.transform; + var type = light.data.raw.type; if (type == "spot") { // Oriented cone // helpMat.setIdentity(); - // var f = lamp.data.raw.spot_size * lamp.data.raw.far_plane * 1.05; - // helpVec2.set(f, f, lamp.data.raw.far_plane); + // var f = light.data.raw.spot_size * light.data.raw.far_plane * 1.05; + // helpVec2.set(f, f, light.data.raw.far_plane); // helpMat.scale(helpVec2); // helpMat2.setFrom(tr.world); // helpMat2.toRotation(); @@ -317,13 +317,13 @@ class Uniforms { // helpMat.translate(tr.worldx(), tr.worldy(), tr.worldz()); helpVec.set(tr.worldx(), tr.worldy(), tr.worldz()); var f2:kha.FastFloat = 2.0; - helpVec2.set(lamp.data.raw.far_plane, lamp.data.raw.far_plane * f2, lamp.data.raw.far_plane * f2); + helpVec2.set(light.data.raw.far_plane, light.data.raw.far_plane * f2, light.data.raw.far_plane * f2); helpMat.compose(helpVec, helpQuat, helpVec2); } else if (type == "point" || type == "area") { // Sphere helpVec.set(tr.worldx(), tr.worldy(), tr.worldz()); var f2:kha.FastFloat = 2.0; - helpVec2.set(lamp.data.raw.far_plane, lamp.data.raw.far_plane * f2, lamp.data.raw.far_plane * f2); + helpVec2.set(light.data.raw.far_plane, light.data.raw.far_plane * f2, light.data.raw.far_plane * f2); helpMat.compose(helpVec, helpQuat, helpVec2); } @@ -343,17 +343,17 @@ class Uniforms { helpMat.multmat(camera.P); m = helpMat; } - else if (c.link == "_lampViewMatrix") { - if (lamp != null) { + else if (c.link == "_lightViewMatrix") { + if (light != null) { #if arm_centerworld - m = vmat(lamp.V); + m = vmat(light.V); #else - m = lamp.V; + m = light.V; #end } } - else if (c.link == "_lampProjectionMatrix") { - if (lamp != null) m = lamp.P; + else if (c.link == "_lightProjectionMatrix") { + if (light != null) m = light.P; } #if arm_vr else if (c.link == "_undistortionMatrix") { @@ -389,67 +389,67 @@ class Uniforms { else if (c.type == "vec3") { var v:Vec4 = null; helpVec.set(0, 0, 0); - if (c.link == "_lampPosition") { - if (lamp != null) { + if (c.link == "_lightPosition") { + if (light != null) { #if arm_centerworld var t = camera.transform; - helpVec.set(lamp.transform.worldx() - t.worldx(), lamp.transform.worldy() - t.worldy(), lamp.transform.worldz() - t.worldz()); + helpVec.set(light.transform.worldx() - t.worldx(), light.transform.worldy() - t.worldy(), light.transform.worldz() - t.worldz()); #else - helpVec.set(lamp.transform.worldx(), lamp.transform.worldy(), lamp.transform.worldz()); + helpVec.set(light.transform.worldx(), light.transform.worldy(), light.transform.worldz()); #end v = helpVec; } } - else if (c.link == "_lampDirection") { - if (lamp != null) { - helpVec = lamp.look(); + else if (c.link == "_lightDirection") { + if (light != null) { + helpVec = light.look(); v = helpVec; } } - else if (c.link == "_lampColor") { - if (lamp != null) { - var str = lamp.data.raw.strength; // Merge with strength - helpVec.set(lamp.data.raw.color[0] * str, lamp.data.raw.color[1] * str, lamp.data.raw.color[2] * str); + else if (c.link == "_lightColor") { + if (light != null) { + var str = light.data.raw.strength; // Merge with strength + helpVec.set(light.data.raw.color[0] * str, light.data.raw.color[1] * str, light.data.raw.color[2] * str); v = helpVec; } } - else if (c.link == "_lampArea0") { - if (lamp != null && lamp.data.raw.size != null) { + else if (c.link == "_lightArea0") { + if (light != null && light.data.raw.size != null) { var f2:kha.FastFloat = 0.5; - var sx:kha.FastFloat = lamp.data.raw.size * f2; - var sy:kha.FastFloat = lamp.data.raw.size_y * f2; + var sx:kha.FastFloat = light.data.raw.size * f2; + var sy:kha.FastFloat = light.data.raw.size_y * f2; helpVec.set(-sx, sy, 0.0); - helpVec.applymat(lamp.transform.world); + helpVec.applymat(light.transform.world); v = helpVec; } } - else if (c.link == "_lampArea1") { - if (lamp != null && lamp.data.raw.size != null) { + else if (c.link == "_lightArea1") { + if (light != null && light.data.raw.size != null) { var f2:kha.FastFloat = 0.5; - var sx:kha.FastFloat = lamp.data.raw.size * f2; - var sy:kha.FastFloat = lamp.data.raw.size_y * f2; + var sx:kha.FastFloat = light.data.raw.size * f2; + var sy:kha.FastFloat = light.data.raw.size_y * f2; helpVec.set(sx, sy, 0.0); - helpVec.applymat(lamp.transform.world); + helpVec.applymat(light.transform.world); v = helpVec; } } - else if (c.link == "_lampArea2") { - if (lamp != null && lamp.data.raw.size != null) { + else if (c.link == "_lightArea2") { + if (light != null && light.data.raw.size != null) { var f2:kha.FastFloat = 0.5; - var sx:kha.FastFloat = lamp.data.raw.size * f2; - var sy:kha.FastFloat = lamp.data.raw.size_y * f2; + var sx:kha.FastFloat = light.data.raw.size * f2; + var sy:kha.FastFloat = light.data.raw.size_y * f2; helpVec.set(sx, -sy, 0.0); - helpVec.applymat(lamp.transform.world); + helpVec.applymat(light.transform.world); v = helpVec; } } - else if (c.link == "_lampArea3") { - if (lamp != null && lamp.data.raw.size != null) { + else if (c.link == "_lightArea3") { + if (light != null && light.data.raw.size != null) { var f2:kha.FastFloat = 0.5; - var sx:kha.FastFloat = lamp.data.raw.size * f2; - var sy:kha.FastFloat = lamp.data.raw.size_y * f2; + var sx:kha.FastFloat = light.data.raw.size * f2; + var sy:kha.FastFloat = light.data.raw.size_y * f2; helpVec.set(-sx, -sy, 0.0); - helpVec.applymat(lamp.transform.world); + helpVec.applymat(light.transform.world); v = helpVec; } } @@ -578,17 +578,17 @@ class Uniforms { v.x = far / (far - near); v.y = (-far * near) / (far - near); } - else if (c.link == "_lampPlane") { - if (lamp != null) { + else if (c.link == "_lightPlane") { + if (light != null) { v = helpVec; - v.x = lamp.data.raw.near_plane; - v.y = lamp.data.raw.far_plane; + v.x = light.data.raw.near_plane; + v.y = light.data.raw.far_plane; } } - else if (c.link == "_lampPlaneProj") { // shadowCube - if (lamp != null) { - var near:kha.FastFloat = lamp.data.raw.near_plane; - var far:kha.FastFloat = lamp.data.raw.far_plane; + else if (c.link == "_lightPlaneProj") { // shadowCube + if (light != null) { + var near:kha.FastFloat = light.data.raw.near_plane; + var far:kha.FastFloat = light.data.raw.far_plane; var a:kha.FastFloat = far + near; var b:kha.FastFloat = far - near; var f2:kha.FastFloat = 2.0; @@ -598,12 +598,12 @@ class Uniforms { v.y = c / b; } } - else if (c.link == "_spotlampData") { + else if (c.link == "_spotlightData") { // cutoff, cutoff - exponent - if (lamp != null) { + if (light != null) { v = helpVec; - v.x = lamp.data.raw.spot_size; - v.y = v.x - lamp.data.raw.spot_blend; + v.x = light.data.raw.spot_size; + v.y = v.x - light.data.raw.spot_blend; } } @@ -620,17 +620,17 @@ class Uniforms { else if (c.link == "_deltaTime") { f = iron.system.Time.delta; } - else if (c.link == "_lampRadius") { - f = lamp == null ? 0.0 : lamp.data.raw.far_plane; + else if (c.link == "_lightRadius") { + f = light == null ? 0.0 : light.data.raw.far_plane; } - else if (c.link == "_lampShadowsBias") { - f = lamp == null ? 0.0 : lamp.data.raw.shadows_bias; + else if (c.link == "_lightShadowsBias") { + f = light == null ? 0.0 : light.data.raw.shadows_bias; } - else if (c.link == "_lampSize") { - if (lamp != null && lamp.data.raw.lamp_size != null) f = lamp.data.raw.lamp_size; + else if (c.link == "_lightSize") { + if (light != null && light.data.raw.light_size != null) f = light.data.raw.light_size; } - // else if (c.link == "_lampSizeUV") { - // if (lamp != null && lamp.data.raw.lamp_size != null) f = lamp.data.raw.lamp_size / lamp.data.raw.fov; + // else if (c.link == "_lightSizeUV") { + // if (light != null && light.data.raw.light_size != null) f = light.data.raw.light_size / light.data.raw.fov; // } else if (c.link == "_envmapStrength") { f = Scene.active.world == null ? 0.0 : Scene.active.world.getGlobalProbe().raw.strength; @@ -668,7 +668,7 @@ class Uniforms { } #if arm_csm else if (c.link == "_cascadeData") { - if (lamp != null) fa = lamp.getCascadeData(); + if (light != null) fa = light.getCascadeData(); } #end @@ -679,15 +679,15 @@ class Uniforms { } else if (c.type == "int") { var i:Null = null; - if (c.link == "_lampType") { - i = lamp == null ? 0 : LampData.typeToInt(lamp.data.raw.type); + if (c.link == "_lightType") { + i = light == null ? 0 : LightData.typeToInt(light.data.raw.type); } - else if (c.link == "_lampIndex") { - i = RenderPath.active.currentLampIndex; + else if (c.link == "_lightIndex") { + i = RenderPath.active.currentLightIndex; } - else if (c.link == "_lampCastShadow") { - if (lamp != null && lamp.data.raw.cast_shadow) { - i = lamp.data.raw.shadowmap_cube ? 2 : 1; + else if (c.link == "_lightCastShadow") { + if (light != null && light.data.raw.cast_shadow) { + i = light.data.raw.shadowmap_cube ? 2 : 1; } else i = 0; } @@ -704,7 +704,7 @@ class Uniforms { return false; } - static function setObjectConstant(g:Graphics, object:Object, camera:CameraObject, lamp:LampObject, + static function setObjectConstant(g:Graphics, object:Object, camera:CameraObject, light:LightObject, location:ConstantLocation, c:TShaderConstant) { if (c.link == null) return; @@ -766,16 +766,16 @@ class Uniforms { m = cast(object, MeshObject).prevMatrix; } #end - else if (c.link == "_lampWorldViewProjectionMatrix") { - if (lamp != null) { + else if (c.link == "_lightWorldViewProjectionMatrix") { + if (light != null) { // object is null for DrawQuad object == null ? helpMat.setIdentity() : helpMat.setFrom(object.transform.world); - helpMat.multmat(lamp.VP); + helpMat.multmat(light.VP); m = helpMat; } } - else if (c.link == "_lampWorldViewProjectionMatrixSphere") { - if (lamp != null) { + else if (c.link == "_lightWorldViewProjectionMatrixSphere") { + if (light != null) { helpMat.setFrom(object.transform.world); // Align to camera.. @@ -786,12 +786,12 @@ class Uniforms { helpMat2.getInverse(camera.V); helpMat.multmat(helpMat2); - helpMat.multmat(lamp.VP); + helpMat.multmat(light.VP); m = helpMat; } } - else if (c.link == "_lampWorldViewProjectionMatrixCylinder") { - if (lamp != null) { + else if (c.link == "_lightWorldViewProjectionMatrixCylinder") { + if (light != null) { helpMat.setFrom(object.transform.world); // Align to camera.. @@ -802,15 +802,15 @@ class Uniforms { helpMat2.getInverse(camera.V); helpMat.multmat(helpMat2); - helpMat.multmat(lamp.VP); + helpMat.multmat(light.VP); m = helpMat; } } - else if (c.link == "_biasLampWorldViewProjectionMatrix") { - if (lamp != null) { + else if (c.link == "_biasLightWorldViewProjectionMatrix") { + if (light != null) { // object is null for DrawQuad object == null ? helpMat.setIdentity() : helpMat.setFrom(object.transform.world); - helpMat.multmat(lamp.VP); + helpMat.multmat(light.VP); helpMat.multmat(biasMat); m = helpMat; } diff --git a/tools/arm_exporter.py b/tools/arm_exporter.py index bf52c352..85c6717f 100644 --- a/tools/arm_exporter.py +++ b/tools/arm_exporter.py @@ -33,7 +33,7 @@ NodeTypeNode = 0 NodeTypeBone = 1 NodeTypeMesh = 2 -NodeTypeLamp = 3 +NodeTypeLight = 3 NodeTypeCamera = 4 NodeTypeSpeaker = 5 NodeTypeDecal = 6 @@ -42,7 +42,7 @@ AnimationTypeBezier = 2 ExportEpsilon = 1.0e-6 -structIdentifier = ["object", "bone_object", "mesh_object", "lamp_object", "camera_object", "speaker_object", "decal_object"] +structIdentifier = ["object", "bone_object", "mesh_object", "light_object", "camera_object", "speaker_object", "decal_object"] subtranslationName = ["xloc", "yloc", "zloc"] subrotationName = ["xrot", "yrot", "zrot"]