Android Open Source - mgcube Fast Bloom Shader






From Project

Back to project page mgcube.

License

The source code is released under:

qp is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported http://creativecommons.org/licenses/by-nc-nd/3.0/ Your are not allowed to publish this game under your name.

If you think the Android project mgcube listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.redlion.qb.shader;
/*from   w  w w.  j  ava2 s  .  c  o  m*/
public class FastBloomShader {

    public static final String mVertexShader =                    
    "varying vec2 TexCoord2; \n" +
    "varying vec2 TexCoord1; \n" + 
    "varying vec2 TexCoord0; \n" +
    "uniform float TexelOffsetY; \n" +
    "uniform float TexelOffsetX; \n" +
    "attribute vec2 a_texCoord; \n" +
    "attribute vec4 a_position; \n" +
    "void main () \n" +
    "{ \n" +
    "  gl_Position = a_position; \n" +
    "  vec2 tmpvar_1; \n" +
    "  tmpvar_1.x = TexelOffsetX; \n" +
    "  tmpvar_1.y = TexelOffsetY; \n" +
    "  TexCoord0 = (a_texCoord - tmpvar_1); \n" +
    "  TexCoord1 = a_texCoord; \n" +
    "  TexCoord2 = (a_texCoord + tmpvar_1); \n" +
    "} \n";
    
    public static final String mFragmentShader =   
        "#ifdef GL_ES\n" +
        "precision highp float;\n" +
        "#endif\n" +
    "varying vec2 TexCoord2;\n" +
    "varying vec2 TexCoord1;\n" +
    "varying vec2 TexCoord0;\n" +
    "uniform float bloomFactor;\n" +
    "uniform sampler2D sTexture;\n" +
    "void main ()\n" +
    "{\n" +
    "  gl_FragColor.xyz = (((texture2D (sTexture, TexCoord2).xyz * 0.333333) + ((texture2D (sTexture, TexCoord1).xyz * 0.333333) + (texture2D (sTexture, TexCoord0).xyz * 0.333333))) * bloomFactor);\n" +
    "} \n";
    }

/** Precision qualifiers gain one frame on milestone but break desktop support an look a bit uglier
public static final String mVertexShader =                    
"attribute highp vec4 a_vertex;   \n" +
"attribute mediump vec2 a_texCoord;   \n" +
"uniform mediump float TexelOffsetX;   \n" +
"uniform mediump float TexelOffsetY;   \n" +
"varying mediump vec2  TexCoord0;   \n" +
"varying mediump vec2  TexCoord1;   \n" +
"varying mediump vec2  TexCoord2;   \n" +
"void main()   \n" +
"{   \n" +
"  // Pass through vertex   \n" +
"  gl_Position = a_vertex;   \n" +
"     \n" +
"  // Calculate texture offsets and pass through     \n" +
"  mediump vec2 offset = vec2(TexelOffsetX, TexelOffsetY);   \n" +
"     \n" +
"    TexCoord0 = a_texCoord - offset;   \n" +
"    TexCoord1 = a_texCoord;   \n" +
"    TexCoord2 = a_texCoord + offset;       \n" +
"}   \n";

public static final String mFragmentShader =   
"#ifdef GL_ES\n" +
"precision highp float;\n" +
"#endif\n" +
"uniform lowp sampler2D  sTexture;\n" +
"uniform lowp float bloomFactor;\n" +
"varying mediump vec2  TexCoord0;\n" +
"varying mediump vec2  TexCoord1;\n" +
"varying mediump vec2  TexCoord2;\n" +
"void main()\n" +
"{\n" +
"    lowp vec3 color = texture2D(sTexture, TexCoord0).rgb * 0.333333;\n" +
"    color = (texture2D(sTexture, TexCoord1).rgb * 0.333333) + color;\n" +
"    color = (texture2D(sTexture, TexCoord2).rgb * 0.333333) + color;\n" + 
"    gl_FragColor.rgb = color*bloomFactor;\n" +
"}\n";
**/




Java Source Code List

de.redlion.qb.Block.java
de.redlion.qb.Constants.java
de.redlion.qb.DefaultScreen.java
de.redlion.qb.EditorBlock.java
de.redlion.qb.EditorScreen.java
de.redlion.qb.GameInstance.java
de.redlion.qb.GameScreen.java
de.redlion.qb.Helper.java
de.redlion.qb.HighScoreManager.java
de.redlion.qb.HighScoreTimeAttack.java
de.redlion.qb.HighScore.java
de.redlion.qb.IntroScreen.java
de.redlion.qb.LZW.java
de.redlion.qb.LevelButton.java
de.redlion.qb.LevelSelectScreen.java
de.redlion.qb.MainActivity.java
de.redlion.qb.MainMenuScreenReduced.java
de.redlion.qb.MainMenuScreen.java
de.redlion.qb.Main.java
de.redlion.qb.MovableBlock.java
de.redlion.qb.OptionsScreen.java
de.redlion.qb.Player.java
de.redlion.qb.Portal.java
de.redlion.qb.QBLogo.java
de.redlion.qb.Renderable.java
de.redlion.qb.Resources.java
de.redlion.qb.RobovmLauncher.java
de.redlion.qb.ScreenshotSaver.java
de.redlion.qb.Starter.java
de.redlion.qb.Switch.java
de.redlion.qb.SwitchableBlock.java
de.redlion.qb.Target.java
de.redlion.qb.TutorialScreen.java
de.redlion.qb.client.GwtLauncher.java
de.redlion.qb.shader.FastBloomShader.java
de.redlion.qb.shader.TVShader.java
de.redlion.qb.shader.TransShader.java