diff -ruN javie-0.3.7-src/ch.kuramo.javie.api/META-INF/MANIFEST.MF javie-0.3.8-src/ch.kuramo.javie.api/META-INF/MANIFEST.MF --- javie-0.3.7-src/ch.kuramo.javie.api/META-INF/MANIFEST.MF 2010-03-25 01:38:17.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.api/META-INF/MANIFEST.MF 2010-04-03 00:59:14.000000000 +0900 @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Javie API Bundle-SymbolicName: ch.kuramo.javie.api;singleton:=true -Bundle-Version: 0.3.7.qualifier +Bundle-Version: 0.3.8.qualifier Bundle-Vendor: rakusan Export-Package: ch.kuramo.javie.api, ch.kuramo.javie.api.annotations, diff -ruN javie-0.3.7-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle.properties javie-0.3.8-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle.properties --- javie-0.3.7-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle.properties 2010-03-04 06:49:01.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle.properties 2010-03-30 00:36:28.000000000 +0900 @@ -27,6 +27,7 @@ effectCategory.stylize = Stylize effectCategory.distort = Distort effectCategory.transition = Transition +effectCategory.noiseGrain = Noise & Grain effectCategory.blurAndSharpen = Blur & Sharpen effectCategory.utility = Utility effectCategory.time = Time diff -ruN javie-0.3.7-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle_ja.properties javie-0.3.8-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle_ja.properties --- javie-0.3.7-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle_ja.properties 2010-03-04 06:49:01.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.api/OSGI-INF/l10n/bundle_ja.properties 2010-03-30 00:36:28.000000000 +0900 @@ -27,6 +27,7 @@ effectCategory.stylize = \u30b9\u30bf\u30a4\u30e9\u30a4\u30ba effectCategory.distort = \u30c7\u30a3\u30b9\u30c8\u30fc\u30b7\u30e7\u30f3 effectCategory.transition = \u30c8\u30e9\u30f3\u30b8\u30b7\u30e7\u30f3 +effectCategory.noiseGrain = \u30ce\u30a4\u30ba\uff06\u30b0\u30ec\u30a4\u30f3 effectCategory.blurAndSharpen = \u30d6\u30e9\u30fc\uff06\u30b7\u30e3\u30fc\u30d7 effectCategory.utility = \u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3 effectCategory.time = \u6642\u9593 diff -ruN javie-0.3.7-src/ch.kuramo.javie.api/plugin.xml javie-0.3.8-src/ch.kuramo.javie.api/plugin.xml --- javie-0.3.7-src/ch.kuramo.javie.api/plugin.xml 2010-03-04 06:49:01.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.api/plugin.xml 2010-03-30 00:36:28.000000000 +0900 @@ -26,6 +26,10 @@ name="%effectCategory.transition"> + + diff -ruN javie-0.3.7-src/ch.kuramo.javie.api/src/main/java/ch/kuramo/javie/api/annotations/Effect.java javie-0.3.8-src/ch.kuramo.javie.api/src/main/java/ch/kuramo/javie/api/annotations/Effect.java --- javie-0.3.7-src/ch.kuramo.javie.api/src/main/java/ch/kuramo/javie/api/annotations/Effect.java 2010-03-04 06:49:01.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.api/src/main/java/ch/kuramo/javie/api/annotations/Effect.java 2010-03-30 00:36:28.000000000 +0900 @@ -42,6 +42,7 @@ final String STYLIZE = "ch.kuramo.javie.api.effectCategory.stylize"; final String DISTORT = "ch.kuramo.javie.api.effectCategory.distort"; final String TRANSITION = "ch.kuramo.javie.api.effectCategory.transition"; + final String NOISE_AND_GRAIN = "ch.kuramo.javie.api.effectCategory.noiseGrain"; final String BLUR_AND_SHARPEN = "ch.kuramo.javie.api.effectCategory.blurAndSharpen"; final String UTILITY = "ch.kuramo.javie.api.effectCategory.utility"; final String TIME = "ch.kuramo.javie.api.effectCategory.time"; diff -ruN javie-0.3.7-src/ch.kuramo.javie.app/META-INF/MANIFEST.MF javie-0.3.8-src/ch.kuramo.javie.app/META-INF/MANIFEST.MF --- javie-0.3.7-src/ch.kuramo.javie.app/META-INF/MANIFEST.MF 2010-03-25 01:38:17.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.app/META-INF/MANIFEST.MF 2010-04-03 00:59:14.000000000 +0900 @@ -2,15 +2,15 @@ Bundle-ManifestVersion: 2 Bundle-Name: Javie Application Plug-in Bundle-SymbolicName: ch.kuramo.javie.app; singleton:=true -Bundle-Version: 0.3.7.qualifier +Bundle-Version: 0.3.8.qualifier Bundle-Activator: ch.kuramo.javie.app.Activator Bundle-Vendor: rakusan Require-Bundle: org.eclipse.ui, org.eclipse.ui.console, org.eclipse.core.runtime, - ch.kuramo.javie.api;bundle-version="0.3.7", - ch.kuramo.javie.core;bundle-version="0.3.7", - ch.kuramo.javie.effects;bundle-version="0.3.7", + ch.kuramo.javie.api;bundle-version="0.3.8", + ch.kuramo.javie.core;bundle-version="0.3.8", + ch.kuramo.javie.effects;bundle-version="0.3.8", com.google.code.guice;bundle-version="2.0.0", javassist;bundle-version="3.11.0", org.scannotation;bundle-version="1.0.2", diff -ruN javie-0.3.7-src/ch.kuramo.javie.app/README.txt javie-0.3.8-src/ch.kuramo.javie.app/README.txt --- javie-0.3.7-src/ch.kuramo.javie.app/README.txt 2010-03-25 01:39:35.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.app/README.txt 2010-04-03 00:57:49.000000000 +0900 @@ -1,5 +1,5 @@ ====================================================================== -Javie 0.3.7 +Javie 0.3.8 ====================================================================== ------------ @@ -89,6 +89,11 @@ バージョン履歴 -------------- +2010-04-03 ver 0.3.8 + ・フラクタルノイズエフェクトを追加(いくつか不備があるため暫定版です) + ・グローエフェクトに[A&B(アルファチャンネル基準)]オプションを追加 + ・コラップストランスフォームを使用した場合に時刻の計算が誤っていたバグを修正 + 2010-03-25 ver 0.3.7  ・更新マネージャを使用して更新できる最初のバージョン  ・グローエフェクトを追加 diff -ruN javie-0.3.7-src/ch.kuramo.javie.app/app.product javie-0.3.8-src/ch.kuramo.javie.app/app.product --- javie-0.3.7-src/ch.kuramo.javie.app/app.product 2010-03-25 01:39:35.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.app/app.product 2010-04-03 01:00:34.000000000 +0900 @@ -1,11 +1,11 @@ - + - Javie 0.3.7 + Javie 0.3.8 Copyright (c) 2009,2010 Yoshikazu Kuramochi All rights reserved. @@ -36,7 +36,6 @@ - @@ -77,7 +76,7 @@ - + diff -ruN javie-0.3.7-src/ch.kuramo.javie.app/plugin.xml javie-0.3.8-src/ch.kuramo.javie.app/plugin.xml --- javie-0.3.7-src/ch.kuramo.javie.app/plugin.xml 2010-03-25 01:39:35.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.app/plugin.xml 2010-04-03 01:00:34.000000000 +0900 @@ -13,7 +13,7 @@ + value="Javie 0.3.8 Copyright (c) 2009,2010 Yoshikazu Kuramochi All rights reserved. This product include third party software: Eclipse RCP: http://www.eclipse.org/ FreeType2: http://www.freetype.org/ FTGL: http://sourceforge.net/projects/ftgl/ Guice: http://code.google.com/p/google-guice/ Vecmath: https://vecmath.dev.java.net/ Javassist: http://www.csg.is.titech.ac.jp/~chiba/javassist/ JOGL: http://kenai.com/projects/jogl/ JSONIC: http://jsonic.sourceforge.jp/ JNA: https://jna.dev.java.net/ Scannotation: http://sourceforge.net/projects/scannotation/ SLF4J: http://www.slf4j.org/ Rhino: http://www.mozilla.org/rhino/ Tritonus: http://www.tritonus.org/"> diff -ruN javie-0.3.7-src/ch.kuramo.javie.app.feature/feature.xml javie-0.3.8-src/ch.kuramo.javie.app.feature/feature.xml --- javie-0.3.7-src/ch.kuramo.javie.app.feature/feature.xml 2010-03-25 01:39:35.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.app.feature/feature.xml 2010-04-03 01:00:34.000000000 +0900 @@ -1,8 +1,8 @@ - - - @@ -83,6 +80,9 @@ + + + inputBufferOperation = new WrappedOperation() { @@ -436,8 +441,13 @@ opacity = _opacity.value(_vrContext) / 100d * ct.getOpacity(); } + final Time time = _vrContext.getTime(); + VideoLayerRenderer r = new VideoLayerRenderer() { public VideoLayerBuffer render(boolean withDepthBuffer) { + // 繧ウ繝ゥ繝繝励せ縺励※縺繧九→縺阪ッ縺薙%縺ァ譎ょ綾繧貞榊コヲ險ュ螳壹☆繧句ソ隕√′縺ゅk縲 + _vrContext.setTime(time); + final VideoBuffer rasterBuffer = _vrSupport.createVideoBuffer(_vrContext.getColorMode(), camera.getViewportSize()); rasterBuffer.allocateAsTexture(); rasterBuffer.clear(); diff -ruN javie-0.3.7-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/LayerMatrixUtil.java javie-0.3.8-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/LayerMatrixUtil.java --- javie-0.3.7-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/LayerMatrixUtil.java 2009-12-21 21:43:29.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/LayerMatrixUtil.java 2010-03-28 03:54:51.000000000 +0900 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Yoshikazu Kuramochi + * Copyright (c) 2009,2010 Yoshikazu Kuramochi * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -32,6 +32,7 @@ import ch.kuramo.javie.core.LayerNature; import ch.kuramo.javie.core.MediaItemLayer; import ch.kuramo.javie.core.TransformableLayer; +import ch.kuramo.javie.core.WrappedOperation; import ch.kuramo.javie.core.services.VideoRenderContext; import ch.kuramo.javie.core.services.VideoRenderSupport; @@ -80,7 +81,13 @@ multCollapseTransformation(ct.getParent(), threeD && LayerNature.isThreeD(layer)); } - multModelViewMatrix(layer, null, threeD); + _vrContext.saveAndExecute(new WrappedOperation() { + public Object execute() { + _vrContext.setTime(ct.getTime()); + multModelViewMatrix(layer, null, threeD); + return null; + } + }); } private void multModelViewMatrix(Layer layer, Vec2d offset, boolean threeD) { diff -ruN javie-0.3.7-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/MediaItemLayerImpl.java javie-0.3.8-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/MediaItemLayerImpl.java --- javie-0.3.7-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/MediaItemLayerImpl.java 2010-02-13 11:47:48.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/MediaItemLayerImpl.java 2010-03-28 03:54:51.000000000 +0900 @@ -24,6 +24,7 @@ package ch.kuramo.javie.core.internal; import net.arnx.jsonic.JSONHint; +import ch.kuramo.javie.api.Time; import ch.kuramo.javie.core.Camera; import ch.kuramo.javie.core.CollapseTransformation; import ch.kuramo.javie.core.Composition; @@ -162,6 +163,8 @@ final VideoLayerComposer composer, final Camera camera, final CollapseTransformation ct, final LayerComposition preComp) { + final Time time = _vrContext.getTime(); + final double opacity; if (ct != null) { opacity = getOpacity().value(_vrContext) / 100d * ct.getOpacity(); @@ -172,11 +175,13 @@ final CollapseTransformation ct2 = new CollapseTransformation() { public CollapseTransformation getParent() { return ct; } public MediaItemLayer getLayer() { return MediaItemLayerImpl.this; } + public Time getTime() { return time; } public double getOpacity() { return opacity; } }; _vrContext.saveAndExecute(new WrappedOperation() { public Object execute() { + _vrContext.setTime(calcVideoMediaTime(getMediaInput())); preComp.setupCollapseTransformation(composer, camera, ct2); return null; } diff -ruN javie-0.3.7-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/services/VideoRenderSupportImpl.java javie-0.3.8-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/services/VideoRenderSupportImpl.java --- javie-0.3.7-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/services/VideoRenderSupportImpl.java 2010-03-17 09:58:48.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.core/src/main/java/ch/kuramo/javie/core/internal/services/VideoRenderSupportImpl.java 2010-04-03 00:41:43.000000000 +0900 @@ -631,6 +631,7 @@ gl.glActiveTexture(GL2.GL_TEXTURE0 + j); gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, 0); } + gl.glActiveTexture(GL2.GL_TEXTURE0); gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, 0, 0); diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/META-INF/MANIFEST.MF javie-0.3.8-src/ch.kuramo.javie.effects/META-INF/MANIFEST.MF --- javie-0.3.7-src/ch.kuramo.javie.effects/META-INF/MANIFEST.MF 2010-03-25 01:38:17.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/META-INF/MANIFEST.MF 2010-04-03 00:59:14.000000000 +0900 @@ -2,8 +2,9 @@ Bundle-ManifestVersion: 2 Bundle-Name: Javie Effects Bundle-SymbolicName: ch.kuramo.javie.effects;singleton:=true -Bundle-Version: 0.3.7.qualifier +Bundle-Version: 0.3.8.qualifier Bundle-Vendor: rakusan Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Require-Bundle: ch.kuramo.javie.api;bundle-version="0.3.7" +Require-Bundle: ch.kuramo.javie.api;bundle-version="0.3.8", + java3d.vecmath;bundle-version="1.5.2" Eclipse-BuddyPolicy: global diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoise.java javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoise.java --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoise.java 1970-01-01 09:00:00.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoise.java 2010-04-02 22:51:23.000000000 +0900 @@ -0,0 +1,652 @@ +/* + * Copyright (c) 2010 Yoshikazu Kuramochi + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package ch.kuramo.javie.effects.noiseGrain; + +import javax.media.opengl.GL2; +import javax.media.opengl.glu.GLU; +import javax.vecmath.Matrix3d; + +import ch.kuramo.javie.api.IAnimatableBoolean; +import ch.kuramo.javie.api.IAnimatableDouble; +import ch.kuramo.javie.api.IAnimatableEnum; +import ch.kuramo.javie.api.IAnimatableInteger; +import ch.kuramo.javie.api.IAnimatableVec2d; +import ch.kuramo.javie.api.IShaderProgram; +import ch.kuramo.javie.api.IVideoBuffer; +import ch.kuramo.javie.api.RenderResolution; +import ch.kuramo.javie.api.Vec2d; +import ch.kuramo.javie.api.VideoBounds; +import ch.kuramo.javie.api.annotations.Effect; +import ch.kuramo.javie.api.annotations.GLProgram; +import ch.kuramo.javie.api.annotations.GLShader; +import ch.kuramo.javie.api.annotations.Property; +import ch.kuramo.javie.api.annotations.GLShader.ShaderType; +import ch.kuramo.javie.api.services.IShaderRegistry; +import ch.kuramo.javie.api.services.IVideoEffectContext; +import ch.kuramo.javie.effects.VideoEffectUtil; + +import com.google.inject.Inject; + +@Effect(id="ch.kuramo.javie.FractalNoise", category=Effect.NOISE_AND_GRAIN) +public class FractalNoise { + + @GLShader(ShaderType.FRAGMENT_SHADER) + public static final String noise = "noise.frag"; + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="noise") + public static final String[] FRACTAL_NOISE = { + "uniform int fractalType;", + "uniform float contrast;", + "uniform float brightness;", + "uniform int overflow;", + "uniform int complexity;", + "uniform float influences[20];", + "uniform mat3 matrices[20];", + "uniform float evolution;", + "uniform float cycle;", + "", + "float noise(vec3 P);", + "", + "void main(void)", + "{", + " float sum = 0.0;", + " vec3 pt = vec3(gl_FragCoord.st/128.0, 1.0);", + "", + " if (fractalType == 0) {", + " if (cycle == 0.0) {", + " for (int i = 0; i < complexity; ++i) {", + " sum += influences[i]*noise(vec3((matrices[i]*pt).xy, evolution));", + " }", + " } else {", + " for (int i = 0; i < complexity; ++i) {", + " sum += influences[i]/cycle*(", + " (cycle-evolution)*noise(vec3((matrices[i]*pt).xy, evolution))", + " + evolution*noise(vec3((matrices[i]*pt).xy, evolution-cycle)));", + " }", + " }", + " sum *= 2.0;", + " } else if (fractalType == 1) {", + " if (cycle == 0.0) {", + " for (int i = 0; i < complexity; ++i) {", + " sum += influences[i]*abs(noise(vec3((matrices[i]*pt).xy, evolution)));", + " }", + " } else {", + " for (int i = 0; i < complexity; ++i) {", + " sum += influences[i]/cycle*(", + " (cycle-evolution)*abs(noise(vec3((matrices[i]*pt).xy, evolution)))", + " + evolution*abs(noise(vec3((matrices[i]*pt).xy, evolution-cycle))));", + " }", + " }", + " sum = sum * 2.0 - 1.0;", + " }", + "", + " float t = sum * contrast + brightness;", + "", + " if (overflow == 0) {", // CLIP + " t = min(max(0.5+0.5*t, 0.0), 1.0);", + " } else if (overflow == 1) {", // SOFT_CLAMP + " t = 0.5+0.3183099*atan(t);", + " } else if (overflow == 2) {", // WRAP_BACK + " t = abs(0.5+0.5*t);", + " t = 1.0 - abs(t - 2.0*float(int(t*0.5)) - 1.0);", + " } else {", // HDR + " t = 0.5+0.5*t;", + " }", + " ", + " gl_FragColor = vec4(t, t, t, 1.0);", + "}", + }; + + + public enum FractalType { BASIC, TURBULENT } + + public enum Overflow { CLIP, SOFT_CLAMP, WRAP_BACK, HDR } + + public enum BlendMode { + NONE, + NORMAL, + //DISSOLVE, + //DANCING_DISSOLVE, + + DARKEN, + MULTIPLY, + COLOR_BURN, + LINEAR_BURN, + DARKER_COLOR, + + ADD, + LIGHTEN, + SCREEN, + COLOR_DODGE, + LINEAR_DODGE, + LIGHTER_COLOR, + + OVERLAY, + SOFT_LIGHT, + HARD_LIGHT, + LINEAR_LIGHT, + VIVID_LIGHT, + PIN_LIGHT, + HARD_MIX, + + DIFFERENCE, + EXCLUSION, + + //HUE, // TODO + //SATURATION, // TODO + //COLOR, + LUMINOSITY, + + //STENCIL_ALPHA, + STENCIL_LUMA, + //SILHOUETTE_ALPHA, + SILHOUETTE_LUMA; + } + + + @Property + private IAnimatableEnum fractalType; + +// @Property +// private IAnimatableEnum noiseType; + + @Property + private IAnimatableBoolean invert; + + @Property(value="100", min="0", max="10000") + private IAnimatableDouble contrast; + + @Property(value="0", min="-10000", max="10000") + private IAnimatableDouble brightness; + + @Property("HDR") + private IAnimatableEnum overflow; + + @Property + private IAnimatableDouble rotation; + + @Property(value="100", min="1", max="10000") + private IAnimatableVec2d scale; + + @Property + private IAnimatableVec2d offset; + + @Property(value="6", min="1", max="20") + private IAnimatableDouble complexity; + + @Property(value="70", min="0", max="10000") + private IAnimatableDouble subInfluence; + + @Property(value="56", min="10", max="10000") + private IAnimatableDouble subScale; + + @Property + private IAnimatableDouble subRotation; + + @Property + private IAnimatableVec2d subOffset; + + @Property + private IAnimatableBoolean centerSubscale; + + @Property + private IAnimatableDouble evolution; + + @Property(value="0", min="0", max="100") + private IAnimatableInteger cycle; + + @Property(value="0", min="0", max="100000") + private IAnimatableInteger randomSeed; + + @Property(value="100", min="0", max="100") + private IAnimatableDouble opacity; + + @Property("NORMAL") + private IAnimatableEnum blendMode; + + + private final IVideoEffectContext context; + + private final IShaderRegistry shaders; + + private final IShaderProgram program; + + @Inject + public FractalNoise(IVideoEffectContext context, IShaderRegistry shaders) { + this.context = context; + this.shaders = shaders; + program = shaders.getProgram(FractalNoise.class, "FRACTAL_NOISE"); + } + + public IVideoBuffer doVideoEffect() { + GL2 gl = context.getGL().getGL2(); + GLU glu = context.getGLU(); + + IVideoBuffer input = null; + IVideoBuffer buf1 = null; + IVideoBuffer buf2 = null; + try { + input = context.doPreviousEffect(); + buf1 = doFractalNoise(gl, glu, input); + + BlendMode blendMode = context.value(this.blendMode); + double opacity = context.value(this.opacity) / 100; + if ((blendMode == BlendMode.NONE || blendMode == BlendMode.NORMAL) && opacity == 1.0) { + buf2 = buf1; + buf1 = null; + } else { + buf2 = doBlend(gl, glu, buf1, input, blendMode, opacity); + } + + IVideoBuffer result = buf2; + buf2 = null; + return result; + + } finally { + if (input != null) input.dispose(); + if (buf1 != null) buf1.dispose(); + if (buf2 != null) buf2.dispose(); + } + } + + private IVideoBuffer doFractalNoise(GL2 gl, GLU glu, IVideoBuffer input) { + int permTexture = FractalNoiseTexture.getPermTexture(gl); + + VideoBounds bounds = input.getBounds(); + int w = bounds.width; + int h = bounds.height; + + RenderResolution resolution = context.getRenderResolution(); + + + FractalType fractalType = context.value(this.fractalType); + double invert = context.value(this.invert) ? -1 : 1; + double contrast = context.value(this.contrast); + double brightness = context.value(this.brightness); + Overflow overflow = context.value(this.overflow); + double rotation = Math.toRadians(context.value(this.rotation)); + Vec2d scale = resolution.scale(context.value(this.scale)); + Vec2d offset = resolution.scale(context.value(this.offset)); + double complexity = context.value(this.complexity); + double subInfluence = context.value(this.subInfluence); + double subScale = context.value(this.subScale); + double subRotation = Math.toRadians(context.value(this.subRotation)); + Vec2d subOffset = context.value(this.subOffset); + boolean centerSubscale = context.value(this.centerSubscale); + double evolution = context.value(this.evolution); + int cycle = context.value(this.cycle); + int randomSeed = context.value(this.randomSeed); + + + contrast /= invert*100; + brightness /= 100; + subInfluence /= 100; + + evolution += randomSeed*367; + evolution /= 180; + if (cycle != 0) { + cycle *= 2; + evolution %= cycle; + } + + double cosRot = Math.cos(rotation); + double sinRot = Math.sin(rotation); + Matrix3d transformMat = new Matrix3d(100/scale.x, 0.0, 0.0, 0.0, 100/scale.y, 0.0, 0.0, 0.0, 1.0); // scale + transformMat.mul(new Matrix3d(cosRot, sinRot, 0.0, -sinRot, cosRot, 0.0, 0.0, 0.0, 1.0)); // rotation + transformMat.mul(new Matrix3d(1.0, 0.0, -offset.x/128, 0.0, 1.0, -offset.y/128, 0.0, 0.0, 1.0)); // offset + + double cosSubRot = Math.cos(subRotation); + double sinSubRot = Math.sin(subRotation); + Matrix3d subScaleMat1 = new Matrix3d(100/subScale, 0.0, 0.0, 0.0, 100/subScale, 0.0, 0.0, 0.0, 1.0); // subScale 1蝗槫 + Matrix3d subRotMat1 = new Matrix3d(cosSubRot, sinSubRot, 0.0, -sinSubRot, cosSubRot, 0.0, 0.0, 0.0, 1.0); // subRotation 1蝗槫 + Matrix3d subOffsetMat1 = new Matrix3d(1.0, 0.0, -subOffset.x/128, 0.0, 1.0, -subOffset.y/128, 0.0, 0.0, 1.0); // subOffset 1蝗槫 + + Matrix3d subScaleMat = new Matrix3d(); // subScaleMat1 縺ョ邏ッ遨 + subScaleMat.setIdentity(); + Matrix3d subRotMat = new Matrix3d(); // subRotMat1 縺ョ邏ッ遨 + subRotMat.setIdentity(); + Matrix3d subOffsetMat = new Matrix3d(); // subOffsetMat1 縺ョ邏ッ遨 + if (centerSubscale) { + subOffsetMat.set(subOffsetMat1); + } else { + subOffsetMat.setIdentity(); + } + + int ceiledComplexity = (int)Math.ceil(complexity); + float[] influences = new float[ceiledComplexity]; + float infTotal = 0; + float[] matrices = new float[9*ceiledComplexity]; + + for (int i = 0; i < ceiledComplexity; ++i) { + influences[i] = (float)Math.pow(subInfluence, i); + if (i+1 > complexity) { + influences[i] *= complexity-i; + } + + // 隍髮大コヲ繧偵い繝九Γ繝シ繧キ繝ァ繝ウ縺輔○縺溘→縺阪√h繧頑サ代i縺九↓螟牙喧縺吶k險育ョ怜シ上ョ萓 + //double t = complexity - i; + //influences[i] = (float)(Math.pow(subInfluence, i) + // *(Math.atan(Math.PI/2*(t-1))+Math.atan(Math.PI/2))/(Math.PI/2+Math.atan(Math.PI/2))); + + infTotal += influences[i]; + + Matrix3d mat = new Matrix3d(subOffsetMat); + mat.mul(subScaleMat); + mat.mul(subRotMat); + mat.mul(transformMat); + + for (int j = 0; j < 9; ++j) { + matrices[i*9+j] = (float)mat.getElement(j%3, j/3); + // (j/3, j%3) 縺ァ縺ッ縺ェ縺縺ョ縺ッ transpose 縺励↑縺後i蜿門セ励@縺ヲ縺繧九◆繧√ + } + + subScaleMat.mul(subScaleMat1); + subRotMat.mul(subRotMat1); + + if (!centerSubscale) { + subOffsetMat.mul(new Matrix3d( + 1.0, 0.0, w/resolution.scale/128, // TODO 縺薙%縺ョ蛟、縺ッ縺薙l縺ァ縺縺縺ョ縺具シ + 0.0, 1.0, h/resolution.scale/128, // 縺ゅ→縲128縺ァ蜑イ繧峨↑縺縺ィ縺ェ縺懊°1/3隗」蜒丞コヲ縺縺代♀縺九@縺上↑繧九 + 0.0, 0.0, 1.0)); + subOffsetMat.mul(subOffsetMat1); + } + } + for (int i = 0; i < ceiledComplexity; ++i) { + influences[i] /= infTotal; + } + + + VideoEffectUtil.ortho2D(gl, glu, w, h); + + IVideoBuffer buffer = context.createVideoBuffer(bounds); + try { + gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, + GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, buffer.getTexture(), 0); + gl.glDrawBuffer(GL2.GL_COLOR_ATTACHMENT0); + + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, permTexture); +// gl.glActiveTexture(GL2.GL_TEXTURE1); +// gl.glBindTexture(GL2.GL_TEXTURE_2D, gradTexture); + + synchronized (program) { + gl.glUseProgram(program.getProgram()); + gl.glUniform1i(program.getUniformLocation("permTexture"), 0); +// gl.glUniform1i(program.getUniformLocation("gradTexture"), 1); + gl.glUniform1i(program.getUniformLocation("fractalType"), fractalType.ordinal()); + gl.glUniform1f(program.getUniformLocation("contrast"), (float)contrast); + gl.glUniform1f(program.getUniformLocation("brightness"), (float)brightness); + gl.glUniform1i(program.getUniformLocation("overflow"), overflow.ordinal()); + gl.glUniform1i(program.getUniformLocation("complexity"), ceiledComplexity); + gl.glUniform1fv(program.getUniformLocation("influences[0]"), ceiledComplexity, influences, 0); + gl.glUniformMatrix3fv(program.getUniformLocation("matrices[0]"), ceiledComplexity, false, matrices, 0); + gl.glUniform1f(program.getUniformLocation("evolution"), (float)evolution); + gl.glUniform1f(program.getUniformLocation("cycle"), cycle); + + gl.glBegin(GL2.GL_QUADS); + gl.glVertex2f(0, 0); + gl.glVertex2f(w, 0); + gl.glVertex2f(w, h); + gl.glVertex2f(0, h); + gl.glEnd(); + + gl.glFinish(); + gl.glUseProgram(0); + } + +// gl.glActiveTexture(GL2.GL_TEXTURE1); +// gl.glBindTexture(GL2.GL_TEXTURE_2D, 0); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, 0); + + gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, + GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, 0, 0); + + IVideoBuffer result = buffer; + buffer = null; + return result; + + } finally { + if (buffer != null) buffer.dispose(); + } + } + + private IVideoBuffer doBlend( + GL2 gl, GLU glu, IVideoBuffer noise, IVideoBuffer input, BlendMode blendMode, double opacity) { + + VideoBounds bounds = input.getBounds(); + int w = bounds.width; + int h = bounds.height; + + VideoEffectUtil.ortho2D(gl, glu, w, h); + + IVideoBuffer buffer = context.createVideoBuffer(bounds); + try { + gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, + GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, buffer.getTexture(), 0); + gl.glDrawBuffer(GL2.GL_COLOR_ATTACHMENT0); + + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, noise.getTexture()); + gl.glActiveTexture(GL2.GL_TEXTURE1); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, input.getTexture()); + + IShaderProgram program = shaders.getProgram(FractalNoise.class, blendMode.name()); + synchronized (program) { + gl.glUseProgram(program.getProgram()); + gl.glUniform1i(program.getUniformLocation("texNoise"), 0); + if (blendMode != BlendMode.NONE) { + gl.glUniform1i(program.getUniformLocation("texOrig"), 1); + } + gl.glUniform1f(program.getUniformLocation("opacity"), (float)opacity); + + gl.glBegin(GL2.GL_QUADS); + gl.glTexCoord2f(0, 0); + gl.glVertex2f(0, 0); + gl.glTexCoord2f(w, 0); + gl.glVertex2f(w, 0); + gl.glTexCoord2f(w, h); + gl.glVertex2f(w, h); + gl.glTexCoord2f(0, h); + gl.glVertex2f(0, h); + gl.glEnd(); + + gl.glFinish(); + gl.glUseProgram(0); + } + + gl.glActiveTexture(GL2.GL_TEXTURE1); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, 0); + gl.glActiveTexture(GL2.GL_TEXTURE0); + gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, 0); + + gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, + GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, 0, 0); + + IVideoBuffer result = buffer; + buffer = null; + return result; + + } finally { + if (buffer != null) buffer.dispose(); + } + } + + private static final String[] createBlendSource(String name) { + return new String[] { + "uniform sampler2DRect texNoise;", + "uniform sampler2DRect texOrig;", + "uniform float opacity;", + "", + String.format( "vec4 blend_%s(vec4 pDst, vec4 pSrc, float opacity);", name), + "", + "void main(void)", + "{", + " vec2 texCoord = gl_TexCoord[0].st;", + " vec4 noise = texture2DRect(texNoise, texCoord);", + " vec4 orig = texture2DRect(texOrig, texCoord);", + String.format( " gl_FragColor = blend_%s(orig, noise, opacity);", name), + "}" + }; + } + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram + public static final String[] NONE = { + "uniform sampler2DRect texNoise;", + "uniform float opacity;", + "", + "void main(void)", + "{", + " vec3 rgb = texture2DRect(texNoise, gl_TexCoord[0].st).rgb;", + " gl_FragColor = vec4(rgb*opacity, 1.0);", + "}" + }; + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] NORMAL = createBlendSource("normal"); + +// @GLShader(ShaderType.FRAGMENT_SHADER) +// @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") +// public static final String[] DISSOLVE = createBlendSource("dissolve"); +// +// @GLShader(ShaderType.FRAGMENT_SHADER) +// @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") +// public static final String[] DANCING_DISSOLVE = createBlendSource("dancing_dissolve"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] DARKEN = createBlendSource("darken"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] MULTIPLY = createBlendSource("multiply"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] COLOR_BURN = createBlendSource("color_burn"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] LINEAR_BURN = createBlendSource("linear_burn"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] DARKER_COLOR = createBlendSource("darker_color"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] ADD = createBlendSource("add"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] LIGHTEN = createBlendSource("lighten"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] SCREEN = createBlendSource("screen"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] COLOR_DODGE = createBlendSource("color_dodge"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] LINEAR_DODGE = createBlendSource("linear_dodge"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] LIGHTER_COLOR = createBlendSource("lighter_color"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] OVERLAY = createBlendSource("overlay"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] SOFT_LIGHT = createBlendSource("soft_light"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] HARD_LIGHT = createBlendSource("hard_light"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] LINEAR_LIGHT = createBlendSource("linear_light"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] VIVID_LIGHT = createBlendSource("vivid_light"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] PIN_LIGHT = createBlendSource("pin_light"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] HARD_MIX = createBlendSource("hard_mix"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] DIFFERENCE = createBlendSource("difference"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] EXCLUSION = createBlendSource("exclusion"); + +// @GLShader(ShaderType.FRAGMENT_SHADER) +// @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") +// public static final String[] HUE = createBlendSource("hue"); +// +// @GLShader(ShaderType.FRAGMENT_SHADER) +// @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") +// public static final String[] SATURATION = createBlendSource("saturation"); +// +// @GLShader(ShaderType.FRAGMENT_SHADER) +// @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") +// public static final String[] COLOR = createBlendSource("color"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] LUMINOSITY = createBlendSource("luminosity"); + +// @GLShader(ShaderType.FRAGMENT_SHADER) +// @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") +// public static final String[] STENCIL_ALPHA = createBlendSource("stencil_alpha"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] STENCIL_LUMA = createBlendSource("stencil_luma"); + +// @GLShader(ShaderType.FRAGMENT_SHADER) +// @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") +// public static final String[] SILHOUETTE_ALPHA = createBlendSource("silhouette_alpha"); + + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram(attach="ch.kuramo.javie.core.shaders.BlendModeShaders.blend_functions") + public static final String[] SILHOUETTE_LUMA = createBlendSource("silhouette_luma"); + +} diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoiseTexture.java javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoiseTexture.java --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoiseTexture.java 1970-01-01 09:00:00.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/FractalNoiseTexture.java 2010-04-02 22:54:45.000000000 +0900 @@ -0,0 +1,73 @@ +/* + * Original Author: Stefan Gustavson (stegu@itn.liu.se) 2004, 2005 + * Port to Javie: Yoshikazu Kuramochi 2010 + * + * Original source code is available at http://staffwww.itn.liu.se/~stegu/simplexnoise/ + */ + +package ch.kuramo.javie.effects.noiseGrain; + +import java.nio.ByteBuffer; + +import javax.media.opengl.GL2; + +public class FractalNoiseTexture { + + private static final int[] perm = {151,160,137,91,90,15, + 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, + 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, + 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, + 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, + 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, + 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, + 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, + 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, + 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, + 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, + 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, + 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180}; + + private static final int[][] grad3 = {{0,1,1},{0,1,-1},{0,-1,1},{0,-1,-1}, + {1,0,1},{1,0,-1},{-1,0,1},{-1,0,-1}, + {1,1,0},{1,-1,0},{-1,1,0},{-1,-1,0}, // 12 cube edges + {1,0,-1},{-1,0,-1},{0,-1,1},{0,1,1}}; // 4 more to make 16 + + private static volatile int permTexture; + + static int getPermTexture(GL2 gl) { + if (permTexture == 0) { + byte[] bytes = new byte[256 * 256 * 4]; + for (int i = 0; i < 256; ++i) { + for (int j = 0; j < 256; ++j) { + int offset = (i*256+j)*4; + int value = perm[(j+perm[i]) & 0xFF]; + bytes[offset] = (byte)(grad3[value & 0x0F][0] * 64 + 64); // Gradient x + bytes[offset+1] = (byte)(grad3[value & 0x0F][1] * 64 + 64); // Gradient y + bytes[offset+2] = (byte)(grad3[value & 0x0F][2] * 64 + 64); // Gradient z + bytes[offset+3] = (byte)value; // Permuted index + } + } + + int[] tex = new int[1]; + gl.glGenTextures(1, tex, 0); + gl.glBindTexture(GL2.GL_TEXTURE_2D, tex[0]); + + gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, 256, 256, 0, GL2.GL_RGBA, + GL2.GL_UNSIGNED_BYTE, ByteBuffer.wrap(bytes)); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); + gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST); + + gl.glBindTexture(GL2.GL_TEXTURE_2D, 0); + + synchronized (FractalNoiseTexture.class) { + if (permTexture == 0) { + permTexture = tex[0]; + } else { + gl.glDeleteTextures(1, tex, 0); + } + } + } + return permTexture; + } + +} diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/messages_ja.properties javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/messages_ja.properties --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/messages_ja.properties 1970-01-01 09:00:00.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/messages_ja.properties 2010-04-02 22:51:23.000000000 +0900 @@ -0,0 +1,98 @@ +# +# Copyright (c) 2010 Yoshikazu Kuramochi +# All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +FractalNoise.label=\u30d5\u30e9\u30af\u30bf\u30eb\u30ce\u30a4\u30ba +FractalNoise.fractalType.label=\u30d5\u30e9\u30af\u30bf\u30eb\u306e\u7a2e\u985e +#FractalNoise.noiseType.label=\u30ce\u30a4\u30ba\u306e\u7a2e\u985e +FractalNoise.invert.label=\u53cd\u8ee2 +FractalNoise.contrast.label=\u30b3\u30f3\u30c8\u30e9\u30b9\u30c8 +FractalNoise.brightness.label=\u660e\u308b\u3055 +FractalNoise.overflow.label=\u30aa\u30fc\u30d0\u30fc\u30d5\u30ed\u30fc +FractalNoise.rotation.label=\uff84\uff97\uff9d\uff7d\uff8c\uff6b\uff70\uff91\uff0f\u56de\u8ee2 +FractalNoise.scale.label=\uff84\uff97\uff9d\uff7d\uff8c\uff6b\uff70\uff91\uff0f\u30b9\u30b1\u30fc\u30eb +FractalNoise.scale.unit=% +FractalNoise.offset.label=\uff84\uff97\uff9d\uff7d\uff8c\uff6b\uff70\uff91\uff0f\u30aa\u30d5\u30bb\u30c3\u30c8 +FractalNoise.complexity.label=\u8907\u96d1\u5ea6 +FractalNoise.complexity.increment=0.01 +FractalNoise.complexity.displayPrecision=2 +FractalNoise.subInfluence.label=\u30b5\u30d6\u8a2d\u5b9a\uff0f\u5f71\u97ff +FractalNoise.subInfluence.unit=% +FractalNoise.subInfluence.increment=0.1 +FractalNoise.subScale.label=\u30b5\u30d6\u8a2d\u5b9a\uff0f\u30b9\u30b1\u30fc\u30eb +FractalNoise.subScale.unit=% +FractalNoise.subScale.increment=0.1 +FractalNoise.subRotation.label=\u30b5\u30d6\u8a2d\u5b9a\uff0f\u56de\u8ee2 +FractalNoise.subOffset.label=\u30b5\u30d6\u8a2d\u5b9a\uff0f\u30aa\u30d5\u30bb\u30c3\u30c8 +FractalNoise.centerSubscale.label=\u30b5\u30d6\u8a2d\u5b9a\uff0f\u4e2d\u5fc3\u3092\u63c3\u3048\u308b +FractalNoise.evolution.label=\u5c55\u958b +FractalNoise.cycle.label=\u5c55\u958b\u8a2d\u5b9a\uff0f\u30b5\u30a4\u30af\u30eb +FractalNoise.randomSeed.label=\u5c55\u958b\u8a2d\u5b9a\uff0f\u30e9\u30f3\u30c0\u30e0\u30b7\u30fc\u30c9 +FractalNoise.randomSeed.increment=10 +FractalNoise.opacity.label=\u4e0d\u900f\u660e\u5ea6 +FractalNoise.blendMode.label=\u63cf\u753b\u30e2\u30fc\u30c9 + +FractalType.BASIC=\u57fa\u672c +FractalType.TURBULENT=\u30bf\u30fc\u30d3\u30e5\u30ec\u30f3\u30c8 +Overflow.CLIP=\u30af\u30ea\u30c3\u30d7 +Overflow.SOFT_CLAMP=\u30bd\u30d5\u30c8\u30af\u30e9\u30f3\u30d7 +Overflow.WRAP_BACK=\u30e9\u30c3\u30d7\u30d0\u30c3\u30af +Overflow.HDR=HDR + +BlendMode.NONE=\u306a\u3057 +BlendMode.NORMAL=\u901a\u5e38 +#BlendMode.DISSOLVE=\u30c7\u30a3\u30b6\u5408\u6210 +#BlendMode.DANCING_DISSOLVE=\u30c0\u30a4\u30ca\u30df\u30c3\u30af\u30c7\u30a3\u30b6\u5408\u6210 + +BlendMode.DARKEN=\u6bd4\u8f03(\u6697) +BlendMode.MULTIPLY=\u4e57\u7b97 +BlendMode.COLOR_BURN=\u713c\u304d\u8fbc\u307f\u30ab\u30e9\u30fc +BlendMode.LINEAR_BURN=\u713c\u304d\u8fbc\u307f\u30ea\u30cb\u30a2 +BlendMode.DARKER_COLOR=\u30ab\u30e9\u30fc\u6bd4\u8f03(\u6697) + +BlendMode.ADD=\u52a0\u7b97 +BlendMode.LIGHTEN=\u6bd4\u8f03(\u660e) +BlendMode.SCREEN=\u30b9\u30af\u30ea\u30fc\u30f3 +BlendMode.COLOR_DODGE=\u8986\u3044\u713c\u304d\u30ab\u30e9\u30fc +BlendMode.LINEAR_DODGE=\u8986\u3044\u713c\u304d\u30ea\u30cb\u30a2 +BlendMode.LIGHTER_COLOR=\u30ab\u30e9\u30fc\u6bd4\u8f03(\u660e) + +BlendMode.OVERLAY=\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4 +BlendMode.SOFT_LIGHT=\u30bd\u30d5\u30c8\u30e9\u30a4\u30c8 +BlendMode.HARD_LIGHT=\u30cf\u30fc\u30c9\u30e9\u30a4\u30c8 +BlendMode.LINEAR_LIGHT=\u30ea\u30cb\u30a2\u30e9\u30a4\u30c8 +BlendMode.VIVID_LIGHT=\u30d3\u30d3\u30c3\u30c9\u30e9\u30a4\u30c8 +BlendMode.PIN_LIGHT=\u30d4\u30f3\u30e9\u30a4\u30c8 +BlendMode.HARD_MIX=\u30cf\u30fc\u30c9\u30df\u30c3\u30af\u30b9 + +BlendMode.DIFFERENCE=\u5dee +BlendMode.EXCLUSION=\u9664\u5916 + +BlendMode.HUE=\u8272\u76f8 +BlendMode.SATURATION=\u5f69\u5ea6 +#BlendMode.COLOR=\u30ab\u30e9\u30fc +BlendMode.LUMINOSITY=\u8f1d\u5ea6 + +#BlendMode.STENCIL_ALPHA=\u30b9\u30c6\u30f3\u30b7\u30eb\u30a2\u30eb\u30d5\u30a1 +BlendMode.STENCIL_LUMA=\u30b9\u30c6\u30f3\u30b7\u30eb\u30eb\u30df\u30ca\u30f3\u30b9 +#BlendMode.SILHOUETTE_ALPHA=\u30b7\u30eb\u30a8\u30c3\u30c8\u30a2\u30eb\u30d5\u30a1 +BlendMode.SILHOUETTE_LUMA=\u30b7\u30eb\u30a8\u30c3\u30c8\u30eb\u30df\u30ca\u30f3\u30b9 diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/noise.frag javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/noise.frag --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/noise.frag 1970-01-01 09:00:00.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/noiseGrain/noise.frag 2010-04-02 22:12:55.000000000 +0900 @@ -0,0 +1,579 @@ +/* + * 2D, 3D and 4D Perlin noise, classic and simplex, in a GLSL fragment shader. + * + * Classic noise is implemented by the functions: + * float noise(vec2 P) + * float noise(vec3 P) + * float noise(vec4 P) + * + * Simplex noise is implemented by the functions: + * float snoise(vec2 P) + * float snoise(vec3 P) + * float snoise(vec4 P) + * + * Author: Stefan Gustavson ITN-LiTH (stegu@itn.liu.se) 2004-12-05 + * Simplex indexing functions by Bill Licea-Kane, ATI (bill@ati.com) + * + * You may use, modify and redistribute this code free of charge, + * provided that the author's names and this notice appear intact. + */ + +/* + * NOTE: there is a formal problem with the dependent texture lookups. + * A texture coordinate of exactly 1.0 will wrap to 0.0, so strictly speaking, + * an error occurs every 256 units of the texture domain, and the same gradient + * is used for two adjacent noise cells. One solution is to set the texture + * wrap mode to "CLAMP" and do the wrapping explicitly in GLSL with the "mod" + * operator. This could also give you noise with repetition intervals other + * than 256 without any extra cost. + * This error is not even noticeable to the eye even if you isolate the exact + * position in the domain where it occurs and know exactly what to look for. + * The noise pattern is still visually correct, so I left the bug in there. + * + * The value of classic 4D noise goes above 1.0 and below -1.0 at some + * points. Not much and only very sparsely, but it happens. This is a + * bug from the original software implementation, so I left it untouched. + */ + + +/* + * "permTexture" is a 256x256 texture that is used for both the permutations + * and the 2D and 3D gradient lookup. For details, see the main C program. + * "gradTexture" is a 256x256 texture with 4D gradients, similar to + * "permTexture" but with the permutation index in the alpha component + * replaced by the w component of the 4D gradient. + * 2D classic noise uses only permTexture. + * 2D simplex noise uses only permTexture. + * 3D classic noise uses only permTexture. + * 3D simplex noise uses only permTexture. + * 4D classic noise uses permTexture and gradTexture. + * 4D simplex noise uses permTexture and gradTexture. + */ +uniform sampler2D permTexture; +uniform sampler2D gradTexture; +//uniform float time; // Used for texture animation + +/* + * Both 2D and 3D texture coordinates are defined, for testing purposes. + */ +//varying vec2 v_texCoord2D; +//varying vec3 v_texCoord3D; +//varying vec4 v_color; + + +/* + * To create offsets of one texel and one half texel in the + * texture lookup, we need to know the texture image size. + */ +#define ONE 0.00390625 +#define ONEHALF 0.001953125 +// The numbers above are 1/256 and 0.5/256, change accordingly +// if you change the code to use another texture size. + + +/* + * The interpolation function. This could be a 1D texture lookup + * to get some more speed, but it's not the main part of the algorithm. + */ +float fade(float t) +{ + // return t*t*(3.0-2.0*t); // Old fade, yields discontinuous second derivative + return t*t*t*(t*(t*6.0-15.0)+10.0); // Improved fade, yields C2-continuous noise +} + + +/* + * Efficient simplex indexing functions by Bill Licea-Kane, ATI. Thanks! + * (This was originally implemented as a texture lookup. Nice to avoid that.) + */ +void simplex( const in vec3 P, out vec3 offset1, out vec3 offset2 ) +{ + vec3 offset0; + + vec2 isX = step( P.yz, P.xx ); // P.x >= P.y ? 1.0 : 0.0; P.x >= P.z ? 1.0 : 0.0; + offset0.x = dot( isX, vec2( 1.0 ) ); // Accumulate all P.x >= other channels in offset.x + offset0.yz = 1.0 - isX; // Accumulate all P.x < other channels in offset.yz + + float isY = step( P.z, P.y ); // P.y >= P.z ? 1.0 : 0.0; + offset0.y += isY; // Accumulate P.y >= P.z in offset.y + offset0.z += 1.0 - isY; // Accumulate P.y < P.z in offset.z + + // offset0 now contains the unique values 0,1,2 in each channel + // 2 for the channel greater than other channels + // 1 for the channel that is less than one but greater than another + // 0 for the channel less than other channels + // Equality ties are broken in favor of first x, then y + // (z always loses ties) + + offset2 = clamp( offset0, 0.0, 1.0 ); + // offset2 contains 1 in each channel that was 1 or 2 + offset1 = clamp( --offset0, 0.0, 1.0 ); + // offset1 contains 1 in the single channel that was 1 +} + + +void simplex( const in vec4 P, out vec4 offset1, out vec4 offset2, out vec4 offset3 ) +{ + vec4 offset0; + + vec3 isX = step( P.yzw, P.xxx ); // See comments in 3D simplex function + offset0.x = dot( isX, vec3( 1.0 ) ); + offset0.yzw = 1.0 - isX; + + vec2 isY = step( P.zw, P.yy ); + offset0.y += dot( isY, vec2( 1.0 ) ); + offset0.zw += 1.0 - isY; + + float isZ = step( P.w, P.z ); + offset0.z += isZ; + offset0.w += 1.0 - isZ; + + // offset0 now contains the unique values 0,1,2,3 in each channel + + offset3 = clamp( offset0, 0.0, 1.0 ); + offset2 = clamp( --offset0, 0.0, 1.0 ); + offset1 = clamp( --offset0, 0.0, 1.0 ); +} + + +/* + * 2D classic Perlin noise. Fast, but less useful than 3D noise. + */ +float noise(vec2 P) +{ + vec2 Pi = ONE*floor(P)+ONEHALF; // Integer part, scaled and offset for texture lookup + vec2 Pf = fract(P); // Fractional part for interpolation + + // Noise contribution from lower left corner + vec2 grad00 = texture2D(permTexture, Pi).rg * 4.0 - 1.0; + float n00 = dot(grad00, Pf); + + // Noise contribution from lower right corner + vec2 grad10 = texture2D(permTexture, Pi + vec2(ONE, 0.0)).rg * 4.0 - 1.0; + float n10 = dot(grad10, Pf - vec2(1.0, 0.0)); + + // Noise contribution from upper left corner + vec2 grad01 = texture2D(permTexture, Pi + vec2(0.0, ONE)).rg * 4.0 - 1.0; + float n01 = dot(grad01, Pf - vec2(0.0, 1.0)); + + // Noise contribution from upper right corner + vec2 grad11 = texture2D(permTexture, Pi + vec2(ONE, ONE)).rg * 4.0 - 1.0; + float n11 = dot(grad11, Pf - vec2(1.0, 1.0)); + + // Blend contributions along x + vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade(Pf.x)); + + // Blend contributions along y + float n_xy = mix(n_x.x, n_x.y, fade(Pf.y)); + + // We're done, return the final noise value. + return n_xy; +} + + +/* + * 3D classic noise. Slower, but a lot more useful than 2D noise. + */ +float noise(vec3 P) +{ + vec3 Pi = ONE*floor(P)+ONEHALF; // Integer part, scaled so +1 moves one texel + // and offset 1/2 texel to sample texel centers + vec3 Pf = fract(P); // Fractional part for interpolation + + // Noise contributions from (x=0, y=0), z=0 and z=1 + float perm00 = texture2D(permTexture, Pi.xy).a ; + vec3 grad000 = texture2D(permTexture, vec2(perm00, Pi.z)).rgb * 4.0 - 1.0; + float n000 = dot(grad000, Pf); + vec3 grad001 = texture2D(permTexture, vec2(perm00, Pi.z + ONE)).rgb * 4.0 - 1.0; + float n001 = dot(grad001, Pf - vec3(0.0, 0.0, 1.0)); + + // Noise contributions from (x=0, y=1), z=0 and z=1 + float perm01 = texture2D(permTexture, Pi.xy + vec2(0.0, ONE)).a ; + vec3 grad010 = texture2D(permTexture, vec2(perm01, Pi.z)).rgb * 4.0 - 1.0; + float n010 = dot(grad010, Pf - vec3(0.0, 1.0, 0.0)); + vec3 grad011 = texture2D(permTexture, vec2(perm01, Pi.z + ONE)).rgb * 4.0 - 1.0; + float n011 = dot(grad011, Pf - vec3(0.0, 1.0, 1.0)); + + // Noise contributions from (x=1, y=0), z=0 and z=1 + float perm10 = texture2D(permTexture, Pi.xy + vec2(ONE, 0.0)).a ; + vec3 grad100 = texture2D(permTexture, vec2(perm10, Pi.z)).rgb * 4.0 - 1.0; + float n100 = dot(grad100, Pf - vec3(1.0, 0.0, 0.0)); + vec3 grad101 = texture2D(permTexture, vec2(perm10, Pi.z + ONE)).rgb * 4.0 - 1.0; + float n101 = dot(grad101, Pf - vec3(1.0, 0.0, 1.0)); + + // Noise contributions from (x=1, y=1), z=0 and z=1 + float perm11 = texture2D(permTexture, Pi.xy + vec2(ONE, ONE)).a ; + vec3 grad110 = texture2D(permTexture, vec2(perm11, Pi.z)).rgb * 4.0 - 1.0; + float n110 = dot(grad110, Pf - vec3(1.0, 1.0, 0.0)); + vec3 grad111 = texture2D(permTexture, vec2(perm11, Pi.z + ONE)).rgb * 4.0 - 1.0; + float n111 = dot(grad111, Pf - vec3(1.0, 1.0, 1.0)); + + // Blend contributions along x + vec4 n_x = mix(vec4(n000, n001, n010, n011), + vec4(n100, n101, n110, n111), fade(Pf.x)); + + // Blend contributions along y + vec2 n_xy = mix(n_x.xy, n_x.zw, fade(Pf.y)); + + // Blend contributions along z + float n_xyz = mix(n_xy.x, n_xy.y, fade(Pf.z)); + + // We're done, return the final noise value. + return n_xyz; +} + + +/* + * 4D classic noise. Slow, but very useful. 4D simplex noise is a lot faster. + * + * This function performs 8 texture lookups and 16 dependent texture lookups, + * 16 dot products, 4 mix operations and a lot of additions and multiplications. + * Needless to say, it's not super fast. But it's not dead slow either. + */ +float noise(vec4 P) +{ + vec4 Pi = ONE*floor(P)+ONEHALF; // Integer part, scaled so +1 moves one texel + // and offset 1/2 texel to sample texel centers + vec4 Pf = fract(P); // Fractional part for interpolation + + // "n0000" is the noise contribution from (x=0, y=0, z=0, w=0), and so on + float perm00xy = texture2D(permTexture, Pi.xy).a ; + float perm00zw = texture2D(permTexture, Pi.zw).a ; + vec4 grad0000 = texture2D(gradTexture, vec2(perm00xy, perm00zw)).rgba * 4.0 -1.0; + float n0000 = dot(grad0000, Pf); + + float perm01zw = texture2D(permTexture, Pi.zw + vec2(0.0, ONE)).a ; + vec4 grad0001 = texture2D(gradTexture, vec2(perm00xy, perm01zw)).rgba * 4.0 - 1.0; + float n0001 = dot(grad0001, Pf - vec4(0.0, 0.0, 0.0, 1.0)); + + float perm10zw = texture2D(permTexture, Pi.zw + vec2(ONE, 0.0)).a ; + vec4 grad0010 = texture2D(gradTexture, vec2(perm00xy, perm10zw)).rgba * 4.0 - 1.0; + float n0010 = dot(grad0010, Pf - vec4(0.0, 0.0, 1.0, 0.0)); + + float perm11zw = texture2D(permTexture, Pi.zw + vec2(ONE, ONE)).a ; + vec4 grad0011 = texture2D(gradTexture, vec2(perm00xy, perm11zw)).rgba * 4.0 - 1.0; + float n0011 = dot(grad0011, Pf - vec4(0.0, 0.0, 1.0, 1.0)); + + float perm01xy = texture2D(permTexture, Pi.xy + vec2(0.0, ONE)).a ; + vec4 grad0100 = texture2D(gradTexture, vec2(perm01xy, perm00zw)).rgba * 4.0 - 1.0; + float n0100 = dot(grad0100, Pf - vec4(0.0, 1.0, 0.0, 0.0)); + + vec4 grad0101 = texture2D(gradTexture, vec2(perm01xy, perm01zw)).rgba * 4.0 - 1.0; + float n0101 = dot(grad0101, Pf - vec4(0.0, 1.0, 0.0, 1.0)); + + vec4 grad0110 = texture2D(gradTexture, vec2(perm01xy, perm10zw)).rgba * 4.0 - 1.0; + float n0110 = dot(grad0110, Pf - vec4(0.0, 1.0, 1.0, 0.0)); + + vec4 grad0111 = texture2D(gradTexture, vec2(perm01xy, perm11zw)).rgba * 4.0 - 1.0; + float n0111 = dot(grad0111, Pf - vec4(0.0, 1.0, 1.0, 1.0)); + + float perm10xy = texture2D(permTexture, Pi.xy + vec2(ONE, 0.0)).a ; + vec4 grad1000 = texture2D(gradTexture, vec2(perm10xy, perm00zw)).rgba * 4.0 - 1.0; + float n1000 = dot(grad1000, Pf - vec4(1.0, 0.0, 0.0, 0.0)); + + vec4 grad1001 = texture2D(gradTexture, vec2(perm10xy, perm01zw)).rgba * 4.0 - 1.0; + float n1001 = dot(grad1001, Pf - vec4(1.0, 0.0, 0.0, 1.0)); + + vec4 grad1010 = texture2D(gradTexture, vec2(perm10xy, perm10zw)).rgba * 4.0 - 1.0; + float n1010 = dot(grad1010, Pf - vec4(1.0, 0.0, 1.0, 0.0)); + + vec4 grad1011 = texture2D(gradTexture, vec2(perm10xy, perm11zw)).rgba * 4.0 - 1.0; + float n1011 = dot(grad1011, Pf - vec4(1.0, 0.0, 1.0, 1.0)); + + float perm11xy = texture2D(permTexture, Pi.xy + vec2(ONE, ONE)).a ; + vec4 grad1100 = texture2D(gradTexture, vec2(perm11xy, perm00zw)).rgba * 4.0 - 1.0; + float n1100 = dot(grad1100, Pf - vec4(1.0, 1.0, 0.0, 0.0)); + + vec4 grad1101 = texture2D(gradTexture, vec2(perm11xy, perm01zw)).rgba * 4.0 - 1.0; + float n1101 = dot(grad1101, Pf - vec4(1.0, 1.0, 0.0, 1.0)); + + vec4 grad1110 = texture2D(gradTexture, vec2(perm11xy, perm10zw)).rgba * 4.0 - 1.0; + float n1110 = dot(grad1110, Pf - vec4(1.0, 1.0, 1.0, 0.0)); + + vec4 grad1111 = texture2D(gradTexture, vec2(perm11xy, perm11zw)).rgba * 4.0 - 1.0; + float n1111 = dot(grad1111, Pf - vec4(1.0, 1.0, 1.0, 1.0)); + + // Blend contributions along x + float fadex = fade(Pf.x); + vec4 n_x0 = mix(vec4(n0000, n0001, n0010, n0011), + vec4(n1000, n1001, n1010, n1011), fadex); + vec4 n_x1 = mix(vec4(n0100, n0101, n0110, n0111), + vec4(n1100, n1101, n1110, n1111), fadex); + + // Blend contributions along y + vec4 n_xy = mix(n_x0, n_x1, fade(Pf.y)); + + // Blend contributions along z + vec2 n_xyz = mix(n_xy.xy, n_xy.zw, fade(Pf.z)); + + // Blend contributions along w + float n_xyzw = mix(n_xyz.x, n_xyz.y, fade(Pf.w)); + + // We're done, return the final noise value. + return n_xyzw; +} + + +/* + * 2D simplex noise. Somewhat slower but much better looking than classic noise. + */ +float snoise(vec2 P) { + +// Skew and unskew factors are a bit hairy for 2D, so define them as constants +// This is (sqrt(3.0)-1.0)/2.0 +#define F2 0.366025403784 +// This is (3.0-sqrt(3.0))/6.0 +#define G2 0.211324865405 + + // Skew the (x,y) space to determine which cell of 2 simplices we're in + float s = (P.x + P.y) * F2; // Hairy factor for 2D skewing + vec2 Pi = floor(P + s); + float t = (Pi.x + Pi.y) * G2; // Hairy factor for unskewing + vec2 P0 = Pi - t; // Unskew the cell origin back to (x,y) space + Pi = Pi * ONE + ONEHALF; // Integer part, scaled and offset for texture lookup + + vec2 Pf0 = P - P0; // The x,y distances from the cell origin + + // For the 2D case, the simplex shape is an equilateral triangle. + // Find out whether we are above or below the x=y diagonal to + // determine which of the two triangles we're in. + vec2 o1; + if(Pf0.x > Pf0.y) o1 = vec2(1.0, 0.0); // +x, +y traversal order + else o1 = vec2(0.0, 1.0); // +y, +x traversal order + + // Noise contribution from simplex origin + vec2 grad0 = texture2D(permTexture, Pi).rg * 4.0 - 1.0; + float t0 = 0.5 - dot(Pf0, Pf0); + float n0; + if (t0 < 0.0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad0, Pf0); + } + + // Noise contribution from middle corner + vec2 Pf1 = Pf0 - o1 + G2; + vec2 grad1 = texture2D(permTexture, Pi + o1*ONE).rg * 4.0 - 1.0; + float t1 = 0.5 - dot(Pf1, Pf1); + float n1; + if (t1 < 0.0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad1, Pf1); + } + + // Noise contribution from last corner + vec2 Pf2 = Pf0 - vec2(1.0-2.0*G2); + vec2 grad2 = texture2D(permTexture, Pi + vec2(ONE, ONE)).rg * 4.0 - 1.0; + float t2 = 0.5 - dot(Pf2, Pf2); + float n2; + if(t2 < 0.0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad2, Pf2); + } + + // Sum up and scale the result to cover the range [-1,1] + return 70.0 * (n0 + n1 + n2); +} + + +/* + * 3D simplex noise. Comparable in speed to classic noise, better looking. + */ +float snoise(vec3 P) { + +// The skewing and unskewing factors are much simpler for the 3D case +#define F3 0.333333333333 +#define G3 0.166666666667 + + // Skew the (x,y,z) space to determine which cell of 6 simplices we're in + float s = (P.x + P.y + P.z) * F3; // Factor for 3D skewing + vec3 Pi = floor(P + s); + float t = (Pi.x + Pi.y + Pi.z) * G3; + vec3 P0 = Pi - t; // Unskew the cell origin back to (x,y,z) space + Pi = Pi * ONE + ONEHALF; // Integer part, scaled and offset for texture lookup + + vec3 Pf0 = P - P0; // The x,y distances from the cell origin + + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // To find out which of the six possible tetrahedra we're in, we need to + // determine the magnitude ordering of x, y and z components of Pf0. + vec3 o1; + vec3 o2; + simplex(Pf0, o1, o2); + + // Noise contribution from simplex origin + float perm0 = texture2D(permTexture, Pi.xy).a; + vec3 grad0 = texture2D(permTexture, vec2(perm0, Pi.z)).rgb * 4.0 - 1.0; + float t0 = 0.6 - dot(Pf0, Pf0); + float n0; + if (t0 < 0.0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad0, Pf0); + } + + // Noise contribution from second corner + vec3 Pf1 = Pf0 - o1 + G3; + float perm1 = texture2D(permTexture, Pi.xy + o1.xy*ONE).a; + vec3 grad1 = texture2D(permTexture, vec2(perm1, Pi.z + o1.z*ONE)).rgb * 4.0 - 1.0; + float t1 = 0.6 - dot(Pf1, Pf1); + float n1; + if (t1 < 0.0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad1, Pf1); + } + + // Noise contribution from third corner + vec3 Pf2 = Pf0 - o2 + 2.0 * G3; + float perm2 = texture2D(permTexture, Pi.xy + o2.xy*ONE).a; + vec3 grad2 = texture2D(permTexture, vec2(perm2, Pi.z + o2.z*ONE)).rgb * 4.0 - 1.0; + float t2 = 0.6 - dot(Pf2, Pf2); + float n2; + if (t2 < 0.0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad2, Pf2); + } + + // Noise contribution from last corner + vec3 Pf3 = Pf0 - vec3(1.0-3.0*G3); + float perm3 = texture2D(permTexture, Pi.xy + vec2(ONE, ONE)).a; + vec3 grad3 = texture2D(permTexture, vec2(perm3, Pi.z + ONE)).rgb * 4.0 - 1.0; + float t3 = 0.6 - dot(Pf3, Pf3); + float n3; + if(t3 < 0.0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad3, Pf3); + } + + // Sum up and scale the result to cover the range [-1,1] + return 32.0 * (n0 + n1 + n2 + n3); +} + + +/* + * 4D simplex noise. A lot faster than classic 4D noise, and better looking. + */ + +float snoise(vec4 P) { + +// The skewing and unskewing factors are hairy again for the 4D case +// This is (sqrt(5.0)-1.0)/4.0 +#define F4 0.309016994375 +// This is (5.0-sqrt(5.0))/20.0 +#define G4 0.138196601125 + + // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in + float s = (P.x + P.y + P.z + P.w) * F4; // Factor for 4D skewing + vec4 Pi = floor(P + s); + float t = (Pi.x + Pi.y + Pi.z + Pi.w) * G4; + vec4 P0 = Pi - t; // Unskew the cell origin back to (x,y,z,w) space + Pi = Pi * ONE + ONEHALF; // Integer part, scaled and offset for texture lookup + + vec4 Pf0 = P - P0; // The x,y distances from the cell origin + + // For the 4D case, the simplex is a 4D shape I won't even try to describe. + // To find out which of the 24 possible simplices we're in, we need to + // determine the magnitude ordering of x, y, z and w components of Pf0. + vec4 o1; + vec4 o2; + vec4 o3; + simplex(Pf0, o1, o2, o3); + + // Noise contribution from simplex origin + float perm0xy = texture2D(permTexture, Pi.xy).a; + float perm0zw = texture2D(permTexture, Pi.zw).a; + vec4 grad0 = texture2D(gradTexture, vec2(perm0xy, perm0zw)).rgba * 4.0 - 1.0; + float t0 = 0.6 - dot(Pf0, Pf0); + float n0; + if (t0 < 0.0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad0, Pf0); + } + + // Noise contribution from second corner + vec4 Pf1 = Pf0 - o1 + G4; + o1 = o1 * ONE; + float perm1xy = texture2D(permTexture, Pi.xy + o1.xy).a; + float perm1zw = texture2D(permTexture, Pi.zw + o1.zw).a; + vec4 grad1 = texture2D(gradTexture, vec2(perm1xy, perm1zw)).rgba * 4.0 - 1.0; + float t1 = 0.6 - dot(Pf1, Pf1); + float n1; + if (t1 < 0.0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad1, Pf1); + } + + // Noise contribution from third corner + vec4 Pf2 = Pf0 - o2 + 2.0 * G4; + o2 = o2 * ONE; + float perm2xy = texture2D(permTexture, Pi.xy + o2.xy).a; + float perm2zw = texture2D(permTexture, Pi.zw + o2.zw).a; + vec4 grad2 = texture2D(gradTexture, vec2(perm2xy, perm2zw)).rgba * 4.0 - 1.0; + float t2 = 0.6 - dot(Pf2, Pf2); + float n2; + if (t2 < 0.0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad2, Pf2); + } + + // Noise contribution from fourth corner + vec4 Pf3 = Pf0 - o3 + 3.0 * G4; + o3 = o3 * ONE; + float perm3xy = texture2D(permTexture, Pi.xy + o3.xy).a; + float perm3zw = texture2D(permTexture, Pi.zw + o3.zw).a; + vec4 grad3 = texture2D(gradTexture, vec2(perm3xy, perm3zw)).rgba * 4.0 - 1.0; + float t3 = 0.6 - dot(Pf3, Pf3); + float n3; + if (t3 < 0.0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad3, Pf3); + } + + // Noise contribution from last corner + vec4 Pf4 = Pf0 - vec4(1.0-4.0*G4); + float perm4xy = texture2D(permTexture, Pi.xy + vec2(ONE, ONE)).a; + float perm4zw = texture2D(permTexture, Pi.zw + vec2(ONE, ONE)).a; + vec4 grad4 = texture2D(gradTexture, vec2(perm4xy, perm4zw)).rgba * 4.0 - 1.0; + float t4 = 0.6 - dot(Pf4, Pf4); + float n4; + if(t4 < 0.0) n4 = 0.0; + else { + t4 *= t4; + n4 = t4 * t4 * dot(grad4, Pf4); + } + + // Sum up and scale the result to cover the range [-1,1] + return 27.0 * (n0 + n1 + n2 + n3 + n4); +} + + +//void main( void ) +//{ +// +// /* These lines test, in order, 2D classic noise, 2D simplex noise, +// * 3D classic noise, 3D simplex noise, 4D classic noise, and finally +// * 4D simplex noise. +// * Everything but the 4D simplex noise will make some uniform +// * variables remain unused and be optimized away by the compiler, +// * so OpenGL will fail to bind them. It's safe to ignore these +// * warnings from the C program. The program is designed to work anyway. +// */ +// //float n = noise(v_texCoord2D * 32.0 + 240.0); +// //float n = snoise(v_texCoord2D * 16.0); +// //float n = noise(vec3(4.0 * v_texCoord3D.xyz * (2.0 + sin(0.5 * time)))); +// float n = snoise(vec3(2.0 * v_texCoord3D.xyz * (2.0 + sin(0.5 * time)))); +// //float n = noise(vec4(8.0 * v_texCoord3D.xyz, 0.5 * time)); +// //float n = snoise(vec4(4.0 * v_texCoord3D.xyz, 0.5 * time)); +// +// gl_FragColor = v_color * vec4(0.5 + 0.5 * vec3(n, n, n), 1.0); +//} + diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/Glow.java javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/Glow.java --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/Glow.java 2010-03-24 10:32:35.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/Glow.java 2010-03-28 23:11:00.000000000 +0900 @@ -49,7 +49,7 @@ @Effect(id="ch.kuramo.javie.Glow", category=Effect.STYLIZE) public class Glow { -// public enum GlowBase { ALPHA, COLOR } + public enum GlowColors { ORIGINAL_COLORS, A_AND_B_COLORS, A_AND_B_COLORS_ALPHA_BASE } public enum GlowComposite { ON_TOP, BEHIND, NONE } @@ -96,13 +96,11 @@ SILHOUETTE_LUMA; } - public enum GlowColors { ORIGINAL_COLORS, A_AND_B_COLORS } - public enum GlowLooping { SAWTOOTH_AB, SAWTOOTH_BA, TRIANGLE_ABA, TRIANGLE_BAB } -// @Property("COLOR") -// private IAnimatableEnum base; + @Property("ORIGINAL_COLORS") + private IAnimatableEnum colors; @Property(value="60", min="0", max="100") private IAnimatableDouble threshold; @@ -119,9 +117,6 @@ @Property("ADD") private IAnimatableEnum operation; - @Property - private IAnimatableEnum colors; - @Property("TRIANGLE_ABA") private IAnimatableEnum colorLooping; @@ -155,6 +150,8 @@ private final IShaderProgram abColorsThresholdProgram; + private final IShaderProgram alphaBaseThresholdProgram; + private final IShaderProgram sawtoothProgram; private final IShaderProgram triangleProgram; @@ -169,6 +166,7 @@ this.shaders = shaders; oColorsThresholdProgram = shaders.getProgram(Glow.class, "OCOLORS_THRESHOLD"); abColorsThresholdProgram = shaders.getProgram(Glow.class, "ABCOLORS_THRESHOLD"); + alphaBaseThresholdProgram = shaders.getProgram(Glow.class, "ALPHA_BASE_THRESHOLD"); sawtoothProgram = shaders.getProgram(Glow.class, "SAWTOOTH"); triangleProgram = shaders.getProgram(Glow.class, "TRIANGLE"); oColorsIntensityProgram = shaders.getProgram(Glow.class, "OCOLORS_INTENSITY"); @@ -235,11 +233,11 @@ buf2 = blur(buf1); if (buf2 == buf1) buf1 = null; - if (colors == GlowColors.A_AND_B_COLORS) { - buf3 = abColors(buf2); - } else { + if (colors == GlowColors.ORIGINAL_COLORS) { buf3 = buf2; buf2 = null; + } else { + buf3 = abColors(buf2); } buf4 = intensity(buf3, colors); @@ -304,9 +302,27 @@ "}" }; + @GLShader(ShaderType.FRAGMENT_SHADER) + @GLProgram + public static final String[] ALPHA_BASE_THRESHOLD = { + "uniform sampler2DRect texture;", + "uniform float upper;", + "uniform float lower;", + "", + "void main(void)", + "{", + " float a = texture2DRect(texture, gl_TexCoord[0].st).a;", + "", + " a = clamp((a - lower) / (upper - lower), 0.0, 1.0);", + "", + " gl_FragColor = vec4(a);", + "}" + }; + private IVideoBuffer threshold(IVideoBuffer input, GlowColors colors) { - IShaderProgram program = (colors == GlowColors.ORIGINAL_COLORS) - ? oColorsThresholdProgram : abColorsThresholdProgram; + IShaderProgram program = + (colors == GlowColors.ORIGINAL_COLORS) ? oColorsThresholdProgram : + (colors == GlowColors.A_AND_B_COLORS) ? abColorsThresholdProgram : alphaBaseThresholdProgram; double threshold = context.value(this.threshold) / 100; double upper = Math.min(threshold + 0.0625, 1); @@ -685,6 +701,7 @@ return input; } + // A_AND_B_COLORS 縺ィ A_AND_B_COLORS_ALPHA_BASE 縺ョ繧キ繧ァ繝シ繝縺ッ蜷後§ IShaderProgram program = (colors == GlowColors.ORIGINAL_COLORS) ? oColorsIntensityProgram : abColorsIntensityProgram; diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/messages_ja.properties javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/messages_ja.properties --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/messages_ja.properties 2010-03-24 00:23:54.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/stylize/messages_ja.properties 2010-03-28 23:11:00.000000000 +0900 @@ -27,7 +27,7 @@ Mosaic.sharpColors.label=\u30b7\u30e3\u30fc\u30d7\u30ab\u30e9\u30fc Glow.label=\u30b0\u30ed\u30fc -#Glow.base.label=\u30b0\u30ed\u30fc\u57fa\u6e96 +Glow.colors.label=\u30b0\u30ed\u30fc\u30ab\u30e9\u30fc Glow.threshold.label=\u30b0\u30ed\u30fc\u3057\u304d\u3044\u5024 Glow.threshold.increment=0.1 Glow.threshold.unit=% @@ -37,7 +37,6 @@ Glow.intensity.displayPrecision=2 Glow.composite.label=\u5143\u3092\u5408\u6210 Glow.operation.label=\u30b0\u30ed\u30fc\u64cd\u4f5c -Glow.colors.label=\u30b0\u30ed\u30fc\u30ab\u30e9\u30fc Glow.colorLooping.label=\u30ab\u30e9\u30fc\u30eb\u30fc\u30d4\u30f3\u30b0 Glow.colorLoops.label=\u30ab\u30e9\u30fc\u30eb\u30fc\u30d7 Glow.colorLoops.increment=0.01 @@ -50,13 +49,12 @@ Glow.dimensions.label=\u30b0\u30ed\u30fc\u306e\u65b9\u5411 Glow.fast.label=\u9ad8\u901f -#GlowBase.ALPHA=\u30a2\u30eb\u30d5\u30a1\u30c1\u30e3\u30f3\u30cd\u30eb -#GlowBase.COLOR=\u30ab\u30e9\u30fc\u30c1\u30e3\u30f3\u30cd\u30eb +GlowColors.ORIGINAL_COLORS=\u5143\u306e\u30ab\u30e9\u30fc +GlowColors.A_AND_B_COLORS=A & B (\u30ab\u30e9\u30fc\u30c1\u30e3\u30f3\u30cd\u30eb\u57fa\u6e96) +GlowColors.A_AND_B_COLORS_ALPHA_BASE=A & B (\u30a2\u30eb\u30d5\u30a1\u30c1\u30e3\u30f3\u30cd\u30eb\u57fa\u6e96) GlowComposite.ON_TOP=\u4e0a GlowComposite.BEHIND=\u5f8c\u308d GlowComposite.NONE=\u306a\u3057 -GlowColors.ORIGINAL_COLORS=\u5143\u306e\u30ab\u30e9\u30fc -GlowColors.A_AND_B_COLORS=A & B \u30ab\u30e9\u30fc GlowLooping.SAWTOOTH_AB=\u306e\u3053\u304e\u308a\u6ce2 A>B GlowLooping.SAWTOOTH_BA=\u306e\u3053\u304e\u308a\u6ce2 B>A GlowLooping.TRIANGLE_ABA=\u4e09\u89d2\u5f62 A>B>A diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/LinearWipe.java javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/LinearWipe.java --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/LinearWipe.java 2010-03-22 14:07:42.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/LinearWipe.java 2010-04-03 00:41:43.000000000 +0900 @@ -110,6 +110,7 @@ GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, input.getTexture(), 0); gl.glDrawBuffer(GL2.GL_COLOR_ATTACHMENT0); + gl.glActiveTexture(GL2.GL_TEXTURE0); gl.glBindTexture(GL2.GL_TEXTURE_1D, wipeTex[0]); gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR); gl.glTexParameteri(GL2.GL_TEXTURE_1D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); diff -ruN javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/RadialWipe.java javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/RadialWipe.java --- javie-0.3.7-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/RadialWipe.java 2010-03-24 21:30:09.000000000 +0900 +++ javie-0.3.8-src/ch.kuramo.javie.effects/src/main/java/ch/kuramo/javie/effects/transition/RadialWipe.java 2010-04-03 00:41:43.000000000 +0900 @@ -156,6 +156,7 @@ GL2.GL_COLOR_ATTACHMENT0, GL2.GL_TEXTURE_RECTANGLE, inputBuffer.getTexture(), 0); gl.glDrawBuffer(GL2.GL_COLOR_ATTACHMENT0); + gl.glActiveTexture(GL2.GL_TEXTURE0); gl.glBindTexture(GL2.GL_TEXTURE_RECTANGLE, wipeBuffer.getTexture()); gl.glEnable(GL2.GL_TEXTURE_RECTANGLE);