Revert "Adds a fix for a rendering issue where models with a texture driving both color and opacity would be rendered fully opaque"

This commit is contained in:
samcake 2016-01-22 11:51:02 -08:00
parent 7a3401a8d7
commit f98f8d5bbb
7 changed files with 5 additions and 188 deletions

View file

@ -105,8 +105,7 @@
alphaStart: 0.5,
alphaFinish: 0.5,
textures: "https://s3.amazonaws.com/hifi-public/eric/textures/particleSprites/beamParticle.png",
emitterShouldTrail: false,
lifetime: 1000
emitterShouldTrail: false
}
this.beam = Entities.addEntity(props);

View file

@ -1,161 +0,0 @@
//
// weatherBox.js
// examples/widgets/weatherBox
//
// Created by Eric Levin on 1/20/16.
// Copyright 2016 High Fidelity, Inc.
//
// This script creates a weatherBox widget which (in final version) will display the current weather
//
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
Script.include("../libraries/utils.js");
var weatherBox, boxDimensions;
var orientation = Camera.getOrientation();
orientation = Quat.safeEulerAngles(orientation);
orientation.x = 0;
orientation = Quat.fromVec3Degrees(orientation);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
var emitters = [];
var spheres = [];
createWeatherBox(center);
center.y += boxDimensions.y / 2;
createCloud(center);
for (var i = 0; i < 7; i++) {
createLightningStrike(center)
}
function createLightningStrike(basePosition) {
var normal = Vec3.subtract(position, MyAvatar.position);
normal.y = 0;
var textureURL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/textures/lightning.png"
var linePoints = [];
var normals = [];
var strokeWidths = [];
var strokeWidth = 0.02
var currentPointPosition = {x: 0, y: 0, z: 0};
for (var i = 0; i < 8; i++) {
linePoints.push(currentPointPosition);
currentPointPosition = Vec3.sum(currentPointPosition, {x: randFloat(-0.05, 0.05), y: randFloat(-0.1, -0.05), z: randFloat(-0.05, 0.05)});
linePoints.push(currentPointPosition);
normals.push(normal);
normals.push(normal);
strokeWidth -= 0.002;
strokeWidths.push(strokeWidth);
strokeWidths.push(strokeWidth);
}
var position = Vec3.sum(basePosition, {x: randFloat(-boxDimensions.x/20, boxDimensions.x/20), y: 0, z: randFloat(-boxDimensions.x/20, boxDimensions.x/20)});
var bolt = Entities.addEntity({
type: "PolyLine",
textures: textureURL,
position: position,
dimensions: {
x: 10,
y: 10,
z: 10
},
linePoints: linePoints,
normals: normals,
strokeWidths: strokeWidths,
lifetime: randFloat(0.01, 0.2)
});
Script.setTimeout(function() {
createLightningStrike(position)
}, randInt(500, 5000));
}
function createWeatherBox(position) {
var naturalDimensions = {
x: 1.11,
y: 1.3,
z: 1.11
};
boxDimensions = Vec3.multiply(naturalDimensions, 0.7);
var modelURL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/weatherBox.fbx"
weatherBox = Entities.addEntity({
type: "Model",
name: "Weather Box",
modelURL: modelURL,
position: position,
dimensions: boxDimensions
});
}
function createCloud(position) {
var props = {
"type": "ParticleEffect",
"position": position,
"isEmitting": true,
"maxParticles": 10000,
"lifespan": 3,
"emitRate": 2000,
"emitSpeed": 0.025,
"speedSpread": 0,
"emitDimensions": {
x: boxDimensions.x,
y: boxDimensions.x,
z: 0.1
},
"emitRadiusStart": 1,
"polarStart": 0,
"polarFinish": 1.570796012878418,
"azimuthStart": -3.1415927410125732,
"azimuthFinish": 3.1415927410125732,
"emitAcceleration": {
"x": 0,
"y": 0,
"z": 0
},
"particleRadius": 0.04,
"radiusSpread": 0.02,
"radiusStart": 0.04,
radiusFinish: 0.04,
"colorStart": {
"red": 40,
"green": 40,
"blue": 100
},
color: {
red: 40,
green: 40,
blue: 100
},
"colorFinish": {
"red": 40,
"green": 40,
"blue": 100
},
"alpha": 1,
"alphaSpread": 0,
"alphaStart": 0.3,
"alphaFinish": 0,
"emitterShouldTrail": true,
"textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png"
}
var oceanEmitter = Entities.addEntity(props);
emitters.push(oceanEmitter);
}
function cleanup() {
emitters.forEach(function(emitter) {
Entities.deleteEntity(emitter);
});
spheres.forEach(function(sphere) {
Entities.deleteEntity(sphere);
});
Entities.deleteEntity(weatherBox);
}
Script.scriptEnding.connect(cleanup);

View file

@ -1035,7 +1035,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
} else if (type.contains("transparentcolor")) { // it should be TransparentColor...
// THis is how Maya assign a texture that affect diffuse color AND transparency ?
opacityTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
} else if (type.contains("bump")) {
bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
} else if (type.contains("normal")) {

View file

@ -402,7 +402,6 @@ public:
QHash<QString, QString> specularTextures;
QHash<QString, QString> emissiveTextures;
QHash<QString, QString> ambientTextures;
QHash<QString, QString> opacityTextures;
QHash<QString, FBXMaterial> _fbxMaterials;

View file

@ -70,7 +70,8 @@ void FBXReader::consolidateFBXMaterials() {
FBXTexture diffuseTexture;
QString diffuseTextureID = diffuseTextures.value(material.materialID);
if (!diffuseTextureID.isNull()) {
diffuseTexture = getTexture(diffuseTextureID);
diffuseTexture = getTexture(diffuseTextureID);
// FBX files generated by 3DSMax have an intermediate texture parent, apparently
foreach (const QString& childTextureID, _connectionChildMap.values(diffuseTextureID)) {
if (_textureFilenames.contains(childTextureID)) {
@ -79,16 +80,9 @@ void FBXReader::consolidateFBXMaterials() {
}
material.diffuseTexture = diffuseTexture;
detectDifferentUVs = (diffuseTexture.texcoordSet != 0) || (!diffuseTexture.transform.isIdentity());
}
FBXTexture opacityTexture;
QString opacityTextureID = opacityTextures.value(material.materialID);
if (!opacityTextureID.isNull()) {
opacityTexture = getTexture(opacityTextureID);
material.opacityTexture = opacityTexture;
}
FBXTexture normalTexture;
QString bumpTextureID = bumpTextures.value(material.materialID);

View file

@ -155,8 +155,6 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
material->specularTexture = textureCache->getTexture(url);
} else if (material->emissiveTextureName == name) {
material->emissiveTexture = textureCache->getTexture(url);
} else if (material->opacityTextureName == name) {
material->opacityTexture = textureCache->getTexture(url);
}
}
} else {
@ -288,16 +286,6 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
material._material->setTextureMap(model::MaterialKey::DIFFUSE_MAP, diffuseMap);
}
if (!material.opacityTexture.filename.isEmpty()) {
networkMaterial->opacityTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.opacityTexture.filename)), DEFAULT_TEXTURE, material.opacityTexture.content);
networkMaterial->opacityTextureName = material.opacityTexture.name;
auto opacityMap = model::TextureMapPointer(new model::TextureMap());
opacityMap->setTextureSource(networkMaterial->opacityTexture->_textureSource);
opacityMap->setTextureTransform(material.opacityTexture.transform);
material._material->setTextureMap(model::MaterialKey::TRANSPARENT_MAP, opacityMap);
}
if (!material.normalTexture.filename.isEmpty()) {
networkMaterial->normalTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.normalTexture.filename)), (material.normalTexture.isBumpmap ? BUMP_TEXTURE : NORMAL_TEXTURE), material.normalTexture.content);
networkMaterial->normalTextureName = material.normalTexture.name;

View file

@ -182,8 +182,6 @@ public:
QSharedPointer<NetworkTexture> specularTexture;
QString emissiveTextureName;
QSharedPointer<NetworkTexture> emissiveTexture;
QString opacityTextureName;
QSharedPointer<NetworkTexture> opacityTexture;
};