mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-27 02:19:11 -07:00
work version
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@
|
||||
.idea/**/*
|
||||
.settings/*
|
||||
*.iml
|
||||
pom.xml
|
||||
*.svn*
|
||||
*.DS_store*
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
||||
<groupId>platform.clients.fp11.libraries</groupId>
|
||||
<artifactId>Alternativa3D</artifactId>
|
||||
<packaging>swc</packaging>
|
||||
<version>8.31.0-SNAPSHOT</version>
|
||||
<version>8.32.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>platform.clients.fp11.tools.maven</groupId>
|
||||
<artifactId>BasePom</artifactId>
|
||||
|
||||
@@ -17,6 +17,6 @@ package alternativa {
|
||||
/**
|
||||
* 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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ package alternativa.engine3d.materials {
|
||||
|
||||
private static var caches:Dictionary = new Dictionary(true);
|
||||
private var cachedContext3D:Context3D;
|
||||
private var programsCache:Array;
|
||||
private var programsCache:Dictionary;
|
||||
private var groups:Vector.<Vector.<Light3D>> = new Vector.<Vector.<Light3D>>();
|
||||
|
||||
/**
|
||||
@@ -417,10 +417,11 @@ package alternativa.engine3d.materials {
|
||||
|
||||
// inputs: tNormal", "tViewVector", "shadow", "cAmbientColor"
|
||||
// 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 = [
|
||||
"#c0=c" + light.lightID + "Direction",
|
||||
"#c1=c" + light.lightID + "Color",
|
||||
// Position - dirction vector of light
|
||||
"#c0=c" + index + "Position",
|
||||
"#c1=c" + index + "Color",
|
||||
// Calculate half-way vector
|
||||
"add t0.xyz, i1.xyz, c0.xyz",
|
||||
"mov t0.w, c0.w",
|
||||
@@ -430,7 +431,7 @@ package alternativa.engine3d.materials {
|
||||
"pow t0.w, t0.w, o1.w",
|
||||
// Calculate light
|
||||
"dp3 t0.x, i0.xyz, c0.xyz",
|
||||
"sat t0.x, t0.x",
|
||||
"sat t0.x, t0.x"
|
||||
];
|
||||
if (useShadow) {
|
||||
source.push("mul t0.xw, t0.xw, i2.x");
|
||||
@@ -447,12 +448,12 @@ package alternativa.engine3d.materials {
|
||||
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");
|
||||
var source:Array = [
|
||||
"#c0=c" + light.lightID + "Position",
|
||||
"#c1=c" + light.lightID + "Color",
|
||||
"#c2=c" + light.lightID + "Radius",
|
||||
"#c0=c" + index + "Position",
|
||||
"#c1=c" + index + "Color",
|
||||
"#c2=c" + index + "Radius",
|
||||
"#v0=vPosition"
|
||||
];
|
||||
if (useShadow) {
|
||||
@@ -633,11 +634,8 @@ package alternativa.engine3d.materials {
|
||||
fragmentLinker.addProcedure(shadowProc);
|
||||
fragmentLinker.setOutputParams(shadowProc, "tTotalLight");
|
||||
|
||||
var dirMulShadowProcedure:Procedure = _lightFragmentProcedures[shadowedLight.shadow];
|
||||
if (dirMulShadowProcedure == null) {
|
||||
dirMulShadowProcedure = new Procedure();
|
||||
formDirectionalProcedure(dirMulShadowProcedure, shadowedLight, true);
|
||||
}
|
||||
var dirMulShadowProcedure:Procedure = new Procedure(null, "lightShadowDirectional");
|
||||
formDirectionalProcedure(dirMulShadowProcedure, 0, true);
|
||||
fragmentLinker.addProcedure(dirMulShadowProcedure);
|
||||
fragmentLinker.setInputParams(dirMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor");
|
||||
fragmentLinker.setOutputParams(dirMulShadowProcedure, "tTotalLight", "tTotalHighLight");
|
||||
@@ -649,11 +647,8 @@ package alternativa.engine3d.materials {
|
||||
fragmentLinker.addProcedure(shadowProc);
|
||||
fragmentLinker.setOutputParams(shadowProc, "tTotalLight");
|
||||
|
||||
var omniMulShadowProcedure:Procedure = _lightFragmentProcedures[shadowedLight.shadow];
|
||||
if (omniMulShadowProcedure == null) {
|
||||
omniMulShadowProcedure= new Procedure();
|
||||
formOmniProcedure(omniMulShadowProcedure, shadowedLight, true);
|
||||
}
|
||||
var omniMulShadowProcedure:Procedure = new Procedure(null, "lightShadowDirectional");
|
||||
formOmniProcedure(omniMulShadowProcedure, 0, true);
|
||||
fragmentLinker.addProcedure(omniMulShadowProcedure);
|
||||
fragmentLinker.setInputParams(omniMulShadowProcedure, "tNormal", "tViewVector", "tTotalLight", "cAmbientColor");
|
||||
fragmentLinker.setOutputParams(omniMulShadowProcedure, "tTotalLight", "tTotalHighLight");
|
||||
@@ -663,22 +658,20 @@ package alternativa.engine3d.materials {
|
||||
for (i = 0; i < lightsLength; i++) {
|
||||
var light:Light3D = lightsGroup[i];
|
||||
if (light == shadowedLight && (shadowedLight is DirectionalLight || shadowedLight is OmniLight)) continue;
|
||||
var lightFragmentProcedure:Procedure = _lightFragmentProcedures[light];
|
||||
if (lightFragmentProcedure == null) {
|
||||
lightFragmentProcedure = new Procedure();
|
||||
var lightFragmentProcedure:Procedure = new Procedure();
|
||||
lightFragmentProcedure.name = "light" + i.toString();
|
||||
if (light is DirectionalLight) {
|
||||
formDirectionalProcedure(lightFragmentProcedure, light, false);
|
||||
formDirectionalProcedure(lightFragmentProcedure, i, false);
|
||||
lightFragmentProcedure.name += "Directional";
|
||||
} else if (light is OmniLight) {
|
||||
formOmniProcedure(lightFragmentProcedure, light, false);
|
||||
formOmniProcedure(lightFragmentProcedure, i, false);
|
||||
lightFragmentProcedure.name += "Omni";
|
||||
} else if (light is SpotLight) {
|
||||
lightFragmentProcedure.compileFromArray([
|
||||
"#c0=c" + light.lightID + "Position",
|
||||
"#c1=c" + light.lightID + "Color",
|
||||
"#c2=c" + light.lightID + "Radius",
|
||||
"#c3=c" + light.lightID + "Axis",
|
||||
"#c0=c" + i + "Position",
|
||||
"#c1=c" + i + "Color",
|
||||
"#c2=c" + i + "Radius",
|
||||
"#c3=c" + i + "Axis",
|
||||
"#v0=vPosition",
|
||||
// Calculate vector from the point to light
|
||||
"sub t0, c0, v0",// L = pos - lightPos
|
||||
@@ -709,7 +702,6 @@ package alternativa.engine3d.materials {
|
||||
]);
|
||||
lightFragmentProcedure.name += "Spot";
|
||||
}
|
||||
}
|
||||
fragmentLinker.addProcedure(lightFragmentProcedure);
|
||||
fragmentLinker.setInputParams(lightFragmentProcedure, "tNormal", "tViewVector");
|
||||
fragmentLinker.setOutputParams(lightFragmentProcedure, "tTotalLight", "tTotalHighLight");
|
||||
@@ -757,10 +749,9 @@ package alternativa.engine3d.materials {
|
||||
// }
|
||||
|
||||
fragmentLinker.varyings = vertexLinker.varyings;
|
||||
program = new StandardMaterialProgram(vertexLinker, fragmentLinker);
|
||||
program.upload(camera.context3D);
|
||||
program = new StandardMaterialProgram(vertexLinker, fragmentLinker, (shadowedLight != null) ? 1 : lightsLength);
|
||||
|
||||
// program.key = key;
|
||||
program.upload(camera.context3D);
|
||||
programs[key] = program;
|
||||
}
|
||||
return program;
|
||||
@@ -817,8 +808,8 @@ package alternativa.engine3d.materials {
|
||||
transform = light.lightToObjectTransform;
|
||||
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.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], -transform.c/len, -transform.g/len, -transform.k/len, 1);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue);
|
||||
} else if (light is OmniLight) {
|
||||
omni = light as OmniLight;
|
||||
transform = light.lightToObjectTransform;
|
||||
@@ -827,9 +818,9 @@ package alternativa.engine3d.materials {
|
||||
rScale += Math.sqrt(transform.c*transform.c + transform.g*transform.g + transform.k*transform.k);
|
||||
rScale /= 3;
|
||||
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Position"), 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.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], transform.d, transform.h, transform.l);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cRadius[i], 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue);
|
||||
} else if (light is SpotLight) {
|
||||
spot = light as SpotLight;
|
||||
transform = light.lightToObjectTransform;
|
||||
@@ -840,10 +831,10 @@ package alternativa.engine3d.materials {
|
||||
falloff = Math.cos(spot.falloff*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.fragmentShader.getVariableIndex("c" + light.lightID + "Axis"), -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.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cPosition[i], transform.d, transform.h, transform.l);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cAxis[i], -transform.c/len, -transform.g/len, -transform.k/len);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cRadius[i], spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cColor[i], light.red, light.green, light.blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -853,8 +844,8 @@ package alternativa.engine3d.materials {
|
||||
if (light is DirectionalLight) {
|
||||
transform = light.lightToObjectTransform;
|
||||
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.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], -transform.c/len, -transform.g/len, -transform.k/len, 1);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue);
|
||||
} else if (light is OmniLight) {
|
||||
omni = light as OmniLight;
|
||||
transform = light.lightToObjectTransform;
|
||||
@@ -862,9 +853,9 @@ package alternativa.engine3d.materials {
|
||||
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 /= 3;
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.fragmentShader.getVariableIndex("c" + light.lightID + "Position"), 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.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], transform.d, transform.h, transform.l);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cRadius[0], 1, omni.attenuationEnd*rScale - omni.attenuationBegin*rScale, omni.attenuationBegin*rScale);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue);
|
||||
} else if (light is SpotLight) {
|
||||
spot = light as SpotLight;
|
||||
transform = light.lightToObjectTransform;
|
||||
@@ -875,10 +866,10 @@ package alternativa.engine3d.materials {
|
||||
falloff = Math.cos(spot.falloff*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.fragmentShader.getVariableIndex("c" + light.lightID + "Axis"), -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.fragmentShader.getVariableIndex("c" + light.lightID + "Color"), light.red, light.green, light.blue);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cPosition[0], transform.d, transform.h, transform.l);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cAxis[0], -transform.c/len, -transform.g/len, -transform.k/len);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cRadius[0], spot.attenuationEnd*rScale - spot.attenuationBegin*rScale, spot.attenuationBegin*rScale, hotspot == falloff ? 0.000001 : hotspot - falloff, falloff);
|
||||
drawUnit.setFragmentConstantsFromNumbers(program.cColor[0], light.red, light.green, light.blue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,16 +1005,16 @@ package alternativa.engine3d.materials {
|
||||
cachedContext3D = camera.context3D;
|
||||
programsCache = caches[cachedContext3D];
|
||||
if (programsCache == null) {
|
||||
programsCache = new Array();
|
||||
programsCache = new Dictionary(true);
|
||||
caches[cachedContext3D] = programsCache;
|
||||
}
|
||||
}
|
||||
|
||||
// var optionsPrograms:Dictionary = programsCache[object.transformProcedure];
|
||||
// if (optionsPrograms == null) {
|
||||
// optionsPrograms = new Dictionary(false);
|
||||
// programsCache[object.transformProcedure] = optionsPrograms;
|
||||
// }
|
||||
var optionsPrograms:Array = programsCache[object.transformProcedure];
|
||||
if (optionsPrograms == null) {
|
||||
optionsPrograms = new Array();
|
||||
programsCache[object.transformProcedure] = optionsPrograms;
|
||||
}
|
||||
|
||||
// Form groups of lights
|
||||
var groupsCount:int = 0;
|
||||
@@ -1064,11 +1055,11 @@ package alternativa.engine3d.materials {
|
||||
if (alphaThreshold > 0) {
|
||||
// Alpha test
|
||||
// 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);
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1077,11 +1068,11 @@ package alternativa.engine3d.materials {
|
||||
// use opacityMap if it is presented
|
||||
if (alphaThreshold <= alpha && !opaquePass) {
|
||||
// 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);
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1116,11 +1107,11 @@ package alternativa.engine3d.materials {
|
||||
if (alphaThreshold > 0) {
|
||||
// Alpha test
|
||||
// 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);
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1129,11 +1120,11 @@ package alternativa.engine3d.materials {
|
||||
// use opacityMap if it is presented
|
||||
if (alphaThreshold <= alpha && !opaquePass) {
|
||||
// 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);
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1141,7 +1132,7 @@ package alternativa.engine3d.materials {
|
||||
lightGroup.length = 0;
|
||||
}
|
||||
|
||||
if (shadowGroupLength > 0){
|
||||
if (shadowGroupLength > 0) {
|
||||
// Group of ligths with shadow
|
||||
// For each light we will create new drawUnit
|
||||
for (j = 0; j < shadowGroupLength; j++) {
|
||||
@@ -1184,11 +1175,11 @@ package alternativa.engine3d.materials {
|
||||
if (alphaThreshold > 0) {
|
||||
// Alpha test
|
||||
// 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);
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1197,11 +1188,11 @@ package alternativa.engine3d.materials {
|
||||
// use opacityMap if it is presented
|
||||
if (alphaThreshold <= alpha && !opaquePass) {
|
||||
// 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);
|
||||
} else {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -1262,8 +1253,18 @@ class StandardMaterialProgram extends ShaderProgram {
|
||||
public var sSpecular: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);
|
||||
|
||||
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 {
|
||||
@@ -1286,6 +1287,14 @@ class StandardMaterialProgram extends ShaderProgram {
|
||||
sGlossiness = fragmentShader.findVariable("sGlossiness");
|
||||
sSpecular = fragmentShader.findVariable("sSpecular");
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user