mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-18 17:08:07 +01:00
Code sanity
This commit is contained in:
parent
f12d9452b4
commit
45b1412837
2 changed files with 31 additions and 40 deletions
|
@ -83,9 +83,6 @@ public class EffectsHandler {
|
|||
|
||||
GL20.glDepthRange(getNearPlane(), getFarPlane());
|
||||
|
||||
// float[] floats = new float[2];
|
||||
// GL20.glGetFloatv(GL20.GL_DEPTH_RANGE, floats);
|
||||
|
||||
prepFramebufferSize();
|
||||
|
||||
Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer();
|
||||
|
@ -112,36 +109,19 @@ public class EffectsHandler {
|
|||
program.bindInverseView(inverseView);
|
||||
|
||||
Vector3d pos1 = new Vector3d(330, 0, 110);
|
||||
// Vector3d pos1 = new Vector3d(852, 79, -204);
|
||||
// Vector3d pos2 = new Vector3d(858, 95, -260);
|
||||
// Vector3d pos3 = new Vector3d(906, 84, -207);
|
||||
Vector3d cameraPos = gameRenderer.getActiveRenderInfo().getProjectedView();
|
||||
|
||||
program.setTestParam((float) (Math.E - 0.99));
|
||||
program.setCameraPos(cameraPos.inverse());
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
double angle = (Math.PI * AnimationTickHolder.getRenderTime() / 40) + i * Math.PI / 4;
|
||||
|
||||
program.addSphere(new SphereFilterProgram.FilterSphere()
|
||||
.setCenter(pos1.subtract(cameraPos).add(0, 0, i * 30))
|
||||
.setCenter(pos1.subtract(cameraPos).add(0, 0, i * 10))
|
||||
.setRadius(15)
|
||||
.setFeather(0.5f)
|
||||
.setFeather(0f)
|
||||
.setFilter(ColorMatrices.hueShift((float) i / 16 * 360 + AnimationTickHolder.getRenderTime())));
|
||||
}
|
||||
|
||||
// program.addSphere(new SphereFilterProgram.FilterSphere()
|
||||
// .setCenter(pos2.subtract(cameraPos))
|
||||
// .setRadius(50)
|
||||
// .setFeather(0.5f)
|
||||
// .setFilter(ColorMatrices.sepia(1)));
|
||||
//
|
||||
// program.addSphere(new SphereFilterProgram.FilterSphere()
|
||||
// .setCenter(pos3.subtract(cameraPos))
|
||||
// .setRadius(20)
|
||||
// .setFeather(3f)
|
||||
// .setFilter(ColorMatrices.saturate(4)));
|
||||
|
||||
program.uploadFilters();
|
||||
|
||||
program.setFarPlane(getFarPlane());
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#version 140
|
||||
|
||||
#define LC 1.7282818// e - 0.99
|
||||
|
||||
#flwinclude <"create:core/color.glsl">
|
||||
|
||||
in vec2 ScreenCoord;
|
||||
|
@ -34,7 +36,7 @@ layout (std140) uniform Filters {
|
|||
float linearizeDepth(float d, float zNear, float zFar) {
|
||||
float clipZ = 2.0 * d - 1.0;
|
||||
float linearized = zNear * zFar / (zFar + zNear - clipZ * (zFar - zNear));
|
||||
return testParam * linearized;
|
||||
return LC * linearized;
|
||||
}
|
||||
|
||||
vec4 filterColor(mat4 colorOp, vec4 frag) {
|
||||
|
@ -54,26 +56,35 @@ float getDepth() {
|
|||
return depth;
|
||||
}
|
||||
|
||||
void main() {
|
||||
float depth = getDepth();
|
||||
vec3 worldPos = WorldDir * depth - uCameraPos;
|
||||
vec4 applyFilters(vec3 worldPos, vec4 diffuse) {
|
||||
vec4 accum = diffuse;
|
||||
|
||||
vec4 diffuse = texture2D(uColor, ScreenCoord);
|
||||
//
|
||||
// for (int i = 0; i < uCount; i++) {
|
||||
// SphereFilter s = uSpheres[i];
|
||||
//
|
||||
// float distance = distance(s.sphere.xyz, worldPos);
|
||||
// float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance);
|
||||
//
|
||||
// accum = mix(accum, filterColor(s.colorOp, accum), strength);
|
||||
// }
|
||||
//
|
||||
// Color = accum;
|
||||
for (int i = 0; i < uCount; i++) {
|
||||
SphereFilter s = uSpheres[i];
|
||||
|
||||
vec3 fractionalCoords = fract(worldPos);
|
||||
float distance = distance(s.sphere.xyz, worldPos);
|
||||
float strength = 1 - smoothstep(s.sphere.w - s.feather, s.sphere.w + s.feather, distance);
|
||||
|
||||
accum = mix(accum, filterColor(s.colorOp, diffuse), strength);
|
||||
}
|
||||
|
||||
return accum;
|
||||
}
|
||||
|
||||
vec4 debugGrid(vec3 worldPos, vec4 diffuse) {
|
||||
vec3 fractionalCoords = fract(worldPos - uCameraPos);
|
||||
|
||||
vec3 isBonudary = step(15./16., fractionalCoords);
|
||||
|
||||
Color = vec4(mix(diffuse.rgb, fractionalCoords, isBonudary), 1.);
|
||||
return vec4(mix(diffuse.rgb, fractionalCoords, isBonudary), 1.);
|
||||
}
|
||||
|
||||
void main() {
|
||||
float depth = getDepth();
|
||||
vec3 worldPos = WorldDir * depth;
|
||||
|
||||
vec4 diffuse = texture2D(uColor, ScreenCoord);
|
||||
|
||||
//Color = applyFilters(worldPos, diffuse);
|
||||
Color = debugGrid(worldPos, diffuse);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue