From 864f00ee6156c554fc4bfc6a5658558f5f252bfb Mon Sep 17 00:00:00 2001 From: Nex Pro Date: Wed, 24 Feb 2016 01:02:17 +0000 Subject: [PATCH 1/2] Fixed inverted particle rendering. --- libraries/entities-renderer/src/textured_particle.slv | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/entities-renderer/src/textured_particle.slv b/libraries/entities-renderer/src/textured_particle.slv index 4d819d389f..bbd7a1daa7 100644 --- a/libraries/entities-renderer/src/textured_particle.slv +++ b/libraries/entities-renderer/src/textured_particle.slv @@ -44,11 +44,12 @@ out vec4 varColor; out vec2 varTexcoord; const int NUM_VERTICES_PER_PARTICLE = 4; +// This ordering ensures that un-rotated particles render upright in the wiewer. const vec4 UNIT_QUAD[NUM_VERTICES_PER_PARTICLE] = vec4[NUM_VERTICES_PER_PARTICLE]( - vec4(-1.0, -1.0, 0.0, 0.0), - vec4(1.0, -1.0, 0.0, 0.0), vec4(-1.0, 1.0, 0.0, 0.0), - vec4(1.0, 1.0, 0.0, 0.0) + vec4(-1.0, -1.0, 0.0, 0.0), + vec4(1.0, 1.0, 0.0, 0.0), + vec4(1.0, -1.0, 0.0, 0.0) ); float bezierInterpolate(float y1, float y2, float y3, float u) { @@ -115,7 +116,8 @@ void main(void) { float seed = inColor.y; // Pass the texcoord and the z texcoord is representing the texture icon - varTexcoord = vec2((UNIT_QUAD[twoTriID].xy + 1.0) * 0.5); + // Offset for corrected vertex ordering. + varTexcoord = vec2((UNIT_QUAD[twoTriID].xy -1.0) * vec2(0.5, -0.5)); varColor = interpolate3Vec4(particle.color.start, particle.color.middle, particle.color.finish, age); // anchor point in eye space From 6403bb60a5ea751c6bd2a41c2f35925fdf2e969b Mon Sep 17 00:00:00 2001 From: Nex Pro Date: Wed, 24 Feb 2016 01:20:49 +0000 Subject: [PATCH 2/2] added particleOrientationTest.js for testing. --- examples/tests/particleOrientationTest.js | 101 ++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 examples/tests/particleOrientationTest.js diff --git a/examples/tests/particleOrientationTest.js b/examples/tests/particleOrientationTest.js new file mode 100644 index 0000000000..7fe670f4b7 --- /dev/null +++ b/examples/tests/particleOrientationTest.js @@ -0,0 +1,101 @@ +// +// particleOrientationTest.js +// examples/tests +// +// Created by Piper.Peppercorn. +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var emitterBone = 'Head' +var particleEntities = []; + +function emitter(jointName) { + var jointID = MyAvatar.jointNames.indexOf(jointName); + var newEmitter = Entities.addEntity({ + name: 'particleEmitter ' + jointName, + type: 'ParticleEffect', + emitterShouldTrail: true, + textures: 'https://dl.dropboxusercontent.com/u/96759331/ParticleTest.png', + position: Vec3.sum(MyAvatar.getAbsoluteJointRotationInObjectFrame(jointID), MyAvatar.position), + parentJointIndex: jointID, + position: MyAvatar.getJointPosition(jointName), + color: { + red: 255, + green: 255, + blue: 255 + }, + isEmitting: 1, + maxParticles: 1, + lifespan: 2.0 + , + emitRate: 1, + emitSpeed: 0.0, + speedSpread: 0.0, + /* + emitOrientation: { + x: -0.7035577893257141, + y: -0.000015259007341228426, + z: -0.000015259007341228426, + w: 1.7106381058692932 + }, + */ + emitOrientation: { + x:0, + y: 0, + z: 0, + w: Math.PI + }, + emitRadiusStart: 0, + polarStart: 0, + polarFinish: 0, + azimuthFinish: 3.1415927410125732, + emitAcceleration: { + x: 0, + y: 0, + z: 0 + }, + accelerationSpread: { + x: 0, + y: 0, + z: 0 + }, + particleRadius: 2.0, + radiusSpread: 1.0, + radiusStart: 2.0, + radiusFinish: 2.0, + colorSpread: { + red: 0, + green: 0, + blue: 0 + }, + colorStart: { + red: 255, + green: 255, + blue: 255 + }, + colorFinish: { + red: 255, + green: 255, + blue: 255 + }, + alpha: 1, + alphaSpread: 0, + alphaStart: 1, + alphaFinish: 1 + }); + return newEmitter; +} + + +Script.scriptEnding.connect(function() { + for (var i = 0; i < particleEntities.length; i++) { + // Fixes a crash on shutdown: + Entities.editEntity(particleEntities[i], { parentID: '' }); + Entities.deleteEntity(particleEntities[i]); + } +}); + +particleEntities.push(emitter(emitterBone));