Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service
android:name="net.t106.sinkerglwallpaper.SinkerService"
android:name="net.t106.sinkerglwallpaper.rendering.services.SinkerService"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER"
android:exported="true">
Expand All @@ -27,9 +27,9 @@
</service>

<activity
android:name="net.t106.sinkerglwallpaper.SettingsActivity"
android:name="net.t106.sinkerglwallpaper.ui.activities.SettingsActivity"
android:label="@string/title_activity_settings"
android:exported="false">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
Expand Down
25 changes: 20 additions & 5 deletions app/src/main/assets/shaders/blend_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,23 @@ void main() {
vec4 blendColor = u_color;
vec4 finalColor;

// Calculate luminance to detect dark areas (for black background transparency)
float luminance = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));

// Apply different blend modes
if (u_blendMode == BLEND_ADD) {
// Additive blending: add colors together
finalColor = clamp(texColor + blendColor, 0.0, 1.0);
// Additive blending: multiply texture with color first, then add in framebuffer
finalColor.rgb = texColor.rgb * blendColor.rgb;
finalColor.a = texColor.a * blendColor.a;

} else if (u_blendMode == BLEND_MULTIPLY) {
// Multiplicative blending: multiply colors
finalColor = texColor * blendColor;

} else if (u_blendMode == BLEND_ALPHA) {
// Alpha blending: interpolate based on alpha
finalColor = mix(texColor, blendColor, blendColor.a);
// Alpha blending: preserve texture transparency
finalColor.rgb = texColor.rgb * blendColor.rgb;
finalColor.a = texColor.a * blendColor.a;

} else if (u_blendMode == BLEND_XOR) {
// XOR-like blending: absolute difference
Expand All @@ -52,7 +57,17 @@ void main() {
finalColor = texColor * blendColor;
}

// Ensure alpha is reasonable
// Discard dark pixels (black background) to create transparency
if (luminance < 0.1) {
discard;
}

// Discard completely transparent pixels from texture alpha
if (texColor.a < 0.01) {
discard;
}

// Also discard if final alpha is too low
if (finalColor.a < 0.01) {
discard;
}
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/assets/shaders/color_fragment.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#version 320 es

precision mediump float;

// Input from vertex shader
in vec2 v_texCoord;

// Uniforms
uniform vec4 u_color;
uniform int u_blendMode;

// Output color
out vec4 fragColor;

// Blend mode constants
const int BLEND_ADD = 0;
const int BLEND_MULTIPLY = 1;
const int BLEND_ALPHA = 2;
const int BLEND_XOR = 3;

void main() {
// Use solid color (no texture)
vec4 finalColor = u_color;

// For XOR mode, apply some color manipulation
if (u_blendMode == BLEND_XOR) {
// Enhance color for invert effect
finalColor.rgb = 1.0 - finalColor.rgb;
}

// Discard completely transparent pixels
if (finalColor.a < 0.01) {
discard;
}

fragColor = finalColor;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,9 @@ public static int createBasicProgram(Context context) {
public static int createBlendProgram(Context context) {
return createProgramFromAssets(context, "basic_vertex.glsl", "blend_fragment.glsl");
}

public static int createColorProgram(Context context) {
return createProgramFromAssets(context, "basic_vertex.glsl", "color_fragment.glsl");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,27 @@ public LeftFilter()

@Override
protected void createShaderProgram() {
// Use blend shader program for customizable blending
shaderProgram = ShaderLoader.Programs.createBlendProgram(SinkerService.getContext());
// Use color shader program for color-only rendering
shaderProgram = ShaderLoader.Programs.createColorProgram(SinkerService.getContext());
}

@Override
public void Draw(float[] viewMatrix, float[] projectionMatrix) {

// Update MVP matrix (no rotation, just basic transformation)
updateMVP(viewMatrix, projectionMatrix);

// Bind shader and set uniforms
bindShader();

// No texture binding needed for color-only rendering
ShaderUtils.setUniform1i(textureLocation, 0);

// Set blend mode from user settings
ShaderUtils.setUniform1i(blendModeLocation, SinkerService.blend_type);

// Set color from user settings (convert from 0-100 range to 0.0-1.0)
int[] col = SinkerService.col;
float red = col[0] / 100.0f;
float green = col[1] / 100.0f;
float blue = col[2] / 100.0f;
float alpha = col[3] / 100.0f;
ShaderUtils.setUniform4f(colorLocation, red, green, blue, alpha);

// Enable blending with mode based on user settings

GLES32.glEnable(GLES32.GL_BLEND);

switch(SinkerService.blend_type)
{
// Additive
case 0:
GLES32.glBlendFunc(GLES32.GL_ONE, GLES32.GL_ONE);
break;
// Multiplicative
case 1:
GLES32.glBlendFunc(GLES32.GL_ZERO, GLES32.GL_SRC_COLOR);
break;
// Alpha
case 2:
GLES32.glBlendFunc(GLES32.GL_SRC_ALPHA, GLES32.GL_ONE);
break;
// XOR (Exclusive OR)
case 3:
GLES32.glBlendFunc(GLES32.GL_ONE_MINUS_DST_COLOR, GLES32.GL_ONE_MINUS_SRC_COLOR);
break;
default:
GLES32.glBlendFunc(GLES32.GL_SRC_ALPHA, GLES32.GL_ONE_MINUS_SRC_ALPHA);
break;
}

// Bind VAO and draw

ShaderUtils.setUniform4f(colorLocation, 0.2f, 0.4f, 0.60f, 0.4f);
GLES32.glBlendFunc(GLES32.GL_ONE, GLES32.GL_ONE);
BufferUtils.bindVAO(vao);
BufferUtils.drawQuad();
BufferUtils.unbindVAO();

// Disable blending

GLES32.glDisable(GLES32.GL_BLEND);
}

Expand All @@ -102,7 +65,7 @@ public void sizechange(boolean smollflg)

// Update vertex data based on size
if(smollflg) {
apex = new float[] { -0.5f, -1.5f, 0.5f, -1.5f, -0.5f, 1.5f, 0.5f, 1.5f, };
apex = new float[] { -0.5f, -1.5f, 0.0f, -1.5f, -0.5f, 1.5f, 0.0f, 1.5f, };
} else {
apex = new float[] { -0.7f, -1.5f, 0.7f, -1.5f, -0.7f, 1.5f, 0.7f, 1.5f, };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public RightFilter()

@Override
protected void createShaderProgram() {
// Use basic shader program without texture
shaderProgram = ShaderLoader.Programs.createBasicProgram(SinkerService.getContext());
// Use color shader program for color-only rendering
shaderProgram = ShaderLoader.Programs.createColorProgram(SinkerService.getContext());
}

@Override
Expand All @@ -46,21 +46,17 @@ public void Draw(float[] viewMatrix, float[] projectionMatrix) {

// Bind shader and set uniforms
bindShader();

// No texture binding needed for color-only rendering
ShaderUtils.setUniform1i(textureLocation, 0);

// Set blend mode to custom invert effect (can be simulated with XOR mode)
ShaderUtils.setUniform1i(blendModeLocation, 3); // XOR mode

// Set filter color (pinkish)
ShaderUtils.setUniform4f(colorLocation, RED, GREEN, BLUE, ALPHA);

// Enable special blending for invert effect

GLES32.glEnable(GLES32.GL_BLEND);

ShaderUtils.setUniform4f(colorLocation, 0.2f, 0.4f, 0.60f, 0.4f);
GLES32.glBlendFunc(GLES32.GL_ZERO, GLES32.GL_SRC_COLOR);
BufferUtils.bindVAO(vao);
BufferUtils.drawQuad();
BufferUtils.unbindVAO();

ShaderUtils.setUniform4f(colorLocation, 0.85f, 0.85f, 0.85f, 1.00f);
GLES32.glBlendFunc(GLES32.GL_ONE_MINUS_DST_COLOR, GLES32.GL_ZERO);

// Bind VAO and draw
BufferUtils.bindVAO(vao);
BufferUtils.drawQuad();
BufferUtils.unbindVAO();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public class BackgroundGraveyard extends Graveyard {
private static final float ROTATION_SPEED = 0.125f; // Positive rotation (opposite to center)
private static final int MAX_COUNT = 2880;

// Color tint for background
private static final float RED = 0.375f;
private static final float GREEN = 0.04f;
private static final float BLUE = 0.09f;
private static final float ALPHA = 0.5f;

public BackgroundGraveyard()
{
super();
Expand Down Expand Up @@ -57,7 +51,7 @@ public void Draw(float[] viewMatrix, float[] projectionMatrix) {
ShaderUtils.setUniform1i(blendModeLocation, 0);

// Set color tint (reddish-brown tint)
ShaderUtils.setUniform4f(colorLocation, RED, GREEN, BLUE, ALPHA);
ShaderUtils.setUniform4f(colorLocation, 0.375f, 0.04f, 0.09f, 1.0f);

// Enable blending for additive effect
GLES32.glEnable(GLES32.GL_BLEND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ protected void createShaderProgram() {

@Override
public void Draw(float[] viewMatrix, float[] projectionMatrix) {
// android.util.Log.d("CenterGraveyard", "Draw() called");

// Debug: Check if shader and texture are valid
if (shaderProgram == 0) {
android.util.Log.e("CenterGraveyard", "Shader program is 0!");
return;
}
if (SinkerService.textures[0] == 0) {
android.util.Log.e("CenterGraveyard", "Texture is 0!");
return;
}
if (vao == 0) {
android.util.Log.e("CenterGraveyard", "VAO is 0!");
return;
}

// Update MVP matrix with current rotation
updateMVP(viewMatrix, projectionMatrix);

Expand All @@ -47,16 +63,17 @@ public void Draw(float[] viewMatrix, float[] projectionMatrix) {
// Set texture
TextureUtils.bindTexture(0, SinkerService.textures[0]);

// Set blend mode to additive (0)
// Set blend mode to additive (0) for beautiful color effects
ShaderUtils.setUniform1i(blendModeLocation, 0);

// Set color (white for no tinting)
ShaderUtils.setUniform4f(colorLocation, 1.0f, 1.0f, 1.0f, 1.0f);
ShaderUtils.setUniform4f(colorLocation, 0.37f, 1.0f, 1.0f, 1.0f);

// Enable blending for additive effect
// Use additive blending for glowing effects
GLES32.glEnable(GLES32.GL_BLEND);
GLES32.glBlendFunc(GLES32.GL_ONE, GLES32.GL_ONE);

// GLES32.glBlendFunc(GLES32.GL_SRC_ALPHA, GLES32.GL_ONE_MINUS_SRC_ALPHA);

// Bind VAO and draw
BufferUtils.bindVAO(vao);
BufferUtils.drawQuad();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,31 @@ public Graveyard() {
* Must be called after OpenGL context is created
*/
public void initGL() {
android.util.Log.d("Graveyard", getClass().getSimpleName() + " initGL() started");

// Create shader program
createShaderProgram();
android.util.Log.d("Graveyard", getClass().getSimpleName() + " shader program: " + shaderProgram);

if (shaderProgram == 0) {
android.util.Log.e("Graveyard", getClass().getSimpleName() + " failed to create shader program!");
return;
}

// Get uniform locations
mvpMatrixLocation = ShaderUtils.getUniformLocation(shaderProgram, "u_mvpMatrix");
textureLocation = ShaderUtils.getUniformLocation(shaderProgram, "u_texture");
colorLocation = ShaderUtils.getUniformLocation(shaderProgram, "u_color");
blendModeLocation = ShaderUtils.getUniformLocation(shaderProgram, "u_blendMode");

android.util.Log.d("Graveyard", getClass().getSimpleName() + " uniform locations: mvp=" + mvpMatrixLocation +
", texture=" + textureLocation + ", color=" + colorLocation + ", blend=" + blendModeLocation);

// Create VAO and VBOs
createBuffers();
android.util.Log.d("Graveyard", getClass().getSimpleName() + " VAO: " + vao);

android.util.Log.d("Graveyard", getClass().getSimpleName() + " initGL() completed");
}

/**
Expand Down
Loading