fix .gitignore

This commit is contained in:
Leonid Gaev
2012-06-13 14:35:42 +06:00
4 changed files with 121 additions and 120 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
.idea/**/* .idea/**/*
.settings/* .settings/*
*.iml *.iml
pom.xml
*.svn* *.svn*
*.DS_store* *.DS_store*

View File

@@ -3,7 +3,7 @@
<groupId>platform.clients.fp11.libraries</groupId> <groupId>platform.clients.fp11.libraries</groupId>
<artifactId>Alternativa3D</artifactId> <artifactId>Alternativa3D</artifactId>
<packaging>swc</packaging> <packaging>swc</packaging>
<version>8.31.0-SNAPSHOT</version> <version>8.32.0-SNAPSHOT</version>
<parent> <parent>
<groupId>platform.clients.fp11.tools.maven</groupId> <groupId>platform.clients.fp11.tools.maven</groupId>
<artifactId>BasePom</artifactId> <artifactId>BasePom</artifactId>

View File

@@ -17,6 +17,6 @@ package alternativa {
/** /**
* Library version in the format: generation.feature-version.fix-version. * Library version in the format: generation.feature-version.fix-version.
*/ */
public static const version:String = "8.30.0"; public static const version:String = "8.31.0";
} }
} }

View File

@@ -53,7 +53,7 @@ package alternativa.engine3d.materials {
private static var caches:Dictionary = new Dictionary(true); private static var caches:Dictionary = new Dictionary(true);
private var cachedContext3D:Context3D; private var cachedContext3D:Context3D;
private var programsCache:Vector.<ShaderProgram>; private var programsCache:Dictionary;
private var groups:Vector.<Vector.<Light3D>> = new Vector.<Vector.<Light3D>>(); private var groups:Vector.<Vector.<Light3D>> = new Vector.<Vector.<Light3D>>();
/** /**
@@ -104,8 +104,6 @@ package alternativa.engine3d.materials {
* @private * @private
*/ */
alternativa3d static var fogTexture:TextureResource; alternativa3d static var fogTexture:TextureResource;
//light procedure caching. The key is light3d instance.
private static const _lightFragmentProcedures:Dictionary = new Dictionary();
// inputs : position // inputs : position
private static const _passVaryingsProcedure:Procedure = new Procedure([ private static const _passVaryingsProcedure:Procedure = new Procedure([
@@ -405,10 +403,11 @@ package alternativa.engine3d.materials {
// inputs: tNormal", "tViewVector", "shadow", "cAmbientColor" // inputs: tNormal", "tViewVector", "shadow", "cAmbientColor"
// outputs : light, hightlight // outputs : light, hightlight
private function formDirectionalProcedure(procedure:Procedure, light:Light3D, useShadow:Boolean):void { private function formDirectionalProcedure(procedure:Procedure, index:int, useShadow:Boolean):void {
var source:Array = [ var source:Array = [
"#c0=c" + light.lightID + "Direction", // Position - dirction vector of light
"#c1=c" + light.lightID + "Color", "#c0=c" + index + "Position",
"#c1=c" + index + "Color",
// Calculate half-way vector // Calculate half-way vector
"add t0.xyz, i1.xyz, c0.xyz", "add t0.xyz, i1.xyz, c0.xyz",
"mov t0.w, c0.w", "mov t0.w, c0.w",
@@ -418,7 +417,7 @@ package alternativa.engine3d.materials {
"pow t0.w, t0.w, o1.w", "pow t0.w, t0.w, o1.w",
// Calculate light // Calculate light
"dp3 t0.x, i0.xyz, c0.xyz", "dp3 t0.x, i0.xyz, c0.xyz",
"sat t0.x, t0.x", "sat t0.x, t0.x"
]; ];
if (useShadow) { if (useShadow) {
source.push("mul t0.xw, t0.xw, i2.x"); source.push("mul t0.xw, t0.xw, i2.x");
@@ -435,12 +434,12 @@ package alternativa.engine3d.materials {
procedure.compileFromArray(source); procedure.compileFromArray(source);
} }
private function formOmniProcedure(procedure:Procedure, light:Light3D, useShadow:Boolean):void { private function formOmniProcedure(procedure:Procedure, index:int, useShadow:Boolean):void {
// fragmentLinker.setInputParams(omniMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor"); // fragmentLinker.setInputParams(omniMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor");
var source:Array = [ var source:Array = [
"#c0=c" + light.lightID + "Position", "#c0=c" + index + "Position",
"#c1=c" + light.lightID + "Color", "#c1=c" + index + "Color",
"#c2=c" + light.lightID + "Radius", "#c2=c" + index + "Radius",
"#v0=vPosition" "#v0=vPosition"
]; ];
if (useShadow) { if (useShadow) {
@@ -515,16 +514,9 @@ package alternativa.engine3d.materials {
* @param directionalLight * @param directionalLight
* @param lightsLength * @param lightsLength
*/ */
private function getProgram(object:Object3D, programs:Vector.<ShaderProgram>, camera:Camera3D, materialKey:String, opacityMap:TextureResource, alphaTest:int, lightsGroup:Vector.<Light3D>, lightsLength:int, isFirstGroup:Boolean, shadowedLight:Light3D):StandardMaterialProgram { private function getProgram(object:Object3D, programs:Dictionary, camera:Camera3D, materialKey:String, opacityMap:TextureResource, alphaTest:int, lightsGroup:Vector.<Light3D>, lightsLength:int, isFirstGroup:Boolean, shadowedLight:Light3D):StandardMaterialProgram {
var key:String = materialKey + (opacityMap != null ? "O" : "o") + alphaTest.toString(); var key:String = materialKey + (opacityMap != null ? "O" : "o") + alphaTest.toString();
var program:StandardMaterialProgram = null;//programs[key]; var program:StandardMaterialProgram = programs[key];
for (var i:int = 0; i<programs.length; i++){
if (programs[i].key == key){
program = StandardMaterialProgram(programs[i]);
}
}
if (program == null) { if (program == null) {
var vertexLinker:Linker = new Linker(Context3DProgramType.VERTEX); var vertexLinker:Linker = new Linker(Context3DProgramType.VERTEX);
var fragmentLinker:Linker = new Linker(Context3DProgramType.FRAGMENT); var fragmentLinker:Linker = new Linker(Context3DProgramType.FRAGMENT);
@@ -620,11 +612,8 @@ package alternativa.engine3d.materials {
fragmentLinker.addProcedure(shadowProc); fragmentLinker.addProcedure(shadowProc);
fragmentLinker.setOutputParams(shadowProc, "tTotalLight"); fragmentLinker.setOutputParams(shadowProc, "tTotalLight");
var dirMulShadowProcedure:Procedure = _lightFragmentProcedures[shadowedLight.shadow]; var dirMulShadowProcedure:Procedure = new Procedure(null, "lightShadowDirectional");
if (dirMulShadowProcedure == null) { formDirectionalProcedure(dirMulShadowProcedure, 0, true);
dirMulShadowProcedure = new Procedure();
formDirectionalProcedure(dirMulShadowProcedure, shadowedLight, true);
}
fragmentLinker.addProcedure(dirMulShadowProcedure); fragmentLinker.addProcedure(dirMulShadowProcedure);
fragmentLinker.setInputParams(dirMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor"); fragmentLinker.setInputParams(dirMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor");
fragmentLinker.setOutputParams(dirMulShadowProcedure, "tTotalLight", "tTotalHighLight"); fragmentLinker.setOutputParams(dirMulShadowProcedure, "tTotalLight", "tTotalHighLight");
@@ -636,11 +625,8 @@ package alternativa.engine3d.materials {
fragmentLinker.addProcedure(shadowProc); fragmentLinker.addProcedure(shadowProc);
fragmentLinker.setOutputParams(shadowProc, "tTotalLight"); fragmentLinker.setOutputParams(shadowProc, "tTotalLight");
var omniMulShadowProcedure:Procedure = _lightFragmentProcedures[shadowedLight.shadow]; var omniMulShadowProcedure:Procedure = new Procedure(null, "lightShadowDirectional");
if (omniMulShadowProcedure == null) { formOmniProcedure(omniMulShadowProcedure, 0, true);
omniMulShadowProcedure= new Procedure();
formOmniProcedure(omniMulShadowProcedure, shadowedLight, true);
}
fragmentLinker.addProcedure(omniMulShadowProcedure); fragmentLinker.addProcedure(omniMulShadowProcedure);
fragmentLinker.setInputParams(omniMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor"); fragmentLinker.setInputParams(omniMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor");
fragmentLinker.setOutputParams(omniMulShadowProcedure, "tTotalLight", "tTotalHighLight"); fragmentLinker.setOutputParams(omniMulShadowProcedure, "tTotalLight", "tTotalHighLight");
@@ -650,52 +636,49 @@ package alternativa.engine3d.materials {
for (i = 0; i < lightsLength; i++) { for (i = 0; i < lightsLength; i++) {
var light:Light3D = lightsGroup[i]; var light:Light3D = lightsGroup[i];
if (light == shadowedLight && (shadowedLight is DirectionalLight || shadowedLight is OmniLight)) continue; if (light == shadowedLight && (shadowedLight is DirectionalLight || shadowedLight is OmniLight)) continue;
var lightFragmentProcedure:Procedure = _lightFragmentProcedures[light]; var lightFragmentProcedure:Procedure = new Procedure();
if (lightFragmentProcedure == null) { lightFragmentProcedure.name = "light" + i.toString();
lightFragmentProcedure = new Procedure(); if (light is DirectionalLight) {
lightFragmentProcedure.name = "light" + i.toString(); formDirectionalProcedure(lightFragmentProcedure, i, false);
if (light is DirectionalLight) { lightFragmentProcedure.name += "Directional";
formDirectionalProcedure(lightFragmentProcedure, light, false); } else if (light is OmniLight) {
lightFragmentProcedure.name += "Directional"; formOmniProcedure(lightFragmentProcedure, i, false);
} else if (light is OmniLight) { lightFragmentProcedure.name += "Omni";
formOmniProcedure(lightFragmentProcedure, light, false); } else if (light is SpotLight) {
lightFragmentProcedure.name += "Omni"; lightFragmentProcedure.compileFromArray([
} else if (light is SpotLight) { "#c0=c" + i + "Position",
lightFragmentProcedure.compileFromArray([ "#c1=c" + i + "Color",
"#c0=c" + light.lightID + "Position", "#c2=c" + i + "Radius",
"#c1=c" + light.lightID + "Color", "#c3=c" + i + "Axis",
"#c2=c" + light.lightID + "Radius", "#v0=vPosition",
"#c3=c" + light.lightID + "Axis", // Calculate vector from the point to light
"#v0=vPosition", "sub t0, c0, v0",// L = pos - lightPos
// Calculate vector from the point to light "dp3 t0.w, t0, t0",// lenSqr
"sub t0, c0, v0",// L = pos - lightPos "nrm t0.xyz,t0.xyz",// L = normalize(L)
"dp3 t0.w, t0, t0",// lenSqr // Calculate half-way vector
"nrm t0.xyz,t0.xyz",// L = normalize(L) "add t2.xyz, i1.xyz, t0.xyz",
// Calculate half-way vector "nrm t2.xyz, t2.xyz",
"add t2.xyz, i1.xyz, t0.xyz", //Calculate a flare
"nrm t2.xyz, t2.xyz", "dp3 t2.x, t2.xyz, i0.xyz",
//Calculate a flare "pow t2.x, t2.x, o1.w",
"dp3 t2.x, t2.xyz, i0.xyz", "dp3 t1.x, t0.xyz, c3.xyz", //axisDirDot
"pow t2.x, t2.x, o1.w", "dp3 t0.x, t0, i0.xyz",// dot = dot(normal, L)
"dp3 t1.x, t0.xyz, c3.xyz", //axisDirDot "sqt t0.w, t0.w",// len = sqt(lensqr)
"dp3 t0.x, t0, i0.xyz",// dot = dot(normal, L) "sub t0.w, t0.w, c2.y",// len = len - atenuationBegin
"sqt t0.w, t0.w",// len = sqt(lensqr) "div t0.y, t0.w, c2.x",// att = len/radius
"sub t0.w, t0.w, c2.y",// len = len - atenuationBegin "sub t0.w, c0.w, t0.y",// att = 1 - len/radius
"div t0.y, t0.w, c2.x",// att = len/radius "sub t0.y, t1.x, c2.w",
"sub t0.w, c0.w, t0.y",// att = 1 - len/radius "div t0.y, t0.y, c2.z",
"sub t0.y, t1.x, c2.w", "sat t0.xyw,t0.xyw",// t = sat(t)
"div t0.y, t0.y, c2.z", "mul t1.xyz,c1.xyz,t0.yyy",// t = color*t
"sat t0.xyw,t0.xyw",// t = sat(t) "mul t1.xyz,t1.xyz,t0.www",//
"mul t1.xyz,c1.xyz,t0.yyy",// t = color*t "mul t2.xyz, t2.x, t1.xyz",
"mul t1.xyz,t1.xyz,t0.www",// "add o1.xyz, o1.xyz, t2.xyz",
"mul t2.xyz, t2.x, t1.xyz", "mul t1.xyz, t1.xyz, t0.xxx",
"add o1.xyz, o1.xyz, t2.xyz",
"mul t1.xyz, t1.xyz, t0.xxx",
"add o0.xyz, o0.xyz, t1.xyz" "add o0.xyz, o0.xyz, t1.xyz"
]); ]);
lightFragmentProcedure.name += "Spot"; lightFragmentProcedure.name += "Spot";
}
} }
fragmentLinker.addProcedure(lightFragmentProcedure); fragmentLinker.addProcedure(lightFragmentProcedure);
fragmentLinker.setInputParams(lightFragmentProcedure, "tNormal", "tViewVector"); fragmentLinker.setInputParams(lightFragmentProcedure, "tNormal", "tViewVector");
@@ -744,11 +727,10 @@ package alternativa.engine3d.materials {
// } // }
fragmentLinker.varyings = vertexLinker.varyings; fragmentLinker.varyings = vertexLinker.varyings;
program = new StandardMaterialProgram(vertexLinker, fragmentLinker); program = new StandardMaterialProgram(vertexLinker, fragmentLinker, (shadowedLight != null) ? 1 : lightsLength);
program.upload(camera.context3D);
program.key = key; program.upload(camera.context3D);
programs.push(program); programs[key] = program;
} }
return program; return program;
} }
@@ -804,8 +786,8 @@ package alternativa.engine3d.materials {
transform = light.lightToObjectTransform; transform = light.lightToObjectTransform;
len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Direction"), -transform.c/len, -transform.g/len, -transform.k/len, 1); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], -transform.c/len, -transform.g/len, -transform.k/len, 1);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue); drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue);
} else if (light is OmniLight) { } else if (light is OmniLight) {
omni = light as OmniLight; omni = light as OmniLight;
transform = light.lightToObjectTransform; transform = light.lightToObjectTransform;
@@ -814,9 +796,9 @@ package alternativa.engine3d.materials {
rScale += Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); rScale += Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k);
rScale /= 3; rScale /= 3;
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Position"), transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], transform.d, transform.h, transform.l);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Radius"), 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[i], 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue); drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue);
} else if (light is SpotLight) { } else if (light is SpotLight) {
spot = light as SpotLight; spot = light as SpotLight;
transform = light.lightToObjectTransform; transform = light.lightToObjectTransform;
@@ -827,10 +809,10 @@ package alternativa.engine3d.materials {
falloff = Math.cos(spot.falloff*0.5); falloff = Math.cos(spot.falloff*0.5);
hotspot = Math.cos(spot.hotspot*0.5); hotspot = Math.cos(spot.hotspot*0.5);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Position"), transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], transform.d, transform.h, transform.l);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Axis"), -transform.c/len, -transform.g/len, -transform.k/len); drawUnit.setFragmentConstantsFromNumbers(program.cAxis[i], -transform.c/len, -transform.g/len, -transform.k/len);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Radius"), spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[i], spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue); drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue);
} }
} }
} }
@@ -840,8 +822,8 @@ package alternativa.engine3d.materials {
if (light is DirectionalLight) { if (light is DirectionalLight) {
transform = light.lightToObjectTransform; transform = light.lightToObjectTransform;
len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); len = Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Direction"), -transform.c/len, -transform.g/len, -transform.k/len, 1); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], -transform.c/len, -transform.g/len, -transform.k/len, 1);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue); drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue);
} else if (light is OmniLight) { } else if (light is OmniLight) {
omni = light as OmniLight; omni = light as OmniLight;
transform = light.lightToObjectTransform; transform = light.lightToObjectTransform;
@@ -849,9 +831,9 @@ package alternativa.engine3d.materials {
rScale += Math.sqrt(transform.b*transform.b + transform.f*transform.f + transform.j*transform.j); rScale += Math.sqrt(transform.b*transform.b + transform.f*transform.f + transform.j*transform.j);
rScale += Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k); rScale += Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k);
rScale /= 3; rScale /= 3;
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Position"), transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], transform.d, transform.h, transform.l);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Radius"), 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[0], 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue); drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue);
} else if (light is SpotLight) { } else if (light is SpotLight) {
spot = light as SpotLight; spot = light as SpotLight;
transform = light.lightToObjectTransform; transform = light.lightToObjectTransform;
@@ -862,10 +844,10 @@ package alternativa.engine3d.materials {
falloff = Math.cos(spot.falloff*0.5); falloff = Math.cos(spot.falloff*0.5);
hotspot = Math.cos(spot.hotspot*0.5); hotspot = Math.cos(spot.hotspot*0.5);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Position"), transform.d, transform.h, transform.l); drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], transform.d, transform.h, transform.l);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Axis"), -transform.c/len, -transform.g/len, -transform.k/len); drawUnit.setFragmentConstantsFromNumbers(program.cAxis[0], -transform.c/len, -transform.g/len, -transform.k/len);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Radius"), spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff); drawUnit.setFragmentConstantsFromNumbers(program.cRadius[0], spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff);
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue); drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue);
} }
} }
@@ -1001,16 +983,16 @@ package alternativa.engine3d.materials {
cachedContext3D = camera.context3D; cachedContext3D = camera.context3D;
programsCache = caches[cachedContext3D]; programsCache = caches[cachedContext3D];
if (programsCache == null) { if (programsCache == null) {
programsCache = new Vector.<ShaderProgram>(); programsCache = new Dictionary();
caches[cachedContext3D] = programsCache; caches[cachedContext3D] = programsCache;
} }
} }
// var optionsPrograms:Dictionary = programsCache[object.transformProcedure]; var optionsPrograms:Dictionary = programsCache[object.transformProcedure];
// if (optionsPrograms == null) { if (optionsPrograms == null) {
// optionsPrograms = new Dictionary(false); optionsPrograms = new Dictionary(false);
// programsCache[object.transformProcedure] = optionsPrograms; programsCache[object.transformProcedure] = optionsPrograms;
// } }
// Form groups of lights // Form groups of lights
var groupsCount:int = 0; var groupsCount:int = 0;
@@ -1048,11 +1030,11 @@ package alternativa.engine3d.materials {
if (alphaThreshold > 0) { if (alphaThreshold > 0) {
// Alpha test // Alpha test
// use opacityMap if it is presented // use opacityMap if it is presented
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 1, null, 0, true, null); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 1, null, 0, true, null);
addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, true, false, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, true, false, objectRenderPriority);
} else { } else {
// do not use opacityMap at all // do not use opacityMap at all
program = getProgram(object, programsCache, camera, materialKey, null, 0, null, 0, true, null); program = getProgram(object, optionsPrograms, camera, materialKey, null, 0, null, 0, true, null);
addDrawUnits(program, camera, surface, geometry, null, null, 0, true, null, true, false, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, null, null, 0, true, null, true, false, objectRenderPriority);
} }
} }
@@ -1061,11 +1043,11 @@ package alternativa.engine3d.materials {
// use opacityMap if it is presented // use opacityMap if it is presented
if (alphaThreshold <= alpha && !opaquePass) { if (alphaThreshold <= alpha && !opaquePass) {
// Alpha threshold // Alpha threshold
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 2, null, 0, true, null); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 2, null, 0, true, null);
addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, false, true, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, false, true, objectRenderPriority);
} else { } else {
// There is no Alpha threshold or check z-buffer by previous pass // There is no Alpha threshold or check z-buffer by previous pass
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 0, null, 0, true, null); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 0, null, 0, true, null);
addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, false, true, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, true, null, false, true, objectRenderPriority);
} }
} }
@@ -1094,11 +1076,11 @@ package alternativa.engine3d.materials {
if (alphaThreshold > 0) { if (alphaThreshold > 0) {
// Alpha test // Alpha test
// use opacityMap if it is presented // use opacityMap if it is presented
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 1, lightGroup, lightGroupLength, isFirstGroup, null); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 1, lightGroup, lightGroupLength, isFirstGroup, null);
addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, true, false, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, true, false, objectRenderPriority);
} else { } else {
// do not use opacityMap at all // do not use opacityMap at all
program = getProgram(object, programsCache, camera, materialKey, null, 0, lightGroup, lightGroupLength, isFirstGroup, null); program = getProgram(object, optionsPrograms, camera, materialKey, null, 0, lightGroup, lightGroupLength, isFirstGroup, null);
addDrawUnits(program, camera, surface, geometry, null, lightGroup, lightGroupLength, isFirstGroup, null, true, false, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, null, lightGroup, lightGroupLength, isFirstGroup, null, true, false, objectRenderPriority);
} }
} }
@@ -1107,11 +1089,11 @@ package alternativa.engine3d.materials {
// use opacityMap if it is presented // use opacityMap if it is presented
if (alphaThreshold <= alpha && !opaquePass) { if (alphaThreshold <= alpha && !opaquePass) {
// Alpha threshold // Alpha threshold
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 2, lightGroup, lightGroupLength, isFirstGroup, null); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 2, lightGroup, lightGroupLength, isFirstGroup, null);
addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, false, true, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, false, true, objectRenderPriority);
} else { } else {
// There is no Alpha threshold or check z-buffer by previous pass // There is no Alpha threshold or check z-buffer by previous pass
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 0, lightGroup, lightGroupLength, isFirstGroup, null); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 0, lightGroup, lightGroupLength, isFirstGroup, null);
addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, false, true, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, lightGroup, lightGroupLength, isFirstGroup, null, false, true, objectRenderPriority);
} }
} }
@@ -1119,7 +1101,7 @@ package alternativa.engine3d.materials {
lightGroup.length = 0; lightGroup.length = 0;
} }
if (shadowGroupLength > 0){ if (shadowGroupLength > 0) {
// Group of ligths with shadow // Group of ligths with shadow
// For each light we will create new drawUnit // For each light we will create new drawUnit
for (j = 0; j < shadowGroupLength; j++) { for (j = 0; j < shadowGroupLength; j++) {
@@ -1140,11 +1122,11 @@ package alternativa.engine3d.materials {
if (alphaThreshold > 0) { if (alphaThreshold > 0) {
// Alpha test // Alpha test
// use opacityMap if it is presented // use opacityMap if it is presented
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 1, null, 0, isFirstGroup, light); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 1, null, 0, isFirstGroup, light);
addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, true, false, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, true, false, objectRenderPriority);
} else { } else {
// do not use opacityMap at all // do not use opacityMap at all
program = getProgram(object, programsCache, camera, materialKey, null, 0, null, 0, isFirstGroup, light); program = getProgram(object, optionsPrograms, camera, materialKey, null, 0, null, 0, isFirstGroup, light);
addDrawUnits(program, camera, surface, geometry, null, null, 0, isFirstGroup, light, true, false, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, null, null, 0, isFirstGroup, light, true, false, objectRenderPriority);
} }
} }
@@ -1153,11 +1135,11 @@ package alternativa.engine3d.materials {
// use opacityMap if it is presented // use opacityMap if it is presented
if (alphaThreshold <= alpha && !opaquePass) { if (alphaThreshold <= alpha && !opaquePass) {
// Alpha threshold // Alpha threshold
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 2, null, 0, isFirstGroup, light); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 2, null, 0, isFirstGroup, light);
addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, false, true, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, false, true, objectRenderPriority);
} else { } else {
// There is no Alpha threshold or check z-buffer by previous pass // There is no Alpha threshold or check z-buffer by previous pass
program = getProgram(object, programsCache, camera, materialKey, opacityMap, 0, null, 0, isFirstGroup, light); program = getProgram(object, optionsPrograms, camera, materialKey, opacityMap, 0, null, 0, isFirstGroup, light);
addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, false, true, objectRenderPriority); addDrawUnits(program, camera, surface, geometry, opacityMap, null, 0, isFirstGroup, light, false, true, objectRenderPriority);
} }
} }
@@ -1218,8 +1200,18 @@ class StandardMaterialProgram extends ShaderProgram {
public var sSpecular:int = -1; public var sSpecular:int = -1;
public var sLightMap:int = -1; public var sLightMap:int = -1;
public function StandardMaterialProgram(vertex:Linker, fragment:Linker) { public var cPosition:Vector.<int>;
public var cRadius:Vector.<int>;
public var cAxis:Vector.<int>;
public var cColor:Vector.<int>;
public function StandardMaterialProgram(vertex:Linker, fragment:Linker, numLigths:int) {
super(vertex, fragment); super(vertex, fragment);
cPosition = new Vector.<int>(numLigths);
cRadius = new Vector.<int>(numLigths);
cAxis = new Vector.<int>(numLigths);
cColor = new Vector.<int>(numLigths);
} }
override public function upload(context3D:Context3D):void { override public function upload(context3D:Context3D):void {
@@ -1242,6 +1234,14 @@ class StandardMaterialProgram extends ShaderProgram {
sGlossiness = fragmentShader.findVariable("sGlossiness"); sGlossiness = fragmentShader.findVariable("sGlossiness");
sSpecular = fragmentShader.findVariable("sSpecular"); sSpecular = fragmentShader.findVariable("sSpecular");
sLightMap = fragmentShader.findVariable("sLightMap"); sLightMap = fragmentShader.findVariable("sLightMap");
}
var count:int = cPosition.length;
for (var i:int = 0; i < count; i++) {
cPosition[i] = fragmentShader.findVariable("c" + i + "Position");
cRadius[i] = fragmentShader.findVariable("c" + i + "Radius");
cAxis[i] = fragmentShader.findVariable("c" + i + "Axis");
cColor[i] = fragmentShader.findVariable("c" + i + "Color");
}
}
} }