Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSillyDoggo committed Aug 8, 2024
1 parent 741f9a6 commit be11dba
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
39 changes: 14 additions & 25 deletions resources/pp-frag-android.glsl
Original file line number Diff line number Diff line change
@@ -1,53 +1,42 @@
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
#version 300 es

#if __VERSION__ == 300
#version 300 es
in vec2 TexCoords;
out vec4 FragColor;
#else
varying vec2 TexCoords;
#endif
precision highp float;

in vec2 TexCoords;

uniform sampler2D screen;
uniform vec2 screenSize;
uniform bool fast;
uniform bool first;
uniform float radius;

out vec4 FragColor;

void main() {
float scaledRadius = radius * screenSize.y * 0.5;
vec2 texOffset = 1.0 / screenSize; // gets size of single texel

vec3 result = texture2D(screen, TexCoords).rgb;
vec3 result = texture(screen, TexCoords).rgb;
scaledRadius *= radius * 10.0 / ((radius * 10.0 + 1.0) * (radius * 10.0 + 1.0) - 1.0);
float weight = 1.0;
float weightSum = weight;
if (first) {
for (int i = 1; float(i) < scaledRadius; i++) {
weight -= 1.0 / scaledRadius;
weightSum += weight * 2.0;
result += texture2D(screen, TexCoords + vec2(texOffset.x * float(i), 0.0)).rgb * weight;
result += texture2D(screen, TexCoords - vec2(texOffset.x * float(i), 0.0)).rgb * weight;
result += texture(screen, TexCoords + vec2(texOffset.x * float(i), 0.0)).rgb * weight;
result += texture(screen, TexCoords - vec2(texOffset.x * float(i), 0.0)).rgb * weight;
}
} else {
}
else {
for (int i = 1; float(i) < scaledRadius; i++) {
weight -= 1.0 / scaledRadius;
weightSum += weight * 2.0;
result += texture2D(screen, TexCoords + vec2(0.0, texOffset.y * float(i))).rgb * weight;
result += texture2D(screen, TexCoords - vec2(0.0, texOffset.y * float(i))).rgb * weight;
result += texture(screen, TexCoords + vec2(0.0, texOffset.y * float(i))).rgb * weight;
result += texture(screen, TexCoords - vec2(0.0, texOffset.y * float(i))).rgb * weight;
}
}
result /= weightSum;

#if __VERSION__ == 300

FragColor = vec4(result, 1.0);
#else
gl_FragColor = vec4(result, 1.0);
#endif
}
22 changes: 22 additions & 0 deletions src/Utils/CCBlurLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ void CCBlurLayer::draw()
if (blurStrength == 0)
return CCLayerColor::draw();

auto start1 = std::chrono::high_resolution_clock::now();

GLint drawFbo = 0;
GLint readFbo = 0;
glGetIntegerv(0x8CA6, &drawFbo);
Expand All @@ -103,7 +105,11 @@ void CCBlurLayer::draw()
glBindFramebuffer(0x8D40, ppRt0.fbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

auto end1 = std::chrono::high_resolution_clock::now();

std::chrono::duration<double, std::milli> duration1 = end1 - start1;

log::info("link 1 took {}ms", duration1.count());

CCLayerColor::draw();

Expand All @@ -120,9 +126,17 @@ void CCBlurLayer::draw()
kmGLPushMatrix();
#endif

auto start = std::chrono::high_resolution_clock::now();

parent->transform();
parent->visit();

auto end = std::chrono::high_resolution_clock::now();

std::chrono::duration<double, std::milli> duration = end - start;

log::info("scene render took {}ms", duration.count());


#ifdef GEODE_IS_IOS
reinterpret_cast<void(__cdecl*)()>(geode::base::get() + 0x174250)();
Expand All @@ -136,6 +150,8 @@ void CCBlurLayer::draw()
if (getParent())
getParent()->setVisible(true);

auto start2 = std::chrono::high_resolution_clock::now();

glBindVertexArray(ppVao);
#ifdef GEODE_IS_IOS
reinterpret_cast<void(__cdecl*)(GLuint)>(geode::base::get() + 0x19a4f8)(ppShader.program);
Expand All @@ -161,6 +177,12 @@ void CCBlurLayer::draw()

glBindVertexArray(0);

auto end2 = std::chrono::high_resolution_clock::now();

std::chrono::duration<double, std::milli> duration2 = end2 - start2;

log::info("scene end took {}ms", duration2.count());

#endif
}

Expand Down
1 change: 1 addition & 0 deletions src/Utils/CCBlurLayer.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <numbers>
#include <chrono>
#include <Geode/Geode.hpp>
#include <Geode/modify/GameManager.hpp>
#include <Geode/modify/CCScheduler.hpp>
Expand Down

0 comments on commit be11dba

Please sign in to comment.