├── .gitignore ├── pack.png ├── img ├── rot_1.png ├── rot_2.png ├── rot_3.png ├── rot_4.png ├── rot_5.png ├── align_1.png ├── align_2.png ├── crop_1.png ├── crop_2.png ├── crop_3.png ├── crop_4.png ├── flip_1.png ├── offset_1.png ├── offset_2.png ├── scale_1.png ├── scale_2.png ├── skew_1.png ├── skew_2.png ├── skew_3.png ├── stretch_1.png ├── stretch_2.png ├── unscale_1.png └── unscale_2.png ├── assets └── minecraft │ ├── textures │ └── effect │ │ └── image.png │ └── shaders │ ├── program │ └── util │ │ ├── vertex_edit.fsh │ │ ├── image.fsh │ │ ├── combine.fsh │ │ ├── util.vsh │ │ ├── combine.json │ │ ├── image.json │ │ ├── vertex_edit.json │ │ └── vertex_edit.vsh │ └── post │ └── transparency.json ├── pack.mcmeta ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | distr -------------------------------------------------------------------------------- /pack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/pack.png -------------------------------------------------------------------------------- /img/rot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/rot_1.png -------------------------------------------------------------------------------- /img/rot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/rot_2.png -------------------------------------------------------------------------------- /img/rot_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/rot_3.png -------------------------------------------------------------------------------- /img/rot_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/rot_4.png -------------------------------------------------------------------------------- /img/rot_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/rot_5.png -------------------------------------------------------------------------------- /img/align_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/align_1.png -------------------------------------------------------------------------------- /img/align_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/align_2.png -------------------------------------------------------------------------------- /img/crop_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/crop_1.png -------------------------------------------------------------------------------- /img/crop_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/crop_2.png -------------------------------------------------------------------------------- /img/crop_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/crop_3.png -------------------------------------------------------------------------------- /img/crop_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/crop_4.png -------------------------------------------------------------------------------- /img/flip_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/flip_1.png -------------------------------------------------------------------------------- /img/offset_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/offset_1.png -------------------------------------------------------------------------------- /img/offset_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/offset_2.png -------------------------------------------------------------------------------- /img/scale_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/scale_1.png -------------------------------------------------------------------------------- /img/scale_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/scale_2.png -------------------------------------------------------------------------------- /img/skew_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/skew_1.png -------------------------------------------------------------------------------- /img/skew_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/skew_2.png -------------------------------------------------------------------------------- /img/skew_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/skew_3.png -------------------------------------------------------------------------------- /img/stretch_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/stretch_1.png -------------------------------------------------------------------------------- /img/stretch_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/stretch_2.png -------------------------------------------------------------------------------- /img/unscale_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/unscale_1.png -------------------------------------------------------------------------------- /img/unscale_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/img/unscale_2.png -------------------------------------------------------------------------------- /assets/minecraft/textures/effect/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onnowhere/VertexEdit/HEAD/assets/minecraft/textures/effect/image.png -------------------------------------------------------------------------------- /pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 9, 4 | "description": "§7Shader tools for image editing\n§bBy Onnowhere" 5 | } 6 | } -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/vertex_edit.fsh: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D DiffuseSampler; 4 | 5 | in vec2 inTexCoord; 6 | out vec4 fragColor; 7 | 8 | void main() { 9 | fragColor = texture(DiffuseSampler, inTexCoord); 10 | } 11 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/image.fsh: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D DiffuseSampler; 4 | uniform sampler2D ImageSampler; 5 | 6 | in vec2 texCoord; 7 | out vec4 fragColor; 8 | 9 | void main() { 10 | fragColor = texture(ImageSampler, vec2(texCoord.x, -texCoord.y)); 11 | } 12 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/combine.fsh: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D DiffuseSampler; 4 | uniform sampler2D CombineSampler; 5 | 6 | uniform vec2 InSize; 7 | uniform vec2 OutSize; 8 | 9 | in vec2 fragCoord; 10 | in vec2 texCoord; 11 | out vec4 fragColor; 12 | 13 | void main() { 14 | vec4 src = texture(CombineSampler, texCoord); 15 | vec4 dst = texture(DiffuseSampler, texCoord); 16 | fragColor = vec4(src.rgb*src.a + (1-src.a)*dst.rgb, min(src.a + dst.a,1.0)); 17 | if (dst == vec4(0.0) && src != vec4(0.0)) { 18 | fragColor = vec4(src.rgb, src.a); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/util.vsh: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec4 Position; 4 | out vec2 texCoord; 5 | out vec2 fragCoord; 6 | out vec2 inTexCoord; 7 | 8 | uniform mat4 ProjMat; 9 | uniform vec2 InSize; 10 | uniform vec2 OutSize; 11 | uniform vec2 ScreenSize; 12 | 13 | void main() { 14 | vec2 outPos = vec2(-1.0, -1.0); 15 | if (Position.x > 0.5) outPos.x = 1.0; 16 | if (Position.y > 0.5) outPos.y = 1.0; 17 | gl_Position = vec4(outPos.xy, 0.2, 1.0); 18 | 19 | // Coordinate between 0 and 1 based on outtarget buffer size 20 | texCoord = Position.xy / OutSize; 21 | 22 | // Raw position 23 | fragCoord = Position.xy; 24 | 25 | // Coordinate between 0 and 1 based on intarget buffer size 26 | inTexCoord = Position.xy / InSize; 27 | } 28 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/combine.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "util/util", 8 | "fragment": "util/combine", 9 | "attributes": [ "Position" ], 10 | "samplers": [ 11 | { "name": "DiffuseSampler" }, 12 | { "name": "CombineSampler" } 13 | ], 14 | "uniforms": [ 15 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 17 | { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/image.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "one", 5 | "dstrgb": "zero" 6 | }, 7 | "vertex": "util/util", 8 | "fragment": "util/image", 9 | "attributes": [ "Position" ], 10 | "samplers": [ 11 | { "name": "DiffuseSampler" }, 12 | { "name": "ImageSampler" } 13 | ], 14 | "uniforms": [ 15 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 17 | { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 18 | { "name": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/vertex_edit.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "one", 5 | "dstrgb": "zero" 6 | }, 7 | "vertex": "util/vertex_edit", 8 | "fragment": "util/vertex_edit", 9 | "attributes": [ "Position" ], 10 | "samplers": [ 11 | { "name": "DiffuseSampler" } 12 | ], 13 | "uniforms": [ 14 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 15 | { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 16 | { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 17 | { "name": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, 18 | { "name": "_Unscale", "type": "float", "count": 1, "values": [ 0.0 ] }, 19 | { "name": "_CropPixel", "type": "float", "count": 1, "values": [ 0.0 ] }, 20 | { "name": "_CropResize", "type": "float", "count": 1, "values": [ 0.0 ] }, 21 | { "name": "_CropRecenter", "type": "float", "count": 1, "values": [ 0.0 ] }, 22 | { "name": "_Crop", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 23 | { "name": "_Stretched", "type": "float", "count": 1, "values": [ 0.0 ] }, 24 | { "name": "_StretchMin", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] }, 25 | { "name": "_StretchMax", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] }, 26 | { "name": "_ScalePixel", "type": "float", "count": 1, "values": [ 0.0 ] }, 27 | { "name": "_Scale", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] }, 28 | { "name": "_OffsetPixel", "type": "float", "count": 1, "values": [ 0.0 ] }, 29 | { "name": "_Offset", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] }, 30 | { "name": "_Align", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] }, 31 | { "name": "_Flip", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] }, 32 | { "name": "_RotPixel", "type": "float", "count": 1, "values": [ 0.0 ] }, 33 | { "name": "_RotGlobal", "type": "float", "count": 1, "values": [ 0.0 ] }, 34 | { "name": "_RotOrigin", "type": "float", "count": 2, "values": [ 0.0, 0.0 ] }, 35 | { "name": "_RotAngle", "type": "float", "count": 1, "values": [ 0.0 ] }, 36 | { "name": "_SkewPixel", "type": "float", "count": 1, "values": [ 0.0 ] }, 37 | { "name": "_Skew", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/post/transparency.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { "name": "image_in", "width": 256, "height": 256, "bilinear": false }, 4 | "image_out", 5 | "swap", 6 | "main", 7 | "water", 8 | "translucent", 9 | "itemEntity", 10 | "particles", 11 | "clouds", 12 | "weather" 13 | ], 14 | "passes": [ 15 | { 16 | "name": "transparency", 17 | "intarget": "minecraft:main", 18 | "outtarget": "main", 19 | "auxtargets": [ 20 | { 21 | "name": "DiffuseDepthSampler", 22 | "id": "minecraft:main:depth" 23 | }, 24 | { 25 | "name": "TranslucentSampler", 26 | "id": "translucent" 27 | }, 28 | { 29 | "name": "TranslucentDepthSampler", 30 | "id": "translucent:depth" 31 | }, 32 | { 33 | "name": "ItemEntitySampler", 34 | "id": "itemEntity" 35 | }, 36 | { 37 | "name": "ItemEntityDepthSampler", 38 | "id": "itemEntity:depth" 39 | }, 40 | { 41 | "name": "ParticlesSampler", 42 | "id": "particles" 43 | }, 44 | { 45 | "name": "ParticlesDepthSampler", 46 | "id": "particles:depth" 47 | }, 48 | { 49 | "name": "CloudsSampler", 50 | "id": "clouds" 51 | }, 52 | { 53 | "name": "CloudsDepthSampler", 54 | "id": "clouds:depth" 55 | }, 56 | { 57 | "name": "WeatherSampler", 58 | "id": "weather" 59 | }, 60 | { 61 | "name": "WeatherDepthSampler", 62 | "id": "weather:depth" 63 | } 64 | ] 65 | }, 66 | { 67 | "name": "util/image", 68 | "intarget": "image_out", 69 | "auxtargets": [ 70 | { 71 | "name": "ImageSampler", 72 | "id": "image", 73 | "width": 256, 74 | "height": 256, 75 | "bilinear": true 76 | } 77 | ], 78 | "outtarget": "image_in" 79 | }, 80 | { 81 | "name": "util/vertex_edit", 82 | "intarget": "image_in", 83 | "outtarget": "image_out", 84 | "uniforms": [ 85 | { "name": "_Unscale", "values": [ 0.0 ] }, 86 | { "name": "_CropPixel", "values": [ 0.0 ] }, 87 | { "name": "_CropResize", "values": [ 0.0 ] }, 88 | { "name": "_CropRecenter", "values": [ 0.0 ] }, 89 | { "name": "_Crop", "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 90 | { "name": "_Stretched", "values": [ 0.0 ] }, 91 | { "name": "_StretchMin", "values": [ 0.0, 0.0 ] }, 92 | { "name": "_StretchMax", "values": [ 0.0, 0.0 ] }, 93 | { "name": "_ScalePixel", "values": [ 0.0 ] }, 94 | { "name": "_Scale", "values": [ 0.0, 0.0 ] }, 95 | { "name": "_OffsetPixel", "values": [ 0.0 ] }, 96 | { "name": "_Offset", "values": [ 0.0, 0.0 ] }, 97 | { "name": "_Align", "values": [ 0.0, 0.0 ] }, 98 | { "name": "_Flip", "values": [ 0.0, 0.0 ] }, 99 | { "name": "_RotPixel", "values": [ 0.0 ] }, 100 | { "name": "_RotGlobal", "values": [ 0.0 ] }, 101 | { "name": "_RotOrigin", "values": [ 0.0, 0.0 ] }, 102 | { "name": "_RotAngle", "values": [ 0.0 ] }, 103 | { "name": "_SkewPixel", "values": [ 0.0 ] }, 104 | { "name": "_Skew", "values": [ 0.0, 0.0, 0.0, 0.0 ] } 105 | ] 106 | }, 107 | { 108 | "name": "util/combine", 109 | "intarget": "main", 110 | "outtarget": "swap", 111 | "auxtargets": [ 112 | { 113 | "name": "CombineSampler", 114 | "id": "image_out" 115 | } 116 | ] 117 | }, 118 | { 119 | "name": "blit", 120 | "intarget": "swap", 121 | "outtarget": "minecraft:main" 122 | } 123 | ] 124 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /assets/minecraft/shaders/program/util/vertex_edit.vsh: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec4 Position; 4 | out vec2 texCoord; 5 | out vec2 fragCoord; 6 | out vec2 inTexCoord; 7 | 8 | uniform mat4 ProjMat; 9 | uniform vec2 InSize; 10 | uniform vec2 OutSize; 11 | uniform vec2 ScreenSize; 12 | 13 | uniform float _Unscale = 0.0; // Rescale image relative to pixel size instead of to buffer height (accepted values: 0, 1) 14 | uniform float _CropPixel = 0.0; // Crop by pixels instead of ratios (accepted values: 0, 1) 15 | uniform float _CropResize = 0.0; // Resize crop to fill original size (accepted values: 0, 1) 16 | uniform float _CropRecenter = 0.0; // Recenter image after crop (accepted values: 0, 1) 17 | uniform vec4 _Crop = vec4(0.0, 0.0, 0.0, 0.0); // Crop from xy corner to zw corner (set values to 0 to skip) 18 | uniform float _Stretched = 0.0; // Stretch image horizontally to fill screen (accepted values: 0, 1) 19 | uniform vec2 _StretchMin = vec2(0.0, 0.0); // Stretch image horizontally if screen ratio is larger than x/y ratio (set values to 0 to skip) 20 | uniform vec2 _StretchMax = vec2(0.0, 0.0); // Maximum ratio to stop stretching after (set values to 0 to skip) 21 | uniform float _ScalePixel = 0.0; // Scale by pixels instead of ratios (accepted values: 0, 1) 22 | uniform vec2 _Scale = vec2(0.0, 0.0); // Scale image on x and y axes (set values to 0 to skip) 23 | uniform float _OffsetPixel = 0.0; // Offset by pixels instead of ratios (accepted values: 0, 1) 24 | uniform vec2 _Offset = vec2(0.0, 0.0); // Offset image on x and y axes 25 | uniform vec2 _Align = vec2(0.0, 0.0); // Align to a corner or origin (accepted values: -1, 0, 1) 26 | uniform vec2 _Flip = vec2(0.0, 0.0); // Flip horizontally or vertically (accepted values: 0, 1) 27 | uniform float _RotPixel = 0.0; // Rotation origin by pixels instead of ratios (accepted values: 0, 1) 28 | uniform float _RotGlobal = 0.0; // Rotation on global axis instead of local (accepted values: 0, 1) 29 | uniform vec2 _RotOrigin = vec2(0.0, 0.0); // Rotation origin 30 | uniform float _RotAngle = 0.0; // Rotation angle in degrees 31 | uniform float _SkewPixel = 0.0; // Skew by pixels instead of ratios (accepted values: 0, 1) 32 | uniform vec4 _Skew = vec4(0.0, 0.0, 0.0, 0.0); // Skew top corners and their opposite corner by values xy and zw (set values to 0 to skip) 33 | 34 | void main() { 35 | vec2 minPos = vec2(-1.0); 36 | vec2 maxPos = vec2(1.0); 37 | 38 | float inSizeRatio = InSize.x / InSize.y; 39 | float outSizeRatio = OutSize.x / OutSize.y; 40 | float inoutSizeRatio = inSizeRatio / outSizeRatio; 41 | float inoutScaleRatio = InSize.y / OutSize.y; 42 | 43 | // Crop 44 | vec2 cropSize = _Crop.zw - _Crop.xy; 45 | vec2 cropMin = _Crop.xy; 46 | vec2 rescaleFactor = vec2(1.0); 47 | if (bool(_CropPixel)) { 48 | cropSize /= InSize; 49 | cropMin.x /= inoutSizeRatio; 50 | rescaleFactor = InSize; 51 | } else { 52 | cropMin *= InSize; 53 | cropMin.x /= inoutSizeRatio; 54 | } 55 | if (cropSize.x == 0 || cropSize.y == 0) { 56 | cropSize = vec2(1.0); 57 | cropMin = vec2(0.0); 58 | } else if (!bool(_CropResize)) { 59 | vec2 lowerOffset = _Crop.xy / rescaleFactor; 60 | vec2 upperOffset = _Crop.zw / rescaleFactor - vec2(1.0); 61 | minPos += lowerOffset * 2.0; 62 | maxPos += upperOffset * 2.0; 63 | } 64 | if (bool(_CropRecenter)) { 65 | vec2 centerAlign = vec2(0.0) - (minPos + maxPos) / 2.0; 66 | minPos += centerAlign; 67 | maxPos += centerAlign; 68 | } 69 | cropSize *= inoutScaleRatio; 70 | vec2 croppedPosition = Position.xy * cropSize + cropMin; 71 | croppedPosition.x *= inoutSizeRatio; 72 | 73 | // Unscale 74 | if (bool(_Unscale)) { 75 | minPos *= inoutScaleRatio; 76 | maxPos *= inoutScaleRatio; 77 | } 78 | 79 | // Stretch 80 | float stretchRatio = 1.0; 81 | bool doStretchMin = all(greaterThan(_StretchMin, vec2(0.0))); 82 | bool doStretchMax = all(greaterThan(_StretchMax, vec2(0.0))); 83 | if (doStretchMin || doStretchMax) { 84 | float stretchMinRatio = _StretchMin.x / _StretchMin.y; 85 | float stretchMaxRatio = _StretchMax.x / _StretchMax.y; 86 | if (doStretchMin && outSizeRatio < stretchMinRatio) { 87 | stretchRatio = outSizeRatio / stretchMinRatio; 88 | } else if (doStretchMax && outSizeRatio > stretchMaxRatio) { 89 | stretchRatio = outSizeRatio / stretchMaxRatio; 90 | } 91 | if (bool(_Stretched)) { 92 | stretchRatio = 1.0 / stretchRatio; 93 | } 94 | minPos.x *= stretchRatio; 95 | maxPos.x *= stretchRatio; 96 | } 97 | 98 | // Stretched 99 | if (!bool(_Stretched)) { 100 | minPos.x *= inoutSizeRatio; 101 | maxPos.x *= inoutSizeRatio; 102 | } 103 | 104 | // Flip 105 | if (bool(_Flip.x)) { 106 | croppedPosition.x = InSize.x - croppedPosition.x; 107 | } 108 | if (bool(_Flip.y)) { 109 | croppedPosition.y = InSize.y - croppedPosition.y; 110 | } 111 | 112 | // Scale 113 | vec2 scale = _Scale; 114 | if (bool(_ScalePixel)) { 115 | scale /= InSize; 116 | } 117 | if (scale.x != 0.0 && scale.y != 0.0) { 118 | minPos *= scale; 119 | maxPos *= scale; 120 | } 121 | 122 | // Align 123 | vec2 alignOffset = vec2(0.0, 0.0); 124 | if (_Align.x == -1.0) { 125 | alignOffset.x = _Align.x - minPos.x; 126 | } else if (_Align.x == 1.0) { 127 | alignOffset.x = _Align.x - maxPos.x; 128 | } 129 | if (_Align.y == -1.0) { 130 | alignOffset.y = _Align.y - minPos.y; 131 | } else if (_Align.y == 1.0) { 132 | alignOffset.y = _Align.y - maxPos.y; 133 | } 134 | minPos += alignOffset; 135 | maxPos += alignOffset; 136 | 137 | vec2 outPos = minPos; 138 | if (Position.x > 0.5) outPos.x = maxPos.x; 139 | if (Position.y > 0.5) outPos.y = maxPos.y; 140 | 141 | // Skew 142 | if (_Skew != vec4(0.0)) { 143 | vec4 skew = _Skew; 144 | if (bool(_SkewPixel)) { 145 | skew /= InSize.xyxy; 146 | skew.xz /= outSizeRatio; 147 | } else { 148 | skew *= abs(maxPos - minPos).xyxy; 149 | } 150 | if (skew.xy != vec2(0.0)) { 151 | if (Position.x < 0.5 && Position.y > 0.5) { 152 | outPos += skew.xy; 153 | } else if (Position.x > 0.5 && Position.y < 0.5) { 154 | outPos -= skew.xy; 155 | } 156 | } 157 | if (skew.zw != vec2(0.0)) { 158 | if (Position.x > 0.5 && Position.y > 0.5) { 159 | outPos += skew.zw; 160 | } else if (Position.x < 0.5 && Position.y < 0.5) { 161 | outPos -= skew.zw; 162 | } 163 | } 164 | } 165 | 166 | // Rotate 167 | if (_RotAngle != 0.0) { 168 | vec2 origin = _RotOrigin; 169 | if (bool(_RotPixel)) { 170 | origin *= 2.0; 171 | if (!bool(_RotGlobal)) { 172 | if (bool(_Stretched)) { 173 | origin.x *= outSizeRatio; 174 | } 175 | origin.x *= stretchRatio; 176 | origin *= scale / inoutScaleRatio; 177 | origin += alignOffset * OutSize; 178 | } 179 | outPos *= OutSize; 180 | } else { 181 | if (!bool(_RotGlobal)) { 182 | if (!bool(_Stretched)) { 183 | origin.x /= outSizeRatio; 184 | } 185 | origin.x *= stretchRatio; 186 | origin *= scale; 187 | origin += alignOffset; 188 | } 189 | outPos.x *= outSizeRatio; 190 | origin.x *= outSizeRatio; 191 | } 192 | float angle = radians(_RotAngle); 193 | mat2 rotation = mat2( 194 | cos(angle), -sin(angle), 195 | sin(angle), cos(angle) 196 | ); 197 | outPos = origin + rotation * (outPos - origin); 198 | if (bool(_RotPixel)) { 199 | outPos /= OutSize; 200 | } else { 201 | outPos.x /= outSizeRatio; 202 | } 203 | } 204 | 205 | // Offset 206 | if (bool(_OffsetPixel)) { 207 | outPos += _Offset / (OutSize / 2.0); 208 | } else { 209 | outPos += _Offset; 210 | } 211 | 212 | gl_Position = vec4(outPos.xy, 0.2, 1.0); 213 | 214 | inTexCoord = croppedPosition.xy / InSize; 215 | texCoord = croppedPosition.xy / OutSize; 216 | fragCoord = croppedPosition.xy; 217 | } 218 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Download the template resource pack from the [Releases page](https://github.com/onnowhere/VertexEdit/releases).** 2 | 3 | ---- 4 | 5 | # Table of Contents 6 | - [VertexEdit](#VertexEdit) 7 | - [Shader Pass Setup](#Shader-Pass-Setup) 8 | - [Tools](#Tools) 9 | 1. [Unscale](#Unscale) 10 | 1. [Crop](#Crop) 11 | 1. [Stretch](#Stretch) 12 | 1. [Scale](#Scale) 13 | 1. [Offset](#Offset) 14 | 1. [Align](#Align) 15 | 1. [Flip](#Flip) 16 | 1. [Rotate](#Rotate) 17 | 1. [Skew](#Skew) 18 | - [License](#License) 19 | 20 | 21 | # VertexEdit 22 | 23 | VertexEdit is a GLSL shader image tool for vanilla Minecraft with various vertex and UV editing features. It provides a vertex shader (`util/vertex_edit`) that can perform various operations to your image. This includes cropping, positioning, scaling, rotating, and more. This shader can either be used within its own shader pass or included as your shader program's vertex shader, allowing you to customize your fragment shader. This can be useful for displaying visuals anywhere on the user's screen. All shaders provided in this resource pack can be copied and reused for your own resource pack shaders. 24 | 25 | This template resource pack can be viewed by going into your Video Settings options and setting Graphics to *Fabulous!* 26 | 27 | # Shader Pass Setup 28 | 29 | An example of the shader pass setup can be found in the file [assets/minecraft/shaders/post/transparency.json](assets/minecraft/shaders/post/transparency.json). 30 | 31 | For our shader targets in this example, we take an input buffer called `image_in` of size 256x256 and output buffer `image_out` of default size. If you are using `image_in` to load in a custom image from a file, the values for width and height **must** match your source image resolution. We also have `main` and `swap` which are buffers used for combining our image buffer with Minecraft's render. The remaining buffers are just the default ones used by the `post/transparency.json` Minecraft shader. 32 | 33 | ```json 34 | "targets": [ 35 | { "name": "image_in", "width": 256, "height": 256, "bilinear": false }, 36 | "image_out", 37 | "swap", 38 | "main", 39 | "water", 40 | "translucent", 41 | "itemEntity", 42 | "particles", 43 | "clouds", 44 | "weather" 45 | ], 46 | ``` 47 | 48 | The first pass in the example is a direct copy of Minecraft's pass to combine the default passes to create the final image Minecraft renders to the screen. This is used only in the `post/transparency.json` shader. We will be using this as the base image to combine our custom image into. The output will be stored in our buffer called `main`. 49 | ```json 50 | { 51 | "name": "transparency", 52 | "intarget": "minecraft:main", 53 | "outtarget": "main", 54 | "auxtargets": [ ... ] 55 | }, 56 | ``` 57 | 58 | The second pass loads the image we want to display into the `image_in` buffer target using a custom image loading shader called `util/image`. In this case, we are sourcing a 256x256 image via `"id": "image"`, which loads from the file called `assets/minecraft/textures/effect/image.png`. If you are directly using an image, you will need to use this pass to load it in. You can of course use any target buffer with VertexEdit, not just ones loaded from a custom image. The `intarget` here is just a dummy buffer, as we are only using the buffer from the `ImageSampler` to load an image. 59 | ```json 60 | { 61 | "name": "util/image", 62 | "intarget": "image_out", 63 | "auxtargets": [ 64 | { 65 | "name": "ImageSampler", 66 | "id": "image", 67 | "width": 256, 68 | "height": 256, 69 | "bilinear": true 70 | } 71 | ], 72 | "outtarget": "image_in" 73 | }, 74 | ``` 75 | 76 | This pass utilizes `util/vertex_edit`, which is where the main work is done. Here we have all the operations we can adjust to perform different edits to your input image from `image_in`. Detail about these operations can be found under the [Tools](#Tools) section. The output **must** be a buffer that matches the size of the buffer you will combine this image with. In this case, `image_out` is the same default size as `main`. 77 | ```json 78 | { 79 | "name": "util/vertex_edit", 80 | "intarget": "image_in", 81 | "outtarget": "image_out", 82 | "uniforms": [ 83 | { "name": "_Unscale", "values": [ 0.0 ] }, 84 | { "name": "_CropPixel", "values": [ 0.0 ] }, 85 | { "name": "_CropResize", "values": [ 0.0 ] }, 86 | { "name": "_CropRecenter", "values": [ 0.0 ] }, 87 | { "name": "_Crop", "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 88 | { "name": "_Stretched", "values": [ 0.0 ] }, 89 | { "name": "_StretchMin", "values": [ 0.0, 0.0 ] }, 90 | { "name": "_StretchMax", "values": [ 0.0, 0.0 ] }, 91 | { "name": "_Scale", "values": [ 0.0, 0.0 ] }, 92 | { "name": "_OffsetPixel", "values": [ 0.0 ] }, 93 | { "name": "_Offset", "values": [ 0.0, 0.0 ] }, 94 | { "name": "_Align", "values": [ 0.0, 0.0 ] }, 95 | { "name": "_Flip", "values": [ 0.0, 0.0 ] }, 96 | { "name": "_RotPixel", "values": [ 0.0 ] }, 97 | { "name": "_RotGlobal", "values": [ 0.0 ] }, 98 | { "name": "_RotOrigin", "values": [ 0.0, 0.0 ] }, 99 | { "name": "_RotAngle", "values": [ 0.0 ] }, 100 | { "name": "_SkewPixel", "values": [ 0.0 ] }, 101 | { "name": "_Skew", "values": [ 0.0, 0.0, 0.0, 0.0 ] } 102 | ] 103 | } 104 | ``` 105 | 106 | In this pass, we use `util/combine` to combine the source image from `main` with our custom edited image from `image_out` via the `CombineSampler`. We output to another buffer called `swap` so that we can pass it over to the last buffer which finalizes the image. 107 | ```json 108 | { 109 | "name": "util/combine", 110 | "intarget": "main", 111 | "outtarget": "swap", 112 | "auxtargets": [ 113 | { 114 | "name": "CombineSampler", 115 | "id": "image_out" 116 | } 117 | ] 118 | }, 119 | ``` 120 | 121 | This final pass simply copies the final output from `swap` into Minecraft's main rendering buffer `minecraft:main`. This is a necessary step as without it, there can be issues with Minecraft's rendering when you go in F1 or third person mode. Typically, we want to do this final pass in most of our shaders to avoid these potential issues. 122 | ```json 123 | { 124 | "name": "blit", 125 | "intarget": "swap", 126 | "outtarget": "minecraft:main" 127 | } 128 | ``` 129 | 130 | # Tools 131 | 132 | The following examples use an input image of size 256x256 and an output buffer with size equal to the screen resolution. 133 | 134 | ## Unscale 135 | - `_Unscale`: Rescale image relative to pixel size instead of to buffer height (accepted values: 0, 1) 136 | 137 | If `_Unscale` is set to `0.0`, the image will be scaled to fill the full height of the output buffer. 138 | ```json 139 | { "name": "_Unscale", "values": [ 0.0 ] } 140 | ``` 141 | 142 | 143 | If `_Unscale` is set to `1.0`, the image will be scaled to be one-to-one in pixels on the screen. 144 | ```json 145 | { "name": "_Unscale", "values": [ 1.0 ] } 146 | ``` 147 | 148 | 149 | ## Crop 150 | 151 | - `_CropPixel`: Crop by pixels instead of ratios (accepted values: 0, 1) 152 | - `_CropResize`: Resize crop to fill original size (accepted values: 0, 1) 153 | - `_CropRecenter`: Recenter image after crop (accepted values: 0, 1) 154 | - `_Crop`: Crop from xy corner to zw corner (set values to 0 to skip) 155 | 156 | The first two crop values are the bottom left corner, and the second two crop values are the top right corner. By default, we are cropping using ratios. If all values of `_Crop` are set to `0.0`, the crop is skipped. Here we crop the picture between the two points `(0.5, 0.25)` and `(0.75, 0.75)`. 157 | ```json 158 | { "name": "_Crop", "values": [ 0.5, 0.25, 0.75, 0.75 ] } 159 | ``` 160 | 161 | 162 | If `_CropRecenter` is set to `1.0`, the cropped image will be recentered. 163 | ```json 164 | { "name": "_CropRecenter", "values": [ 1.0 ] }, 165 | { "name": "_Crop", "values": [ 0.5, 0.25, 0.75, 0.75 ] } 166 | ``` 167 | 168 | 169 | If `_CropResize` is set to `1.0`, the cropped image will be auto-resized to fill the size of the original uncropped frame. 170 | ```json 171 | { "name": "_CropResize", "values": [ 1.0 ] }, 172 | { "name": "_Crop", "values": [ 0.5, 0.25, 0.75, 0.75 ] } 173 | ``` 174 | 175 | 176 | If `_CropPixel` is set to `1.0`, the values used in `_Crop` will be pixel positions relative to the size of the input buffer. 177 | ```json 178 | { "name": "_CropPixel", "values": [ 1.0 ] }, 179 | { "name": "_Crop", "values": [ 64.0, 64.0, 192.0, 192.0 ] } 180 | ``` 181 | 182 | 183 | ## Stretch 184 | - `_Stretched`: Stretch image horizontally to fill screen (accepted values: 0, 1) 185 | - `_StretchMin`: Stretch image horizontally if screen ratio is larger than x/y ratio (set values to 0 to skip) 186 | - `_StretchMax`: Maximum ratio to stop stretching after (set values to 0 to skip) 187 | 188 | If `_Stretched` is set to `1.0`, the image will stretch horizontally to fill the output buffer. 189 | ```json 190 | { "name": "_Stretched", "values": [ 1.0 ] } 191 | ``` 192 | 193 | 194 | If a `_StretchedMin` ratio is defined, when the output buffer ratio exceeds this ratio, it will stretch horizontally, otherwise it will crop the image. If a `_StretchedMax` ratio is defined, when the output buffer ratio is below this ratio, it will stretch horizontally, otherwise it will retain the specified ratio. In this case, we have a minimum stretch width/height ratio of `1.0/1.0` and a maximum stretch width/height ratio of `2.0/1.0`. If `_Stretched` is set to `1.0`, this will also make sure the image is stretched to fill the horizontal width when the output buffer ratio is between the min and max stretch, otherwise it will stretch using the original image size. The image demonstrates four stages (going top to bottom) of progressively increasing the horizontal length of the screen. 195 | ```json 196 | { "name": "_Stretched", "values": [ 1.0 ] }, 197 | { "name": "_StretchMin", "values": [ 1.0, 1.0 ] }, 198 | { "name": "_StretchMax", "values": [ 2.0, 1.0 ] } 199 | ``` 200 | 201 | 202 | ## Scale 203 | - `_ScalePixel`: Scale by pixels instead of ratios (accepted values: 0, 1) 204 | - `_Scale`: Scale image on x and y axes (set values to 0 to skip) 205 | 206 | If `_Scale` is defined, the image will be scaled horizontally by the first value and vertically by the second value relative to the size of the input buffer. 207 | ```json 208 | { "name": "_Scale", "values": [ 0.25, 0.5 ] } 209 | ``` 210 | 211 | 212 | If `_ScalePixel` is set to `1.0`, the image will be scaled by the values of `_Scale` relative to the size of the input buffer in pixels instead of by ratios. 213 | ```json 214 | { "name": "_ScalePixel", "values": [ 1.0 ] }, 215 | { "name": "_Scale", "values": [ 128.0, 64.0 ] } 216 | ``` 217 | 218 | 219 | ## Offset 220 | - `_OffsetPixel`: Offset by pixels instead of ratios (accepted values: 0, 1) 221 | - `_Offset`: Offset image on x and y axes 222 | 223 | If `_Offset` is defined, the image will be offset horizontally the first value and vertically by the second value relative to the size of the output buffer. 224 | ```json 225 | { "name": "_Offset", "values": [ 1.0, -0.5 ] } 226 | ``` 227 | 228 | 229 | If `_OffsetPixel` is set to `1.0`, the image will be offset by the values of `_Offset` relative to the size of the output buffer in pixels instead of by ratios. 230 | ```json 231 | { "name": "_OffsetPixel", "values": [ 1.0 ] }, 232 | { "name": "_Offset", "values": [ -560.0, 315.0 ] } 233 | ``` 234 | 235 | 236 | ## Align 237 | - `_Align`: Align to a corner or origin (accepted values: -1, 0, 1) 238 | 239 | The values of `_Align` correspond to corners and centerpoints on the output buffer. The first value is horizontal alignment and the second value is vertical alignment. `-1.0` corresponds to the left and bottom side of the buffer, `0.0` corresponds to the center of the buffer, and `1.0` corresponds to the right and top side of the buffer. In this example, we are aligning to the right and bottom of the screen. 240 | ```json 241 | { "name": "_Scale", "values": [ 0.4, 0.4 ] }, 242 | { "name": "_Align", "values": [ 1.0, -1.0 ] } 243 | ``` 244 | 245 | 246 | In this example, we are aligning to the left and vertical center of the screen. 247 | ```json 248 | { "name": "_Scale", "values": [ 0.4, 0.4 ] }, 249 | { "name": "_Align", "values": [ -1.0, 0.0 ] } 250 | ``` 251 | 252 | 253 | ## Flip 254 | - `_Flip`: Flip horizontally or vertically (accepted values: 0, 1) 255 | 256 | Setting the values of `_Flip` to `1.0` determine whether the image will flip horizontally and/or vertically. 257 | ```json 258 | { "name": "_Flip", "values": [ 0.0, 1.0 ] } 259 | ``` 260 | 261 | 262 | ## Rotate 263 | - `_RotPixel`: Rotation origin by pixels instead of ratios (accepted values: 0, 1) 264 | - `_RotGlobal`: Rotation on global axis instead of local (accepted values: 0, 1) 265 | - `_RotOrigin`: Rotation origin 266 | - `_RotAngle`: Rotation angle in degrees 267 | 268 | The value of `_RotAngle` is in degrees, and will rotate the image about the rotation origin which is default in the center of the image. 269 | ```json 270 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 271 | { "name": "_RotAngle", "values": [ 30.0 ] } 272 | ``` 273 | 274 | 275 | The values of `_RotOrigin` determine the `(x,y)` position of the origin. By default it is relative to the image. Here we rotate about the left top corner. 276 | ```json 277 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 278 | { "name": "_RotOrigin", "values": [ -1.0, 1.0 ] }, 279 | { "name": "_RotAngle", "values": [ 30.0 ] } 280 | ``` 281 | 282 | 283 | If `_RotGlobal` is set to `1.0`, the values of `_RotOrigin` determine the `(x,y)` position of the origin relative to the output buffer. Here we rotate about the bottom center of the output buffer. 284 | ```json 285 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 286 | { "name": "_RotGlobal", "values": [ 1.0 ] }, 287 | { "name": "_RotOrigin", "values": [ 0.0, -1.0 ] }, 288 | { "name": "_RotAngle", "values": [ 30.0 ] } 289 | ``` 290 | 291 | 292 | If `_RotPixel` is set to `1.0`, the values of `_RotOrigin` determine the `(x,y)` position of the origin in pixels. By default it is relative to the image in pixels. Here we rotate about the right top corner of the image. 293 | ```json 294 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 295 | { "name": "_RotPixel", "values": [ 1.0 ] }, 296 | { "name": "_RotOrigin", "values": [ 128.0, 128.0 ] }, 297 | { "name": "_RotAngle", "values": [ 30.0 ] } 298 | ``` 299 | 300 | 301 | If `_RotPixel` and `_RotGlobal` are set to `1.0`, the values of `_RotOrigin` determine the `(x,y)` position of the origin in pixels relative to the output buffer in pixels. Here we rotate about the right center of the output buffer. 302 | ```json 303 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 304 | { "name": "_RotPixel", "values": [ 1.0 ] }, 305 | { "name": "_RotGlobal", "values": [ 1.0 ] }, 306 | { "name": "_RotOrigin", "values": [ 560.0, 0.0 ] }, 307 | { "name": "_RotAngle", "values": [ 30.0 ] } 308 | ``` 309 | 310 | 311 | ## Skew 312 | - `_SkewPixel`: Skew by pixels instead of ratios (accepted values: 0, 1) 313 | - `_Skew`: Skew top corners and their opposite corner by values xy and zw (set values to 0 to skip) 314 | 315 | The values of `_Skew` correspond to the offsets of the top two corners of the image as well as the mirrored offset of the opposite corner. The first two values are the offset of the left top corner, which will be mirrored by the right bottom corner. The second two values are the offset of the right top corner, which will be mirrored by the left bottom corner. In this example, we offset the left top corner by `(-1.0, 0.5)`. 316 | ```json 317 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 318 | { "name": "_Skew", "values": [ -1.0, 0.5, 0.0, 0.0 ] } 319 | ``` 320 | 321 | 322 | In this example, we offset the right top corner by `(-0.25, -0.5)`. 323 | ```json 324 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 325 | { "name": "_Skew", "values": [ 0.0, 0.0, -0.25, -0.5 ] } 326 | ``` 327 | 328 | 329 | If `_SkewPixel` is set to `1.0`, the offset will be relative to the original image in pixels instead of by ratio. In this case we are offsetting the left top corner by `(0.0, -128.0)` in pixels. 330 | ```json 331 | { "name": "_Scale", "values": [ 0.5, 0.5 ] }, 332 | { "name": "_SkewPixel", "values": [ 1.0 ] }, 333 | { "name": "_Skew", "values": [ 0.0, -128.0, 0.0, 0.0 ] } 334 | ``` 335 | 336 | 337 | # License 338 | 339 | This project is made available under the [Creative Commons CC0 Public Domain license](LICENSE). --------------------------------------------------------------------------------