Forráskód Böngészése

Merged manually with master. @pharan please check AttachmentTools, stretchyman diffuse pma material

badlogic 8 éve
szülő
commit
4ee17864a2
58 módosított fájl, 7812 hozzáadás és 6189 törlés
  1. 5 0
      README.md
  2. 1 1
      spine-c/spine-c-unit-tests/tests/MemoryTestFixture.cpp
  3. 2 1
      spine-lua/Slot.lua
  4. 3 3
      spine-ts/README.md
  5. 293 293
      spine-ts/build/spine-all.d.ts
  6. 259 921
      spine-ts/build/spine-all.js
  7. 0 0
      spine-ts/build/spine-all.js.map
  8. 242 242
      spine-ts/build/spine-canvas.d.ts
  9. 335 776
      spine-ts/build/spine-canvas.js
  10. 0 0
      spine-ts/build/spine-canvas.js.map
  11. 148 148
      spine-ts/build/spine-core.d.ts
  12. 404 746
      spine-ts/build/spine-core.js
  13. 0 0
      spine-ts/build/spine-core.js.map
  14. 148 148
      spine-ts/build/spine-threejs.d.ts
  15. 404 746
      spine-ts/build/spine-threejs.js
  16. 0 0
      spine-ts/build/spine-threejs.js.map
  17. 164 164
      spine-ts/build/spine-webgl.d.ts
  18. 404 746
      spine-ts/build/spine-webgl.js
  19. 0 0
      spine-ts/build/spine-webgl.js.map
  20. 164 164
      spine-ts/build/spine-widget.d.ts
  21. 404 746
      spine-ts/build/spine-widget.js
  22. 0 0
      spine-ts/build/spine-widget.js.map
  23. 3 2
      spine-ts/widget/src/Widget.ts
  24. 1 1
      spine-ue4/README.md
  25. 1 1
      spine-unity/Assets/Examples/Getting Started/Scripts/SpineboyBeginnerView.cs
  26. 0 2
      spine-unity/Assets/Examples/Scripts/MixAndMatch.cs
  27. 1 1
      spine-unity/Assets/Examples/Scripts/RaggedySpineboy.cs
  28. 1 1
      spine-unity/Assets/Examples/Spine/Strechyman/stretchyman-diffuse-pma.png.meta
  29. BIN
      spine-unity/Assets/Examples/Spine/Strechyman/stretchyman-diffuse-pma_Material.mat
  30. 1 0
      spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs
  31. 134 10
      spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs
  32. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes.meta
  33. 70 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderMaths.cginc
  34. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderMaths.cginc.meta
  35. 472 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderShared.cginc
  36. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderShared.cginc.meta
  37. 200 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteLighting.cginc
  38. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteLighting.cginc.meta
  39. 252 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc
  40. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc.meta
  41. 49 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteShadows.cginc
  42. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteShadows.cginc.meta
  43. 246 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteSpecular.cginc
  44. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteSpecular.cginc.meta
  45. 72 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc
  46. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc.meta
  47. 474 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc
  48. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc.meta
  49. 522 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthNormalsTexture.shader
  50. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthNormalsTexture.shader.meta
  51. 518 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthTexture.shader
  52. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthTexture.shader.meta
  53. 522 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraNormalsTexture.shader
  54. 9 0
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraNormalsTexture.shader.meta
  55. 712 300
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/Editor/SpineSpriteShaderGUI.cs
  56. 33 13
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/SpritesPixelLit.shader
  57. 14 5
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/SpritesUnlit.shader
  58. 26 8
      spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/SpritesVertexLit.shader

+ 5 - 0
README.md

@@ -19,3 +19,8 @@ Review our backlog of bugs, enhancements, and tasks in the [spine-runtimes](http
 ## Versioning
 
 The code provided here is continuously under development. Generally the latest Git `master` source works with the data exported from the latest version of Spine. The Spine version can be [frozen](http://esotericsoftware.com/spine-settings#Version) at a specific Spine version that matches the Spine Runtimes source being used. Occaisionally the Spine Runtimes are [tagged](https://github.com/EsotericSoftware/spine-runtimes/releases) to work with a specific Spine version.
+
+## Contributing
+Before we can merge your contributions, we will need a signed [contributor license agreement (CLA)](http://esotericsoftware.com/files/cla.txt) from you. You can send a copy of the CLA to [email protected].
+
+If possible, base your contributions on the current development branch, which is `$version-beta`, e.g. `3.6-beta`. Makre sure to follow the formatting you find in the respective runtime code you contribute to.

+ 1 - 1
spine-c/spine-c-unit-tests/tests/MemoryTestFixture.cpp

@@ -305,7 +305,7 @@ void MemoryTestFixture::skeletonClipper() {
 	spUnsignedShortArray_add(indices, 1);
 	spUnsignedShortArray_add(indices, 2);
 
-	spSkeletonClipping_clipTriangles(clipping, vertices->items, vertices->size, indices->items, indices->size, uvs->items);
+	spSkeletonClipping_clipTriangles(clipping, vertices->items, vertices->size, indices->items, indices->size, uvs->items, 2);
 
 	float expectedVertices[8] = { 83.333328, 50.000000, 76.666664, 70.000000, 23.333334, 70.000000, 16.666672, 50.000000 };
 	ASSERT(clipping->clippedVertices->size == 8);

+ 2 - 1
spine-lua/Slot.lua

@@ -48,6 +48,7 @@ function Slot.new (data, bone)
 		attachmentTime = 0,
 		attachmentVertices = {}
 	}	
+
 	setmetatable(self, Slot)
 	
 	if data.darkColor then self.darkColor = Color.newWith(1, 1, 1, 1) end
@@ -61,7 +62,7 @@ function Slot:setAttachment (attachment)
 	if self.attachment == attachment then return end
 	self.attachment = attachment
 	self.attachmentTime = self.bone.skeleton.time
-	self.attachmentVertices = {};
+	self.attachmentVertices = {}
 end
 
 function Slot:setAttachmentTime (time)

+ 3 - 3
spine-ts/README.md

@@ -58,12 +58,12 @@ To run the examples, the image, atlas, and JSON files must be served by a webser
 ```
 cd spine-ts
 python -m SimpleHTTPServer
-````
+```
 
 Then open `http://localhost:8000/webgl/example`, `http://localhost:8000/canvas/example`, `https://localhost:8000/threejs/example` or `http://localhost:8000/widget/example` in your browser.
 
 ## WebGL Demos
-The spine-ts WebGL demos load their image, atlas, and JSON files from our webserver and so can be run directly, without needing a webserver. View the demos [all on one page](http://esotericsoftware.com/spine-demos/) or use the [standalone demos]() which are easy for you to explore and edit. The standalone demos can also be viewed here:
+The spine-ts WebGL demos load their image, atlas, and JSON files from our webserver and so can be run directly, without needing a webserver. The demos can be viewed [all on one page](http://esotericsoftware.com/spine-demos/) or in individual, standalone pages which are easy for you to explore and edit. See the [standalone demos source code](https://github.com/EsotericSoftware/spine-runtimes/tree/master/spine-ts/webgl/demos) and view the pages here:
 
 - [Spine vs sprite sheets](http://rawgit.com/EsotericSoftware/spine-runtimes/master/spine-ts/webgl/demos/spritesheets.html)
 - [Image changes](http://rawgit.com/EsotericSoftware/spine-runtimes/master/spine-ts/webgl/demos/imagechanges.html)
@@ -217,4 +217,4 @@ an element via JavaScript on demand.
 The resulting `SpineWidget` has various fields that let you modify the animation programmatically. Most notably, the `skeleton` and `state` fields
 let you modify all aspects of your animation as you wish. See the [example](https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-ts/widget/example/index.html#L21).
 
-You can also modify what debug information is shown by accessing `SpineWidget.debugRenderer` and set the various `drawXXX` fields to `true` or `false`.
+You can also modify what debug information is shown by accessing `SpineWidget.debugRenderer` and set the various `drawXXX` fields to `true` or `false`.

+ 293 - 293
spine-ts/build/spine-all.d.ts

@@ -1,97 +1,3 @@
-declare module spine {
-	class AssetManager implements Disposable {
-		private pathPrefix;
-		private textureLoader;
-		private assets;
-		private errors;
-		private toLoad;
-		private loaded;
-		constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
-		loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
-		loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
-		loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
-		get(path: string): any;
-		remove(path: string): void;
-		removeAll(): void;
-		isLoadingComplete(): boolean;
-		getToLoad(): number;
-		getLoaded(): number;
-		dispose(): void;
-		hasErrors(): boolean;
-		getErrors(): Map<string>;
-	}
-}
-declare module spine.canvas {
-	class AssetManager extends spine.AssetManager {
-		constructor(pathPrefix?: string);
-	}
-}
-declare module spine {
-	abstract class Texture {
-		protected _image: HTMLImageElement;
-		constructor(image: HTMLImageElement);
-		getImage(): HTMLImageElement;
-		abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
-		abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
-		abstract dispose(): void;
-		static filterFromString(text: string): TextureFilter;
-		static wrapFromString(text: string): TextureWrap;
-	}
-	enum TextureFilter {
-		Nearest = 9728,
-		Linear = 9729,
-		MipMap = 9987,
-		MipMapNearestNearest = 9984,
-		MipMapLinearNearest = 9985,
-		MipMapNearestLinear = 9986,
-		MipMapLinearLinear = 9987,
-	}
-	enum TextureWrap {
-		MirroredRepeat = 33648,
-		ClampToEdge = 33071,
-		Repeat = 10497,
-	}
-	class TextureRegion {
-		renderObject: any;
-		u: number;
-		v: number;
-		u2: number;
-		v2: number;
-		width: number;
-		height: number;
-		rotate: boolean;
-		offsetX: number;
-		offsetY: number;
-		originalWidth: number;
-		originalHeight: number;
-	}
-}
-declare module spine.canvas {
-	class CanvasTexture extends Texture {
-		constructor(image: HTMLImageElement);
-		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
-		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
-		dispose(): void;
-	}
-}
-declare module spine.canvas {
-	class SkeletonRenderer {
-		static QUAD_TRIANGLES: number[];
-		static VERTEX_SIZE: number;
-		private ctx;
-		triangleRendering: boolean;
-		debugRendering: boolean;
-		private vertices;
-		private tempColor;
-		constructor(context: CanvasRenderingContext2D);
-		draw(skeleton: Skeleton): void;
-		private drawImages(skeleton);
-		private drawTriangles(skeleton);
-		private drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
-		private computeRegionVertices(slot, region, pma);
-		private computeMeshVertices(slot, mesh, pma);
-	}
-}
 declare module spine {
 	class Animation {
 		name: string;
@@ -446,33 +352,32 @@ declare module spine {
 	}
 }
 declare module spine {
-	class AtlasAttachmentLoader implements AttachmentLoader {
-		atlas: TextureAtlas;
-		constructor(atlas: TextureAtlas);
-		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
-		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
-		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
-		newPathAttachment(skin: Skin, name: string): PathAttachment;
-		newPointAttachment(skin: Skin, name: string): PointAttachment;
-		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
-	}
-}
-declare module spine {
-	abstract class Attachment {
-		name: string;
-		constructor(name: string);
-	}
-	abstract class VertexAttachment extends Attachment {
-		bones: Array<number>;
-		vertices: ArrayLike<number>;
-		worldVerticesLength: number;
-		constructor(name: string);
-		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
+	class AssetManager implements Disposable {
+		private pathPrefix;
+		private textureLoader;
+		private assets;
+		private errors;
+		private toLoad;
+		private loaded;
+		constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
+		loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
+		loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
+		loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
+		get(path: string): any;
+		remove(path: string): void;
+		removeAll(): void;
+		isLoadingComplete(): boolean;
+		getToLoad(): number;
+		getLoaded(): number;
+		dispose(): void;
+		hasErrors(): boolean;
+		getErrors(): Map<string>;
 	}
 }
 declare module spine {
-	interface AttachmentLoader {
+	class AtlasAttachmentLoader implements AttachmentLoader {
+		atlas: TextureAtlas;
+		constructor(atlas: TextureAtlas);
 		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
 		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
 		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
@@ -481,130 +386,6 @@ declare module spine {
 		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
 	}
 }
-declare module spine {
-	enum AttachmentType {
-		Region = 0,
-		BoundingBox = 1,
-		Mesh = 2,
-		LinkedMesh = 3,
-		Path = 4,
-		Point = 5,
-	}
-}
-declare module spine {
-	class BoundingBoxAttachment extends VertexAttachment {
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class ClippingAttachment extends VertexAttachment {
-		endSlot: SlotData;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class MeshAttachment extends VertexAttachment {
-		region: TextureRegion;
-		path: string;
-		regionUVs: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		triangles: Array<number>;
-		color: Color;
-		hullLength: number;
-		private parentMesh;
-		inheritDeform: boolean;
-		tempColor: Color;
-		constructor(name: string);
-		updateUVs(): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-		getParentMesh(): MeshAttachment;
-		setParentMesh(parentMesh: MeshAttachment): void;
-	}
-}
-declare module spine {
-	class PathAttachment extends VertexAttachment {
-		lengths: Array<number>;
-		closed: boolean;
-		constantSpeed: boolean;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class PointAttachment extends VertexAttachment {
-		x: number;
-		y: number;
-		rotation: number;
-		color: Color;
-		constructor(name: string);
-		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
-		computeWorldRotation(bone: Bone): number;
-	}
-}
-declare module spine {
-	class RegionAttachment extends Attachment {
-		static OX1: number;
-		static OY1: number;
-		static OX2: number;
-		static OY2: number;
-		static OX3: number;
-		static OY3: number;
-		static OX4: number;
-		static OY4: number;
-		static X1: number;
-		static Y1: number;
-		static C1R: number;
-		static C1G: number;
-		static C1B: number;
-		static C1A: number;
-		static U1: number;
-		static V1: number;
-		static X2: number;
-		static Y2: number;
-		static C2R: number;
-		static C2G: number;
-		static C2B: number;
-		static C2A: number;
-		static U2: number;
-		static V2: number;
-		static X3: number;
-		static Y3: number;
-		static C3R: number;
-		static C3G: number;
-		static C3B: number;
-		static C3A: number;
-		static U3: number;
-		static V3: number;
-		static X4: number;
-		static Y4: number;
-		static C4R: number;
-		static C4G: number;
-		static C4B: number;
-		static C4A: number;
-		static U4: number;
-		static V4: number;
-		x: number;
-		y: number;
-		scaleX: number;
-		scaleY: number;
-		rotation: number;
-		width: number;
-		height: number;
-		color: Color;
-		path: string;
-		rendererObject: any;
-		region: TextureRegion;
-		offset: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		tempColor: Color;
-		constructor(name: string);
-		updateOffset(): void;
-		setRegion(region: TextureRegion): void;
-		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-	}
-}
 declare module spine {
 	enum BlendMode {
 		Normal = 0,
@@ -990,6 +771,46 @@ declare module spine {
 		constructor(index: number, name: string, boneData: BoneData);
 	}
 }
+declare module spine {
+	abstract class Texture {
+		protected _image: HTMLImageElement;
+		constructor(image: HTMLImageElement);
+		getImage(): HTMLImageElement;
+		abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
+		abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
+		abstract dispose(): void;
+		static filterFromString(text: string): TextureFilter;
+		static wrapFromString(text: string): TextureWrap;
+	}
+	enum TextureFilter {
+		Nearest = 9728,
+		Linear = 9729,
+		MipMap = 9987,
+		MipMapNearestNearest = 9984,
+		MipMapLinearNearest = 9985,
+		MipMapNearestLinear = 9986,
+		MipMapLinearLinear = 9987,
+	}
+	enum TextureWrap {
+		MirroredRepeat = 33648,
+		ClampToEdge = 33071,
+		Repeat = 10497,
+	}
+	class TextureRegion {
+		renderObject: any;
+		u: number;
+		v: number;
+		u2: number;
+		v2: number;
+		width: number;
+		height: number;
+		rotate: boolean;
+		offsetX: number;
+		offsetY: number;
+		originalWidth: number;
+		originalHeight: number;
+	}
+}
 declare module spine {
 	class TextureAtlas implements Disposable {
 		pages: TextureAtlasPage[];
@@ -1185,51 +1006,183 @@ declare module spine {
 		getMean(): number;
 	}
 }
-declare module spine.threejs {
-	class AssetManager extends spine.AssetManager {
-		constructor(pathPrefix?: string);
+declare module spine {
+	abstract class Attachment {
+		name: string;
+		constructor(name: string);
+	}
+	abstract class VertexAttachment extends Attachment {
+		bones: Array<number>;
+		vertices: ArrayLike<number>;
+		worldVerticesLength: number;
+		constructor(name: string);
+		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
 	}
 }
-declare module spine.threejs {
-	class MeshBatcher {
-		mesh: THREE.Mesh;
-		private static VERTEX_SIZE;
-		private vertexBuffer;
-		private vertices;
-		private verticesLength;
-		private indices;
-		private indicesLength;
-		constructor(mesh: THREE.Mesh, maxVertices?: number);
-		begin(): void;
-		batch(vertices: ArrayLike<number>, verticesLength: number, indices: ArrayLike<number>, indicesLength: number, z?: number): void;
-		end(): void;
+declare module spine {
+	interface AttachmentLoader {
+		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
+		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
+		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
+		newPathAttachment(skin: Skin, name: string): PathAttachment;
+		newPointAttachment(skin: Skin, name: string): PointAttachment;
+		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
 	}
 }
-declare module spine.threejs {
-	class SkeletonMesh extends THREE.Mesh {
-		skeleton: Skeleton;
-		state: AnimationState;
-		zOffset: number;
-		private batcher;
-		private clipper;
-		static QUAD_TRIANGLES: number[];
-		static VERTEX_SIZE: number;
-		private vertices;
-		private tempColor;
-		constructor(skeletonData: SkeletonData);
-		update(deltaTime: number): void;
-		private updateGeometry();
+declare module spine {
+	enum AttachmentType {
+		Region = 0,
+		BoundingBox = 1,
+		Mesh = 2,
+		LinkedMesh = 3,
+		Path = 4,
+		Point = 5,
 	}
 }
-declare module spine.threejs {
-	class ThreeJsTexture extends Texture {
-		texture: THREE.Texture;
+declare module spine {
+	class BoundingBoxAttachment extends VertexAttachment {
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class ClippingAttachment extends VertexAttachment {
+		endSlot: SlotData;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class MeshAttachment extends VertexAttachment {
+		region: TextureRegion;
+		path: string;
+		regionUVs: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		triangles: Array<number>;
+		color: Color;
+		hullLength: number;
+		private parentMesh;
+		inheritDeform: boolean;
+		tempColor: Color;
+		constructor(name: string);
+		updateUVs(): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+		getParentMesh(): MeshAttachment;
+		setParentMesh(parentMesh: MeshAttachment): void;
+	}
+}
+declare module spine {
+	class PathAttachment extends VertexAttachment {
+		lengths: Array<number>;
+		closed: boolean;
+		constantSpeed: boolean;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class PointAttachment extends VertexAttachment {
+		x: number;
+		y: number;
+		rotation: number;
+		color: Color;
+		constructor(name: string);
+		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
+		computeWorldRotation(bone: Bone): number;
+	}
+}
+declare module spine {
+	class RegionAttachment extends Attachment {
+		static OX1: number;
+		static OY1: number;
+		static OX2: number;
+		static OY2: number;
+		static OX3: number;
+		static OY3: number;
+		static OX4: number;
+		static OY4: number;
+		static X1: number;
+		static Y1: number;
+		static C1R: number;
+		static C1G: number;
+		static C1B: number;
+		static C1A: number;
+		static U1: number;
+		static V1: number;
+		static X2: number;
+		static Y2: number;
+		static C2R: number;
+		static C2G: number;
+		static C2B: number;
+		static C2A: number;
+		static U2: number;
+		static V2: number;
+		static X3: number;
+		static Y3: number;
+		static C3R: number;
+		static C3G: number;
+		static C3B: number;
+		static C3A: number;
+		static U3: number;
+		static V3: number;
+		static X4: number;
+		static Y4: number;
+		static C4R: number;
+		static C4G: number;
+		static C4B: number;
+		static C4A: number;
+		static U4: number;
+		static V4: number;
+		x: number;
+		y: number;
+		scaleX: number;
+		scaleY: number;
+		rotation: number;
+		width: number;
+		height: number;
+		color: Color;
+		path: string;
+		rendererObject: any;
+		region: TextureRegion;
+		offset: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		tempColor: Color;
+		constructor(name: string);
+		updateOffset(): void;
+		setRegion(region: TextureRegion): void;
+		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+	}
+}
+declare module spine.canvas {
+	class AssetManager extends spine.AssetManager {
+		constructor(pathPrefix?: string);
+	}
+}
+declare module spine.canvas {
+	class CanvasTexture extends Texture {
 		constructor(image: HTMLImageElement);
 		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
 		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
 		dispose(): void;
-		static toThreeJsTextureFilter(filter: TextureFilter): THREE.TextureFilter;
-		static toThreeJsTextureWrap(wrap: TextureWrap): THREE.Wrapping;
+	}
+}
+declare module spine.canvas {
+	class SkeletonRenderer {
+		static QUAD_TRIANGLES: number[];
+		static VERTEX_SIZE: number;
+		private ctx;
+		triangleRendering: boolean;
+		debugRendering: boolean;
+		private vertices;
+		private tempColor;
+		constructor(context: CanvasRenderingContext2D);
+		draw(skeleton: Skeleton): void;
+		private drawImages(skeleton);
+		private drawTriangles(skeleton);
+		private drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
+		private computeRegionVertices(slot, region, pma);
+		private computeMeshVertices(slot, mesh, pma);
 	}
 }
 declare module spine.webgl {
@@ -1323,22 +1276,22 @@ declare module spine.webgl {
 	}
 }
 declare module spine.webgl {
-	const M00: number;
-	const M01: number;
-	const M02: number;
-	const M03: number;
-	const M10: number;
-	const M11: number;
-	const M12: number;
-	const M13: number;
-	const M20: number;
-	const M21: number;
-	const M22: number;
-	const M23: number;
-	const M30: number;
-	const M31: number;
-	const M32: number;
-	const M33: number;
+	const M00 = 0;
+	const M01 = 4;
+	const M02 = 8;
+	const M03 = 12;
+	const M10 = 1;
+	const M11 = 5;
+	const M12 = 9;
+	const M13 = 13;
+	const M20 = 2;
+	const M21 = 6;
+	const M22 = 10;
+	const M23 = 14;
+	const M30 = 3;
+	const M31 = 7;
+	const M32 = 11;
+	const M33 = 15;
 	class Matrix4 {
 		temp: Float32Array;
 		values: Float32Array;
@@ -1657,6 +1610,53 @@ declare module spine.webgl {
 		static getSourceGLBlendMode(blendMode: BlendMode, premultipliedAlpha?: boolean): number;
 	}
 }
+declare module spine.threejs {
+	class AssetManager extends spine.AssetManager {
+		constructor(pathPrefix?: string);
+	}
+}
+declare module spine.threejs {
+	class MeshBatcher {
+		mesh: THREE.Mesh;
+		private static VERTEX_SIZE;
+		private vertexBuffer;
+		private vertices;
+		private verticesLength;
+		private indices;
+		private indicesLength;
+		constructor(mesh: THREE.Mesh, maxVertices?: number);
+		begin(): void;
+		batch(vertices: ArrayLike<number>, verticesLength: number, indices: ArrayLike<number>, indicesLength: number, z?: number): void;
+		end(): void;
+	}
+}
+declare module spine.threejs {
+	class SkeletonMesh extends THREE.Mesh {
+		skeleton: Skeleton;
+		state: AnimationState;
+		zOffset: number;
+		private batcher;
+		private clipper;
+		static QUAD_TRIANGLES: number[];
+		static VERTEX_SIZE: number;
+		private vertices;
+		private tempColor;
+		constructor(skeletonData: SkeletonData);
+		update(deltaTime: number): void;
+		private updateGeometry();
+	}
+}
+declare module spine.threejs {
+	class ThreeJsTexture extends Texture {
+		texture: THREE.Texture;
+		constructor(image: HTMLImageElement);
+		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
+		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
+		dispose(): void;
+		static toThreeJsTextureFilter(filter: TextureFilter): THREE.TextureFilter;
+		static toThreeJsTextureWrap(wrap: TextureWrap): THREE.Wrapping;
+	}
+}
 declare module spine {
 	class SpineWidget {
 		skeleton: Skeleton;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 259 - 921
spine-ts/build/spine-all.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
spine-ts/build/spine-all.js.map


+ 242 - 242
spine-ts/build/spine-canvas.d.ts

@@ -1,97 +1,3 @@
-declare module spine {
-	class AssetManager implements Disposable {
-		private pathPrefix;
-		private textureLoader;
-		private assets;
-		private errors;
-		private toLoad;
-		private loaded;
-		constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
-		loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
-		loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
-		loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
-		get(path: string): any;
-		remove(path: string): void;
-		removeAll(): void;
-		isLoadingComplete(): boolean;
-		getToLoad(): number;
-		getLoaded(): number;
-		dispose(): void;
-		hasErrors(): boolean;
-		getErrors(): Map<string>;
-	}
-}
-declare module spine.canvas {
-	class AssetManager extends spine.AssetManager {
-		constructor(pathPrefix?: string);
-	}
-}
-declare module spine {
-	abstract class Texture {
-		protected _image: HTMLImageElement;
-		constructor(image: HTMLImageElement);
-		getImage(): HTMLImageElement;
-		abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
-		abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
-		abstract dispose(): void;
-		static filterFromString(text: string): TextureFilter;
-		static wrapFromString(text: string): TextureWrap;
-	}
-	enum TextureFilter {
-		Nearest = 9728,
-		Linear = 9729,
-		MipMap = 9987,
-		MipMapNearestNearest = 9984,
-		MipMapLinearNearest = 9985,
-		MipMapNearestLinear = 9986,
-		MipMapLinearLinear = 9987,
-	}
-	enum TextureWrap {
-		MirroredRepeat = 33648,
-		ClampToEdge = 33071,
-		Repeat = 10497,
-	}
-	class TextureRegion {
-		renderObject: any;
-		u: number;
-		v: number;
-		u2: number;
-		v2: number;
-		width: number;
-		height: number;
-		rotate: boolean;
-		offsetX: number;
-		offsetY: number;
-		originalWidth: number;
-		originalHeight: number;
-	}
-}
-declare module spine.canvas {
-	class CanvasTexture extends Texture {
-		constructor(image: HTMLImageElement);
-		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
-		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
-		dispose(): void;
-	}
-}
-declare module spine.canvas {
-	class SkeletonRenderer {
-		static QUAD_TRIANGLES: number[];
-		static VERTEX_SIZE: number;
-		private ctx;
-		triangleRendering: boolean;
-		debugRendering: boolean;
-		private vertices;
-		private tempColor;
-		constructor(context: CanvasRenderingContext2D);
-		draw(skeleton: Skeleton): void;
-		private drawImages(skeleton);
-		private drawTriangles(skeleton);
-		private drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
-		private computeRegionVertices(slot, region, pma);
-		private computeMeshVertices(slot, mesh, pma);
-	}
-}
 declare module spine {
 	class Animation {
 		name: string;
@@ -446,33 +352,32 @@ declare module spine {
 	}
 }
 declare module spine {
-	class AtlasAttachmentLoader implements AttachmentLoader {
-		atlas: TextureAtlas;
-		constructor(atlas: TextureAtlas);
-		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
-		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
-		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
-		newPathAttachment(skin: Skin, name: string): PathAttachment;
-		newPointAttachment(skin: Skin, name: string): PointAttachment;
-		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
-	}
-}
-declare module spine {
-	abstract class Attachment {
-		name: string;
-		constructor(name: string);
-	}
-	abstract class VertexAttachment extends Attachment {
-		bones: Array<number>;
-		vertices: ArrayLike<number>;
-		worldVerticesLength: number;
-		constructor(name: string);
-		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
+	class AssetManager implements Disposable {
+		private pathPrefix;
+		private textureLoader;
+		private assets;
+		private errors;
+		private toLoad;
+		private loaded;
+		constructor(textureLoader: (image: HTMLImageElement) => any, pathPrefix?: string);
+		loadText(path: string, success?: (path: string, text: string) => void, error?: (path: string, error: string) => void): void;
+		loadTexture(path: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
+		loadTextureData(path: string, data: string, success?: (path: string, image: HTMLImageElement) => void, error?: (path: string, error: string) => void): void;
+		get(path: string): any;
+		remove(path: string): void;
+		removeAll(): void;
+		isLoadingComplete(): boolean;
+		getToLoad(): number;
+		getLoaded(): number;
+		dispose(): void;
+		hasErrors(): boolean;
+		getErrors(): Map<string>;
 	}
 }
 declare module spine {
-	interface AttachmentLoader {
+	class AtlasAttachmentLoader implements AttachmentLoader {
+		atlas: TextureAtlas;
+		constructor(atlas: TextureAtlas);
 		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
 		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
 		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
@@ -481,130 +386,6 @@ declare module spine {
 		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
 	}
 }
-declare module spine {
-	enum AttachmentType {
-		Region = 0,
-		BoundingBox = 1,
-		Mesh = 2,
-		LinkedMesh = 3,
-		Path = 4,
-		Point = 5,
-	}
-}
-declare module spine {
-	class BoundingBoxAttachment extends VertexAttachment {
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class ClippingAttachment extends VertexAttachment {
-		endSlot: SlotData;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class MeshAttachment extends VertexAttachment {
-		region: TextureRegion;
-		path: string;
-		regionUVs: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		triangles: Array<number>;
-		color: Color;
-		hullLength: number;
-		private parentMesh;
-		inheritDeform: boolean;
-		tempColor: Color;
-		constructor(name: string);
-		updateUVs(): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-		getParentMesh(): MeshAttachment;
-		setParentMesh(parentMesh: MeshAttachment): void;
-	}
-}
-declare module spine {
-	class PathAttachment extends VertexAttachment {
-		lengths: Array<number>;
-		closed: boolean;
-		constantSpeed: boolean;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class PointAttachment extends VertexAttachment {
-		x: number;
-		y: number;
-		rotation: number;
-		color: Color;
-		constructor(name: string);
-		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
-		computeWorldRotation(bone: Bone): number;
-	}
-}
-declare module spine {
-	class RegionAttachment extends Attachment {
-		static OX1: number;
-		static OY1: number;
-		static OX2: number;
-		static OY2: number;
-		static OX3: number;
-		static OY3: number;
-		static OX4: number;
-		static OY4: number;
-		static X1: number;
-		static Y1: number;
-		static C1R: number;
-		static C1G: number;
-		static C1B: number;
-		static C1A: number;
-		static U1: number;
-		static V1: number;
-		static X2: number;
-		static Y2: number;
-		static C2R: number;
-		static C2G: number;
-		static C2B: number;
-		static C2A: number;
-		static U2: number;
-		static V2: number;
-		static X3: number;
-		static Y3: number;
-		static C3R: number;
-		static C3G: number;
-		static C3B: number;
-		static C3A: number;
-		static U3: number;
-		static V3: number;
-		static X4: number;
-		static Y4: number;
-		static C4R: number;
-		static C4G: number;
-		static C4B: number;
-		static C4A: number;
-		static U4: number;
-		static V4: number;
-		x: number;
-		y: number;
-		scaleX: number;
-		scaleY: number;
-		rotation: number;
-		width: number;
-		height: number;
-		color: Color;
-		path: string;
-		rendererObject: any;
-		region: TextureRegion;
-		offset: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		tempColor: Color;
-		constructor(name: string);
-		updateOffset(): void;
-		setRegion(region: TextureRegion): void;
-		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-	}
-}
 declare module spine {
 	enum BlendMode {
 		Normal = 0,
@@ -990,6 +771,46 @@ declare module spine {
 		constructor(index: number, name: string, boneData: BoneData);
 	}
 }
+declare module spine {
+	abstract class Texture {
+		protected _image: HTMLImageElement;
+		constructor(image: HTMLImageElement);
+		getImage(): HTMLImageElement;
+		abstract setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
+		abstract setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
+		abstract dispose(): void;
+		static filterFromString(text: string): TextureFilter;
+		static wrapFromString(text: string): TextureWrap;
+	}
+	enum TextureFilter {
+		Nearest = 9728,
+		Linear = 9729,
+		MipMap = 9987,
+		MipMapNearestNearest = 9984,
+		MipMapLinearNearest = 9985,
+		MipMapNearestLinear = 9986,
+		MipMapLinearLinear = 9987,
+	}
+	enum TextureWrap {
+		MirroredRepeat = 33648,
+		ClampToEdge = 33071,
+		Repeat = 10497,
+	}
+	class TextureRegion {
+		renderObject: any;
+		u: number;
+		v: number;
+		u2: number;
+		v2: number;
+		width: number;
+		height: number;
+		rotate: boolean;
+		offsetX: number;
+		offsetY: number;
+		originalWidth: number;
+		originalHeight: number;
+	}
+}
 declare module spine {
 	class TextureAtlas implements Disposable {
 		pages: TextureAtlasPage[];
@@ -1185,3 +1006,182 @@ declare module spine {
 		getMean(): number;
 	}
 }
+declare module spine {
+	abstract class Attachment {
+		name: string;
+		constructor(name: string);
+	}
+	abstract class VertexAttachment extends Attachment {
+		bones: Array<number>;
+		vertices: ArrayLike<number>;
+		worldVerticesLength: number;
+		constructor(name: string);
+		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+	}
+}
+declare module spine {
+	interface AttachmentLoader {
+		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
+		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
+		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
+		newPathAttachment(skin: Skin, name: string): PathAttachment;
+		newPointAttachment(skin: Skin, name: string): PointAttachment;
+		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
+	}
+}
+declare module spine {
+	enum AttachmentType {
+		Region = 0,
+		BoundingBox = 1,
+		Mesh = 2,
+		LinkedMesh = 3,
+		Path = 4,
+		Point = 5,
+	}
+}
+declare module spine {
+	class BoundingBoxAttachment extends VertexAttachment {
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class ClippingAttachment extends VertexAttachment {
+		endSlot: SlotData;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class MeshAttachment extends VertexAttachment {
+		region: TextureRegion;
+		path: string;
+		regionUVs: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		triangles: Array<number>;
+		color: Color;
+		hullLength: number;
+		private parentMesh;
+		inheritDeform: boolean;
+		tempColor: Color;
+		constructor(name: string);
+		updateUVs(): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+		getParentMesh(): MeshAttachment;
+		setParentMesh(parentMesh: MeshAttachment): void;
+	}
+}
+declare module spine {
+	class PathAttachment extends VertexAttachment {
+		lengths: Array<number>;
+		closed: boolean;
+		constantSpeed: boolean;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class PointAttachment extends VertexAttachment {
+		x: number;
+		y: number;
+		rotation: number;
+		color: Color;
+		constructor(name: string);
+		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
+		computeWorldRotation(bone: Bone): number;
+	}
+}
+declare module spine {
+	class RegionAttachment extends Attachment {
+		static OX1: number;
+		static OY1: number;
+		static OX2: number;
+		static OY2: number;
+		static OX3: number;
+		static OY3: number;
+		static OX4: number;
+		static OY4: number;
+		static X1: number;
+		static Y1: number;
+		static C1R: number;
+		static C1G: number;
+		static C1B: number;
+		static C1A: number;
+		static U1: number;
+		static V1: number;
+		static X2: number;
+		static Y2: number;
+		static C2R: number;
+		static C2G: number;
+		static C2B: number;
+		static C2A: number;
+		static U2: number;
+		static V2: number;
+		static X3: number;
+		static Y3: number;
+		static C3R: number;
+		static C3G: number;
+		static C3B: number;
+		static C3A: number;
+		static U3: number;
+		static V3: number;
+		static X4: number;
+		static Y4: number;
+		static C4R: number;
+		static C4G: number;
+		static C4B: number;
+		static C4A: number;
+		static U4: number;
+		static V4: number;
+		x: number;
+		y: number;
+		scaleX: number;
+		scaleY: number;
+		rotation: number;
+		width: number;
+		height: number;
+		color: Color;
+		path: string;
+		rendererObject: any;
+		region: TextureRegion;
+		offset: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		tempColor: Color;
+		constructor(name: string);
+		updateOffset(): void;
+		setRegion(region: TextureRegion): void;
+		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+	}
+}
+declare module spine.canvas {
+	class AssetManager extends spine.AssetManager {
+		constructor(pathPrefix?: string);
+	}
+}
+declare module spine.canvas {
+	class CanvasTexture extends Texture {
+		constructor(image: HTMLImageElement);
+		setFilters(minFilter: TextureFilter, magFilter: TextureFilter): void;
+		setWraps(uWrap: TextureWrap, vWrap: TextureWrap): void;
+		dispose(): void;
+	}
+}
+declare module spine.canvas {
+	class SkeletonRenderer {
+		static QUAD_TRIANGLES: number[];
+		static VERTEX_SIZE: number;
+		private ctx;
+		triangleRendering: boolean;
+		debugRendering: boolean;
+		private vertices;
+		private tempColor;
+		constructor(context: CanvasRenderingContext2D);
+		draw(skeleton: Skeleton): void;
+		private drawImages(skeleton);
+		private drawTriangles(skeleton);
+		private drawTriangle(img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2);
+		private computeRegionVertices(slot, region, pma);
+		private computeMeshVertices(slot, mesh, pma);
+	}
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 335 - 776
spine-ts/build/spine-canvas.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
spine-ts/build/spine-canvas.js.map


+ 148 - 148
spine-ts/build/spine-core.d.ts

@@ -386,154 +386,6 @@ declare module spine {
 		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
 	}
 }
-declare module spine {
-	abstract class Attachment {
-		name: string;
-		constructor(name: string);
-	}
-	abstract class VertexAttachment extends Attachment {
-		bones: Array<number>;
-		vertices: ArrayLike<number>;
-		worldVerticesLength: number;
-		constructor(name: string);
-		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-	}
-}
-declare module spine {
-	interface AttachmentLoader {
-		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
-		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
-		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
-		newPathAttachment(skin: Skin, name: string): PathAttachment;
-		newPointAttachment(skin: Skin, name: string): PointAttachment;
-		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
-	}
-}
-declare module spine {
-	enum AttachmentType {
-		Region = 0,
-		BoundingBox = 1,
-		Mesh = 2,
-		LinkedMesh = 3,
-		Path = 4,
-		Point = 5,
-	}
-}
-declare module spine {
-	class BoundingBoxAttachment extends VertexAttachment {
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class ClippingAttachment extends VertexAttachment {
-		endSlot: SlotData;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class MeshAttachment extends VertexAttachment {
-		region: TextureRegion;
-		path: string;
-		regionUVs: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		triangles: Array<number>;
-		color: Color;
-		hullLength: number;
-		private parentMesh;
-		inheritDeform: boolean;
-		tempColor: Color;
-		constructor(name: string);
-		updateUVs(): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-		getParentMesh(): MeshAttachment;
-		setParentMesh(parentMesh: MeshAttachment): void;
-	}
-}
-declare module spine {
-	class PathAttachment extends VertexAttachment {
-		lengths: Array<number>;
-		closed: boolean;
-		constantSpeed: boolean;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class PointAttachment extends VertexAttachment {
-		x: number;
-		y: number;
-		rotation: number;
-		color: Color;
-		constructor(name: string);
-		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
-		computeWorldRotation(bone: Bone): number;
-	}
-}
-declare module spine {
-	class RegionAttachment extends Attachment {
-		static OX1: number;
-		static OY1: number;
-		static OX2: number;
-		static OY2: number;
-		static OX3: number;
-		static OY3: number;
-		static OX4: number;
-		static OY4: number;
-		static X1: number;
-		static Y1: number;
-		static C1R: number;
-		static C1G: number;
-		static C1B: number;
-		static C1A: number;
-		static U1: number;
-		static V1: number;
-		static X2: number;
-		static Y2: number;
-		static C2R: number;
-		static C2G: number;
-		static C2B: number;
-		static C2A: number;
-		static U2: number;
-		static V2: number;
-		static X3: number;
-		static Y3: number;
-		static C3R: number;
-		static C3G: number;
-		static C3B: number;
-		static C3A: number;
-		static U3: number;
-		static V3: number;
-		static X4: number;
-		static Y4: number;
-		static C4R: number;
-		static C4G: number;
-		static C4B: number;
-		static C4A: number;
-		static U4: number;
-		static V4: number;
-		x: number;
-		y: number;
-		scaleX: number;
-		scaleY: number;
-		rotation: number;
-		width: number;
-		height: number;
-		color: Color;
-		path: string;
-		rendererObject: any;
-		region: TextureRegion;
-		offset: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		tempColor: Color;
-		constructor(name: string);
-		updateOffset(): void;
-		setRegion(region: TextureRegion): void;
-		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-	}
-}
 declare module spine {
 	enum BlendMode {
 		Normal = 0,
@@ -1154,3 +1006,151 @@ declare module spine {
 		getMean(): number;
 	}
 }
+declare module spine {
+	abstract class Attachment {
+		name: string;
+		constructor(name: string);
+	}
+	abstract class VertexAttachment extends Attachment {
+		bones: Array<number>;
+		vertices: ArrayLike<number>;
+		worldVerticesLength: number;
+		constructor(name: string);
+		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+	}
+}
+declare module spine {
+	interface AttachmentLoader {
+		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
+		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
+		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
+		newPathAttachment(skin: Skin, name: string): PathAttachment;
+		newPointAttachment(skin: Skin, name: string): PointAttachment;
+		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
+	}
+}
+declare module spine {
+	enum AttachmentType {
+		Region = 0,
+		BoundingBox = 1,
+		Mesh = 2,
+		LinkedMesh = 3,
+		Path = 4,
+		Point = 5,
+	}
+}
+declare module spine {
+	class BoundingBoxAttachment extends VertexAttachment {
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class ClippingAttachment extends VertexAttachment {
+		endSlot: SlotData;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class MeshAttachment extends VertexAttachment {
+		region: TextureRegion;
+		path: string;
+		regionUVs: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		triangles: Array<number>;
+		color: Color;
+		hullLength: number;
+		private parentMesh;
+		inheritDeform: boolean;
+		tempColor: Color;
+		constructor(name: string);
+		updateUVs(): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+		getParentMesh(): MeshAttachment;
+		setParentMesh(parentMesh: MeshAttachment): void;
+	}
+}
+declare module spine {
+	class PathAttachment extends VertexAttachment {
+		lengths: Array<number>;
+		closed: boolean;
+		constantSpeed: boolean;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class PointAttachment extends VertexAttachment {
+		x: number;
+		y: number;
+		rotation: number;
+		color: Color;
+		constructor(name: string);
+		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
+		computeWorldRotation(bone: Bone): number;
+	}
+}
+declare module spine {
+	class RegionAttachment extends Attachment {
+		static OX1: number;
+		static OY1: number;
+		static OX2: number;
+		static OY2: number;
+		static OX3: number;
+		static OY3: number;
+		static OX4: number;
+		static OY4: number;
+		static X1: number;
+		static Y1: number;
+		static C1R: number;
+		static C1G: number;
+		static C1B: number;
+		static C1A: number;
+		static U1: number;
+		static V1: number;
+		static X2: number;
+		static Y2: number;
+		static C2R: number;
+		static C2G: number;
+		static C2B: number;
+		static C2A: number;
+		static U2: number;
+		static V2: number;
+		static X3: number;
+		static Y3: number;
+		static C3R: number;
+		static C3G: number;
+		static C3B: number;
+		static C3A: number;
+		static U3: number;
+		static V3: number;
+		static X4: number;
+		static Y4: number;
+		static C4R: number;
+		static C4G: number;
+		static C4B: number;
+		static C4A: number;
+		static U4: number;
+		static V4: number;
+		x: number;
+		y: number;
+		scaleX: number;
+		scaleY: number;
+		rotation: number;
+		width: number;
+		height: number;
+		color: Color;
+		path: string;
+		rendererObject: any;
+		region: TextureRegion;
+		offset: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		tempColor: Color;
+		constructor(name: string);
+		updateOffset(): void;
+		setRegion(region: TextureRegion): void;
+		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+	}
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 404 - 746
spine-ts/build/spine-core.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
spine-ts/build/spine-core.js.map


+ 148 - 148
spine-ts/build/spine-threejs.d.ts

@@ -386,154 +386,6 @@ declare module spine {
 		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
 	}
 }
-declare module spine {
-	abstract class Attachment {
-		name: string;
-		constructor(name: string);
-	}
-	abstract class VertexAttachment extends Attachment {
-		bones: Array<number>;
-		vertices: ArrayLike<number>;
-		worldVerticesLength: number;
-		constructor(name: string);
-		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-	}
-}
-declare module spine {
-	interface AttachmentLoader {
-		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
-		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
-		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
-		newPathAttachment(skin: Skin, name: string): PathAttachment;
-		newPointAttachment(skin: Skin, name: string): PointAttachment;
-		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
-	}
-}
-declare module spine {
-	enum AttachmentType {
-		Region = 0,
-		BoundingBox = 1,
-		Mesh = 2,
-		LinkedMesh = 3,
-		Path = 4,
-		Point = 5,
-	}
-}
-declare module spine {
-	class BoundingBoxAttachment extends VertexAttachment {
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class ClippingAttachment extends VertexAttachment {
-		endSlot: SlotData;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class MeshAttachment extends VertexAttachment {
-		region: TextureRegion;
-		path: string;
-		regionUVs: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		triangles: Array<number>;
-		color: Color;
-		hullLength: number;
-		private parentMesh;
-		inheritDeform: boolean;
-		tempColor: Color;
-		constructor(name: string);
-		updateUVs(): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-		getParentMesh(): MeshAttachment;
-		setParentMesh(parentMesh: MeshAttachment): void;
-	}
-}
-declare module spine {
-	class PathAttachment extends VertexAttachment {
-		lengths: Array<number>;
-		closed: boolean;
-		constantSpeed: boolean;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class PointAttachment extends VertexAttachment {
-		x: number;
-		y: number;
-		rotation: number;
-		color: Color;
-		constructor(name: string);
-		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
-		computeWorldRotation(bone: Bone): number;
-	}
-}
-declare module spine {
-	class RegionAttachment extends Attachment {
-		static OX1: number;
-		static OY1: number;
-		static OX2: number;
-		static OY2: number;
-		static OX3: number;
-		static OY3: number;
-		static OX4: number;
-		static OY4: number;
-		static X1: number;
-		static Y1: number;
-		static C1R: number;
-		static C1G: number;
-		static C1B: number;
-		static C1A: number;
-		static U1: number;
-		static V1: number;
-		static X2: number;
-		static Y2: number;
-		static C2R: number;
-		static C2G: number;
-		static C2B: number;
-		static C2A: number;
-		static U2: number;
-		static V2: number;
-		static X3: number;
-		static Y3: number;
-		static C3R: number;
-		static C3G: number;
-		static C3B: number;
-		static C3A: number;
-		static U3: number;
-		static V3: number;
-		static X4: number;
-		static Y4: number;
-		static C4R: number;
-		static C4G: number;
-		static C4B: number;
-		static C4A: number;
-		static U4: number;
-		static V4: number;
-		x: number;
-		y: number;
-		scaleX: number;
-		scaleY: number;
-		rotation: number;
-		width: number;
-		height: number;
-		color: Color;
-		path: string;
-		rendererObject: any;
-		region: TextureRegion;
-		offset: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		tempColor: Color;
-		constructor(name: string);
-		updateOffset(): void;
-		setRegion(region: TextureRegion): void;
-		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-	}
-}
 declare module spine {
 	enum BlendMode {
 		Normal = 0,
@@ -1154,6 +1006,154 @@ declare module spine {
 		getMean(): number;
 	}
 }
+declare module spine {
+	abstract class Attachment {
+		name: string;
+		constructor(name: string);
+	}
+	abstract class VertexAttachment extends Attachment {
+		bones: Array<number>;
+		vertices: ArrayLike<number>;
+		worldVerticesLength: number;
+		constructor(name: string);
+		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+	}
+}
+declare module spine {
+	interface AttachmentLoader {
+		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
+		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
+		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
+		newPathAttachment(skin: Skin, name: string): PathAttachment;
+		newPointAttachment(skin: Skin, name: string): PointAttachment;
+		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
+	}
+}
+declare module spine {
+	enum AttachmentType {
+		Region = 0,
+		BoundingBox = 1,
+		Mesh = 2,
+		LinkedMesh = 3,
+		Path = 4,
+		Point = 5,
+	}
+}
+declare module spine {
+	class BoundingBoxAttachment extends VertexAttachment {
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class ClippingAttachment extends VertexAttachment {
+		endSlot: SlotData;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class MeshAttachment extends VertexAttachment {
+		region: TextureRegion;
+		path: string;
+		regionUVs: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		triangles: Array<number>;
+		color: Color;
+		hullLength: number;
+		private parentMesh;
+		inheritDeform: boolean;
+		tempColor: Color;
+		constructor(name: string);
+		updateUVs(): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+		getParentMesh(): MeshAttachment;
+		setParentMesh(parentMesh: MeshAttachment): void;
+	}
+}
+declare module spine {
+	class PathAttachment extends VertexAttachment {
+		lengths: Array<number>;
+		closed: boolean;
+		constantSpeed: boolean;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class PointAttachment extends VertexAttachment {
+		x: number;
+		y: number;
+		rotation: number;
+		color: Color;
+		constructor(name: string);
+		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
+		computeWorldRotation(bone: Bone): number;
+	}
+}
+declare module spine {
+	class RegionAttachment extends Attachment {
+		static OX1: number;
+		static OY1: number;
+		static OX2: number;
+		static OY2: number;
+		static OX3: number;
+		static OY3: number;
+		static OX4: number;
+		static OY4: number;
+		static X1: number;
+		static Y1: number;
+		static C1R: number;
+		static C1G: number;
+		static C1B: number;
+		static C1A: number;
+		static U1: number;
+		static V1: number;
+		static X2: number;
+		static Y2: number;
+		static C2R: number;
+		static C2G: number;
+		static C2B: number;
+		static C2A: number;
+		static U2: number;
+		static V2: number;
+		static X3: number;
+		static Y3: number;
+		static C3R: number;
+		static C3G: number;
+		static C3B: number;
+		static C3A: number;
+		static U3: number;
+		static V3: number;
+		static X4: number;
+		static Y4: number;
+		static C4R: number;
+		static C4G: number;
+		static C4B: number;
+		static C4A: number;
+		static U4: number;
+		static V4: number;
+		x: number;
+		y: number;
+		scaleX: number;
+		scaleY: number;
+		rotation: number;
+		width: number;
+		height: number;
+		color: Color;
+		path: string;
+		rendererObject: any;
+		region: TextureRegion;
+		offset: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		tempColor: Color;
+		constructor(name: string);
+		updateOffset(): void;
+		setRegion(region: TextureRegion): void;
+		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+	}
+}
 declare module spine.threejs {
 	class AssetManager extends spine.AssetManager {
 		constructor(pathPrefix?: string);

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 404 - 746
spine-ts/build/spine-threejs.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
spine-ts/build/spine-threejs.js.map


+ 164 - 164
spine-ts/build/spine-webgl.d.ts

@@ -386,154 +386,6 @@ declare module spine {
 		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
 	}
 }
-declare module spine {
-	abstract class Attachment {
-		name: string;
-		constructor(name: string);
-	}
-	abstract class VertexAttachment extends Attachment {
-		bones: Array<number>;
-		vertices: ArrayLike<number>;
-		worldVerticesLength: number;
-		constructor(name: string);
-		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-	}
-}
-declare module spine {
-	interface AttachmentLoader {
-		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
-		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
-		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
-		newPathAttachment(skin: Skin, name: string): PathAttachment;
-		newPointAttachment(skin: Skin, name: string): PointAttachment;
-		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
-	}
-}
-declare module spine {
-	enum AttachmentType {
-		Region = 0,
-		BoundingBox = 1,
-		Mesh = 2,
-		LinkedMesh = 3,
-		Path = 4,
-		Point = 5,
-	}
-}
-declare module spine {
-	class BoundingBoxAttachment extends VertexAttachment {
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class ClippingAttachment extends VertexAttachment {
-		endSlot: SlotData;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class MeshAttachment extends VertexAttachment {
-		region: TextureRegion;
-		path: string;
-		regionUVs: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		triangles: Array<number>;
-		color: Color;
-		hullLength: number;
-		private parentMesh;
-		inheritDeform: boolean;
-		tempColor: Color;
-		constructor(name: string);
-		updateUVs(): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-		getParentMesh(): MeshAttachment;
-		setParentMesh(parentMesh: MeshAttachment): void;
-	}
-}
-declare module spine {
-	class PathAttachment extends VertexAttachment {
-		lengths: Array<number>;
-		closed: boolean;
-		constantSpeed: boolean;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class PointAttachment extends VertexAttachment {
-		x: number;
-		y: number;
-		rotation: number;
-		color: Color;
-		constructor(name: string);
-		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
-		computeWorldRotation(bone: Bone): number;
-	}
-}
-declare module spine {
-	class RegionAttachment extends Attachment {
-		static OX1: number;
-		static OY1: number;
-		static OX2: number;
-		static OY2: number;
-		static OX3: number;
-		static OY3: number;
-		static OX4: number;
-		static OY4: number;
-		static X1: number;
-		static Y1: number;
-		static C1R: number;
-		static C1G: number;
-		static C1B: number;
-		static C1A: number;
-		static U1: number;
-		static V1: number;
-		static X2: number;
-		static Y2: number;
-		static C2R: number;
-		static C2G: number;
-		static C2B: number;
-		static C2A: number;
-		static U2: number;
-		static V2: number;
-		static X3: number;
-		static Y3: number;
-		static C3R: number;
-		static C3G: number;
-		static C3B: number;
-		static C3A: number;
-		static U3: number;
-		static V3: number;
-		static X4: number;
-		static Y4: number;
-		static C4R: number;
-		static C4G: number;
-		static C4B: number;
-		static C4A: number;
-		static U4: number;
-		static V4: number;
-		x: number;
-		y: number;
-		scaleX: number;
-		scaleY: number;
-		rotation: number;
-		width: number;
-		height: number;
-		color: Color;
-		path: string;
-		rendererObject: any;
-		region: TextureRegion;
-		offset: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		tempColor: Color;
-		constructor(name: string);
-		updateOffset(): void;
-		setRegion(region: TextureRegion): void;
-		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-	}
-}
 declare module spine {
 	enum BlendMode {
 		Normal = 0,
@@ -1154,6 +1006,154 @@ declare module spine {
 		getMean(): number;
 	}
 }
+declare module spine {
+	abstract class Attachment {
+		name: string;
+		constructor(name: string);
+	}
+	abstract class VertexAttachment extends Attachment {
+		bones: Array<number>;
+		vertices: ArrayLike<number>;
+		worldVerticesLength: number;
+		constructor(name: string);
+		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+	}
+}
+declare module spine {
+	interface AttachmentLoader {
+		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
+		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
+		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
+		newPathAttachment(skin: Skin, name: string): PathAttachment;
+		newPointAttachment(skin: Skin, name: string): PointAttachment;
+		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
+	}
+}
+declare module spine {
+	enum AttachmentType {
+		Region = 0,
+		BoundingBox = 1,
+		Mesh = 2,
+		LinkedMesh = 3,
+		Path = 4,
+		Point = 5,
+	}
+}
+declare module spine {
+	class BoundingBoxAttachment extends VertexAttachment {
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class ClippingAttachment extends VertexAttachment {
+		endSlot: SlotData;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class MeshAttachment extends VertexAttachment {
+		region: TextureRegion;
+		path: string;
+		regionUVs: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		triangles: Array<number>;
+		color: Color;
+		hullLength: number;
+		private parentMesh;
+		inheritDeform: boolean;
+		tempColor: Color;
+		constructor(name: string);
+		updateUVs(): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+		getParentMesh(): MeshAttachment;
+		setParentMesh(parentMesh: MeshAttachment): void;
+	}
+}
+declare module spine {
+	class PathAttachment extends VertexAttachment {
+		lengths: Array<number>;
+		closed: boolean;
+		constantSpeed: boolean;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class PointAttachment extends VertexAttachment {
+		x: number;
+		y: number;
+		rotation: number;
+		color: Color;
+		constructor(name: string);
+		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
+		computeWorldRotation(bone: Bone): number;
+	}
+}
+declare module spine {
+	class RegionAttachment extends Attachment {
+		static OX1: number;
+		static OY1: number;
+		static OX2: number;
+		static OY2: number;
+		static OX3: number;
+		static OY3: number;
+		static OX4: number;
+		static OY4: number;
+		static X1: number;
+		static Y1: number;
+		static C1R: number;
+		static C1G: number;
+		static C1B: number;
+		static C1A: number;
+		static U1: number;
+		static V1: number;
+		static X2: number;
+		static Y2: number;
+		static C2R: number;
+		static C2G: number;
+		static C2B: number;
+		static C2A: number;
+		static U2: number;
+		static V2: number;
+		static X3: number;
+		static Y3: number;
+		static C3R: number;
+		static C3G: number;
+		static C3B: number;
+		static C3A: number;
+		static U3: number;
+		static V3: number;
+		static X4: number;
+		static Y4: number;
+		static C4R: number;
+		static C4G: number;
+		static C4B: number;
+		static C4A: number;
+		static U4: number;
+		static V4: number;
+		x: number;
+		y: number;
+		scaleX: number;
+		scaleY: number;
+		rotation: number;
+		width: number;
+		height: number;
+		color: Color;
+		path: string;
+		rendererObject: any;
+		region: TextureRegion;
+		offset: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		tempColor: Color;
+		constructor(name: string);
+		updateOffset(): void;
+		setRegion(region: TextureRegion): void;
+		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+	}
+}
 declare module spine.webgl {
 	class AssetManager extends spine.AssetManager {
 		constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, pathPrefix?: string);
@@ -1245,22 +1245,22 @@ declare module spine.webgl {
 	}
 }
 declare module spine.webgl {
-	const M00: number;
-	const M01: number;
-	const M02: number;
-	const M03: number;
-	const M10: number;
-	const M11: number;
-	const M12: number;
-	const M13: number;
-	const M20: number;
-	const M21: number;
-	const M22: number;
-	const M23: number;
-	const M30: number;
-	const M31: number;
-	const M32: number;
-	const M33: number;
+	const M00 = 0;
+	const M01 = 4;
+	const M02 = 8;
+	const M03 = 12;
+	const M10 = 1;
+	const M11 = 5;
+	const M12 = 9;
+	const M13 = 13;
+	const M20 = 2;
+	const M21 = 6;
+	const M22 = 10;
+	const M23 = 14;
+	const M30 = 3;
+	const M31 = 7;
+	const M32 = 11;
+	const M33 = 15;
 	class Matrix4 {
 		temp: Float32Array;
 		values: Float32Array;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 404 - 746
spine-ts/build/spine-webgl.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
spine-ts/build/spine-webgl.js.map


+ 164 - 164
spine-ts/build/spine-widget.d.ts

@@ -386,154 +386,6 @@ declare module spine {
 		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
 	}
 }
-declare module spine {
-	abstract class Attachment {
-		name: string;
-		constructor(name: string);
-	}
-	abstract class VertexAttachment extends Attachment {
-		bones: Array<number>;
-		vertices: ArrayLike<number>;
-		worldVerticesLength: number;
-		constructor(name: string);
-		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-	}
-}
-declare module spine {
-	interface AttachmentLoader {
-		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
-		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
-		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
-		newPathAttachment(skin: Skin, name: string): PathAttachment;
-		newPointAttachment(skin: Skin, name: string): PointAttachment;
-		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
-	}
-}
-declare module spine {
-	enum AttachmentType {
-		Region = 0,
-		BoundingBox = 1,
-		Mesh = 2,
-		LinkedMesh = 3,
-		Path = 4,
-		Point = 5,
-	}
-}
-declare module spine {
-	class BoundingBoxAttachment extends VertexAttachment {
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class ClippingAttachment extends VertexAttachment {
-		endSlot: SlotData;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class MeshAttachment extends VertexAttachment {
-		region: TextureRegion;
-		path: string;
-		regionUVs: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		triangles: Array<number>;
-		color: Color;
-		hullLength: number;
-		private parentMesh;
-		inheritDeform: boolean;
-		tempColor: Color;
-		constructor(name: string);
-		updateUVs(): void;
-		applyDeform(sourceAttachment: VertexAttachment): boolean;
-		getParentMesh(): MeshAttachment;
-		setParentMesh(parentMesh: MeshAttachment): void;
-	}
-}
-declare module spine {
-	class PathAttachment extends VertexAttachment {
-		lengths: Array<number>;
-		closed: boolean;
-		constantSpeed: boolean;
-		color: Color;
-		constructor(name: string);
-	}
-}
-declare module spine {
-	class PointAttachment extends VertexAttachment {
-		x: number;
-		y: number;
-		rotation: number;
-		color: Color;
-		constructor(name: string);
-		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
-		computeWorldRotation(bone: Bone): number;
-	}
-}
-declare module spine {
-	class RegionAttachment extends Attachment {
-		static OX1: number;
-		static OY1: number;
-		static OX2: number;
-		static OY2: number;
-		static OX3: number;
-		static OY3: number;
-		static OX4: number;
-		static OY4: number;
-		static X1: number;
-		static Y1: number;
-		static C1R: number;
-		static C1G: number;
-		static C1B: number;
-		static C1A: number;
-		static U1: number;
-		static V1: number;
-		static X2: number;
-		static Y2: number;
-		static C2R: number;
-		static C2G: number;
-		static C2B: number;
-		static C2A: number;
-		static U2: number;
-		static V2: number;
-		static X3: number;
-		static Y3: number;
-		static C3R: number;
-		static C3G: number;
-		static C3B: number;
-		static C3A: number;
-		static U3: number;
-		static V3: number;
-		static X4: number;
-		static Y4: number;
-		static C4R: number;
-		static C4G: number;
-		static C4B: number;
-		static C4A: number;
-		static U4: number;
-		static V4: number;
-		x: number;
-		y: number;
-		scaleX: number;
-		scaleY: number;
-		rotation: number;
-		width: number;
-		height: number;
-		color: Color;
-		path: string;
-		rendererObject: any;
-		region: TextureRegion;
-		offset: ArrayLike<number>;
-		uvs: ArrayLike<number>;
-		tempColor: Color;
-		constructor(name: string);
-		updateOffset(): void;
-		setRegion(region: TextureRegion): void;
-		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
-	}
-}
 declare module spine {
 	enum BlendMode {
 		Normal = 0,
@@ -1154,6 +1006,154 @@ declare module spine {
 		getMean(): number;
 	}
 }
+declare module spine {
+	abstract class Attachment {
+		name: string;
+		constructor(name: string);
+	}
+	abstract class VertexAttachment extends Attachment {
+		bones: Array<number>;
+		vertices: ArrayLike<number>;
+		worldVerticesLength: number;
+		constructor(name: string);
+		computeWorldVertices(slot: Slot, start: number, count: number, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+	}
+}
+declare module spine {
+	interface AttachmentLoader {
+		newRegionAttachment(skin: Skin, name: string, path: string): RegionAttachment;
+		newMeshAttachment(skin: Skin, name: string, path: string): MeshAttachment;
+		newBoundingBoxAttachment(skin: Skin, name: string): BoundingBoxAttachment;
+		newPathAttachment(skin: Skin, name: string): PathAttachment;
+		newPointAttachment(skin: Skin, name: string): PointAttachment;
+		newClippingAttachment(skin: Skin, name: string): ClippingAttachment;
+	}
+}
+declare module spine {
+	enum AttachmentType {
+		Region = 0,
+		BoundingBox = 1,
+		Mesh = 2,
+		LinkedMesh = 3,
+		Path = 4,
+		Point = 5,
+	}
+}
+declare module spine {
+	class BoundingBoxAttachment extends VertexAttachment {
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class ClippingAttachment extends VertexAttachment {
+		endSlot: SlotData;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class MeshAttachment extends VertexAttachment {
+		region: TextureRegion;
+		path: string;
+		regionUVs: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		triangles: Array<number>;
+		color: Color;
+		hullLength: number;
+		private parentMesh;
+		inheritDeform: boolean;
+		tempColor: Color;
+		constructor(name: string);
+		updateUVs(): void;
+		applyDeform(sourceAttachment: VertexAttachment): boolean;
+		getParentMesh(): MeshAttachment;
+		setParentMesh(parentMesh: MeshAttachment): void;
+	}
+}
+declare module spine {
+	class PathAttachment extends VertexAttachment {
+		lengths: Array<number>;
+		closed: boolean;
+		constantSpeed: boolean;
+		color: Color;
+		constructor(name: string);
+	}
+}
+declare module spine {
+	class PointAttachment extends VertexAttachment {
+		x: number;
+		y: number;
+		rotation: number;
+		color: Color;
+		constructor(name: string);
+		computeWorldPosition(bone: Bone, point: Vector2): Vector2;
+		computeWorldRotation(bone: Bone): number;
+	}
+}
+declare module spine {
+	class RegionAttachment extends Attachment {
+		static OX1: number;
+		static OY1: number;
+		static OX2: number;
+		static OY2: number;
+		static OX3: number;
+		static OY3: number;
+		static OX4: number;
+		static OY4: number;
+		static X1: number;
+		static Y1: number;
+		static C1R: number;
+		static C1G: number;
+		static C1B: number;
+		static C1A: number;
+		static U1: number;
+		static V1: number;
+		static X2: number;
+		static Y2: number;
+		static C2R: number;
+		static C2G: number;
+		static C2B: number;
+		static C2A: number;
+		static U2: number;
+		static V2: number;
+		static X3: number;
+		static Y3: number;
+		static C3R: number;
+		static C3G: number;
+		static C3B: number;
+		static C3A: number;
+		static U3: number;
+		static V3: number;
+		static X4: number;
+		static Y4: number;
+		static C4R: number;
+		static C4G: number;
+		static C4B: number;
+		static C4A: number;
+		static U4: number;
+		static V4: number;
+		x: number;
+		y: number;
+		scaleX: number;
+		scaleY: number;
+		rotation: number;
+		width: number;
+		height: number;
+		color: Color;
+		path: string;
+		rendererObject: any;
+		region: TextureRegion;
+		offset: ArrayLike<number>;
+		uvs: ArrayLike<number>;
+		tempColor: Color;
+		constructor(name: string);
+		updateOffset(): void;
+		setRegion(region: TextureRegion): void;
+		computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
+	}
+}
 declare module spine.webgl {
 	class AssetManager extends spine.AssetManager {
 		constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, pathPrefix?: string);
@@ -1245,22 +1245,22 @@ declare module spine.webgl {
 	}
 }
 declare module spine.webgl {
-	const M00: number;
-	const M01: number;
-	const M02: number;
-	const M03: number;
-	const M10: number;
-	const M11: number;
-	const M12: number;
-	const M13: number;
-	const M20: number;
-	const M21: number;
-	const M22: number;
-	const M23: number;
-	const M30: number;
-	const M31: number;
-	const M32: number;
-	const M33: number;
+	const M00 = 0;
+	const M01 = 4;
+	const M02 = 8;
+	const M03 = 12;
+	const M10 = 1;
+	const M11 = 5;
+	const M12 = 9;
+	const M13 = 13;
+	const M20 = 2;
+	const M21 = 6;
+	const M22 = 10;
+	const M23 = 14;
+	const M30 = 3;
+	const M31 = 7;
+	const M32 = 11;
+	const M33 = 15;
 	class Matrix4 {
 		temp: Float32Array;
 		values: Float32Array;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 404 - 746
spine-ts/build/spine-widget.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 0
spine-ts/build/spine-widget.js.map


+ 3 - 2
spine-ts/widget/src/Widget.ts

@@ -49,7 +49,7 @@ module spine {
 		private backgroundColor = new Color();
 		private loaded = false;
 		private bounds = { offset: new Vector2(), size: new Vector2() };
-		
+
 
 		constructor (element: HTMLElement | string, config: SpineWidgetConfig) {
 			if (!element) throw new Error("Please provide a DOM element, e.g. document.getElementById('myelement')");
@@ -185,7 +185,7 @@ module spine {
 				var animationState = this.state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
 				animationState.setAnimation(0, config.animation, config.loop);
 				this.loaded = true;
-				if (config.success) config.success(this);				
+				if (config.success) config.success(this);
 				requestAnimationFrame(() => { this.render(); });
 			} else
 				requestAnimationFrame(() => { this.load(); });
@@ -246,6 +246,7 @@ module spine {
 			let w = canvas.clientWidth;
 			let h = canvas.clientHeight;
 			let bounds = this.bounds;
+
 			var devicePixelRatio = window.devicePixelRatio || 1;
 			if (canvas.width != Math.floor(w * devicePixelRatio) || canvas.height != Math.floor(h * devicePixelRatio)) {
 				canvas.width = Math.floor(w * devicePixelRatio);

+ 1 - 1
spine-ue4/README.md

@@ -9,7 +9,7 @@ The Spine Runtimes are developed with the intent to be used with data exported f
 
 ## Spine version
 
-spine-ue4 works with data exported from the latest Spine 3-5.xx.
+spine-ue4 works with data exported from the latest Spine version.
 
 spine-ue4 supports all Spine features.
 

+ 1 - 1
spine-unity/Assets/Examples/Getting Started/Scripts/SpineboyBeginnerView.cs

@@ -123,7 +123,7 @@ namespace Spine.Unity.Examples {
 		public void PlayShoot () {
 			// Play the shoot animation on track 1.
 			skeletonAnimation.AnimationState.SetAnimation(1, shoot, false);
-			//skeletonAnimation.state.AddEmptyAnimation(1, 0.1f, 0f);
+			skeletonAnimation.AnimationState.AddEmptyAnimation(1, .3f, .3f);
 			gunSource.pitch = GetRandomPitch(gunsoundPitchOffset);
 			gunSource.Play();
 			gunParticles.randomSeed = (uint)Random.Range(0, 100);

+ 0 - 2
spine-unity/Assets/Examples/Scripts/MixAndMatch.cs

@@ -42,7 +42,6 @@ namespace Spine.Unity.Examples {
 		[SpineSlot] public string handSlot;
 		public Vector2 newHandOffset;
 		public float newHandRotation;
-		public Texture2D handTexture;
 
 		[Header("From Sprite")]
 		public Sprite dagger;
@@ -79,7 +78,6 @@ namespace Spine.Unity.Examples {
 			newHand.Rotation = newHandRotation;
 			newHand.UpdateOffset();
 			int handSlotIndex = skeleton.FindSlotIndex(handSlot);
-			handTexture = newHand.GetRegion().ToTexture();
 			newSkin.AddAttachment(handSlotIndex, handAttachmentName, newHand);
 
 			// Case 2: Create an attachment from a Unity Sprite (Sprite texture needs to be Read/Write Enabled in the inspector.

+ 1 - 1
spine-unity/Assets/Examples/Scripts/RaggedySpineboy.cs

@@ -49,7 +49,7 @@ namespace Spine.Unity.Examples {
 
 		void AddRigidbody () {
 			var rb = gameObject.AddComponent<Rigidbody2D>();
-			#if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5
+			#if UNITY_5_1 || UNITY_5_2 || UNITY_5_3_OR_NEWER
 	        rb.freezeRotation = true;
 			#else
 			rb.fixedAngle = true;

+ 1 - 1
spine-unity/Assets/Examples/Spine/Strechyman/stretchyman-diffuse-pma.png.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
 guid: 33f10ea7e20549d40a1c23a1adc3f760
-timeCreated: 1487920372
+timeCreated: 1494093108
 licenseType: Free
 TextureImporter:
   fileIDToRecycleName: {}

BIN
spine-unity/Assets/Examples/Spine/Strechyman/stretchyman-diffuse-pma_Material.mat


+ 1 - 0
spine-unity/Assets/spine-unity/Mesh Generation/SpineMesh.cs

@@ -38,6 +38,7 @@ using System.Collections.Generic;
 
 namespace Spine.Unity {
 	public static class SpineMesh {
+
 		internal const HideFlags MeshHideflags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
 
 		/// <summary>Factory method for creating a new mesh for use in Spine components. This can be called in field initializers.</summary>

+ 134 - 10
spine-unity/Assets/spine-unity/Modules/AttachmentTools/AttachmentTools.cs

@@ -129,14 +129,18 @@ namespace Spine.Unity.Modules.AttachmentTools {
 
 		/// <summary>
 		/// Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate texture of the Sprite's texture data. Returns a RegionAttachment that uses it. Use this if you plan to use a premultiply alpha shader such as "Spine/Skeleton"</summary>
-		public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Shader shader, TextureFormat textureFormat = SpriteAtlasRegionExtensions.SpineTextureFormat, bool mipmaps = SpriteAtlasRegionExtensions.UseMipMaps) {
+		public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Shader shader, TextureFormat textureFormat = SpriteAtlasRegionExtensions.SpineTextureFormat, bool mipmaps = SpriteAtlasRegionExtensions.UseMipMaps, Material materialPropertySource = null) {
 			if (sprite == null) throw new System.ArgumentNullException("sprite");
 			if (shader == null) throw new System.ArgumentNullException("shader");
-			var region = sprite.ToAtlasRegionPMAClone(shader, textureFormat, mipmaps);
+			var region = sprite.ToAtlasRegionPMAClone(shader, textureFormat, mipmaps, materialPropertySource);
 			var unitsPerPixel = 1f / sprite.pixelsPerUnit;
 			return region.ToRegionAttachment(sprite.name, unitsPerPixel);
 		}
 
+		public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Material materialPropertySource, TextureFormat textureFormat = SpriteAtlasRegionExtensions.SpineTextureFormat, bool mipmaps = SpriteAtlasRegionExtensions.UseMipMaps) {
+			return sprite.ToRegionAttachmentPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource);
+		}
+
 		/// <summary>
 		/// Creates a new RegionAttachment from a given AtlasRegion.</summary>
 		public static RegionAttachment ToRegionAttachment (this AtlasRegion region, string attachmentName, float scale = 0.01f) {
@@ -203,6 +207,82 @@ namespace Spine.Unity.Modules.AttachmentTools {
 	public static class SpriteAtlasRegionExtensions {
 		internal const TextureFormat SpineTextureFormat = TextureFormat.RGBA32;
 		internal const bool UseMipMaps = false;
+		internal const float DefaultScale = 0.01f;
+
+		public static AtlasRegion ToAtlasRegion (this Texture2D t, Material materialPropertySource, float scale = DefaultScale) {
+			return t.ToAtlasRegion(materialPropertySource.shader, scale, materialPropertySource);
+		}
+
+		public static AtlasRegion ToAtlasRegion (this Texture2D t, Shader shader, float scale = DefaultScale, Material materialPropertySource = null) {
+			var material = new Material(shader);
+			if (materialPropertySource != null) {
+				material.CopyPropertiesFromMaterial(materialPropertySource);
+				material.shaderKeywords = materialPropertySource.shaderKeywords;
+			}
+
+			material.mainTexture = t;
+			var page = material.ToSpineAtlasPage();
+
+			float width = t.width;
+			float height = t.height;
+
+			var region = new AtlasRegion();
+			region.name = t.name;
+			region.index = -1;
+			region.rotate = false;
+
+			// World space units
+			Vector2 boundsMin = Vector2.zero, boundsMax = new Vector2(width, height) * scale;
+
+			// Texture space/pixel units
+			region.width = (int)width;
+			region.originalWidth = (int)width;
+			region.height = (int)height;
+			region.originalHeight = (int)height;
+			region.offsetX = width * (0.5f - InverseLerp(boundsMin.x, boundsMax.x, 0));
+			region.offsetY = height * (0.5f - InverseLerp(boundsMin.y, boundsMax.y, 0));
+
+			// Use the full area of the texture.
+			region.u = 0;
+			region.v = 1;
+			region.u2 = 1;
+			region.v2 = 0;
+			region.x = 0;
+			region.y = 0;
+
+			region.page = page;
+
+			return region;
+		}
+
+		/// <summary>
+		/// Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate of the Sprite's texture data.</summary>
+		public static AtlasRegion ToAtlasRegionPMAClone (this Texture2D t, Material materialPropertySource, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
+			return t.ToAtlasRegionPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource);
+		}
+
+		/// <summary>
+		/// Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate of the Sprite's texture data.</summary>
+		public static AtlasRegion ToAtlasRegionPMAClone (this Texture2D t, Shader shader, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, Material materialPropertySource = null) {
+			var material = new Material(shader);
+			if (materialPropertySource != null) {
+				material.CopyPropertiesFromMaterial(materialPropertySource);
+				material.shaderKeywords = materialPropertySource.shaderKeywords;
+			}
+			var newTexture = t.GetClone(false, textureFormat, mipmaps);
+			newTexture.ApplyPMA(true);
+
+			newTexture.name = t.name + "-pma-";
+			material.name = t.name + shader.name;
+
+			material.mainTexture = newTexture;
+			var page = material.ToSpineAtlasPage();
+
+			var region = newTexture.ToAtlasRegion(shader);
+			region.page = page;
+
+			return region;
+		}
 
 		/// <summary>
 		/// Creates a new Spine.AtlasPage from a UnityEngine.Material. If the material has a preassigned texture, the page width and height will be set.</summary>
@@ -240,8 +320,13 @@ namespace Spine.Unity.Modules.AttachmentTools {
 
 		/// <summary>
 		/// Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate of the Sprite's texture data.</summary>
-		public static AtlasRegion ToAtlasRegionPMAClone (this Sprite s, Shader shader, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
+		public static AtlasRegion ToAtlasRegionPMAClone (this Sprite s, Shader shader, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, Material materialPropertySource = null) {
 			var material = new Material(shader);
+			if (materialPropertySource != null) {
+				material.CopyPropertiesFromMaterial(materialPropertySource);
+				material.shaderKeywords = materialPropertySource.shaderKeywords;
+			}
+
 			var tex = s.ToTexture(false, textureFormat, mipmaps);
 			tex.ApplyPMA(true);
 
@@ -257,7 +342,11 @@ namespace Spine.Unity.Modules.AttachmentTools {
 			return region;
 		}
 
-		static AtlasRegion ToAtlasRegion (this Sprite s, bool isolatedTexture = false) {
+		public static AtlasRegion ToAtlasRegionPMAClone (this Sprite s, Material materialPropertySource, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
+			return s.ToAtlasRegionPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource);
+		}
+
+		internal static AtlasRegion ToAtlasRegion (this Sprite s, bool isolatedTexture = false) {
 			var region = new AtlasRegion();
 			region.name = s.name;
 			region.index = -1;
@@ -301,7 +390,14 @@ namespace Spine.Unity.Modules.AttachmentTools {
 		/// <summary>
 		/// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas comprised of all the regions from the original skin.</summary>
 		/// <remarks>No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.</remarks>
-		public static Skin GetRepackedSkin (this Skin o, string newName, Shader shader, out Material m, out Texture2D t, int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
+		public static Skin GetRepackedSkin (this Skin o, string newName, Material materialPropertySource, out Material m, out Texture2D t, int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
+			return GetRepackedSkin(o, newName, materialPropertySource.shader, out m, out t, maxAtlasSize, padding, textureFormat, mipmaps, materialPropertySource);
+		}
+
+		/// <summary>
+		/// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas comprised of all the regions from the original skin.</summary>
+		/// <remarks>No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.</remarks>
+		public static Skin GetRepackedSkin (this Skin o, string newName, Shader shader, out Material m, out Texture2D t, int maxAtlasSize = 1024, int padding = 2, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, Material materialPropertySource = null) {
 			var skinAttachments = o.Attachments;
 			var newSkin = new Skin(newName);
 
@@ -317,7 +413,6 @@ namespace Spine.Unity.Modules.AttachmentTools {
 			foreach (var kvp in skinAttachments) {
 				var newAttachment = kvp.Value.GetClone(true);
 				if (IsRenderable(newAttachment)) {
-					
 					var region = newAttachment.GetAtlasRegion();
 					int existingIndex;
 					if (existingRegions.TryGetValue(region, out existingIndex)) {
@@ -344,6 +439,11 @@ namespace Spine.Unity.Modules.AttachmentTools {
 
 			// Rehydrate the repacked textures as a Material, Spine atlas and Spine.AtlasAttachments
 			var newMaterial = new Material(shader);
+			if (materialPropertySource != null) {
+				newMaterial.CopyPropertiesFromMaterial(materialPropertySource);
+				newMaterial.shaderKeywords = materialPropertySource.shaderKeywords;
+			}
+
 			newMaterial.name = newName;
 			newMaterial.mainTexture = newTexture;
 			var page = newMaterial.ToSpineAtlasPage();
@@ -398,6 +498,18 @@ namespace Spine.Unity.Modules.AttachmentTools {
 			var r = s.textureRect;
 			var spritePixels = spriteTexture.GetPixels((int)r.x, (int)r.y, (int)r.width, (int)r.height);
 			var newTexture = new Texture2D((int)r.width, (int)r.height, textureFormat, mipmaps);
+
+			newTexture.SetPixels(spritePixels);
+
+			if (applyImmediately)
+				newTexture.Apply();
+
+			return newTexture;
+		}
+
+		static Texture2D GetClone (this Texture2D t, bool applyImmediately = true, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps) {
+			var spritePixels = t.GetPixels(0, 0, (int)t.width, (int)t.height);
+			var newTexture = new Texture2D((int)t.width, (int)t.height, textureFormat, mipmaps);
 			newTexture.SetPixels(spritePixels);
 
 			if (applyImmediately)
@@ -536,7 +648,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
 		}
 		#endregion
 
-		private static float InverseLerp (float a, float b, float value) {
+		static float InverseLerp (float a, float b, float value) {
 			return (value - a) / (b - a);
 		}
 	}
@@ -737,7 +849,7 @@ namespace Spine.Unity.Modules.AttachmentTools {
 		static void CloneVertexAttachment (VertexAttachment src, VertexAttachment dest) {
 			dest.worldVerticesLength = src.worldVerticesLength;
 			if (src.bones != null)
-				dest.bones = src.vertices.Clone() as int[];
+				dest.bones = src.bones.Clone() as int[];
 
 			if (src.vertices != null)
 				dest.vertices = src.vertices.Clone() as float[];
@@ -778,8 +890,20 @@ namespace Spine.Unity.Modules.AttachmentTools {
 		/// <summary>
 		/// Returns a new linked mesh linked to this MeshAttachment. It will be mapped to an AtlasRegion generated from a Sprite. The AtlasRegion will be mapped to a new Material based on the shader.
 		/// For better caching and batching, use GetLinkedMesh(string, AtlasRegion, bool)</summary>
-		public static MeshAttachment GetLinkedMesh (this MeshAttachment o, Sprite sprite, Shader shader, bool inheritDeform = true) {
-			return o.GetLinkedMesh(sprite.name, sprite.ToAtlasRegion(new Material(shader)), inheritDeform);
+		public static MeshAttachment GetLinkedMesh (this MeshAttachment o, Sprite sprite, Shader shader, bool inheritDeform = true, Material materialPropertySource = null) {
+			var m = new Material(shader);
+			if (materialPropertySource != null) {
+				m.CopyPropertiesFromMaterial(materialPropertySource);
+				m.shaderKeywords = materialPropertySource.shaderKeywords;
+			}
+			return o.GetLinkedMesh(sprite.name, sprite.ToAtlasRegion(), inheritDeform);
+		}
+
+		/// <summary>
+		/// Returns a new linked mesh linked to this MeshAttachment. It will be mapped to an AtlasRegion generated from a Sprite. The AtlasRegion will be mapped to a new Material based on the shader.
+		/// For better caching and batching, use GetLinkedMesh(string, AtlasRegion, bool)</summary>
+		public static MeshAttachment GetLinkedMesh (this MeshAttachment o, Sprite sprite, Material materialPropertySource, bool inheritDeform = true) {
+			return o.GetLinkedMesh(sprite, materialPropertySource.shader, inheritDeform, materialPropertySource);
 		}
 		#endregion
 	}

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 4b6fb48f295cd8248a7566315212a3c2
+folderAsset: yes
+timeCreated: 1494092464
+licenseType: Free
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 70 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderMaths.cginc

@@ -0,0 +1,70 @@
+#ifndef SHADER_MATHS_INCLUDED
+#define SHADER_MATHS_INCLUDED
+
+#include "UnityCG.cginc"
+
+////////////////////////////////////////
+// Maths functions
+//
+
+inline half3 safeNormalize(half3 inVec)
+{
+	half dp3 = max(0.001f, dot(inVec, inVec));
+	return inVec * rsqrt(dp3);
+}
+
+inline float dotClamped(float3 a, float3 b)
+{
+	#if (SHADER_TARGET < 30 || defined(SHADER_API_PS3))
+		return saturate(dot(a, b));
+	#else
+		return max(0.0h, dot(a, b));
+	#endif
+}
+
+inline float oneDividedBy(float value)
+{
+	//Catches NANs
+	float sign_value = sign(value);
+	float sign_value_squared = sign_value*sign_value;
+	return sign_value_squared / ( value + sign_value_squared - 1.0);
+}
+
+inline half pow5 (half x)
+{
+	return x*x*x*x*x;
+}
+
+inline float4 quat_from_axis_angle(float3 axis, float angleRadians)
+{ 
+  float4 qr;
+  float half_angle = (angleRadians * 0.5);
+  qr.x = axis.x * sin(half_angle);
+  qr.y = axis.y * sin(half_angle);
+  qr.z = axis.z * sin(half_angle);
+  qr.w = cos(half_angle);
+  return qr;
+}
+
+inline float3 rotate_vertex_position(float3 position, float3 axis, float angleRadians)
+{ 
+  float4 q = quat_from_axis_angle(axis, angleRadians);
+  float3 v = position.xyz;
+  return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);
+}
+
+float3 EncodeFloatRGB(float value)
+{
+   const float max24int = 256*256*256-1;
+   float3 decomp = floor( value * float3( max24int/(256*256), max24int/256, max24int ) ) / 255.0;
+   decomp.z -= decomp.y * 256.0;
+   decomp.y -= decomp.x * 256.0;
+   return decomp;
+}
+
+float DecodeFloatRGB(float3 decomp)
+{
+   return dot( decomp.xyz, float3( 255.0/256, 255.0/(256*256), 255.0/(256*256*256) ) );
+}
+
+#endif // SHADER_MATHS_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderMaths.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: e1de23de2025abe4a84ff2edd3f24491
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 472 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderShared.cginc

@@ -0,0 +1,472 @@
+#ifndef SHADER_SHARED_INCLUDED
+#define SHADER_SHARED_INCLUDED
+
+#include "UnityCG.cginc"
+
+#ifdef UNITY_INSTANCING_ENABLED
+
+    UNITY_INSTANCING_CBUFFER_START(PerDrawSprite)
+        // SpriteRenderer.Color while Non-Batched/Instanced.
+        fixed4 unity_SpriteRendererColorArray[UNITY_INSTANCED_ARRAY_SIZE];
+        // this could be smaller but that's how bit each entry is regardless of type
+        float4 unity_SpriteFlipArray[UNITY_INSTANCED_ARRAY_SIZE];
+    UNITY_INSTANCING_CBUFFER_END
+
+    #define _RendererColor unity_SpriteRendererColorArray[unity_InstanceID]
+    #define _Flip unity_SpriteFlipArray[unity_InstanceID]
+
+#endif // instancing
+
+CBUFFER_START(UnityPerDrawSprite)
+#ifndef UNITY_INSTANCING_ENABLED
+    fixed4 _RendererColor;
+    float4 _Flip;
+#endif
+    float _EnableExternalAlpha;
+CBUFFER_END
+
+////////////////////////////////////////
+// Space functions
+//
+
+inline float4 calculateWorldPos(float4 vertex)
+{
+	return mul(unity_ObjectToWorld, vertex);
+}
+
+inline float4 calculateLocalPos(float4 vertex)
+{
+#ifdef UNITY_INSTANCING_ENABLED
+    vertex.xy *= _Flip.xy;
+#endif
+
+	float4 pos = UnityObjectToClipPos(vertex);
+	
+#ifdef PIXELSNAP_ON
+	pos = UnityPixelSnap(pos);
+#endif
+
+	return pos;
+}
+
+inline half3 calculateWorldNormal(float3 normal)
+{
+	return UnityObjectToWorldNormal(normal);
+}
+
+////////////////////////////////////////
+// Normal map functions
+//
+
+#if defined(_NORMALMAP)
+
+uniform sampler2D _BumpMap;
+uniform half _BumpScale;
+
+half3 UnpackScaleNormal(half4 packednormal, half bumpScale)
+{
+	#if defined(UNITY_NO_DXT5nm)
+		return packednormal.xyz * 2 - 1;
+	#else
+		half3 normal;
+		normal.xy = (packednormal.wy * 2 - 1);
+		#if (SHADER_TARGET >= 30)
+			// SM2.0: instruction count limitation
+			// SM2.0: normal scaler is not supported
+			normal.xy *= bumpScale;
+		#endif
+		normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
+		return normal;
+	#endif
+}		
+
+
+inline half3 calculateWorldTangent(float4 tangent)
+{
+	return UnityObjectToWorldDir(tangent);
+}
+
+inline half3 calculateWorldBinormal(half3 normalWorld, half3 tangentWorld, float tangentSign)
+{
+	//When calculating the binormal we have to flip it when the mesh is scaled negatively.
+	//Normally this would just be unity_WorldTransformParams.w but this isn't set correctly by Unity for its SpriteRenderer meshes so get from objectToWorld matrix scale instead.
+	half worldTransformSign = sign(unity_ObjectToWorld[0][0] * unity_ObjectToWorld[1][1] * unity_ObjectToWorld[2][2]);
+	half sign = tangentSign * worldTransformSign;
+	return cross(normalWorld, tangentWorld) * sign;
+}
+
+inline half3 calculateNormalFromBumpMap(float2 texUV, half3 tangentWorld, half3 binormalWorld, half3 normalWorld)
+{
+	half3 localNormal = UnpackScaleNormal(tex2D(_BumpMap, texUV), _BumpScale);
+	half3x3 rotation = half3x3(tangentWorld, binormalWorld, normalWorld);
+	half3 normal = normalize(mul(localNormal, rotation));
+	return normal;
+}
+
+#endif // _NORMALMAP
+
+////////////////////////////////////////
+// Blending functions
+//
+
+inline fixed4 calculateLitPixel(fixed4 texureColor, fixed4 color, fixed3 lighting) : SV_Target
+{
+	fixed4 finalPixel;
+	
+#if defined(_ALPHABLEND_ON)
+	//Normal Alpha
+	finalPixel.a = texureColor.a * color.a;
+	finalPixel.rgb = texureColor.rgb * color.rgb * (lighting * finalPixel.a);
+#elif defined(_ALPHAPREMULTIPLY_ON)
+	//Pre multiplied alpha
+	finalPixel = texureColor * color;
+	finalPixel.rgb *= lighting * color.a;
+#elif defined(_MULTIPLYBLEND)
+	//Multiply
+	finalPixel = texureColor * color;
+	finalPixel.rgb *= lighting;
+	finalPixel = lerp(fixed4(1,1,1,1), finalPixel, finalPixel.a);
+#elif defined(_MULTIPLYBLEND_X2)
+	//Multiply x2
+	finalPixel.rgb = texureColor.rgb * color.rgb * lighting * 2.0f;
+	finalPixel.a = color.a * texureColor.a;
+	finalPixel = lerp(fixed4(0.5f,0.5f,0.5f,0.5f), finalPixel, finalPixel.a);
+#elif defined(_ADDITIVEBLEND)
+	//Additive
+	finalPixel = texureColor * 2.0f * color;
+	finalPixel.rgb *= lighting * color.a;
+#elif defined(_ADDITIVEBLEND_SOFT)
+	//Additive soft
+	finalPixel = texureColor * color;
+	finalPixel.rgb *= lighting * finalPixel.a;
+#else 
+	//Opaque
+	finalPixel.a = 1;
+	finalPixel.rgb = texureColor.rgb * color.rgb * lighting;
+#endif
+	
+	return finalPixel;
+}
+
+inline fixed4 calculateLitPixel(fixed4 texureColor, fixed3 lighting) : SV_Target
+{
+	fixed4 finalPixel;
+	
+#if defined(_ALPHABLEND_ON)	
+	//Normal Alpha
+	finalPixel.a = texureColor.a;
+	finalPixel.rgb = texureColor.rgb * (lighting * finalPixel.a);
+#elif defined(_ALPHAPREMULTIPLY_ON)
+	//Pre multiplied alpha
+	finalPixel = texureColor;
+	finalPixel.rgb *= lighting;
+#elif defined(_MULTIPLYBLEND)
+	//Multiply
+	finalPixel = texureColor;
+	finalPixel.rgb *= lighting;
+	finalPixel = lerp(fixed4(1,1,1,1), finalPixel, finalPixel.a);
+#elif defined(_MULTIPLYBLEND_X2)
+	//Multiply x2
+	finalPixel.rgb = texureColor.rgb * lighting * 2.0f;
+	finalPixel.a = texureColor.a;
+	finalPixel = lerp(fixed4(0.5f,0.5f,0.5f,0.5f), finalPixel, finalPixel.a);
+#elif defined(_ADDITIVEBLEND)
+	//Additive
+	finalPixel = texureColor * 2.0f;
+	finalPixel.rgb *= lighting;
+#elif defined(_ADDITIVEBLEND_SOFT)
+	//Additive soft
+	finalPixel = texureColor;
+	finalPixel.rgb *= lighting * finalPixel.a;
+#else 
+	//Opaque
+	finalPixel.a = 1;
+	finalPixel.rgb = texureColor.rgb * lighting;
+#endif
+	
+	return finalPixel;
+}
+
+inline fixed4 calculateAdditiveLitPixel(fixed4 texureColor, fixed4 color, fixed3 lighting) : SV_Target
+{
+	fixed4 finalPixel;
+	
+#if defined(_ALPHABLEND_ON)	|| defined(_MULTIPLYBLEND)	|| defined(_MULTIPLYBLEND_X2) || defined(_ADDITIVEBLEND) || defined(_ADDITIVEBLEND_SOFT)
+	//Normal Alpha, Additive and Multiply modes
+	finalPixel.rgb = (texureColor.rgb * lighting * color.rgb) * (texureColor.a * color.a);
+	finalPixel.a = 1.0;
+#elif defined(_ALPHAPREMULTIPLY_ON)
+	//Pre multiplied alpha
+	finalPixel.rgb = texureColor.rgb * lighting * color.rgb * color.a;
+	finalPixel.a = 1.0;
+#else
+	//Opaque
+	finalPixel.rgb = texureColor.rgb * lighting * color.rgb;
+	finalPixel.a = 1.0;
+#endif
+	
+	return finalPixel;
+}
+
+inline fixed4 calculateAdditiveLitPixel(fixed4 texureColor, fixed3 lighting) : SV_Target
+{
+	fixed4 finalPixel;
+	
+#if defined(_ALPHABLEND_ON)	|| defined(_MULTIPLYBLEND) || defined(_MULTIPLYBLEND_X2) || defined(_ADDITIVEBLEND) || defined(_ADDITIVEBLEND_SOFT)
+	//Normal Alpha, Additive and Multiply modes
+	finalPixel.rgb = (texureColor.rgb * lighting) * texureColor.a;
+	finalPixel.a = 1.0;
+#else
+	//Pre multiplied alpha and Opaque
+	finalPixel.rgb = texureColor.rgb * lighting;
+	finalPixel.a = 1.0;
+#endif
+	
+	return finalPixel;
+}
+
+inline fixed4 calculatePixel(fixed4 texureColor, fixed4 color) : SV_Target
+{
+	fixed4 finalPixel;
+	
+#if defined(_ALPHABLEND_ON)	
+	//Normal Alpha
+	finalPixel.a = texureColor.a * color.a;
+	finalPixel.rgb = (texureColor.rgb * color.rgb) * finalPixel.a;
+#elif defined(_ALPHAPREMULTIPLY_ON)
+	//Pre multiplied alpha
+	finalPixel = texureColor * color;
+	finalPixel.rgb *= color.a;
+#elif defined(_MULTIPLYBLEND)
+	//Multiply
+	finalPixel = color * texureColor;
+	finalPixel = lerp(fixed4(1,1,1,1), finalPixel, finalPixel.a);
+#elif defined(_MULTIPLYBLEND_X2)
+	//Multiply x2
+	finalPixel.rgb = texureColor.rgb * color.rgb * 2.0f;
+	finalPixel.a = color.a * texureColor.a;
+	finalPixel = lerp(fixed4(0.5f,0.5f,0.5f,0.5f), finalPixel, finalPixel.a);
+#elif defined(_ADDITIVEBLEND)
+	//Additive
+	finalPixel = texureColor * 2.0f * color;
+#elif defined(_ADDITIVEBLEND_SOFT)
+	//Additive soft
+	finalPixel = color * texureColor;
+	finalPixel.rgb *= finalPixel.a;
+#else 
+	//Opaque
+	finalPixel.a = 1;
+	finalPixel.rgb = texureColor.rgb * color.rgb;
+#endif
+	
+	return finalPixel;
+}
+
+inline fixed4 calculatePixel(fixed4 texureColor) : SV_Target
+{
+	fixed4 finalPixel;
+	
+#if defined(_ALPHABLEND_ON)	
+	//Normal Alpha
+	finalPixel.a = texureColor.a;
+	finalPixel.rgb = texureColor.rgb * finalPixel.a;
+#elif defined(_ALPHAPREMULTIPLY_ON)
+	//Pre multiplied alpha
+	finalPixel = texureColor;
+#elif defined(_MULTIPLYBLEND)
+	//Multiply
+	finalPixel = texureColor;
+	finalPixel = lerp(fixed4(1,1,1,1), finalPixel, finalPixel.a);
+#elif defined(_MULTIPLYBLEND_X2)
+	//Multiply x2
+	finalPixel.rgb = texureColor.rgb * 2.0f;
+	finalPixel.a = texureColor.a;
+	finalPixel = lerp(fixed4(0.5f,0.5f,0.5f,0.5f), finalPixel, finalPixel.a);
+#elif defined(_ADDITIVEBLEND)
+	//Additive
+	finalPixel = texureColor * 2.0f;
+#elif defined(_ADDITIVEBLEND_SOFT)
+	//Additive soft
+	finalPixel = texureColor;
+	finalPixel.rgb *= finalPixel.a;
+#else
+	//Opaque
+	finalPixel.a = 1;
+	finalPixel.rgb = texureColor.rgb;
+#endif 
+
+	return finalPixel;
+}
+
+////////////////////////////////////////
+// Alpha Clipping
+//
+
+#if defined(_ALPHA_CLIP) 
+
+uniform fixed _Cutoff;
+
+#define ALPHA_CLIP(pixel, color) clip((pixel.a * color.a) - _Cutoff);
+
+#else
+
+#define ALPHA_CLIP(pixel, color)
+
+#endif
+
+////////////////////////////////////////
+// Color functions
+//
+
+uniform fixed4 _Color;
+
+inline fixed4 calculateVertexColor(fixed4 color)
+{
+	return color * _Color;
+}
+
+#if defined(_COLOR_ADJUST)
+
+uniform float _Hue;
+uniform float _Saturation;
+uniform float _Brightness;
+uniform fixed4 _OverlayColor;
+
+float3 rgb2hsv(float3 c)
+{
+  float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+  float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
+  float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
+
+  float d = q.x - min(q.w, q.y);
+  float e = 1.0e-10;
+  return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+}
+
+float3 hsv2rgb(float3 c) 
+{
+  c = float3(c.x, clamp(c.yz, 0.0, 1.0));
+  float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+  float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
+  return c.z * lerp(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
+
+inline fixed4 adjustColor(fixed4 color)
+{
+	float3 hsv = rgb2hsv(color.rgb);
+	
+	hsv.x += _Hue; 
+	hsv.y *= _Saturation; 
+	hsv.z *= _Brightness;
+	
+	color.rgb = hsv2rgb(hsv);
+	
+	return color;
+}
+
+#define COLORISE(pixel) pixel.rgb = lerp(pixel.rgb, _OverlayColor.rgb, _OverlayColor.a * pixel.a);
+#define COLORISE_ADDITIVE(pixel) pixel.rgb = ((1.0-_OverlayColor.a) * pixel.rgb);
+
+#else  // !_COLOR_ADJUST
+
+#define COLORISE(pixel)
+#define COLORISE_ADDITIVE(pixel)
+
+#endif // !_COLOR_ADJUST
+
+////////////////////////////////////////
+// Fog
+//
+
+#if defined(_FOG) && (defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2))
+
+inline fixed4 applyFog(fixed4 pixel, float1 fogCoord) 
+{
+#if defined(_ADDITIVEBLEND) || defined(_ADDITIVEBLEND_SOFT)
+	//In additive mode blend from clear to black based on luminance
+	float luminance = pixel.r * 0.3 + pixel.g * 0.59 + pixel.b * 0.11;
+	fixed4 fogColor = lerp(fixed4(0,0,0,0), fixed4(0,0,0,1), luminance);
+#elif defined(_MULTIPLYBLEND)
+	//In multiplied mode fade to white based on inverse luminance
+	float luminance = pixel.r * 0.3 + pixel.g * 0.59 + pixel.b * 0.11;
+	fixed4 fogColor = lerp(fixed4(1,1,1,1), fixed4(0,0,0,0), luminance);
+#elif defined(_MULTIPLYBLEND_X2)
+	//In multipliedx2 mode fade to grey based on inverse luminance
+	float luminance = pixel.r * 0.3 + pixel.g * 0.59 + pixel.b * 0.11;
+	fixed4 fogColor = lerp(fixed4(0.5f,0.5f,0.5f,0.5f), fixed4(0,0,0,0), luminance);
+#elif defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)
+	//In alpha blended modes blend to fog color based on pixel alpha
+	fixed4 fogColor = lerp(fixed4(0,0,0,0), unity_FogColor, pixel.a);
+#else
+	//In opaque mode just return fog color;
+	fixed4 fogColor = unity_FogColor;
+#endif 
+	
+	UNITY_APPLY_FOG_COLOR(fogCoord, pixel, fogColor);
+	
+	return pixel;
+}
+
+#define APPLY_FOG(pixel, input) pixel = applyFog(pixel, input.fogCoord);
+	
+#define APPLY_FOG_ADDITIVE(pixel, input) \
+	UNITY_APPLY_FOG_COLOR(input.fogCoord, pixel.rgb, fixed4(0,0,0,0)); // fog towards black in additive pass
+	
+#else
+
+#define APPLY_FOG(pixel, input)
+#define APPLY_FOG_ADDITIVE(pixel, input)
+
+#endif
+
+////////////////////////////////////////
+// Texture functions
+//
+
+uniform sampler2D _MainTex;
+
+#if ETC1_EXTERNAL_ALPHA
+//External alpha texture for ETC1 compression
+uniform sampler2D _AlphaTex;
+#endif //ETC1_EXTERNAL_ALPHA
+
+#if _TEXTURE_BLEND
+uniform sampler2D _BlendTex;
+uniform float _BlendAmount;
+
+inline fixed4 calculateBlendedTexturePixel(float2 texcoord)
+{
+	return (1.0-_BlendAmount) * tex2D(_MainTex, texcoord) + _BlendAmount * tex2D(_BlendTex, texcoord);
+}
+#endif // _TEXTURE_BLEND
+
+inline fixed4 calculateTexturePixel(float2 texcoord)
+{
+	fixed4 pixel;
+	
+#if _TEXTURE_BLEND
+	pixel = calculateBlendedTexturePixel(texcoord);
+#else
+	pixel = tex2D(_MainTex, texcoord);
+#endif // !_TEXTURE_BLEND
+
+#if ETC1_EXTERNAL_ALPHA
+    fixed4 alpha = tex2D (_AlphaTex, texcoord);
+    pixel.a = lerp (pixel.a, alpha.r, _EnableExternalAlpha);
+#endif
+
+#if defined(_COLOR_ADJUST)
+	pixel = adjustColor(pixel);
+#endif // _COLOR_ADJUST
+
+	return pixel;
+}
+
+uniform fixed4 _MainTex_ST;
+
+inline float2 calculateTextureCoord(float4 texcoord)
+{
+	return TRANSFORM_TEX(texcoord, _MainTex);
+}
+
+#endif // SHADER_SHARED_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/ShaderShared.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: c18c5cab567666f4d8c5b2bd4e61390b
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 200 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteLighting.cginc

@@ -0,0 +1,200 @@
+#ifndef SPRITE_LIGHTING_INCLUDED
+#define SPRITE_LIGHTING_INCLUDED
+
+//Check for using mesh normals
+#if !defined(_FIXED_NORMALS_VIEWSPACE) && !defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE) && !defined(_FIXED_NORMALS_MODELSPACE) && !defined(_FIXED_NORMALS_MODELSPACE_BACKFACE)
+#define MESH_NORMALS
+#endif
+
+//Check for fixing backfacing tangents
+#if defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE) || defined(_FIXED_NORMALS_MODELSPACE_BACKFACE)
+#define FIXED_NORMALS_BACKFACE_RENDERING
+#endif
+
+////////////////////////////////////////
+// Vertex structs
+//
+
+struct VertexInput
+{
+	float4 vertex : POSITION;
+	float4 texcoord : TEXCOORD0;
+	float4 color : COLOR;
+#if defined(MESH_NORMALS)
+	float3 normal : NORMAL;
+#endif // _FIXED_NORMALS
+#if defined(_NORMALMAP)
+	float4 tangent : TANGENT;
+#endif // _NORMALMAP
+	UNITY_INSTANCE_ID
+};
+
+////////////////////////////////////////
+// Normal functions
+//
+
+uniform float4 _FixedNormal = float4(0, 0, 1, 1);
+
+inline float3 getFixedNormal()
+{
+	return _FixedNormal.xyz;
+}
+
+inline float calculateBackfacingSign(float3 worldPos)
+{
+	//If we're using fixed normals and mesh is facing away from camera, flip tangentSign
+	//Unity uses a left handed coordinate system so camera always looks down the negative z axis
+	float3 cameraForward = float3(0,0,-1);
+	float3 meshWorldForward = mul((float3x3)unity_ObjectToWorld, cameraForward);
+	float3 toCamera = _WorldSpaceCameraPos - worldPos;
+	return sign(dot(toCamera, meshWorldForward));
+}
+
+inline half3 calculateSpriteWorldNormal(VertexInput vertex, float backFaceSign)
+{
+#if defined(MESH_NORMALS)
+	
+	return calculateWorldNormal(vertex.normal);
+	
+#else // !MESH_NORMALS
+
+	float3 normal = getFixedNormal();
+
+#if defined(_FIXED_NORMALS_VIEWSPACE) || defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE)
+	//View space fixed normal
+	//Rotate fixed normal by inverse view matrix to convert the fixed normal into world space
+	float3x3 invView = transpose((float3x3)UNITY_MATRIX_V);
+	return normalize(mul(invView, normal));
+#else
+	//Model space fixed normal. 
+#if defined(FIXED_NORMALS_BACKFACE_RENDERING)	
+	//If back face rendering is enabled and the sprite is facing away from the camera (ie we're rendering the backface) then need to flip the normal
+	normal *= backFaceSign;
+#endif
+	return calculateWorldNormal(normal);
+#endif
+	
+#endif // !MESH_NORMALS
+}
+
+inline half3 calculateSpriteViewNormal(VertexInput vertex, float backFaceSign)
+{
+#if defined(MESH_NORMALS)
+	
+	return normalize(mul((float3x3)UNITY_MATRIX_IT_MV, vertex.normal));
+	
+#else // !MESH_NORMALS
+
+	float3 normal = getFixedNormal();
+
+#if defined(_FIXED_NORMALS_VIEWSPACE) || defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE)
+	//View space fixed normal
+	return normal;
+#else
+	//Model space fixed normal
+#if defined(FIXED_NORMALS_BACKFACE_RENDERING)	
+	//If back face rendering is enabled and the sprite is facing away from the camera (ie we're rendering the backface) then need to flip the normal
+	normal *= backFaceSign;
+#endif
+	return normalize(mul((float3x3)UNITY_MATRIX_IT_MV, normal));
+#endif
+		
+#endif // !MESH_NORMALS
+}
+
+////////////////////////////////////////
+// Normal map functions
+//
+
+#if defined(_NORMALMAP)
+
+inline half3 calculateSpriteWorldBinormal(VertexInput vertex, half3 normalWorld, half3 tangentWorld, float backFaceSign)
+{
+	float tangentSign = vertex.tangent.w;
+
+#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
+	tangentSign *= backFaceSign;
+#endif
+
+	return calculateWorldBinormal(normalWorld, tangentWorld, tangentSign);
+}
+
+#endif // _NORMALMAP
+
+#if defined(_DIFFUSE_RAMP)
+
+
+////////////////////////////////////////
+// Diffuse ramp functions
+//
+
+//Disable for softer, more traditional diffuse ramping
+#define HARD_DIFFUSE_RAMP
+
+uniform sampler2D _DiffuseRamp;
+
+inline fixed3 calculateDiffuseRamp(float ramp)
+{
+	return tex2D(_DiffuseRamp, float2(ramp, ramp)).rgb;
+}
+
+inline fixed3 calculateRampedDiffuse(fixed3 lightColor, float attenuation, float angleDot)
+{
+	float d = angleDot * 0.5 + 0.5;
+#if defined(HARD_DIFFUSE_RAMP)
+	half3 ramp = calculateDiffuseRamp(d * attenuation * 2);
+	return lightColor * ramp;
+#else
+	half3 ramp = calculateDiffuseRamp(d);
+	return lightColor * ramp * (attenuation * 2);
+#endif
+}
+#endif // _DIFFUSE_RAMP
+
+////////////////////////////////////////
+// Rim Lighting functions
+//
+
+#ifdef _RIM_LIGHTING
+
+uniform float _RimPower;
+uniform fixed4 _RimColor;
+
+inline fixed3 applyRimLighting(fixed3 posWorld, fixed3 normalWorld, fixed4 pixel) : SV_Target
+{
+	fixed3 viewDir = normalize(_WorldSpaceCameraPos - posWorld);
+	float invDot =  1.0 - saturate(dot(normalWorld, viewDir));
+	float rimPower = pow(invDot, _RimPower);
+	float rim = saturate(rimPower * _RimColor.a);
+	
+#if defined(_DIFFUSE_RAMP)
+	rim = calculateDiffuseRamp(rim).r;
+#endif
+	
+	return lerp(pixel.rgb, _RimColor.xyz * pixel.a, rim);
+}
+
+#endif  //_RIM_LIGHTING
+
+////////////////////////////////////////
+// Emission functions
+//
+
+#ifdef _EMISSION
+
+uniform sampler2D _EmissionMap;
+uniform fixed4 _EmissionColor;
+uniform float _EmissionPower;
+
+
+#define APPLY_EMISSION(diffuse, uv) diffuse += tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb * _EmissionPower;
+#define APPLY_EMISSION_SPECULAR(pixel, uv) pixel.rgb += (tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb * _EmissionPower) * pixel.a;
+
+#else //!_EMISSION
+
+#define APPLY_EMISSION(diffuse, uv)
+#define APPLY_EMISSION_SPECULAR(pixel, uv)
+
+#endif  //!_EMISSION
+
+#endif // SPRITE_LIGHTING_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteLighting.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 0cfb891658099ca4bb0c9544c08e60f9
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 252 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc

@@ -0,0 +1,252 @@
+#ifndef SPRITE_PIXEL_LIGHTING_INCLUDED
+#define SPRITE_PIXEL_LIGHTING_INCLUDED
+	
+#include "ShaderShared.cginc"
+#include "SpriteLighting.cginc"
+#include "SpriteSpecular.cginc"
+#include "AutoLight.cginc"
+
+////////////////////////////////////////
+// Defines
+//
+
+////////////////////////////////////////
+// Vertex output struct
+//
+
+#if defined(_NORMALMAP)
+	#define _VERTEX_LIGHTING_INDEX TEXCOORD5
+	#define _LIGHT_COORD_INDEX_0 6
+	#define _LIGHT_COORD_INDEX_1 7
+	#define _FOG_COORD_INDEX 8
+#else
+	#define _VERTEX_LIGHTING_INDEX TEXCOORD3
+	#define _LIGHT_COORD_INDEX_0 4
+	#define _LIGHT_COORD_INDEX_1 5
+	#define _FOG_COORD_INDEX 6
+#endif // _NORMALMAP	
+
+struct VertexOutput
+{
+	float4 pos : SV_POSITION;				
+	fixed4 color : COLOR;
+	float2 texcoord : TEXCOORD0;
+	float4 posWorld : TEXCOORD1;
+	half3 normalWorld : TEXCOORD2;
+#if defined(_NORMALMAP)
+	half3 tangentWorld : TEXCOORD3;  
+	half3 binormalWorld : TEXCOORD4;
+#endif // _NORMALMAP
+	fixed3 vertexLighting : _VERTEX_LIGHTING_INDEX;
+	LIGHTING_COORDS(_LIGHT_COORD_INDEX_0, _LIGHT_COORD_INDEX_1)
+#if defined(_FOG)
+	UNITY_FOG_COORDS(_FOG_COORD_INDEX)
+#endif // _FOG	
+
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+////////////////////////////////////////
+// Light calculations
+//
+
+uniform fixed4 _LightColor0;
+
+inline fixed3 calculateLightDiffuse(VertexOutput input, float3 normalWorld, inout fixed4 albedo)
+{
+	//For directional lights _WorldSpaceLightPos0.w is set to zero
+	float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w);
+	
+	float attenuation = LIGHT_ATTENUATION(input);
+	float angleDot = max(0, dot(normalWorld, lightWorldDirection));
+	
+#if defined(_DIFFUSE_RAMP)
+	fixed3 lightDiffuse = calculateRampedDiffuse(_LightColor0.rgb, attenuation, angleDot);
+#else
+	fixed3 lightDiffuse = _LightColor0.rgb * (attenuation * angleDot);
+#endif // _DIFFUSE_RAMP
+	
+	return lightDiffuse;
+}
+
+inline float3 calculateNormalWorld(VertexOutput input)
+{
+#if defined(_NORMALMAP)
+	return calculateNormalFromBumpMap(input.texcoord, input.tangentWorld, input.binormalWorld, input.normalWorld);
+#else
+	return input.normalWorld;
+#endif
+}
+
+fixed3 calculateVertexLighting(float3 posWorld, float3 normalWorld)
+{
+	fixed3 vertexLighting = fixed3(0,0,0);
+
+#ifdef VERTEXLIGHT_ON
+	//Get approximated illumination from non-important point lights
+	vertexLighting = Shade4PointLights (	unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
+											unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
+											unity_4LightAtten0, posWorld, normalWorld) * 0.5;
+#endif
+
+	return vertexLighting;
+}
+
+fixed3 calculateAmbientLight(half3 normalWorld)
+{
+#if defined(_SPHERICAL_HARMONICS)
+	fixed3 ambient = ShadeSH9(half4(normalWorld, 1.0));
+#else 
+	fixed3 ambient = unity_AmbientSky.rgb;
+#endif
+	return ambient;
+}
+
+#if defined(SPECULAR)
+
+fixed4 calculateSpecularLight(SpecularCommonData s, float3 viewDir, float3 normal, float3 lightDir, float3 lightColor, half3 ambient)
+{
+	SpecularLightData data = calculatePhysicsBasedSpecularLight (s.specColor, s.oneMinusReflectivity, s.smoothness, normal, viewDir, lightDir, lightColor, ambient, unity_IndirectSpecColor.rgb);
+	fixed4 pixel = calculateLitPixel(fixed4(s.diffColor, s.alpha), data.lighting);
+	pixel.rgb += data.specular * s.alpha;
+	return pixel;
+}
+
+fixed4 calculateSpecularLightAdditive(SpecularCommonData s, float3 viewDir, float3 normal, float3 lightDir, float3 lightColor)
+{
+	SpecularLightData data = calculatePhysicsBasedSpecularLight (s.specColor, s.oneMinusReflectivity, s.smoothness, normal, viewDir, lightDir, lightColor, half3(0,0,0), half3(0,0,0));
+	fixed4 pixel = calculateAdditiveLitPixel(fixed4(s.diffColor, s.alpha), data.lighting);
+	pixel.rgb += data.specular * s.alpha;
+	return pixel;
+}
+
+#endif //SPECULAR
+
+////////////////////////////////////////
+// Vertex program
+//
+
+VertexOutput vert(VertexInput v)
+{
+	VertexOutput output;
+	
+	UNITY_SETUP_INSTANCE_ID(input);
+    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
+	
+	output.pos = calculateLocalPos(v.vertex);
+	output.color = calculateVertexColor(v.color);
+	output.texcoord = calculateTextureCoord(v.texcoord);
+	output.posWorld = calculateWorldPos(v.vertex);
+	
+	float backFaceSign = 1;
+#if defined(FIXED_NORMALS_BACKFACE_RENDERING)	
+	backFaceSign = calculateBackfacingSign(output.posWorld.xyz);
+#endif	
+
+	output.normalWorld = calculateSpriteWorldNormal(v, backFaceSign);
+	output.vertexLighting = calculateVertexLighting(output.posWorld, output.normalWorld);
+	
+#if defined(_NORMALMAP)
+	output.tangentWorld = calculateWorldTangent(v.tangent);
+	output.binormalWorld = calculateSpriteWorldBinormal(v, output.normalWorld, output.tangentWorld, backFaceSign);
+#endif
+
+	TRANSFER_VERTEX_TO_FRAGMENT(output)
+	
+#if defined(_FOG)
+	UNITY_TRANSFER_FOG(output,output.pos);
+#endif // _FOG	
+	
+	return output;
+}
+
+////////////////////////////////////////
+// Fragment programs
+//
+
+fixed4 fragBase(VertexOutput input) : SV_Target
+{
+	fixed4 texureColor = calculateTexturePixel(input.texcoord);
+	ALPHA_CLIP(texureColor, input.color)
+	
+	//Get normal direction
+	fixed3 normalWorld = calculateNormalWorld(input);
+
+	//Get Ambient diffuse
+	fixed3 ambient = calculateAmbientLight(normalWorld);
+
+	
+#if defined(SPECULAR)
+	
+	//For directional lights _WorldSpaceLightPos0.w is set to zero
+	float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w);
+	float attenuation = LIGHT_ATTENUATION(input);
+	
+	//Returns pixel lit by light, texture color should inlcluded alpha
+	half3 viewDir = normalize(_WorldSpaceCameraPos - input.posWorld.xyz);
+	fixed4 pixel = calculateSpecularLight(getSpecularData(input.texcoord.xy, texureColor, input.color), viewDir, normalWorld, lightWorldDirection, _LightColor0.rgb * attenuation, ambient + input.vertexLighting);
+	
+	APPLY_EMISSION_SPECULAR(pixel, input.texcoord)
+	
+#else
+
+	//Get primary pixel light diffuse
+	fixed3 diffuse = calculateLightDiffuse(input, normalWorld, texureColor);
+	
+	//Combine along with vertex lighting for the base lighting pass
+	fixed3 lighting = ambient + diffuse + input.vertexLighting;
+	
+	APPLY_EMISSION(lighting, input.texcoord)
+	
+	fixed4 pixel = calculateLitPixel(texureColor, input.color, lighting);
+	
+#endif
+	
+#if defined(_RIM_LIGHTING)
+	pixel.rgb = applyRimLighting(input.posWorld, normalWorld, pixel);
+#endif
+	
+	COLORISE(pixel)
+	APPLY_FOG(pixel, input)
+	
+	return pixel;
+}
+
+fixed4 fragAdd(VertexOutput input) : SV_Target
+{
+	fixed4 texureColor = calculateTexturePixel(input.texcoord);
+	
+#if defined(_COLOR_ADJUST)
+	texureColor = adjustColor(texureColor);
+#endif // _COLOR_ADJUST	
+
+	ALPHA_CLIP(texureColor, input.color)
+	
+	//Get normal direction
+	fixed3 normalWorld = calculateNormalWorld(input);
+		
+#if defined(SPECULAR)
+	
+	//For directional lights _WorldSpaceLightPos0.w is set to zero
+	float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w);
+	float attenuation = LIGHT_ATTENUATION(input);
+	
+	half3 viewDir = normalize(_WorldSpaceCameraPos - input.posWorld.xyz);
+	fixed4 pixel = calculateSpecularLightAdditive(getSpecularData(input.texcoord.xy, texureColor, input.color), viewDir, normalWorld, lightWorldDirection, _LightColor0.rgb * attenuation);
+	
+#else
+	
+	//Get light diffuse
+	fixed3 lighting = calculateLightDiffuse(input, normalWorld, texureColor);
+	fixed4 pixel = calculateAdditiveLitPixel(texureColor, input.color, lighting);
+	
+#endif
+	
+	COLORISE_ADDITIVE(pixel)
+	APPLY_FOG_ADDITIVE(pixel, input)
+	
+	return pixel;
+}
+
+
+#endif // SPRITE_PIXEL_LIGHTING_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 7ffc57e05c42ec748838bea0a3aff9f9
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 49 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteShadows.cginc

@@ -0,0 +1,49 @@
+#ifndef SPRITE_SHADOWS_INCLUDED
+#define SPRITE_SHADOWS_INCLUDED
+
+#include "ShaderShared.cginc"
+
+////////////////////////////////////////
+// Vertex structs
+//
+
+struct vertexInput
+{
+	float4 vertex : POSITION;
+	float4 texcoord : TEXCOORD0;
+};
+
+struct vertexOutput
+{ 
+	V2F_SHADOW_CASTER;
+	float2 texcoord : TEXCOORD1;
+};
+
+////////////////////////////////////////
+// Vertex program
+//
+
+vertexOutput vert(vertexInput v)
+{
+	vertexOutput o;
+	TRANSFER_SHADOW_CASTER(o)
+	o.texcoord = calculateTextureCoord(v.texcoord);
+	return o;
+}
+
+////////////////////////////////////////
+// Fragment program
+//
+
+
+uniform fixed _ShadowAlphaCutoff;
+
+fixed4 frag(vertexOutput IN) : COLOR 
+{
+	fixed4 texureColor = calculateTexturePixel(IN.texcoord);
+	clip(texureColor.a - _ShadowAlphaCutoff);
+	
+	SHADOW_CASTER_FRAGMENT(IN)
+}
+
+#endif // SPRITE_SHADOWS_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteShadows.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: b7dbdfb1f55ee26459284220ad6d5bc4
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 246 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteSpecular.cginc

@@ -0,0 +1,246 @@
+#ifndef SPRITE_SPECULAR_INCLUDED
+#define SPRITE_SPECULAR_INCLUDED
+
+#include "ShaderMaths.cginc"
+
+////////////////////////////////////////
+// Specular functions
+//
+
+#if defined(_SPECULAR) || defined(_SPECULAR_GLOSSMAP)
+
+#define SPECULAR
+
+
+//ALL THESE FUNCTIONS ARE TAKEN AND ADAPTED FROM UNITY'S OWN PHYSICS BASED STANDARD SHADER
+
+uniform float _Metallic;
+uniform float _Glossiness;
+uniform float _GlossMapScale;
+uniform sampler2D _MetallicGlossMap;
+
+struct SpecularLightData
+{
+	half3 lighting;	
+	half3 specular;
+};
+
+struct SpecularCommonData
+{
+	half3 diffColor, specColor;
+	// Note: smoothness & oneMinusReflectivity for optimization purposes, mostly for DX9 SM2.0 level.
+	// Most of the math is being done on these (1-x) values, and that saves a few precious ALU slots.
+	half oneMinusReflectivity, smoothness;
+	half alpha;
+};
+
+inline half2 getMetallicGloss(float2 uv)
+{
+	half2 mg;
+	
+#ifdef _SPECULAR_GLOSSMAP
+	mg = tex2D(_MetallicGlossMap, uv).ra;
+	mg.g *= _GlossMapScale;
+#else
+	mg.r = _Metallic;
+	mg.g = _Glossiness;
+#endif
+	
+	return mg;
+}
+
+inline half getOneMinusReflectivityFromMetallic(half metallic)
+{
+	// We'll need oneMinusReflectivity, so
+	//   1-reflectivity = 1-lerp(dielectricSpec, 1, metallic) = lerp(1-dielectricSpec, 0, metallic)
+	// store (1-dielectricSpec) in unity_ColorSpaceDielectricSpec.a, then
+	//	 1-reflectivity = lerp(alpha, 0, metallic) = alpha + metallic*(0 - alpha) = 
+	//                  = alpha - metallic * alpha
+	half oneMinusDielectricSpec = unity_ColorSpaceDielectricSpec.a;
+	return oneMinusDielectricSpec - metallic * oneMinusDielectricSpec;
+}
+
+inline SpecularCommonData getSpecularData(float2 uv, half4 texureColor, fixed4 color)
+{
+	half2 metallicGloss = getMetallicGloss(uv);
+	half metallic = metallicGloss.x;
+	half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
+	
+	fixed4 albedo = calculatePixel(texureColor, color);
+	
+	half3 specColor = lerp (unity_ColorSpaceDielectricSpec.rgb, albedo, metallic);
+	half oneMinusReflectivity = getOneMinusReflectivityFromMetallic(metallic);
+	half3 diffColor = albedo * oneMinusReflectivity;
+	
+	SpecularCommonData o = (SpecularCommonData)0;
+	o.diffColor = diffColor;
+	o.specColor = specColor;
+	o.oneMinusReflectivity = oneMinusReflectivity;
+	o.smoothness = smoothness;
+	
+#if defined(_ALPHAPREMULTIPLY_ON) && (SHADER_TARGET >= 30)
+	// Reflectivity 'removes' from the rest of components, including Transparency
+	// outAlpha = 1-(1-alpha)*(1-reflectivity) = 1-(oneMinusReflectivity - alpha*oneMinusReflectivity) =
+	//          = 1-oneMinusReflectivity + alpha*oneMinusReflectivity
+	//o.alpha = 1-oneMinusReflectivity + albedo.a*oneMinusReflectivity;
+	o.alpha = albedo.a;
+#else
+	o.alpha = albedo.a;
+#endif
+	
+	return o;
+}
+inline half SmoothnessToPerceptualRoughness(half smoothness)
+{
+	return (1 - smoothness);
+}
+
+inline half PerceptualRoughnessToRoughness(half perceptualRoughness)
+{
+	return perceptualRoughness * perceptualRoughness;
+}
+
+// Ref: http://jcgt.org/published/0003/02/03/paper.pdf
+inline half SmithJointGGXVisibilityTerm (half NdotL, half NdotV, half roughness)
+{
+#if 0
+	// Original formulation:
+	//	lambda_v	= (-1 + sqrt(a2 * (1 - NdotL2) / NdotL2 + 1)) * 0.5f;
+	//	lambda_l	= (-1 + sqrt(a2 * (1 - NdotV2) / NdotV2 + 1)) * 0.5f;
+	//	G			= 1 / (1 + lambda_v + lambda_l);
+
+	// Reorder code to be more optimal
+	half a			= roughness;
+	half a2			= a * a;
+
+	half lambdaV	= NdotL * sqrt((-NdotV * a2 + NdotV) * NdotV + a2);
+	half lambdaL	= NdotV * sqrt((-NdotL * a2 + NdotL) * NdotL + a2);
+
+	// Simplify visibility term: (2.0f * NdotL * NdotV) /  ((4.0f * NdotL * NdotV) * (lambda_v + lambda_l + 1e-5f));
+	return 0.5f / (lambdaV + lambdaL + 1e-5f);	// This function is not intended to be running on Mobile,
+												// therefore epsilon is smaller than can be represented by half
+#else
+    // Approximation of the above formulation (simplify the sqrt, not mathematically correct but close enough)
+	half a = roughness;
+	half lambdaV = NdotL * (NdotV * (1 - a) + a);
+	half lambdaL = NdotV * (NdotL * (1 - a) + a);
+
+	return 0.5f / (lambdaV + lambdaL + 1e-5f);
+#endif
+}
+
+inline half GGXTerm (half NdotH, half roughness)
+{
+	half a2 = roughness * roughness;
+	half d = (NdotH * a2 - NdotH) * NdotH + 1.0f; // 2 mad
+	return UNITY_INV_PI * a2 / (d * d + 1e-7f); // This function is not intended to be running on Mobile,
+											// therefore epsilon is smaller than what can be represented by half
+}
+
+inline half3 FresnelTerm (half3 F0, half cosA)
+{
+	half t = pow5 (1 - cosA);	// ala Schlick interpoliation
+	return F0 + (1-F0) * t;
+}
+
+inline half3 FresnelLerp (half3 F0, half F90, half cosA)
+{
+	half t = pow5 (1 - cosA);	// ala Schlick interpoliation
+	return lerp (F0, F90, t);
+}
+
+// Note: Disney diffuse must be multiply by diffuseAlbedo / PI. This is done outside of this function.
+inline half DisneyDiffuse(half NdotV, half NdotL, half LdotH, half perceptualRoughness)
+{
+	half fd90 = 0.5 + 2 * LdotH * LdotH * perceptualRoughness;
+	// Two schlick fresnel term
+	half lightScatter	= (1 + (fd90 - 1) * pow5(1 - NdotL));
+	half viewScatter	= (1 + (fd90 - 1) * pow5(1 - NdotV));
+
+	return lightScatter * viewScatter;
+}
+
+// Main Physically Based BRDF
+// Derived from Disney work and based on Torrance-Sparrow micro-facet model
+//
+//   BRDF = kD / pi + kS * (D * V * F) / 4
+//   I = BRDF * NdotL
+//
+// * NDF (depending on UNITY_BRDF_GGX):
+//  a) Normalized BlinnPhong
+//  b) GGX
+// * Smith for Visiblity term
+// * Schlick approximation for Fresnel
+SpecularLightData calculatePhysicsBasedSpecularLight(half3 specColor, half oneMinusReflectivity, half smoothness, half3 normal, half3 viewDir, half3 lightdir, half3 lightColor, half3 indirectDiffuse, half3 indirectSpecular)
+{
+	half perceptualRoughness = SmoothnessToPerceptualRoughness (smoothness);
+	half3 halfDir = safeNormalize (lightdir + viewDir);
+
+// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping
+// In this case normal should be modified to become valid (i.e facing camera) and not cause weird artifacts.
+// but this operation adds few ALU and users may not want it. Alternative is to simply take the abs of NdotV (less correct but works too).
+// Following define allow to control this. Set it to 0 if ALU is critical on your platform.
+// This correction is interesting for GGX with SmithJoint visibility function because artifacts are more visible in this case due to highlight edge of rough surface
+// Edit: Disable this code by default for now as it is not compatible with two sided lighting used in SpeedTree.
+#define UNITY_HANDLE_CORRECTLY_NEGATIVE_NDOTV 0 
+
+#if UNITY_HANDLE_CORRECTLY_NEGATIVE_NDOTV
+	// The amount we shift the normal toward the view vector is defined by the dot product.
+	half shiftAmount = dot(normal, viewDir);
+	normal = shiftAmount < 0.0f ? normal + viewDir * (-shiftAmount + 1e-5f) : normal;
+	// A re-normalization should be applied here but as the shift is small we don't do it to save ALU.
+	//normal = normalize(normal);
+
+	half nv = saturate(dot(normal, viewDir)); // TODO: this saturate should no be necessary here
+#else
+	half nv = abs(dot(normal, viewDir));	// This abs allow to limit artifact
+#endif
+
+	half nl = saturate(dot(normal, lightdir));
+	half nh = saturate(dot(normal, halfDir));
+
+	half lv = saturate(dot(lightdir, viewDir));
+	half lh = saturate(dot(lightdir, halfDir));
+
+	// Diffuse term
+	half diffuseTerm = DisneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;
+
+	// Specular term
+	// HACK: theoretically we should divide diffuseTerm by Pi and not multiply specularTerm!
+	// BUT 1) that will make shader look significantly darker than Legacy ones
+	// and 2) on engine side "Non-important" lights have to be divided by Pi too in cases when they are injected into ambient SH
+	half roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
+	half V = SmithJointGGXVisibilityTerm (nl, nv, roughness);
+	half D = GGXTerm (nh, roughness);
+
+	half specularTerm = V*D * UNITY_PI; // Torrance-Sparrow model, Fresnel is applied later
+
+#	ifdef UNITY_COLORSPACE_GAMMA
+		specularTerm = sqrt(max(1e-4h, specularTerm));
+#	endif
+
+	// specularTerm * nl can be NaN on Metal in some cases, use max() to make sure it's a sane value
+	specularTerm = max(0, specularTerm * nl);
+
+	// surfaceReduction = Int D(NdotH) * NdotH * Id(NdotL>0) dH = 1/(roughness^2+1)
+	half surfaceReduction;
+#	ifdef UNITY_COLORSPACE_GAMMA
+		surfaceReduction = 1.0 - 0.28f * roughness * perceptualRoughness;		// 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]
+#	else
+		surfaceReduction = 1.0 / (roughness*roughness + 1.0);			// fade \in [0.5;1]
+#	endif
+
+	// To provide true Lambert lighting, we need to be able to kill specular completely.
+	specularTerm *= any(specColor) ? 1.0 : 0.0;
+
+	half grazingTerm = saturate(smoothness + (1-oneMinusReflectivity));
+	
+	SpecularLightData outData = (SpecularLightData)0;
+	outData.lighting = indirectDiffuse + lightColor * diffuseTerm;
+	outData.specular = (specularTerm * lightColor * FresnelTerm (specColor, lh)) + (surfaceReduction * indirectSpecular * FresnelLerp (specColor, grazingTerm, nv));
+	return outData;
+}
+
+#endif // _SPECULAR  && _SPECULAR_GLOSSMAP 
+
+#endif // SPRITE_SPECULAR_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteSpecular.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: f195336fc94457241a37a0aa85923681
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 72 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc

@@ -0,0 +1,72 @@
+#ifndef SPRITE_UNLIT_INCLUDED
+#define SPRITE_UNLIT_INCLUDED
+
+#include "ShaderShared.cginc"
+
+////////////////////////////////////////
+// Vertex structs
+//
+				
+struct VertexInput
+{
+	float4 vertex : POSITION;
+	float4 texcoord : TEXCOORD0;
+	fixed4 color : COLOR;
+	UNITY_INSTANCE_ID
+};
+
+struct VertexOutput
+{
+	float4 pos : SV_POSITION;
+	float2 texcoord : TEXCOORD0;
+	fixed4 color : COLOR;
+#if defined(_FOG)
+	UNITY_FOG_COORDS(1)
+#endif // _FOG	
+
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+////////////////////////////////////////
+// Vertex program
+//
+
+VertexOutput vert(VertexInput input)
+{
+	VertexOutput output;
+	
+	UNITY_SETUP_INSTANCE_ID(input);
+    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
+	
+	output.pos = calculateLocalPos(input.vertex);	
+	output.texcoord = calculateTextureCoord(input.texcoord);
+	output.color = calculateVertexColor(input.color);
+
+#if defined(_FOG)
+	UNITY_TRANSFER_FOG(output,output.pos);
+#endif // _FOG
+	
+	return output;
+}
+
+////////////////////////////////////////
+// Fragment program
+//
+
+
+
+
+fixed4 frag(VertexOutput input) : SV_Target
+{
+	fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
+	ALPHA_CLIP(texureColor, input.color)
+
+	fixed4 pixel = calculatePixel(texureColor, input.color);
+	
+	COLORISE(pixel)
+	APPLY_FOG(pixel, input)
+	
+	return pixel;
+}
+
+#endif // SPRITE_UNLIT_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 072e7b07ec7fb1346a9dcd3bcbbb7111
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 474 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc

@@ -0,0 +1,474 @@
+#ifndef SPRITE_VERTEX_LIGHTING_INCLUDED
+#define SPRITE_VERTEX_LIGHTING_INCLUDED
+	
+#include "ShaderShared.cginc"
+#include "SpriteLighting.cginc"
+#include "SpriteSpecular.cginc"
+
+////////////////////////////////////////
+// Defines
+//
+
+//Define to use spot lights (more expensive)
+#define SPOT_LIGHTS
+
+//Have to process lighting per pixel if using normal maps or a diffuse ramp or rim lighting or specular
+#if defined(_NORMALMAP) || defined(_DIFFUSE_RAMP) || defined(_RIM_LIGHTING) || defined(SPECULAR)
+#define PER_PIXEL_LIGHTING
+#endif
+
+//Turn off bump mapping and diffuse ramping on older shader models as they dont support needed number of outputs
+#if defined(PER_PIXEL_LIGHTING) && (SHADER_TARGET < 30)
+	#undef PER_PIXEL_LIGHTING
+	#undef _NORMALMAP
+	#undef _DIFFUSE_RAMP
+	#undef _RIM_LIGHTING
+#endif
+
+//In D3D9 only have a max of 9 TEXCOORD so can't have diffuse ramping or fog or rim lighting if processing lights per pixel
+#if defined(SHADER_API_D3D9) && defined(PER_PIXEL_LIGHTING)
+	#if defined(_NORMALMAP)
+		#undef _DIFFUSE_RAMP
+		#undef _FOG
+		#undef _RIM_LIGHTING
+	#elif defined(_DIFFUSE_RAMP)
+		#undef _FOG
+		#undef _RIM_LIGHTING
+	#elif defined(_RIM_LIGHTING)
+		#undef _FOG
+		#undef _DIFFUSE_RAMP
+	#else
+		#undef _DIFFUSE_RAMP
+		#undef _RIM_LIGHTING
+	#endif
+#endif
+
+#if defined(PER_PIXEL_LIGHTING)
+	#if defined(_NORMALMAP) && defined(_DIFFUSE_RAMP)
+		#define ATTENUATIONS TEXCOORD9
+		#if defined(_RIM_LIGHTING)
+			#define _POS_WORLD_INDEX TEXCOORD10
+			#define _FOG_COORD_INDEX 11
+		#else
+			#define _FOG_COORD_INDEX 10
+		#endif
+	#elif defined(_NORMALMAP) != defined(_DIFFUSE_RAMP)
+		#define ATTENUATIONS TEXCOORD8
+		#if defined(_RIM_LIGHTING)
+			#define _POS_WORLD_INDEX TEXCOORD9
+			#define _FOG_COORD_INDEX 10
+		#else
+			#define _FOG_COORD_INDEX 9
+		#endif
+	#else //!_DIFFUSE_RAMP && !_NORMALMAP
+		#if defined(_RIM_LIGHTING)
+			#define _POS_WORLD_INDEX TEXCOORD8
+			#define _FOG_COORD_INDEX 9
+		#else
+			#define _FOG_COORD_INDEX 8
+		#endif
+	#endif
+#else //!PER_PIXEL_LIGHTING
+	#define _FOG_COORD_INDEX 2
+#endif
+
+////////////////////////////////////////
+// Vertex output struct
+//
+
+struct VertexOutput
+{
+	float4 pos : SV_POSITION;				
+	fixed4 color : COLOR;
+	float3 texcoord : TEXCOORD0;
+	
+#if defined(PER_PIXEL_LIGHTING)
+
+	half4 VertexLightInfo0 : TEXCOORD1; 
+	half4 VertexLightInfo1 : TEXCOORD2;
+	half4 VertexLightInfo2 : TEXCOORD3;  
+	half4 VertexLightInfo3 : TEXCOORD4;
+	half4 VertexLightInfo4 : TEXCOORD5;
+	
+	#if defined(_NORMALMAP)
+		half4 normalWorld : TEXCOORD6;
+		half4 tangentWorld : TEXCOORD7;
+		half4 binormalWorld : TEXCOORD8;
+	#else
+		half3 normalWorld : TEXCOORD6;
+		half3 VertexLightInfo5 : TEXCOORD7;  
+	#endif
+	#if defined(_DIFFUSE_RAMP)
+		half4 LightAttenuations : ATTENUATIONS;
+	#endif
+	#if defined(_RIM_LIGHTING)
+		float4 posWorld : _POS_WORLD_INDEX;
+	#endif
+
+#else //!PER_PIXEL_LIGHTING
+
+	half3 FullLighting : TEXCOORD1; 
+	
+#endif // !PER_PIXEL_LIGHTING
+
+#if defined(_FOG)
+	UNITY_FOG_COORDS(_FOG_COORD_INDEX)
+#endif // _FOG
+
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+////////////////////////////////////////
+// Light calculations
+//
+
+struct VertexLightInfo
+{
+	half3 lightDirection;
+	fixed3 lightColor;
+	
+#if defined(_DIFFUSE_RAMP)	
+	float attenuation;
+#endif // _DIFFUSE_RAMP
+};
+
+inline VertexLightInfo getVertexLightAttenuatedInfo(int index, float3 viewPos)
+{
+	VertexLightInfo lightInfo;
+	
+	//For directional lights unity_LightPosition.w is set to zero
+	lightInfo.lightDirection = unity_LightPosition[index].xyz - viewPos.xyz * unity_LightPosition[index].w;
+	float lengthSq = dot(lightInfo.lightDirection, lightInfo.lightDirection);
+	
+	// don't produce NaNs if some vertex position overlaps with the light
+	lengthSq = max(lengthSq, 0.000001);
+		
+	lightInfo.lightDirection *= rsqrt(lengthSq);
+	
+	float attenuation = 1.0 / (1.0 + lengthSq * unity_LightAtten[index].z);	
+	
+#if defined(SPOT_LIGHTS)
+	//Spot light attenuation - for non-spot lights unity_LightAtten.x is set to -1 and y is set to 1
+	{
+		float rho = max (0, dot(lightInfo.lightDirection, unity_SpotDirection[index].xyz));
+		float spotAtt = (rho - unity_LightAtten[index].x) * unity_LightAtten[index].y;
+		attenuation *= saturate(spotAtt);
+	}
+#endif // SPOT_LIGHTS
+	
+	//If using a diffuse ramp texture then need to pass through the lights attenuation, otherwise premultiply the light color with it
+#if defined(_DIFFUSE_RAMP)	
+	lightInfo.lightColor = unity_LightColor[index].rgb;
+	lightInfo.attenuation = attenuation;
+#else
+	lightInfo.lightColor = unity_LightColor[index].rgb * attenuation;
+#endif // _DIFFUSE_RAMP
+	
+	return lightInfo;
+}
+
+fixed3 calculateAmbientLight(half3 normalWorld)
+{
+#if defined(_SPHERICAL_HARMONICS)	
+
+	//Magic constants used to tweak ambient to approximate pixel shader spherical harmonics 
+	static const fixed3 worldUp = fixed3(0,1,0);
+	static const float skyGroundDotMul = 2.5;
+	static const float minEquatorMix = 0.5;
+	static const float equatorColorBlur = 0.33;
+	
+	float upDot = dot(normalWorld, worldUp);
+	
+	//Fade between a flat lerp from sky to ground and a 3 way lerp based on how bright the equator light is.
+	//This simulates how directional lights get blurred using spherical harmonics
+	
+	//Work out color from ground and sky, ignoring equator
+	float adjustedDot = upDot * skyGroundDotMul;
+	fixed3 skyGroundColor = lerp(unity_AmbientGround, unity_AmbientSky, saturate((adjustedDot + 1.0) * 0.5));
+	
+	//Work out equator lights brightness
+	float equatorBright = saturate(dot(unity_AmbientEquator.rgb, unity_AmbientEquator.rgb));
+	
+	//Blur equator color with sky and ground colors based on how bright it is.
+	fixed3 equatorBlurredColor = lerp(unity_AmbientEquator, saturate(unity_AmbientEquator + unity_AmbientGround + unity_AmbientSky), equatorBright * equatorColorBlur);
+	
+	//Work out 3 way lerp inc equator light
+	fixed3 equatorColor = lerp(equatorBlurredColor, unity_AmbientGround, -upDot) * step(upDot, 0) + lerp(equatorBlurredColor, unity_AmbientSky, upDot) * step(0, upDot);
+	
+	//Mix the two colors together based on how bright the equator light is
+	return lerp(skyGroundColor, equatorColor, saturate(equatorBright + minEquatorMix));
+
+#else // !_SPHERICAL_HARMONICS
+
+	//Flat ambient is just the sky color
+	return unity_AmbientSky.rgb;
+	
+#endif // !_SPHERICAL_HARMONICS	
+}
+
+////////////////////////////////////////
+// Light Packing Functions
+//
+
+#if defined(_DIFFUSE_RAMP)
+
+inline fixed3 calculateLightDiffuse(fixed3 lightColor, half3 viewNormal, half3 lightViewDir, float attenuation)
+{
+	float angleDot = max(0, dot(viewNormal, lightViewDir));
+	fixed3 lightDiffuse = calculateRampedDiffuse(lightColor, attenuation, angleDot);
+	return lightDiffuse;
+}
+
+#else
+
+inline fixed3 calculateLightDiffuse(fixed3 attenuatedLightColor, half3 viewNormal, half3 lightViewDir)
+{
+	float angleDot = max(0, dot(viewNormal, lightViewDir));
+	fixed3 lightDiffuse = attenuatedLightColor * angleDot;
+	
+	return lightDiffuse;
+}
+
+#endif // _NORMALMAP
+
+
+#if defined(PER_PIXEL_LIGHTING)
+
+#define VERTEX_LIGHT_0_DIR VertexLightInfo0.xyz
+#define VERTEX_LIGHT_0_R VertexLightInfo4.x
+#define VERTEX_LIGHT_0_G VertexLightInfo4.y
+#define VERTEX_LIGHT_0_B VertexLightInfo4.z
+
+#define VERTEX_LIGHT_1_DIR  VertexLightInfo1.xyz
+#define VERTEX_LIGHT_1_R VertexLightInfo0.w
+#define VERTEX_LIGHT_1_G VertexLightInfo1.w
+#define VERTEX_LIGHT_1_B VertexLightInfo2.w
+
+#define VERTEX_LIGHT_2_DIR VertexLightInfo2.xyz
+#define VERTEX_LIGHT_2_R VertexLightInfo3.w
+#define VERTEX_LIGHT_2_G VertexLightInfo4.w
+#define VERTEX_LIGHT_2_B texcoord.z
+
+#define VERTEX_LIGHT_3_DIR VertexLightInfo3.xyz
+
+#if defined(_NORMALMAP)
+	#define VERTEX_LIGHT_3_R normalWorld.w
+	#define VERTEX_LIGHT_3_G tangentWorld.w
+	#define VERTEX_LIGHT_3_B binormalWorld.w
+#else
+	#define VERTEX_LIGHT_3_R VertexLightInfo5.x
+	#define VERTEX_LIGHT_3_G VertexLightInfo5.y
+	#define VERTEX_LIGHT_3_B VertexLightInfo5.z
+#endif
+	
+#if defined(_DIFFUSE_RAMP)
+
+	#define LIGHT_DIFFUSE_ATTEN_0 LightAttenuations.x
+	#define LIGHT_DIFFUSE_ATTEN_1 LightAttenuations.y
+	#define LIGHT_DIFFUSE_ATTEN_2 LightAttenuations.z
+	#define LIGHT_DIFFUSE_ATTEN_3 LightAttenuations.w
+
+	#define PACK_VERTEX_LIGHT_DIFFUSE(index, output, lightInfo) \
+	{ \
+		output.LIGHT_DIFFUSE_ATTEN_##index = lightInfo.attenuation; \
+	}
+	
+	#define ADD_VERTEX_LIGHT_DIFFUSE(index, diffuse, input, lightColor, viewNormal, lightViewDir) \
+	{ \
+		diffuse += calculateLightDiffuse(lightColor, viewNormal, lightViewDir, input.LIGHT_DIFFUSE_ATTEN_##index); \
+	}
+#else
+	#define PACK_VERTEX_LIGHT_DIFFUSE(index, output, lightInfo)
+	#define ADD_VERTEX_LIGHT_DIFFUSE(index, diffuse, input, lightColor, viewNormal, lightViewDir) \
+	{ \
+		diffuse += calculateLightDiffuse(lightColor, viewNormal, lightViewDir); \
+	}
+#endif
+
+#define PACK_VERTEX_LIGHT(index, output, viewPos) \
+	{ \
+		VertexLightInfo lightInfo = getVertexLightAttenuatedInfo(index, viewPos); \
+		output.VERTEX_LIGHT_##index##_DIR = lightInfo.lightDirection; \
+		output.VERTEX_LIGHT_##index##_R = lightInfo.lightColor.r; \
+		output.VERTEX_LIGHT_##index##_G = lightInfo.lightColor.g; \
+		output.VERTEX_LIGHT_##index##_B = lightInfo.lightColor.b; \
+		PACK_VERTEX_LIGHT_DIFFUSE(index, output, lightInfo); \
+	}
+
+#define ADD_VERTEX_LIGHT(index, input, viewNormal, diffuse) \
+	{ \
+		half3 lightViewDir = input.VERTEX_LIGHT_##index##_DIR; \
+		fixed3 lightColor = fixed3(input.VERTEX_LIGHT_##index##_R, input.VERTEX_LIGHT_##index##_G, input.VERTEX_LIGHT_##index##_B); \
+		ADD_VERTEX_LIGHT_DIFFUSE(index, diffuse, input, lightColor, viewNormal, lightViewDir) \
+	}
+	
+#if defined(SPECULAR)
+
+#define ADD_VERTEX_LIGHT_SPEC(index, input, viewNormal, specData, combinedLightData, indirectDiffuse, indirectSpecular) \
+	{ \
+		half3 lightViewDir = input.VERTEX_LIGHT_##index##_DIR; \
+		fixed3 lightColor = fixed3(input.VERTEX_LIGHT_##index##_R, input.VERTEX_LIGHT_##index##_G, input.VERTEX_LIGHT_##index##_B); \
+		SpecularLightData lightData = calculatePhysicsBasedSpecularLight(specData.specColor, specData.oneMinusReflectivity, specData.smoothness, viewNormal, fixed3(0,0,1), lightViewDir, lightColor, indirectDiffuse, indirectSpecular); \
+		combinedLightData.lighting += lightData.lighting; \
+		combinedLightData.specular += lightData.specular; \
+	}
+
+#endif
+	
+#else //!PER_PIXEL_LIGHTING
+
+////////////////////////////////////////
+// Vertex Only Functions
+//
+
+inline fixed3 calculateLightDiffuse(int index, float3 viewPos, half3 viewNormal)
+{
+	VertexLightInfo lightInfo = getVertexLightAttenuatedInfo(index, viewPos);
+	float angleDot = max(0, dot(viewNormal, lightInfo.lightDirection));
+	return lightInfo.lightColor * angleDot;
+}
+
+#endif // !PER_PIXEL_LIGHTING
+	
+////////////////////////////////////////
+// Vertex program
+//
+
+VertexOutput vert(VertexInput input)
+{
+	VertexOutput output;
+	
+	UNITY_SETUP_INSTANCE_ID(input);
+    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
+	
+	output.pos = calculateLocalPos(input.vertex);
+	output.color = calculateVertexColor(input.color);
+	output.texcoord = float3(calculateTextureCoord(input.texcoord), 0);
+	
+	float3 viewPos = mul(UNITY_MATRIX_MV, input.vertex);
+#if defined(FIXED_NORMALS_BACKFACE_RENDERING) || defined(_RIM_LIGHTING)
+	float4 powWorld = calculateWorldPos(input.vertex);
+#endif	
+
+	float backFaceSign = 1;
+#if defined(FIXED_NORMALS_BACKFACE_RENDERING)	
+	backFaceSign = calculateBackfacingSign(powWorld.xyz);
+#endif	
+
+#if defined(PER_PIXEL_LIGHTING)
+	
+	#if defined(_RIM_LIGHTING)
+		output.posWorld = powWorld;
+	#endif
+
+	PACK_VERTEX_LIGHT(0, output, viewPos)
+	PACK_VERTEX_LIGHT(1, output, viewPos)
+	PACK_VERTEX_LIGHT(2, output, viewPos)
+	PACK_VERTEX_LIGHT(3, output, viewPos)
+	
+	output.normalWorld.xyz = calculateSpriteWorldNormal(input, backFaceSign);
+	
+	#if defined(_NORMALMAP)
+		output.tangentWorld.xyz = calculateWorldTangent(input.tangent);
+		output.binormalWorld.xyz = calculateSpriteWorldBinormal(input, output.normalWorld, output.tangentWorld, backFaceSign);	
+	#endif
+	
+#else // !PER_PIXEL_LIGHTING
+	
+	//Just pack full lighting
+	float3 viewNormal = calculateSpriteViewNormal(input, backFaceSign);
+	//Get Ambient diffuse
+	float3 normalWorld = calculateSpriteWorldNormal(input, backFaceSign);
+	fixed3 ambient = calculateAmbientLight(normalWorld);	
+	
+	fixed3 diffuse = calculateLightDiffuse(0, viewPos, viewNormal);
+	diffuse += calculateLightDiffuse(1, viewPos, viewNormal);
+	diffuse += calculateLightDiffuse(2, viewPos, viewNormal);
+	diffuse += calculateLightDiffuse(3, viewPos, viewNormal);
+	
+	output.FullLighting = ambient + diffuse;
+	
+#endif // !PER_PIXEL_LIGHTING
+	
+#if defined(_FOG)
+	UNITY_TRANSFER_FOG(output, output.pos);
+#endif // _FOG	
+		
+	return output;
+}
+
+////////////////////////////////////////
+// Fragment program
+//
+
+fixed4 frag(VertexOutput input) : SV_Target
+{
+	fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
+	ALPHA_CLIP(texureColor, input.color)
+	
+#if defined(PER_PIXEL_LIGHTING)
+	
+	#if defined(_NORMALMAP)
+		half3 normalWorld = calculateNormalFromBumpMap(input.texcoord.xy, input.tangentWorld.xyz, input.binormalWorld.xyz, input.normalWorld.xyz);
+	#else
+		half3 normalWorld = input.normalWorld.xyz;
+	#endif
+	
+	//Get Ambient diffuse
+	fixed3 ambient = calculateAmbientLight(normalWorld);
+	
+	half3 normalView = normalize(mul((float3x3)UNITY_MATRIX_V, normalWorld));
+	
+#if defined(SPECULAR)
+
+	SpecularCommonData specData = getSpecularData(input.texcoord.xy, texureColor, input.color);
+	
+	SpecularLightData combinedLightData = (SpecularLightData)0;
+	ADD_VERTEX_LIGHT_SPEC(0, input, normalView, specData, combinedLightData, ambient, unity_IndirectSpecColor.rgb)
+	ADD_VERTEX_LIGHT_SPEC(1, input, normalView, specData, combinedLightData, fixed3(0,0,0), fixed3(0,0,0))
+	ADD_VERTEX_LIGHT_SPEC(2, input, normalView, specData, combinedLightData, fixed3(0,0,0), fixed3(0,0,0))
+	ADD_VERTEX_LIGHT_SPEC(3, input, normalView, specData, combinedLightData, fixed3(0,0,0), fixed3(0,0,0))
+	
+	fixed4 pixel = calculateLitPixel(fixed4(specData.diffColor, specData.alpha), combinedLightData.lighting);
+	pixel.rgb += combinedLightData.specular * specData.alpha;
+	
+	APPLY_EMISSION_SPECULAR(pixel, input.texcoord)
+	
+#else
+		
+	//Find vertex light diffuse
+	fixed3 diffuse = fixed3(0,0,0);
+	
+	//Add each vertex light to diffuse
+	ADD_VERTEX_LIGHT(0, input, normalView, diffuse)
+	ADD_VERTEX_LIGHT(1, input, normalView, diffuse)
+	ADD_VERTEX_LIGHT(2, input, normalView, diffuse)
+	ADD_VERTEX_LIGHT(3, input, normalView, diffuse)
+	
+	fixed3 lighting = ambient + diffuse;
+	
+	APPLY_EMISSION(lighting, input.texcoord.xy)
+
+	fixed4 pixel = calculateLitPixel(texureColor, input.color, lighting);
+	
+#endif
+	
+#if defined(_RIM_LIGHTING)
+	pixel.rgb = applyRimLighting(input.posWorld, normalWorld, pixel);
+#endif
+	
+#else // !PER_PIXEL_LIGHTING
+	
+	APPLY_EMISSION(input.FullLighting, input.texcoord.xy)
+	
+	fixed4 pixel = calculateLitPixel(texureColor, input.color, input.FullLighting);
+
+#endif // !PER_PIXEL_LIGHTING	
+	
+	COLORISE(pixel)
+	APPLY_FOG(pixel, input)
+	
+	return pixel;
+}
+
+#endif // SPRITE_VERTEX_LIGHTING_INCLUDED

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: c739dcf9dbcab944898d0b796e11afb9
+timeCreated: 1494092582
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 522 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthNormalsTexture.shader

@@ -0,0 +1,522 @@
+Shader "Hidden/Sprite-CameraDepthNormalsTexture" {
+
+// Use this shader to render a DepthNormals texture for a camera with correct sprite normals (using camera.RenderWithShader with replacement tag "RenderType")
+
+Properties {
+	_MainTex ("", 2D) = "white" {}
+	_Cutoff ("", Float) = 0.5
+	_Color ("", Color) = (1,1,1,1)
+}
+
+SubShader {
+	Tags { "RenderType"="Sprite" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "CGIncludes/ShaderShared.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+uniform float4 _FixedNormal;
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	o.nz.xyz = COMPUTE_VIEW_NORMAL;
+	o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG 
+		}
+	}
+	
+SubShader {
+	Tags { "RenderType"="SpriteViewSpaceFixedNormal" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "CGIncludes/ShaderShared.cginc"
+#include "CGIncludes/SpriteLighting.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	o.nz.xyz = getFixedNormal();
+	o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG 
+		}
+	}
+
+SubShader {
+	Tags { "RenderType"="SpriteModelSpaceFixedNormal" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "CGIncludes/ShaderShared.cginc"
+#include "CGIncludes/SpriteLighting.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	float3 worldPos = mul(unity_ObjectToWorld, v.vertex);
+	float3 normal = getFixedNormal();
+//Only do this if backface is enabled :/
+	normal *= calculateBackfacingSign(worldPos.xyz);
+//
+	o.nz.xyz = normalize(mul((float3x3)UNITY_MATRIX_IT_MV, normal));
+	o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG 
+		}
+	}
+	
+SubShader {
+	Tags { "RenderType"="Opaque" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float4 nz : TEXCOORD0;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+fixed4 frag(v2f i) : SV_Target {
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TransparentCutout" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+uniform float4 _MainTex_ST;
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+uniform fixed4 _Color;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a*_Color.a - _Cutoff );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeBark" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "Lighting.cginc"
+#include "UnityBuiltin3xTreeLibrary.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_full v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    TreeVertBark(v);
+	
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+fixed4 frag( v2f i ) : SV_Target {
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeLeaf" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "Lighting.cginc"
+#include "UnityBuiltin3xTreeLibrary.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_full v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    TreeVertLeaf(v);
+	
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag( v2f i ) : SV_Target {
+	half alpha = tex2D(_MainTex, i.uv).a;
+
+	clip (alpha - _Cutoff);
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeOpaque" "DisableBatching"="True" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	float4 nz : TEXCOORD0;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+fixed4 frag(v2f i) : SV_Target {
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+} 
+
+SubShader {
+	Tags { "RenderType"="TreeTransparentCutout" "DisableBatching"="True" }
+	Pass {
+		Cull Back
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+    float4 texcoord : TEXCOORD0;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	half alpha = tex2D(_MainTex, i.uv).a;
+
+	clip (alpha - _Cutoff);
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+	Pass {
+		Cull Front
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+    float4 texcoord : TEXCOORD0;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = -COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a - _Cutoff );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+
+}
+
+SubShader {
+	Tags { "RenderType"="TreeBillboard" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert (appdata_tree_billboard v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv.x = v.texcoord.x;
+	o.uv.y = v.texcoord.y > 0;
+    o.nz.xyz = float3(0,0,1);
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a - 0.001 );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="GrassBillboard" }
+	Pass {
+		Cull Off		
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	fixed4 color : COLOR;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+v2f vert (appdata_full v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	WavingGrassBillboardVert (v);
+	o.color = v.color;
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	fixed alpha = texcol.a * i.color.a;
+	clip( alpha - _Cutoff );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="Grass" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	fixed4 color : COLOR;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+v2f vert (appdata_full v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	WavingGrassVert (v);
+	o.color = v.color;
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	fixed alpha = texcol.a * i.color.a;
+	clip( alpha - _Cutoff );
+	return EncodeDepthNormal (i.nz.w, i.nz.xyz);
+}
+ENDCG
+	}
+}
+
+Fallback Off
+}

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthNormalsTexture.shader.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 4794ea6b2d07cc546ba97a809b5f9ada
+timeCreated: 1494092583
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 518 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthTexture.shader

@@ -0,0 +1,518 @@
+Shader "Hidden/Sprite-CameraDepthTexture" {
+
+// Use this shader to render a Depth texture for a camera with soft edged Sprites (using camera.RenderWithShader with replacement tag "RenderType")
+// Note the depth is encoded into the pixels RGB not the full RGBA (alpha is needed for blending)
+
+Properties {
+	_MainTex ("", 2D) = "white" {}
+	_Cutoff ("", Float) = 0.5
+	_Color ("", Color) = (1,1,1,1)
+}
+
+SubShader {
+	Tags { "RenderType"="Sprite" }
+	Pass {
+		Cull Off
+		Blend SrcAlpha OneMinusSrcAlpha
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "CGIncludes/ShaderShared.cginc"
+#include "CGIncludes/ShaderMaths.cginc"
+
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	o.depth = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return fixed4(EncodeFloatRGB (i.depth), alpha);
+}
+ENDCG 
+		}
+	}
+	
+SubShader {
+	Tags { "RenderType"="SpriteViewSpaceFixedNormal" }
+	Pass {
+		Cull Off
+		Blend SrcAlpha OneMinusSrcAlpha
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "CGIncludes/ShaderShared.cginc"
+#include "CGIncludes/ShaderMaths.cginc"
+
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	o.depth = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return fixed4(EncodeFloatRGB (i.depth), alpha);
+}
+ENDCG 
+		}
+	}
+	
+SubShader {
+	Tags { "RenderType"="SpriteModelSpaceFixedNormal" }
+	Pass {
+		Cull Off
+		Blend SrcAlpha OneMinusSrcAlpha
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "CGIncludes/ShaderShared.cginc"
+#include "CGIncludes/ShaderMaths.cginc"
+
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	o.depth = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return fixed4(EncodeFloatRGB (i.depth), alpha);
+}
+ENDCG 
+		}
+	}
+	
+SubShader {
+	Tags { "RenderType"="Opaque" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "CGIncludes/ShaderMaths.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+    o.depth = COMPUTE_DEPTH_01;
+    return o;
+}
+fixed4 frag(v2f i) : SV_Target {
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TransparentCutout" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+uniform float4 _MainTex_ST;
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
+    o.depth = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+uniform fixed4 _Color;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a*_Color.a - _Cutoff );
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeBark" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "Lighting.cginc"
+#include "UnityBuiltin3xTreeLibrary.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float2 uv : TEXCOORD0;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_full v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    TreeVertBark(v);
+	
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.depth = COMPUTE_DEPTH_01;
+    return o;
+}
+fixed4 frag( v2f i ) : SV_Target {
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeLeaf" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "Lighting.cginc"
+#include "UnityBuiltin3xTreeLibrary.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float2 uv : TEXCOORD0;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_full v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    TreeVertLeaf(v);
+	
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.depth = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag( v2f i ) : SV_Target {
+	half alpha = tex2D(_MainTex, i.uv).a;
+
+	clip (alpha - _Cutoff);
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeOpaque" "DisableBatching"="True" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+    o.depth = COMPUTE_DEPTH_01;
+	return o;
+}
+fixed4 frag(v2f i) : SV_Target {
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+} 
+
+SubShader {
+	Tags { "RenderType"="TreeTransparentCutout" "DisableBatching"="True" }
+	Pass {
+		Cull Back
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+    float4 texcoord : TEXCOORD0;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.depth = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	half alpha = tex2D(_MainTex, i.uv).a;
+
+	clip (alpha - _Cutoff);
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+	Pass {
+		Cull Front
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+    float4 texcoord : TEXCOORD0;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.depth = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a - _Cutoff );
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+
+}
+
+SubShader {
+	Tags { "RenderType"="TreeBillboard" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert (appdata_tree_billboard v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv.x = v.texcoord.x;
+	o.uv.y = v.texcoord.y > 0;
+    o.depth = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a - 0.001 );
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="GrassBillboard" }
+	Pass {
+		Cull Off		
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	fixed4 color : COLOR;
+	float2 uv : TEXCOORD0;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+v2f vert (appdata_full v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	WavingGrassBillboardVert (v);
+	o.color = v.color;
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.depth = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	fixed alpha = texcol.a * i.color.a;
+	clip( alpha - _Cutoff );
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="Grass" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc" 
+#include "CGIncludes/ShaderMaths.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	fixed4 color : COLOR;
+	float2 uv : TEXCOORD0;
+	float depth : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+v2f vert (appdata_full v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	WavingGrassVert (v);
+	o.color = v.color;
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord;
+    o.depth = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	fixed alpha = texcol.a * i.color.a;
+	clip( alpha - _Cutoff );
+	return fixed4(EncodeFloatRGB (i.depth), 1);
+}
+ENDCG
+	}
+}
+
+Fallback Off
+}

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraDepthTexture.shader.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: f768a57e040cc48489ad8c7392a31154
+timeCreated: 1494092586
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 522 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraNormalsTexture.shader

@@ -0,0 +1,522 @@
+Shader "Hidden/Sprite-CameraNormalsTexture" {
+
+// Use this shader to render a Normals texture for a camera with correct sprite normals (using camera.RenderWithShader with replacement tag "RenderType")
+
+Properties {
+	_MainTex ("", 2D) = "white" {}
+	_Cutoff ("", Float) = 0.5
+	_Color ("", Color) = (1,1,1,1)
+}
+
+SubShader {
+	Tags { "RenderType"="Sprite" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "CGIncludes/ShaderShared.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+uniform float4 _FixedNormal;
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	o.nz.xyz = COMPUTE_VIEW_NORMAL;
+	o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return i.nz;
+}
+ENDCG 
+		}
+	}
+	
+SubShader {
+	Tags { "RenderType"="SpriteViewSpaceFixedNormal" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "CGIncludes/ShaderShared.cginc"
+#include "CGIncludes/SpriteLighting.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	o.nz.xyz = getFixedNormal();
+	o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return i.nz;
+}
+ENDCG 
+		}
+	}
+
+SubShader {
+	Tags { "RenderType"="SpriteModelSpaceFixedNormal" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "CGIncludes/ShaderShared.cginc"
+#include "CGIncludes/SpriteLighting.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = calculateTextureCoord(v.texcoord);
+	float3 worldPos = mul(unity_ObjectToWorld, v.vertex);
+	float3 normal = getFixedNormal();
+//Only do this if backface is enabled :/
+	normal *= calculateBackfacingSign(worldPos.xyz);
+//
+	o.nz.xyz = normalize(mul((float3x3)UNITY_MATRIX_IT_MV, normal));
+	o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = calculateTexturePixel(i.uv );
+	float alpha = texcol.a*_Color.a;
+	clip( alpha - _Cutoff );
+	return i.nz;
+}
+ENDCG 
+		}
+	}
+	
+SubShader {
+	Tags { "RenderType"="Opaque" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float4 nz : TEXCOORD0;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+fixed4 frag(v2f i) : SV_Target {
+	return i.nz;
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TransparentCutout" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+    float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+uniform float4 _MainTex_ST;
+v2f vert( appdata_base v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+uniform fixed4 _Color;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a*_Color.a - _Cutoff );
+	return i.nz;
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeBark" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "Lighting.cginc"
+#include "UnityBuiltin3xTreeLibrary.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_full v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    TreeVertBark(v);
+	
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+fixed4 frag( v2f i ) : SV_Target {
+	return i.nz;
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeLeaf" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "Lighting.cginc"
+#include "UnityBuiltin3xTreeLibrary.cginc"
+struct v2f {
+    float4 pos : SV_POSITION;
+    float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert( appdata_full v ) {
+    v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+    TreeVertLeaf(v);
+	
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+    return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag( v2f i ) : SV_Target {
+	half alpha = tex2D(_MainTex, i.uv).a;
+
+	clip (alpha - _Cutoff);
+	return i.nz;
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="TreeOpaque" "DisableBatching"="True" }
+	Pass {
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	float4 nz : TEXCOORD0;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+fixed4 frag(v2f i) : SV_Target {
+	return i.nz;
+}
+ENDCG
+	}
+} 
+
+SubShader {
+	Tags { "RenderType"="TreeTransparentCutout" "DisableBatching"="True" }
+	Pass {
+		Cull Back
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+    float4 texcoord : TEXCOORD0;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	half alpha = tex2D(_MainTex, i.uv).a;
+
+	clip (alpha - _Cutoff);
+	return i.nz;
+}
+ENDCG
+	}
+	Pass {
+		Cull Front
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+struct appdata {
+    float4 vertex : POSITION;
+    float3 normal : NORMAL;
+    fixed4 color : COLOR;
+    float4 texcoord : TEXCOORD0;
+	UNITY_INSTANCE_ID
+};
+v2f vert( appdata v ) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainAnimateTree(v.vertex, v.color.w);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = -COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a - _Cutoff );
+	return i.nz;
+}
+ENDCG
+	}
+
+}
+
+SubShader {
+	Tags { "RenderType"="TreeBillboard" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+v2f vert (appdata_tree_billboard v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv.x = v.texcoord.x;
+	o.uv.y = v.texcoord.y > 0;
+    o.nz.xyz = float3(0,0,1);
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	clip( texcol.a - 0.001 );
+	return i.nz;
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="GrassBillboard" }
+	Pass {
+		Cull Off		
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+
+struct v2f {
+	float4 pos : SV_POSITION;
+	fixed4 color : COLOR;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+v2f vert (appdata_full v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	WavingGrassBillboardVert (v);
+	o.color = v.color;
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord.xy;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	fixed alpha = texcol.a * i.color.a;
+	clip( alpha - _Cutoff );
+	return i.nz;
+}
+ENDCG
+	}
+}
+
+SubShader {
+	Tags { "RenderType"="Grass" }
+	Pass {
+		Cull Off
+CGPROGRAM
+#pragma target 3.0
+#pragma vertex vert
+#pragma fragment frag
+#include "UnityCG.cginc"
+#include "TerrainEngine.cginc"
+struct v2f {
+	float4 pos : SV_POSITION;
+	fixed4 color : COLOR;
+	float2 uv : TEXCOORD0;
+	float4 nz : TEXCOORD1;
+	UNITY_VERTEX_OUTPUT_STEREO
+};
+
+v2f vert (appdata_full v) {
+	v2f o;
+	UNITY_SETUP_INSTANCE_ID(v);
+	UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
+	WavingGrassVert (v);
+	o.color = v.color;
+	o.pos = UnityObjectToClipPos(v.vertex);
+	o.uv = v.texcoord;
+    o.nz.xyz = COMPUTE_VIEW_NORMAL;
+    o.nz.w = COMPUTE_DEPTH_01;
+	return o;
+}
+uniform sampler2D _MainTex;
+uniform fixed _Cutoff;
+fixed4 frag(v2f i) : SV_Target {
+	fixed4 texcol = tex2D( _MainTex, i.uv );
+	fixed alpha = texcol.a * i.color.a;
+	clip( alpha - _Cutoff );
+	return i.nz;
+}
+ENDCG
+	}
+}
+
+Fallback Off
+}

+ 9 - 0
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/CameraNormalsTexture.shader.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 537141eca02c6df4bb8b4f77567e9de2
+timeCreated: 1494092584
+licenseType: Free
+ShaderImporter:
+  defaultTextures: []
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 712 - 300
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/Editor/SpineSpriteShaderGUI.cs

@@ -28,65 +28,60 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
 
-using System;
 using UnityEngine;
 using UnityEditor;
 
 using SpineInspectorUtility = Spine.Unity.Editor.SpineInspectorUtility;
 
 public class SpineSpriteShaderGUI : ShaderGUI {
-	
-	#region Constants
-	const string ShaderVertexLit = "Spine/Sprite/Vertex Lit";
-	const string ShaderPixelLit = "Spine/Sprite/Pixel Lit";
-	const string ShaderUnlit = "Spine/Sprite/Unlit";
-
-	const int SolidQueue = 2000;
-	const int AlphaTestQueue = 2450;
-	const int TransparentQueue = 3000;
-
-	const string PremultipledAlpha = "_ALPHAPREMULTIPLY_ON";
-	const string Multiply = "_MULTIPLYBLEND";
-	const string Multiply2x = "_MULTIPLYBLEND_X2";
-	const string Additive = "_ADDITIVEBLEND";
-	const string SoftAdditive = "_ADDITIVEBLEND_SOFT";
-
-	const string _FIXED_NORMALS = "_FIXED_NORMALS";
-	const string _FIXED_NORMALS_BACK_RENDERING = "_FIXED_NORMALS_BACK_RENDERING";
-
-	const string _SPHERICAL_HARMONICS = "_SPHERICAL_HARMONICS";
-
-	enum eBlendMode {
+	static readonly string kShaderVertexLit = "Spine/Sprite/Vertex Lit";
+	static readonly string kShaderPixelLit = "Spine/Sprite/Pixel Lit";
+	static readonly string kShaderUnlit = "Spine/Sprite/Unlit";
+	static readonly int kSolidQueue = 2000;
+	static readonly int kAlphaTestQueue = 2450;
+	static readonly int kTransparentQueue = 3000;
+
+	private enum eBlendMode {
 		PreMultipliedAlpha,
 		StandardAlpha,
-		Solid,
+		Opaque,
 		Additive,
 		SoftAdditive,
 		Multiply,
 		Multiplyx2,
-	}
+	};
 
-	enum eLightMode { VertexLit, PixelLit, Unlit, }
+	private enum eLightMode {
+		VertexLit,
+		PixelLit,
+		Unlit,
+	};
 
-	enum eCulling {
+	private enum eCulling {
 		Off = 0,
-		Back = 2,
 		Front = 1,
-	}
-	#endregion
+		Back = 2,
+	};
+
+	private enum eNormalsMode {
+		MeshNormals = -1,
+		FixedNormalsViewSpace = 0,
+		FixedNormalsModelSpace = 1,
+	};
+
+	MaterialEditor _materialEditor;
 
 	MaterialProperty _mainTexture = null;
 	MaterialProperty _color = null;
 
-	MaterialProperty _emissionMap = null;
-	MaterialProperty _emissionColor = null;
-	MaterialProperty _emissionPower = null;
+	MaterialProperty _pixelSnap = null;
 
 	MaterialProperty _writeToDepth = null;
 	MaterialProperty _depthAlphaCutoff = null;
 	MaterialProperty _shadowAlphaCutoff = null;
 	MaterialProperty _renderQueue = null;
 	MaterialProperty _culling = null;
+	MaterialProperty _customRenderQueue = null;
 
 	MaterialProperty _overlayColor = null;
 	MaterialProperty _hue = null;
@@ -96,67 +91,120 @@ public class SpineSpriteShaderGUI : ShaderGUI {
 	MaterialProperty _rimPower = null;
 	MaterialProperty _rimColor = null;
 
-	MaterialEditor _materialEditor;
-
-	//Normals
 	MaterialProperty _bumpMap = null;
+	MaterialProperty _bumpScale = null;
 	MaterialProperty _diffuseRamp = null;
 	MaterialProperty _fixedNormal = null;
 
-	//Blend texture
 	MaterialProperty _blendTexture = null;
 	MaterialProperty _blendTextureLerp = null;
 
-	bool _firstTimeApply = true;
-	eLightMode _lightMode;
-	static bool showAdvanced = false;
+	MaterialProperty _emissionMap = null;
+	MaterialProperty _emissionColor = null;
+	MaterialProperty _emissionPower = null;
+
+	MaterialProperty _metallic = null;
+	MaterialProperty _metallicGlossMap = null;
+	MaterialProperty _smoothness = null;
+	MaterialProperty _smoothnessScale = null;
+
+	static GUIContent _albedoText = new GUIContent("Albedo", "Albedo (RGB) and Transparency (A)");
+	static GUIContent _altAlbedoText = new GUIContent("Secondary Albedo", "When a secondary albedo texture is set the albedo will be a blended mix of the two textures based on the blend value.");
+	static GUIContent _metallicMapText = new GUIContent("Metallic", "Metallic (R) and Smoothness (A)");
+	static GUIContent _smoothnessText = new GUIContent("Smoothness", "Smoothness value");
+	static GUIContent _smoothnessScaleText = new GUIContent("Smoothness", "Smoothness scale factor");
+	static GUIContent _normalMapText = new GUIContent("Normal Map", "Normal Map");
+	static GUIContent _emissionText = new GUIContent("Emission", "Emission (RGB)");
+	static GUIContent _emissionPowerText = new GUIContent("Emission Power");
+	static GUIContent _emissionToggleText = new GUIContent("Emission", "Enable Emission.");
+	static GUIContent _diffuseRampText = new GUIContent("Diffuse Ramp", "A black and white gradient can be used to create a 'Toon Shading' effect.");
+	static GUIContent _depthText = new GUIContent("Write to Depth", "Write to Depth Buffer by clipping alpha.");
+	static GUIContent _depthAlphaCutoffText = new GUIContent("Depth Alpha Cutoff", "Threshold for depth write alpha cutoff");
+	static GUIContent _shadowAlphaCutoffText = new GUIContent("Shadow Alpha Cutoff", "Threshold for shadow alpha cutoff");
+	static GUIContent _fixedNormalText = new GUIContent("Fixed Normals", "If this is ticked instead of requiring mesh normals a Fixed Normal will be used instead (it's quicker and can result in better looking lighting effects on 2d objects).");
+	static GUIContent _fixedNormalDirectionText = new GUIContent("Fixed Normal Direction", "Should normally be (0,0,1) if in view-space or (0,0,-1) if in model-space.");
+	static GUIContent _adjustBackfaceTangentText = new GUIContent("Adjust Back-face Tangents", "Tick only if you are going to rotate the sprite to face away from the camera, the tangents will be flipped when this is the case to make lighting correct.");
+	static GUIContent _sphericalHarmonicsText = new GUIContent("Spherical Harmonics", "Enable to use spherical harmonics to calculate ambient light / light probes. In vertex-lit mode this will be approximated from scenes ambient trilight settings.");
+	static GUIContent _lightingModeText = new GUIContent("Lighting Mode", "Lighting Mode");
+	static GUIContent[] _lightingModeOptions = {
+		new GUIContent("Vertex Lit"),
+		new GUIContent("Pixel Lit"),
+		new GUIContent("Unlit")
+	};
+	static GUIContent _blendModeText = new GUIContent("Blend Mode", "Blend Mode");
+	static GUIContent[] _blendModeOptions = {
+		new GUIContent("Pre-Multiplied Alpha"),
+		new GUIContent("Standard Alpha"),
+		new GUIContent("Opaque"),
+		new GUIContent("Additive"),
+		new GUIContent("Soft Additive"),
+		new GUIContent("Multiply"),
+		new GUIContent("Multiply x2")
+	};
+	static GUIContent _rendererQueueText = new GUIContent("Renderer Queue");
+	static GUIContent _cullingModeText = new GUIContent("Culling Mode");
+	static GUIContent[] _cullingModeOptions = { new GUIContent("Off"), new GUIContent("Front"), new GUIContent("Back") };
+	static GUIContent _pixelSnapText = new GUIContent("Pixel Snap");
+	//static GUIContent _customRenderTypetagsText = new GUIContent("Use Custom RenderType tags");
+	static GUIContent _fixedNormalSpaceText = new GUIContent("Fixed Normal Space");
+	static GUIContent[] _fixedNormalSpaceOptions = { new GUIContent("View-Space"), new GUIContent("Model-Space") };
+	static GUIContent _rimLightingToggleText = new GUIContent("Rim Lighting", "Enable Rim Lighting.");
+	static GUIContent _rimColorText = new GUIContent("Rim Color");
+	static GUIContent _rimPowerText = new GUIContent("Rim Power");
+	static GUIContent _specularToggleText = new GUIContent("Specular", "Enable Specular.");
+	static GUIContent _colorAdjustmentToggleText = new GUIContent("Color Adjustment", "Enable material color adjustment.");
+	static GUIContent _colorAdjustmentColorText = new GUIContent("Overlay Color");
+	static GUIContent _colorAdjustmentHueText = new GUIContent("Hue");
+	static GUIContent _colorAdjustmentSaturationText = new GUIContent("Saturation");
+	static GUIContent _colorAdjustmentBrightnessText = new GUIContent("Brightness");
+	static GUIContent _fogToggleText = new GUIContent("Fog", "Enable Fog rendering on this renderer.");
+	static GUIContent _meshRequiresTangentsText = new GUIContent("Note: Material requires a mesh with tangents.");
+	static GUIContent _meshRequiresNormalsText = new GUIContent("Note: Material requires a mesh with normals.");
+	static GUIContent _meshRequiresNormalsAndTangentsText = new GUIContent("Note: Material requires a mesh with Normals and Tangents.");
+
+	const string _primaryMapsText = "Main Maps";
+	const string _depthLabelText = "Depth";
+	const string _shadowsText = "Shadows";
+	const string _customRenderType = "Use Custom RenderType";
 
 	#region ShaderGUI
-	public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties)	{
+
+	public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties) {
 		FindProperties(properties); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
 		_materialEditor = materialEditor;
-		Material material = materialEditor.target as Material;
-
-		ShaderPropertiesGUI(material);
-
-		// Make sure that needed keywords are set up if we're switching some existing
-		// material to a standard shader.
-		if (_firstTimeApply) {
-			SetMaterialKeywords(material);
-			SetLightModeFromShader(material);
-			_firstTimeApply = false;
-		}
+		ShaderPropertiesGUI();
 	}
 
 	public override void AssignNewShaderToMaterial (Material material, Shader oldShader, Shader newShader) {
 		base.AssignNewShaderToMaterial(material, oldShader, newShader);
 
-		if (!(oldShader == Shader.Find(ShaderPixelLit) || oldShader == Shader.Find(ShaderVertexLit) || oldShader == Shader.Find(ShaderUnlit)))
+		//If not originally a sprite shader set default keywords
+		if (oldShader.name != kShaderVertexLit && oldShader.name != kShaderPixelLit && oldShader.name != kShaderUnlit) {
 			SetDefaultSpriteKeywords(material, newShader);
+		}
 
 		SetMaterialKeywords(material);
-		SetLightModeFromShader(material);
 	}
 
-
 	#endregion
 
 	#region Virtual Interface
+
 	protected virtual void FindProperties (MaterialProperty[] props) {
 		_mainTexture = FindProperty("_MainTex", props);
 		_color = FindProperty("_Color", props);
 
-		_emissionMap = FindProperty("_EmissionMap", props, false);
-		_emissionColor = FindProperty("_EmissionColor", props, false);
-		_emissionPower = FindProperty("_EmissionPower", props, false);
+		_pixelSnap = FindProperty("PixelSnap", props);
 
 		_writeToDepth = FindProperty("_ZWrite", props);
 		_depthAlphaCutoff = FindProperty("_Cutoff", props);
 		_shadowAlphaCutoff = FindProperty("_ShadowAlphaCutoff", props);
 		_renderQueue = FindProperty("_RenderQueue", props);
 		_culling = FindProperty("_Cull", props);
+		_customRenderQueue = FindProperty("_CustomRenderQueue", props);
 
 		_bumpMap = FindProperty("_BumpMap", props, false);
+		_bumpScale = FindProperty("_BumpScale", props, false);
 		_diffuseRamp = FindProperty("_DiffuseRamp", props, false);
 		_fixedNormal = FindProperty("_FixedNormal", props, false);
 		_blendTexture = FindProperty("_BlendTex", props, false);
@@ -169,388 +217,752 @@ public class SpineSpriteShaderGUI : ShaderGUI {
 
 		_rimPower = FindProperty("_RimPower", props, false);
 		_rimColor = FindProperty("_RimColor", props, false);
+
+		_emissionMap = FindProperty("_EmissionMap", props, false);
+		_emissionColor = FindProperty("_EmissionColor", props, false);
+		_emissionPower = FindProperty("_EmissionPower", props, false);
+
+		_metallic = FindProperty("_Metallic", props, false);
+		_metallicGlossMap = FindProperty("_MetallicGlossMap", props, false);
+		_smoothness = FindProperty("_Glossiness", props, false);
+		_smoothnessScale = FindProperty("_GlossMapScale", props, false);
 	}
 
-	protected virtual void ShaderPropertiesGUI (Material material) {
-		using (new EditorGUILayout.HorizontalScope()) {
-			GUILayout.FlexibleSpace();
-			var showAdvancedLabel = new GUIContent("Show Advanced", "Show extra options under all sections. This only affects the inspector. The Material's resulting shader is still compiled/optimized based on what features you actually use and don't use.");
-			float lw = GUI.skin.toggle.CalcSize(showAdvancedLabel).x;
+	static bool BoldToggleField (GUIContent label, bool value) {
+		FontStyle origFontStyle = EditorStyles.label.fontStyle;
+		EditorStyles.label.fontStyle = FontStyle.Bold;
+		value = EditorGUILayout.Toggle(label, value, EditorStyles.toggle);
+		EditorStyles.label.fontStyle = origFontStyle;
+		return value;
+	}
 
-			EditorGUIUtility.labelWidth = lw;
-			showAdvanced = EditorGUILayout.Toggle(showAdvancedLabel, showAdvanced);
-			EditorGUIUtility.labelWidth = 0f;
+	protected virtual void ShaderPropertiesGUI () {
+		// Use default labelWidth
+		EditorGUIUtility.labelWidth = 0f;
+
+		RenderMeshInfoBox();
+
+		// Detect any changes to the material
+		bool dataChanged = RenderModes();
+
+		GUILayout.Label(_primaryMapsText, EditorStyles.boldLabel);
+		{
+			dataChanged |= RenderTextureProperties();
 		}
 
-		EditorGUILayout.Space();
+		GUILayout.Label(_depthLabelText, EditorStyles.boldLabel);
+		{
+			dataChanged |= RenderDepthProperties();
+		}
 
-		EditorGUI.BeginChangeCheck();
+		GUILayout.Label(_shadowsText, EditorStyles.boldLabel);
 		{
-			LightingModePopup();
-			BlendModePopup();
+			dataChanged |= RenderShadowsProperties();
+		}
 
-			if (showAdvanced) {
-				EditorGUILayout.Space();
-				EditorGUI.BeginChangeCheck();
-				int renderQueue = EditorGUILayout.IntSlider("Renderer Queue Offset", (int)_renderQueue.floatValue, 0, 49);
-				if (EditorGUI.EndChangeCheck()) material.SetInt("_RenderQueue", renderQueue);
+		if (_metallic != null) {
+			dataChanged |= RenderSpecularProperties();
+		}
 
-				EditorGUI.BeginChangeCheck();
-				eCulling culling = (eCulling)Mathf.RoundToInt(_culling.floatValue);
-				culling = (eCulling)EditorGUILayout.EnumPopup("Culling", culling);
-				if (EditorGUI.EndChangeCheck()) material.SetInt("_Cull", (int)culling);
+		if (_emissionMap != null && _emissionColor != null) {
+			dataChanged |= RenderEmissionProperties();
+		}
 
-				EditorGUI.BeginChangeCheck();
-				bool fog = EditorGUILayout.Toggle("Use fog", material.IsKeywordEnabled("_FOG"));
-				if (EditorGUI.EndChangeCheck()) SetKeyword(material, "_FOG", fog);
+		if (_fixedNormal != null) {
+			dataChanged |= RenderNormalsProperties();
+		}
 
-				EditorGUI.BeginChangeCheck();
-				bool enabled = EditorGUILayout.Toggle(
-					new GUIContent(
-						"Use Spherical Harmonics",
-						"Enable to use spherical harmonics to calculate ambient light / light probes. In vertex-lit mode this will be approximated from scenes ambient trilight settings."),
-					material.IsKeywordEnabled(_SPHERICAL_HARMONICS)
-				);
-				if (EditorGUI.EndChangeCheck())
-					SetKeyword(material, _SPHERICAL_HARMONICS, enabled);
-			}
+		if (_fixedNormal != null) {
+			dataChanged |= RenderSphericalHarmonicsProperties();
+		}
 
-			using (new SpineInspectorUtility.BoxScope())
-				RenderTextureProperties("Main Maps", material);
+		{
+			dataChanged |= RenderFogProperties();
+		}
 
-			if (showAdvanced) {
-				using (new SpineInspectorUtility.BoxScope()) {
-					Heading("Depth and Cast Shadow");
-					EditorGUI.BeginChangeCheck();
-					bool writeTodepth = EditorGUILayout.Toggle(new GUIContent("Write to Depth", "Write to Depth Buffer by clipping alpha."), _writeToDepth.floatValue != 0.0f);
-					if (EditorGUI.EndChangeCheck())
-						material.SetInt("_ZWrite", writeTodepth ? 1 : 0);
+		{
+			dataChanged |= RenderColorProperties();
+		}
 
-					if (writeTodepth)
-						_materialEditor.RangeProperty(_depthAlphaCutoff, "Depth Alpha Cutoff");
+		if (_rimColor != null) {
+			dataChanged |= RenderRimLightingProperties();
+		}
+
+		if (dataChanged) {
+			MaterialChanged(_materialEditor);
+		}
+	}
 
-					EditorGUILayout.Space();
+	protected virtual bool RenderModes () {
+		bool dataChanged = false;
 
-					_materialEditor.RangeProperty(_shadowAlphaCutoff, "Shadow Alpha Cutoff");
+		//Lighting Mode
+		{
+			EditorGUI.BeginChangeCheck();
+
+			eLightMode lightMode = GetMaterialLightMode((Material)_materialEditor.target);
+			EditorGUI.showMixedValue = false;
+			foreach (Material material in _materialEditor.targets) {
+				if (lightMode != GetMaterialLightMode(material)) {
+					EditorGUI.showMixedValue = true;
+					break;
 				}
+			}
 
-				if (_fixedNormal != null) {
-					using (new SpineInspectorUtility.BoxScope()) {
-						Heading("Normals");
-						bool meshNormals = UseMeshNormalsCheckbox(material);
-						if (!meshNormals) {
-							Vector3 normal;
-							EditorGUI.BeginChangeCheck();
-							normal = showAdvanced ? EditorGUILayout.Vector3Field(new GUIContent("Fixed Normal", "Defined in Camera Space. Should normally be (0,0,-1)."), _fixedNormal.vectorValue) : (Vector3)_fixedNormal.vectorValue;
-							if (EditorGUI.EndChangeCheck())
-								_fixedNormal.vectorValue = new Vector4(normal.x, normal.y, normal.z, 1.0f);
-
-							bool backRendering;
-							EditorGUI.BeginChangeCheck();
-							if (showAdvanced) {
-								backRendering = EditorGUILayout.Toggle(new GUIContent("Fixed Normal Back Rendering", "Tick only if you are going to rotate the sprite to face away from the camera, the fixed normal will be flipped to compensate."), 
-									material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING));
-							} else {
-								backRendering = material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING);
-							}
-							if (EditorGUI.EndChangeCheck()) {
-								SetKeyword(material, _FIXED_NORMALS_BACK_RENDERING, backRendering);
-								SetKeyword(material, _FIXED_NORMALS, !backRendering);
-							}
-						}
+			lightMode = (eLightMode)EditorGUILayout.Popup(_lightingModeText, (int)lightMode, _lightingModeOptions);
+			if (EditorGUI.EndChangeCheck()) {
+				foreach (Material material in _materialEditor.targets) {
+					switch (lightMode) {
+					case eLightMode.VertexLit:
+						if (material.shader.name != kShaderVertexLit)
+							_materialEditor.SetShader(Shader.Find(kShaderVertexLit), false);
+						break;
+					case eLightMode.PixelLit:
+						if (material.shader.name != kShaderPixelLit)
+							_materialEditor.SetShader(Shader.Find(kShaderPixelLit), false);
+						break;
+					case eLightMode.Unlit:
+						if (material.shader.name != kShaderUnlit)
+							_materialEditor.SetShader(Shader.Find(kShaderUnlit), false);
+						break;
 					}
 				}
-			} else {
-				using (new SpineInspectorUtility.BoxScope()) {
-					EditorGUI.BeginChangeCheck();
-					bool writeTodepth = EditorGUILayout.Toggle(new GUIContent("Write to Depth", "Write to Depth Buffer by clipping alpha."), _writeToDepth.floatValue != 0.0f);
-					if (EditorGUI.EndChangeCheck())
-						material.SetInt("_ZWrite", writeTodepth ? 1 : 0);
-
-					if (_fixedNormal != null)
-						UseMeshNormalsCheckbox(material);
+
+				dataChanged = true;
+			}
+		}
+
+		//Blend Mode
+		{
+			eBlendMode blendMode = GetMaterialBlendMode((Material)_materialEditor.target);
+			EditorGUI.showMixedValue = false;
+			foreach (Material material in _materialEditor.targets) {
+				if (blendMode != GetMaterialBlendMode(material)) {
+					EditorGUI.showMixedValue = true;
+					break;
 				}
 			}
 
-			using (new SpineInspectorUtility.BoxScope())
-				RenderColorProperties("Color Adjustment", material);
+			EditorGUI.BeginChangeCheck();
+			blendMode = (eBlendMode)EditorGUILayout.Popup(_blendModeText, (int)blendMode, _blendModeOptions);
+			if (EditorGUI.EndChangeCheck()) {
+				foreach (Material mat in _materialEditor.targets) {
+					SetBlendMode(mat, blendMode);
+				}
 
-			if (_emissionMap != null && _emissionColor != null && _rimColor != null) {
-				Heading("Extra Lighting");
+				dataChanged = true;
+			}
+		}
 
-				if (_emissionMap != null && _emissionColor != null)
-					using (new SpineInspectorUtility.BoxScope())
-						RenderEmissionProperties(material);
+		//	GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
+		//	m_MaterialEditor.RenderQueueField();
+		//	m_MaterialEditor.EnableInstancingField();
 
-				if (_rimColor != null)
-					using (new SpineInspectorUtility.BoxScope())
-						RenderRimLightingProperties(material);
-			}
+		EditorGUI.BeginChangeCheck();
+		EditorGUI.showMixedValue = _renderQueue.hasMixedValue;
+		int renderQueue = EditorGUILayout.IntSlider(_rendererQueueText, (int)_renderQueue.floatValue, 0, 49);
+		if (EditorGUI.EndChangeCheck()) {
+			SetInt("_RenderQueue", renderQueue);
+			dataChanged = true;
 		}
-		if (EditorGUI.EndChangeCheck())	{
-			MaterialChanged(material);
+
+		EditorGUI.BeginChangeCheck();
+		var culling = (eCulling)Mathf.RoundToInt(_culling.floatValue);
+		EditorGUI.showMixedValue = _culling.hasMixedValue;
+		culling = (eCulling)EditorGUILayout.Popup(_cullingModeText, (int)culling, _cullingModeOptions);
+		if (EditorGUI.EndChangeCheck()) {
+			SetInt("_Cull", (int)culling);
+			dataChanged = true;
 		}
+
+		EditorGUI.showMixedValue = false;
+
+		EditorGUI.BeginChangeCheck();
+		_materialEditor.ShaderProperty(_pixelSnap, _pixelSnapText);
+		dataChanged |= EditorGUI.EndChangeCheck();
+
+		return dataChanged;
 	}
 
-	protected virtual void RenderTextureProperties (string label, Material material) {
-		if (showAdvanced)
-			Heading(label);
+	protected virtual bool RenderTextureProperties () {
+		bool dataChanged = false;
 
-		_materialEditor.TexturePropertySingleLine(new GUIContent(showAdvanced ? "Albedo" : "Main Texture"), _mainTexture, _color);
+		EditorGUI.BeginChangeCheck();
+
+		_materialEditor.TexturePropertySingleLine(_albedoText, _mainTexture, _color);
 
 		if (_bumpMap != null)
-			_materialEditor.TexturePropertySingleLine(new GUIContent("Normal Map"), _bumpMap);
+			_materialEditor.TexturePropertySingleLine(_normalMapText, _bumpMap, _bumpMap.textureValue != null ? _bumpScale : null);
+
+		if (_diffuseRamp != null)
+			_materialEditor.TexturePropertySingleLine(_diffuseRampText, _diffuseRamp);
+
+		dataChanged |= EditorGUI.EndChangeCheck();
+
+		if (_blendTexture != null) {
+			EditorGUI.BeginChangeCheck();
+			_materialEditor.TexturePropertySingleLine(_altAlbedoText, _blendTexture, _blendTextureLerp);
+			if (EditorGUI.EndChangeCheck()) {
+				SetKeyword(_materialEditor, "_TEXTURE_BLEND", _blendTexture != null);
+				dataChanged = true;
+			}
+		}
+
+		EditorGUI.BeginChangeCheck();
+		_materialEditor.TextureScaleOffsetProperty(_mainTexture);
+		dataChanged |= EditorGUI.EndChangeCheck();
+
+		EditorGUI.showMixedValue = false;
+
+		return dataChanged;
+	}
+
+	protected virtual bool RenderDepthProperties () {
+		bool dataChanged = false;
+
+		EditorGUI.BeginChangeCheck();
+
+		bool mixedValue = _writeToDepth.hasMixedValue;
+		EditorGUI.showMixedValue = mixedValue;
+		bool writeTodepth = EditorGUILayout.Toggle(_depthText, _writeToDepth.floatValue != 0.0f);
+
+		if (EditorGUI.EndChangeCheck()) {
+			SetInt("_ZWrite", writeTodepth ? 1 : 0);
+			_depthAlphaCutoff.floatValue = writeTodepth ? 0.5f : 0.0f;
+			mixedValue = false;
+			dataChanged = true;
+		}
+
+		if (writeTodepth && !mixedValue && GetMaterialBlendMode((Material)_materialEditor.target) != eBlendMode.Opaque) {
+			EditorGUI.BeginChangeCheck();
+			_materialEditor.RangeProperty(_depthAlphaCutoff, _depthAlphaCutoffText.text);
+			dataChanged |= EditorGUI.EndChangeCheck();
+		}
+
+		{
+			bool useCustomRenderType = _customRenderQueue.floatValue > 0.0f;
+			EditorGUI.BeginChangeCheck();
+			EditorGUI.showMixedValue = _customRenderQueue.hasMixedValue;
+			useCustomRenderType = EditorGUILayout.Toggle(_customRenderType, useCustomRenderType);
+			if (EditorGUI.EndChangeCheck()) {
+				dataChanged = true;
+
+				_customRenderQueue.floatValue = useCustomRenderType ? 1.0f : 0.0f;
+
+				foreach (Material material in _materialEditor.targets) {
+					eBlendMode blendMode = GetMaterialBlendMode(material);
+
+					switch (blendMode) {
+					case eBlendMode.Opaque:
+						{
+							SetRenderType(material, "Opaque", useCustomRenderType);
+						}
+						break;
+					default:
+						{
+							bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
+							SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderType);
+						}
+						break;
+					}
+				}
+			}
+		}
+
+		EditorGUI.showMixedValue = false;
+
+		return dataChanged;
+	}
+
+	protected virtual bool RenderNormalsProperties () {
+		bool dataChanged = false;
+
+		eNormalsMode normalsMode = GetMaterialNormalsMode((Material)_materialEditor.target);
+		bool mixedNormalsMode = false;
+		foreach (Material material in _materialEditor.targets) {
+			if (normalsMode != GetMaterialNormalsMode(material)) {
+				mixedNormalsMode = true;
+				break;
+			}
+		}
+
+		EditorGUI.BeginChangeCheck();
+		EditorGUI.showMixedValue = mixedNormalsMode;
+		bool fixedNormals = BoldToggleField(_fixedNormalText, normalsMode != eNormalsMode.MeshNormals);
+
+		if (EditorGUI.EndChangeCheck()) {
+			normalsMode = fixedNormals ? eNormalsMode.FixedNormalsViewSpace : eNormalsMode.MeshNormals;
+			SetNormalsMode(_materialEditor, normalsMode, false);
+			_fixedNormal.vectorValue = new Vector4(0.0f, 0.0f, normalsMode == eNormalsMode.FixedNormalsViewSpace ? 1.0f : -1.0f, 1.0f);
+			mixedNormalsMode = false;
+			dataChanged = true;
+		}
+
+		if (fixedNormals) {
+			//Show drop down for normals space
+			EditorGUI.BeginChangeCheck();
+			EditorGUI.showMixedValue = mixedNormalsMode;
+			normalsMode = (eNormalsMode)EditorGUILayout.Popup(_fixedNormalSpaceText, (int)normalsMode, _fixedNormalSpaceOptions);
+			if (EditorGUI.EndChangeCheck()) {
+				SetNormalsMode((Material)_materialEditor.target, normalsMode, GetMaterialFixedNormalsBackfaceRenderingOn((Material)_materialEditor.target));
+
+				foreach (Material material in _materialEditor.targets) {
+					SetNormalsMode(material, normalsMode, GetMaterialFixedNormalsBackfaceRenderingOn(material));
+				}
+
+				//Reset fixed normal to default (Vector3.forward for model-space, -Vector3.forward for view-space).
+				_fixedNormal.vectorValue = new Vector4(0.0f, 0.0f, normalsMode == eNormalsMode.FixedNormalsViewSpace ? 1.0f : -1.0f, 1.0f);
+
+				mixedNormalsMode = false;
+				dataChanged = true;
+			}
+
+			//Show fixed normal
+			EditorGUI.BeginChangeCheck();
+			EditorGUI.showMixedValue = _fixedNormal.hasMixedValue;
+			Vector3 normal = EditorGUILayout.Vector3Field(_fixedNormalDirectionText, _fixedNormal.vectorValue);
+			if (EditorGUI.EndChangeCheck()) {
+				_fixedNormal.vectorValue = new Vector4(normal.x, normal.y, normal.z, 1.0f);
+				dataChanged = true;
+			}
+
+			//Show adjust for back face rendering
+			{
+				bool fixBackFaceRendering = GetMaterialFixedNormalsBackfaceRenderingOn((Material)_materialEditor.target);
+				bool mixedBackFaceRendering = false;
+				foreach (Material material in _materialEditor.targets) {
+					if (fixBackFaceRendering != GetMaterialFixedNormalsBackfaceRenderingOn(material)) {
+						mixedBackFaceRendering = true;
+						break;
+					}
+				}
 
-		if (showAdvanced) {
-			if (_blendTexture != null) {
 				EditorGUI.BeginChangeCheck();
-				_materialEditor.TexturePropertySingleLine(new GUIContent("Blend Texture", "When a blend texture is set the albedo will be a mix of the blend texture and main texture based on the blend amount."), _blendTexture, _blendTextureLerp);
-				if (EditorGUI.EndChangeCheck())
-					SetKeyword(material, "_TEXTURE_BLEND", _blendTexture != null);
+				EditorGUI.showMixedValue = mixedBackFaceRendering;
+				bool backRendering = EditorGUILayout.Toggle(_adjustBackfaceTangentText, fixBackFaceRendering);
+
+				if (EditorGUI.EndChangeCheck()) {
+					SetNormalsMode(_materialEditor, normalsMode, backRendering);
+					dataChanged = true;
+				}
 			}
+
+		}
+
+		EditorGUI.showMixedValue = false;
+
+		return dataChanged;
+	}
+
+	protected virtual bool RenderShadowsProperties () {
+		EditorGUI.BeginChangeCheck();
+		_materialEditor.RangeProperty(_shadowAlphaCutoff, _shadowAlphaCutoffText.text);
+		return EditorGUI.EndChangeCheck();
+	}
+
+	protected virtual bool RenderSphericalHarmonicsProperties () {
+		EditorGUI.BeginChangeCheck();
+		bool mixedValue;
+		bool enabled = IsKeywordEnabled(_materialEditor, "_SPHERICAL_HARMONICS", out mixedValue);
+		EditorGUI.showMixedValue = mixedValue;
+		enabled = BoldToggleField(_sphericalHarmonicsText, enabled);
+		EditorGUI.showMixedValue = false;
+
+		if (EditorGUI.EndChangeCheck()) {
+			SetKeyword(_materialEditor, "_SPHERICAL_HARMONICS", enabled);
+			return true;
 		}
 
-		if (_diffuseRamp != null) {
-			EditorGUILayout.Space();
-			_materialEditor.TexturePropertySingleLine(new GUIContent("Diffuse Ramp", "A gradient can be used to create a 'Toon Shading' effect."), _diffuseRamp);
+		return false;
+	}
+
+	protected virtual bool RenderFogProperties () {
+		EditorGUI.BeginChangeCheck();
+		bool mixedValue;
+		bool fog = IsKeywordEnabled(_materialEditor, "_FOG", out mixedValue);
+		EditorGUI.showMixedValue = mixedValue;
+		fog = BoldToggleField(_fogToggleText, fog);
+		EditorGUI.showMixedValue = false;
+
+		if (EditorGUI.EndChangeCheck()) {
+			SetKeyword(_materialEditor, "_FOG", fog);
+			return true;
 		}
 
-		//		if (showAdvanced)
-		//			_materialEditor.TextureScaleOffsetProperty(_mainTexture);
+		return false;
 	}
 
-	bool UseMeshNormalsCheckbox (Material material) {
+	protected virtual bool RenderColorProperties () {
+		bool dataChanged = false;
+
 		EditorGUI.BeginChangeCheck();
-		bool fixedNormals = material.IsKeywordEnabled(_FIXED_NORMALS);
-		bool fixedNormalsBackRendering = material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING);
-		bool meshNormals = EditorGUILayout.Toggle(new GUIContent("Use Mesh Normals", "If this is unticked, a Fixed Normal value will be used instead of the vertex normals on the mesh. Using a fixed normal is better for performance and can result in better looking lighting effects on 2d objects."), 
-			!fixedNormals && !fixedNormalsBackRendering);
+		bool mixedValue;
+		bool colorAdjust = IsKeywordEnabled(_materialEditor, "_COLOR_ADJUST", out mixedValue);
+		EditorGUI.showMixedValue = mixedValue;
+		colorAdjust = BoldToggleField(_colorAdjustmentToggleText, colorAdjust);
+		EditorGUI.showMixedValue = false;
 		if (EditorGUI.EndChangeCheck()) {
-			SetKeyword(material, _FIXED_NORMALS, meshNormals ? false : fixedNormalsBackRendering ? false : true);
-			SetKeyword(material, _FIXED_NORMALS_BACK_RENDERING, meshNormals ? false : fixedNormalsBackRendering);
+			SetKeyword(_materialEditor, "_COLOR_ADJUST", colorAdjust);
+			mixedValue = false;
+			dataChanged = true;
+		}
+
+		if (colorAdjust && !mixedValue) {
+			EditorGUI.BeginChangeCheck();
+			_materialEditor.ColorProperty(_overlayColor, _colorAdjustmentColorText.text);
+			_materialEditor.RangeProperty(_hue, _colorAdjustmentHueText.text);
+			_materialEditor.RangeProperty(_saturation, _colorAdjustmentSaturationText.text);
+			_materialEditor.RangeProperty(_brightness, _colorAdjustmentBrightnessText.text);
+			dataChanged |= EditorGUI.EndChangeCheck();
 		}
-		return meshNormals;
+
+		return dataChanged;
 	}
 
-	protected virtual void RenderColorProperties (string label, Material material) {
-		if (ToggleHeadingKeyword(label, material, "_COLOR_ADJUST")) {
-			_materialEditor.ColorProperty(_overlayColor, "Overlay Color");
-			EditorGUILayout.Space();
-			using (new SpineInspectorUtility.IndentScope()) {
-				_materialEditor.RangeProperty(_hue, "Hue");
-				_materialEditor.RangeProperty(_saturation, "Saturation");
-				_materialEditor.RangeProperty(_brightness, "Brightness");
+	protected virtual bool RenderSpecularProperties () {
+		bool dataChanged = false;
+
+		bool mixedSpecularValue;
+		bool specular = IsKeywordEnabled(_materialEditor, "_SPECULAR", out mixedSpecularValue);
+		bool mixedSpecularGlossMapValue;
+		bool specularGlossMap = IsKeywordEnabled(_materialEditor, "_SPECULAR_GLOSSMAP", out mixedSpecularGlossMapValue);
+		bool mixedValue = mixedSpecularValue || mixedSpecularGlossMapValue;
+
+		EditorGUI.BeginChangeCheck();
+		EditorGUI.showMixedValue = mixedValue;
+		bool specularEnabled = BoldToggleField(_specularToggleText, specular || specularGlossMap);
+		EditorGUI.showMixedValue = false;
+		if (EditorGUI.EndChangeCheck()) {
+			foreach (Material material in _materialEditor.targets) {
+				bool hasGlossMap = material.GetTexture("_MetallicGlossMap") != null;
+				SetKeyword(material, "_SPECULAR", specularEnabled && !hasGlossMap);
+				SetKeyword(material, "_SPECULAR_GLOSSMAP", specularEnabled && hasGlossMap);
+			}
+
+			mixedValue = false;
+			dataChanged = true;
+		}
+
+		if (specularEnabled && !mixedValue) {
+			EditorGUI.BeginChangeCheck();
+			bool hasGlossMap = _metallicGlossMap.textureValue != null;
+			_materialEditor.TexturePropertySingleLine(_metallicMapText, _metallicGlossMap, hasGlossMap ? null : _metallic);
+			if (EditorGUI.EndChangeCheck()) {
+				hasGlossMap = _metallicGlossMap.textureValue != null;
+				SetKeyword(_materialEditor, "_SPECULAR", !hasGlossMap);
+				SetKeyword(_materialEditor, "_SPECULAR_GLOSSMAP", hasGlossMap);
+
+				dataChanged = true;
 			}
+
+			const int indentation = 2;
+			_materialEditor.ShaderProperty(hasGlossMap ? _smoothnessScale : _smoothness, hasGlossMap ? _smoothnessScaleText : _smoothnessText, indentation);
 		}
+
+		return dataChanged;
 	}
 
-	protected virtual void RenderEmissionProperties (Material material) {
-		if (ToggleHeadingKeyword("Emission", material, "_EMISSION")) {
-			_materialEditor.TexturePropertyWithHDRColor(new GUIContent("Emission"), _emissionMap, _emissionColor, new ColorPickerHDRConfig(0,1, 0.01010101f, 3), true);
-			_materialEditor.FloatProperty(_emissionPower, "Emission Power");
+	protected virtual bool RenderEmissionProperties () {
+		bool dataChanged = false;
+
+		bool mixedValue;
+		bool emission = IsKeywordEnabled(_materialEditor, "_EMISSION", out mixedValue);
+
+		EditorGUI.BeginChangeCheck();
+		EditorGUI.showMixedValue = mixedValue;
+		emission = BoldToggleField(_emissionToggleText, emission);
+		EditorGUI.showMixedValue = false;
+		if (EditorGUI.EndChangeCheck()) {
+			SetKeyword(_materialEditor, "_EMISSION", emission);
+			mixedValue = false;
+			dataChanged = true;
+		}
+
+		if (emission && !mixedValue) {
+			EditorGUI.BeginChangeCheck();
+			_materialEditor.TexturePropertyWithHDRColor(_emissionText, _emissionMap, _emissionColor, new ColorPickerHDRConfig(0, 1, 0.01010101f, 3), true);
+			_materialEditor.FloatProperty(_emissionPower, _emissionPowerText.text);
+			dataChanged |= EditorGUI.EndChangeCheck();
 		}
+
+		return dataChanged;
 	}
 
-	protected virtual void RenderRimLightingProperties (Material material) {
-		if (ToggleHeadingKeyword("Rim Lighting", material, "_RIM_LIGHTING")) {
-			_materialEditor.ColorProperty(_rimColor, "Rim Color");
-			_materialEditor.FloatProperty(_rimPower, "Rim Power");
+	protected virtual bool RenderRimLightingProperties () {
+		bool dataChanged = false;
+
+		bool mixedValue;
+		bool rimLighting = IsKeywordEnabled(_materialEditor, "_RIM_LIGHTING", out mixedValue);
+
+		EditorGUI.BeginChangeCheck();
+		EditorGUI.showMixedValue = mixedValue;
+		rimLighting = BoldToggleField(_rimLightingToggleText, rimLighting);
+		EditorGUI.showMixedValue = false;
+		if (EditorGUI.EndChangeCheck()) {
+			SetKeyword(_materialEditor, "_RIM_LIGHTING", rimLighting);
+			mixedValue = false;
+			dataChanged = true;
+		}
+
+		if (rimLighting && !mixedValue) {
+			EditorGUI.BeginChangeCheck();
+			_materialEditor.ColorProperty(_rimColor, _rimColorText.text);
+			_materialEditor.FloatProperty(_rimPower, _rimPowerText.text);
+			dataChanged |= EditorGUI.EndChangeCheck();
 		}
+
+		return dataChanged;
 	}
+
 	#endregion
 
-	static void SetDefaultSpriteKeywords (Material material, Shader shader) {
-		SetKeyword(material, "_EMISSION", false); // Disabled. standard shader sets this on by default.
-		SetKeyword(material, PremultipledAlpha, true); // PMA by default
-		SetKeyword(material, _FIXED_NORMALS, true); // Fixed normals by default, best for Spine.
-		SetKeyword(material, _SPHERICAL_HARMONICS, true);
+	#region Private Functions
+
+	void RenderMeshInfoBox () {
+		var material = (Material)_materialEditor.target;
+		bool requiresNormals = _fixedNormal != null && GetMaterialNormalsMode(material) == eNormalsMode.MeshNormals;
+		bool requiresTangents = material.HasProperty("_BumpMap") && material.GetTexture("_BumpMap") != null;
+
+		if (requiresNormals || requiresTangents) {
+			GUILayout.Label(requiresNormals && requiresTangents ? _meshRequiresNormalsAndTangentsText : requiresNormals ? _meshRequiresNormalsText : _meshRequiresTangentsText, GUI.skin.GetStyle("helpBox"));
+		}
 	}
 
-	void SetLightModeFromShader (Material material) {
-		if (material.shader.name == ShaderPixelLit)
-			_lightMode = eLightMode.PixelLit;
-		else if (material.shader.name == ShaderUnlit)
-			_lightMode = eLightMode.Unlit;
-		else
-			_lightMode = eLightMode.VertexLit;
+	void SetInt (string propertyName, int value) {
+		foreach (Material material in _materialEditor.targets) {
+			material.SetInt(propertyName, value);
+		}
+	}
+
+	void SetDefaultSpriteKeywords (Material material, Shader shader) {
+		//Disable emission by default (is set on by default in standard shader)
+		SetKeyword(material, "_EMISSION", false);
+		//Start with preMultiply alpha by default
+		SetBlendMode(material, eBlendMode.PreMultipliedAlpha);
+		//Start with mesh normals by default
+		SetNormalsMode(material, eNormalsMode.MeshNormals, false);
+		if (_fixedNormal != null)
+			_fixedNormal.vectorValue = new Vector4(0.0f, 0.0f, 1.0f, 1.0f);
+		//Start with spherical harmonics disabled?
+		SetKeyword(material, "_SPHERICAL_HARMONICS", false);
+		//Start with specular disabled
+		SetKeyword(material, "_SPECULAR", false);
+		SetKeyword(material, "_SPECULAR_GLOSSMAP", false);
+		//Start with Culling disabled
+		material.SetInt("_Cull", (int)eCulling.Off);
+		//Start with Z writing disabled
+		material.SetInt("_ZWrite", 0);
 	}
 
-	static void SetRenderQueue (Material material, string queue) {
-		bool meshNormal = true;
+	//Z write is on then
 
-		if (material.HasProperty("_FixedNormal")) {
-			bool fixedNormals = material.IsKeywordEnabled(_FIXED_NORMALS);
-			bool fixedNormalsBackRendering = material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING);
-			meshNormal = !fixedNormals && !fixedNormalsBackRendering;
+	static void SetRenderType (Material material, string renderType, bool useCustomRenderQueue) {
+		//Want a check box to say if should use Sprite render queue (for custom writing depth and normals)
+		bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
+
+		if (useCustomRenderQueue) {
+			//If sprite has fixed normals then assign custom render type so we can write its correct normal with soft edges
+			eNormalsMode normalsMode = GetMaterialNormalsMode(material);
+
+			switch (normalsMode) {
+			case eNormalsMode.FixedNormalsViewSpace:
+				renderType = "SpriteViewSpaceFixedNormal";
+				break;
+			case eNormalsMode.FixedNormalsModelSpace:
+				renderType = "SpriteModelSpaceFixedNormal";
+				break;
+			case eNormalsMode.MeshNormals:
+				{
+					//If sprite doesn't write to depth assign custom render type so we can write its depth with soft edges
+					if (!zWrite) {
+						renderType = "Sprite";
+					}
+				}
+				break;
+			}
 		}
 
-		material.SetOverrideTag("RenderType", meshNormal ? queue : "Sprite");
+		//If we don't write to depth set tag so custom shaders can write to depth themselves
+		material.SetOverrideTag("AlphaDepth", zWrite ? "False" : "True");
+
+		material.SetOverrideTag("RenderType", renderType);
 	}
 
 	static void SetMaterialKeywords (Material material) {
-		bool normalMap = material.HasProperty("_BumpMap") && material.GetTexture("_BumpMap") != null;
-		SetKeyword(material, "_NORMALMAP", normalMap);
+		eBlendMode blendMode = GetMaterialBlendMode(material);
+		SetBlendMode(material, blendMode);
 
 		bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
-		bool clipAlpha = zWrite && material.GetFloat("_Cutoff") > 0.0f;
+		bool clipAlpha = zWrite && blendMode != eBlendMode.Opaque && material.GetFloat("_Cutoff") > 0.0f;
 		SetKeyword(material, "_ALPHA_CLIP", clipAlpha);
 
+		bool normalMap = material.HasProperty("_BumpMap") && material.GetTexture("_BumpMap") != null;
+		SetKeyword(material, "_NORMALMAP", normalMap);
+
 		bool diffuseRamp = material.HasProperty("_DiffuseRamp") && material.GetTexture("_DiffuseRamp") != null;
 		SetKeyword(material, "_DIFFUSE_RAMP", diffuseRamp);
 
 		bool blendTexture = material.HasProperty("_BlendTex") && material.GetTexture("_BlendTex") != null;
 		SetKeyword(material, "_TEXTURE_BLEND", blendTexture);
+	}
 
-		eBlendMode blendMode = GetMaterialBlendMode(material);
-		SetBlendMode(material, blendMode);
+	static void MaterialChanged (MaterialEditor materialEditor) {
+		foreach (Material material in materialEditor.targets)
+			SetMaterialKeywords(material);
+	}
+
+	static void SetKeyword (MaterialEditor m, string keyword, bool state) {
+		foreach (Material material in m.targets) {
+			SetKeyword(material, keyword, state);
+		}
+	}
+
+	static void SetKeyword (Material m, string keyword, bool state) {
+		if (state)
+			m.EnableKeyword(keyword);
+		else
+			m.DisableKeyword(keyword);
+	}
+
+	static bool IsKeywordEnabled (MaterialEditor editor, string keyword, out bool mixedValue) {
+		bool keywordEnabled = ((Material)editor.target).IsKeywordEnabled(keyword);
+		mixedValue = false;
+
+		foreach (Material material in editor.targets) {
+			if (material.IsKeywordEnabled(keyword) != keywordEnabled) {
+				mixedValue = true;
+				break;
+			}
+		}
+
+		return keywordEnabled;
+	}
+
+	static eLightMode GetMaterialLightMode (Material material) {
+		if (material.shader.name == kShaderPixelLit) {
+			return eLightMode.PixelLit;
+		} else if (material.shader.name == kShaderUnlit) {
+			return eLightMode.Unlit;
+		} else {
+			return eLightMode.VertexLit;
+		}
 	}
 
 	static eBlendMode GetMaterialBlendMode (Material material) {
-		if (material.IsKeywordEnabled(PremultipledAlpha))
+		if (material.IsKeywordEnabled("_ALPHABLEND_ON"))
+			return eBlendMode.StandardAlpha;
+		if (material.IsKeywordEnabled("_ALPHAPREMULTIPLY_ON"))
 			return eBlendMode.PreMultipliedAlpha;
-		if (material.IsKeywordEnabled(Multiply))
+		if (material.IsKeywordEnabled("_MULTIPLYBLEND"))
 			return eBlendMode.Multiply;
-		if (material.IsKeywordEnabled(Multiply2x))
+		if (material.IsKeywordEnabled("_MULTIPLYBLEND_X2"))
 			return eBlendMode.Multiplyx2;
-		if (material.IsKeywordEnabled(Additive))
+		if (material.IsKeywordEnabled("_ADDITIVEBLEND"))
 			return eBlendMode.Additive;
-		if (material.IsKeywordEnabled(SoftAdditive))
+		if (material.IsKeywordEnabled("_ADDITIVEBLEND_SOFT"))
 			return eBlendMode.SoftAdditive;
 
-		return eBlendMode.StandardAlpha;
-	}
-
-	void BlendModePopup () {
-		var material = _materialEditor.target as Material;
-		eBlendMode blendMode = GetMaterialBlendMode(material);
-		EditorGUI.BeginChangeCheck();
-		blendMode = (eBlendMode)EditorGUILayout.Popup("Blend Mode", (int)blendMode, Enum.GetNames(typeof(eBlendMode)));
-
-		if (EditorGUI.EndChangeCheck())
-			SetBlendMode(material, blendMode);
+		return eBlendMode.Opaque;
 	}
 
 	static void SetBlendMode (Material material, eBlendMode blendMode) {
-		SetKeyword(material, PremultipledAlpha, blendMode == eBlendMode.PreMultipliedAlpha);
-		SetKeyword(material, Multiply, blendMode == eBlendMode.Multiply);
-		SetKeyword(material, Multiply2x, blendMode == eBlendMode.Multiplyx2);
-		SetKeyword(material, Additive, blendMode == eBlendMode.Additive);
-		SetKeyword(material, SoftAdditive, blendMode == eBlendMode.SoftAdditive);
+		SetKeyword(material, "_ALPHABLEND_ON", blendMode == eBlendMode.StandardAlpha);
+		SetKeyword(material, "_ALPHAPREMULTIPLY_ON", blendMode == eBlendMode.PreMultipliedAlpha);
+		SetKeyword(material, "_MULTIPLYBLEND", blendMode == eBlendMode.Multiply);
+		SetKeyword(material, "_MULTIPLYBLEND_X2", blendMode == eBlendMode.Multiplyx2);
+		SetKeyword(material, "_ADDITIVEBLEND", blendMode == eBlendMode.Additive);
+		SetKeyword(material, "_ADDITIVEBLEND_SOFT", blendMode == eBlendMode.SoftAdditive);
 
 		int renderQueue;
+		bool useCustomRenderQueue = material.GetFloat("_CustomRenderQueue") > 0.0f;
 
 		switch (blendMode) {
-		case eBlendMode.Solid:
+		case eBlendMode.Opaque:
 			{
 				material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
 				material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
-				SetRenderQueue(material, "Opaque");
-				renderQueue = SolidQueue;
+				SetRenderType(material, "Opaque", useCustomRenderQueue);
+				renderQueue = kSolidQueue;
 			}
 			break;
 		case eBlendMode.Additive:
-			{ 
+			{
 				material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
 				material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
-				SetRenderQueue(material, "Transparent");
-				renderQueue = TransparentQueue;
+				bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
+				SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
+				renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
 			}
 			break;
 		case eBlendMode.SoftAdditive:
 			{
 				material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
 				material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcColor);
-				SetRenderQueue(material, "Transparent");
-				renderQueue = TransparentQueue;
+				bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
+				SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
+				renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
 			}
 			break;
 		case eBlendMode.Multiply:
 			{
 				material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
 				material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
-				SetRenderQueue(material, "Transparent");
-				renderQueue = TransparentQueue;
+				bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
+				SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
+				renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
 			}
 			break;
 		case eBlendMode.Multiplyx2:
 			{
 				material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
 				material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.SrcColor);
-				SetRenderQueue(material, "Transparent");
-				renderQueue = TransparentQueue;
+				bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
+				SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
+				renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
 			}
 			break;
-		case eBlendMode.PreMultipliedAlpha:
-		case eBlendMode.StandardAlpha:
 		default:
 			{
-				bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
 				material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
 				material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
-				SetRenderQueue(material, zWrite ? "TransparentCutout" : "Transparent");
-				renderQueue = zWrite ? AlphaTestQueue : TransparentQueue;
+				bool zWrite = material.GetFloat("_ZWrite") > 0.0f;
+				SetRenderType(material, zWrite ? "TransparentCutout" : "Transparent", useCustomRenderQueue);
+				renderQueue = zWrite ? kAlphaTestQueue : kTransparentQueue;
 			}
 			break;
 		}
 
 		material.renderQueue = renderQueue + material.GetInt("_RenderQueue");
+		material.SetOverrideTag("IgnoreProjector", blendMode == eBlendMode.Opaque ? "False" : "True");
 	}
 
-	static void Heading (string label) {
-		GUILayout.Label(label, EditorStyles.boldLabel);
-	}
-
-	static bool ToggleHeadingKeyword (string label, Material material, string keyword) {
-		int i = EditorGUI.indentLevel;
-		var o = EditorStyles.label.fontStyle;
-		EditorGUI.indentLevel = 0;
-		EditorStyles.label.fontStyle = FontStyle.Bold;
-
-		EditorGUI.BeginChangeCheck();
-		bool r = EditorGUILayout.Toggle(new GUIContent(label, string.Format("This checkbox sets shader keyword: '{0}', which causes the Material to use extra shader features.", keyword)), material.IsKeywordEnabled(keyword));
-		if (EditorGUI.EndChangeCheck())
-			SetKeyword(material, keyword, r);
+	static eNormalsMode GetMaterialNormalsMode (Material material) {
+		if (material.IsKeywordEnabled("_FIXED_NORMALS_VIEWSPACE") || material.IsKeywordEnabled("_FIXED_NORMALS_VIEWSPACE_BACKFACE"))
+			return eNormalsMode.FixedNormalsViewSpace;
+		if (material.IsKeywordEnabled("_FIXED_NORMALS_MODELSPACE") || material.IsKeywordEnabled("_FIXED_NORMALS_MODELSPACE_BACKFACE"))
+			return eNormalsMode.FixedNormalsModelSpace;
 
-		EditorStyles.label.fontStyle = o;
-		EditorGUI.indentLevel = i;
-		return r;
+		return eNormalsMode.MeshNormals;
 	}
 
-	static void MaterialChanged (Material material) {
-		SetMaterialKeywords(material);
-	}
+	static void SetNormalsMode (MaterialEditor materialEditor, eNormalsMode normalsMode, bool allowBackFaceRendering) {
+		SetNormalsMode((Material)materialEditor.target, normalsMode, allowBackFaceRendering);
 
-	static void SetKeyword (Material m, string keyword, bool state) {
-		if (state)
-			m.EnableKeyword(keyword);
-		else
-			m.DisableKeyword(keyword);
+		foreach (Material material in materialEditor.targets) {
+			SetNormalsMode(material, normalsMode, allowBackFaceRendering);
+		}
 	}
 
-	void LightingModePopup () {
-		EditorGUI.BeginChangeCheck();
-		_lightMode = (eLightMode)EditorGUILayout.Popup("Lighting Mode", (int)_lightMode, Enum.GetNames(typeof(eLightMode)));
-		if (EditorGUI.EndChangeCheck()) {
-			var material = _materialEditor.target as Material;
-
-			switch (_lightMode) {
-			case eLightMode.VertexLit:
-				if (material.shader.name != ShaderVertexLit)
-					_materialEditor.SetShader(Shader.Find(ShaderVertexLit), false);
-				break;
-			case eLightMode.PixelLit:
-				if (material.shader.name != ShaderPixelLit)
-					_materialEditor.SetShader(Shader.Find(ShaderPixelLit), false);
-				break;
-			case eLightMode.Unlit:
-				if (material.shader.name != ShaderUnlit)
-					_materialEditor.SetShader(Shader.Find(ShaderUnlit), false);
-				break;
-			}
-
-			MaterialChanged(material);
-		}
+	static void SetNormalsMode (Material material, eNormalsMode normalsMode, bool allowBackFaceRendering) {
+		SetKeyword(material, "_FIXED_NORMALS_VIEWSPACE", normalsMode == eNormalsMode.FixedNormalsViewSpace && !allowBackFaceRendering);
+		SetKeyword(material, "_FIXED_NORMALS_VIEWSPACE_BACKFACE", normalsMode == eNormalsMode.FixedNormalsViewSpace && allowBackFaceRendering);
+		SetKeyword(material, "_FIXED_NORMALS_MODELSPACE", normalsMode == eNormalsMode.FixedNormalsModelSpace && !allowBackFaceRendering);
+		SetKeyword(material, "_FIXED_NORMALS_MODELSPACE_BACKFACE", normalsMode == eNormalsMode.FixedNormalsModelSpace && allowBackFaceRendering);
 	}
 
+	static bool GetMaterialFixedNormalsBackfaceRenderingOn (Material material) {
+		return material.IsKeywordEnabled("_FIXED_NORMALS_VIEWSPACE_BACKFACE") || material.IsKeywordEnabled("_FIXED_NORMALS_MODELSPACE_BACKFACE");
+	}
 
+	#endregion
 }

+ 33 - 13
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/SpritesPixelLit.shader

@@ -4,18 +4,30 @@ Shader "Spine/Sprite/Pixel Lit"
 	{
 		_MainTex ("Main Texture", 2D) = "white" {}
 		_Color ("Color", Color) = (1,1,1,1)
+		
+		_BumpScale("Scale", Float) = 1.0
 		_BumpMap ("Normal Map", 2D) = "bump" {}
 		
+		[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
+		[PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
+		[PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
+		
 		_EmissionColor("Color", Color) = (0,0,0,0)		
 		_EmissionMap("Emission", 2D) = "white" {}
 		_EmissionPower("Emission Power", Float) = 2.0	
 		
+		_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
+		_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
+		[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
+		_MetallicGlossMap("Metallic", 2D) = "white" {}
+		
 		_DiffuseRamp ("Diffuse Ramp Texture", 2D) = "gray" {}
 		
-		_FixedNormal ("Fixed Normal", Vector) = (0,0,-1,1)
+		_FixedNormal ("Fixed Normal", Vector) = (0,0,1,1)
 		_ZWrite ("Depth Write", Float) = 1.0
 		_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.5
 		_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
+		_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
 		
 		_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
 		_Hue("Hue", Range(-0.5,0.5)) = 0.0	
@@ -36,7 +48,7 @@ Shader "Spine/Sprite/Pixel Lit"
 	
 	SubShader
 	{
-		Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" }
+		Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
 		LOD 200
 		
 		Pass
@@ -51,9 +63,10 @@ Shader "Spine/Sprite/Pixel Lit"
 			CGPROGRAM
 				#pragma target 3.0
 				
-				#pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
+				#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
+				#pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE  _FIXED_NORMALS_MODELSPACE_BACKFACE
+				#pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
 				#pragma shader_feature _NORMALMAP
-				#pragma shader_feature _ _FIXED_NORMALS _FIXED_NORMALS_BACK_RENDERING
 				#pragma shader_feature _ALPHA_CLIP
 				#pragma shader_feature _EMISSION
 				#pragma shader_feature _RIM_LIGHTING
@@ -64,13 +77,15 @@ Shader "Spine/Sprite/Pixel Lit"
 				#pragma shader_feature _FOG
 				
 				#pragma multi_compile_fwdbase
-                #pragma fragmentoption ARB_precision_hint_fastest
+				#pragma fragmentoption ARB_precision_hint_fastest
 				#pragma multi_compile_fog
+				#pragma multi_compile _ PIXELSNAP_ON
+				#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
 				
 				#pragma vertex vert
 				#pragma fragment fragBase
 				
-				#include "SpritePixelLighting.cginc"	
+				#include "CGIncludes/SpritePixelLighting.cginc"	
 			ENDCG
 		}
 		Pass
@@ -85,23 +100,26 @@ Shader "Spine/Sprite/Pixel Lit"
 			CGPROGRAM
 				#pragma target 3.0
 				
-				#pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
+				#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
+				#pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE  _FIXED_NORMALS_MODELSPACE_BACKFACE
+				#pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
 				#pragma shader_feature _NORMALMAP
-				#pragma shader_feature _ _FIXED_NORMALS _FIXED_NORMALS_BACK_RENDERING
-				#pragma shader_feature _ALPHA_CLIP
+				#pragma shader_feature _ALPHA_CLIP	
 				#pragma shader_feature _DIFFUSE_RAMP
 				#pragma shader_feature _COLOR_ADJUST
 				#pragma shader_feature _TEXTURE_BLEND
 				#pragma shader_feature _FOG
 				
 				#pragma multi_compile_fwdadd_fullshadows
-                #pragma fragmentoption ARB_precision_hint_fastest
+				#pragma fragmentoption ARB_precision_hint_fastest
 				#pragma multi_compile_fog
+				#pragma multi_compile _ PIXELSNAP_ON
+				#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
 				
 				#pragma vertex vert
 				#pragma fragment fragAdd
 				
-				#include "SpritePixelLighting.cginc"
+				#include "CGIncludes/SpritePixelLighting.cginc"
 			ENDCG
 		}
 		Pass
@@ -117,13 +135,15 @@ Shader "Spine/Sprite/Pixel Lit"
 			Lighting Off
 			
 			CGPROGRAM		
-				#pragma multi_compile_shadowcaster
 				#pragma fragmentoption ARB_precision_hint_fastest
+				#pragma multi_compile_shadowcaster
+				#pragma multi_compile _ PIXELSNAP_ON
+				#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
 				
 				#pragma vertex vert
 				#pragma fragment frag
 				
-				#include "SpriteShadows.cginc"
+				#include "CGIncludes/SpriteShadows.cginc"
 			ENDCG
 		}
 	}

+ 14 - 5
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/SpritesUnlit.shader

@@ -5,9 +5,14 @@ Shader "Spine/Sprite/Unlit"
 		_MainTex ("Main Texture", 2D) = "white" {}
 		_Color ("Color", Color) = (1,1,1,1)
 		
+		[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
+		[PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
+		[PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
+		
 		_ZWrite ("Depth Write", Float) = 0.0
 		_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.0
 		_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
+		_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
 		
 		_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
 		_Hue("Hue", Range(-0.5,0.5)) = 0.0
@@ -25,7 +30,7 @@ Shader "Spine/Sprite/Unlit"
 	
 	SubShader
 	{
-		Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" }
+		Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
 		LOD 100
 		
 		Pass
@@ -38,7 +43,7 @@ Shader "Spine/Sprite/Unlit"
 			Lighting Off
 			
 			CGPROGRAM			
-				#pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
+				#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
 				#pragma shader_feature _ALPHA_CLIP
 				#pragma shader_feature _TEXTURE_BLEND
 				#pragma shader_feature _COLOR_ADJUST
@@ -46,11 +51,13 @@ Shader "Spine/Sprite/Unlit"
 				
 				#pragma fragmentoption ARB_precision_hint_fastest
 				#pragma multi_compile_fog
+				#pragma multi_compile _ PIXELSNAP_ON
+				#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
 				
 				#pragma vertex vert
 				#pragma fragment frag
 				
-				#include "SpriteUnlit.cginc"
+				#include "CGIncludes/SpriteUnlit.cginc"
 			ENDCG
 		}
 		Pass
@@ -66,13 +73,15 @@ Shader "Spine/Sprite/Unlit"
 			Lighting Off
 			
 			CGPROGRAM		
-				#pragma multi_compile_shadowcaster
 				#pragma fragmentoption ARB_precision_hint_fastest
+				#pragma multi_compile_shadowcaster
+				#pragma multi_compile _ PIXELSNAP_ON
+				#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
 				
 				#pragma vertex vert
 				#pragma fragment frag
 				
-				#include "SpriteShadows.cginc"
+				#include "CGIncludes/SpriteShadows.cginc"
 			ENDCG
 		}
 	}

+ 26 - 8
spine-unity/Assets/spine-unity/Modules/Shaders/Sprite/SpritesVertexLit.shader

@@ -4,18 +4,30 @@ Shader "Spine/Sprite/Vertex Lit"
 	{
 		_MainTex ("Main Texture", 2D) = "white" {}
 		_Color ("Color", Color) = (1,1,1,1)
+		
+		_BumpScale("Scale", Float) = 1.0
 		_BumpMap ("Normal Map", 2D) = "bump" {}
 		
+		[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
+		[PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
+		[PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
+		
 		_EmissionColor("Color", Color) = (0,0,0,0)
 		_EmissionMap("Emission", 2D) = "white" {}
 		_EmissionPower("Emission Power", Float) = 2.0	
 		
+		_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
+		_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
+		[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
+		_MetallicGlossMap("Metallic", 2D) = "white" {}
+		
 		_DiffuseRamp ("Diffuse Ramp Texture", 2D) = "gray" {}
 		
-		_FixedNormal ("Fixed Normal", Vector) = (0,0,-1,1)
+		_FixedNormal ("Fixed Normal", Vector) = (0,0,1,1)
 		_ZWrite ("Depth Write", Float) = 0.0
 		_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.0
 		_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
+		_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
 		
 		_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
 		_Hue("Hue", Range(-0.5,0.5)) = 0.0
@@ -36,7 +48,7 @@ Shader "Spine/Sprite/Vertex Lit"
 	
 	SubShader
 	{
-		Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" }
+		Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
 		LOD 150
 		
 		Pass
@@ -52,9 +64,10 @@ Shader "Spine/Sprite/Vertex Lit"
 			CGPROGRAM
 				#pragma target 3.0
 				
-				#pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
+				#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
+				#pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE  _FIXED_NORMALS_MODELSPACE_BACKFACE
+				#pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
 				#pragma shader_feature _NORMALMAP
-				#pragma shader_feature _ _FIXED_NORMALS _FIXED_NORMALS_BACK_RENDERING
 				#pragma shader_feature _ALPHA_CLIP
 				#pragma shader_feature _EMISSION
 				#pragma shader_feature _DIFFUSE_RAMP
@@ -64,13 +77,16 @@ Shader "Spine/Sprite/Vertex Lit"
 				#pragma shader_feature _SPHERICAL_HARMONICS
 				#pragma shader_feature _FOG
 				
-                #pragma fragmentoption ARB_precision_hint_fastest
+			
+				#pragma fragmentoption ARB_precision_hint_fastest
 				#pragma multi_compile_fog
+				#pragma multi_compile _ PIXELSNAP_ON
+				#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
 				
 				#pragma vertex vert
 				#pragma fragment frag
 				
-				#include "SpriteVertexLighting.cginc"	
+				#include "CGIncludes/SpriteVertexLighting.cginc"	
 			ENDCG
 		}
 		Pass
@@ -86,13 +102,15 @@ Shader "Spine/Sprite/Vertex Lit"
 			Lighting Off
 			
 			CGPROGRAM		
-				#pragma multi_compile_shadowcaster
 				#pragma fragmentoption ARB_precision_hint_fastest
+				#pragma multi_compile_shadowcaster
+				#pragma multi_compile _ PIXELSNAP_ON
+				#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
 				
 				#pragma vertex vert
 				#pragma fragment frag
 				
-				#include "SpriteShadows.cginc"
+				#include "CGIncludes/SpriteShadows.cginc"
 			ENDCG
 		}
 	}

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott