This commit is contained in:
lunarcleint
2024-03-22 20:52:11 -07:00
6 changed files with 35 additions and 29 deletions
@@ -6,6 +6,6 @@ void main() {
float len = length(openfl_TextureCoordv - vec2(0.5, 0.5));
float r = 0.5 - (1.0 / openfl_TextureSize.x);
vec4 c = flixel_texture2D(bitmap, openfl_TextureCoordv);
vec4 color = mix(vec4(0, 0, 0, 0.5), c, c.a);
gl_FragColor = color * clamp(1 - ((len - r) * openfl_TextureSize.x), 0, 1);
vec4 color = mix(vec4(0.0, 0.0, 0.0, 0.5), c, c.a);
gl_FragColor = color * clamp(1.0 - ((len - r) * openfl_TextureSize.x), 0.0, 1.0);
}
+8 -5
View File
@@ -7,9 +7,9 @@ int steps = 16;
int stepsInside = 2;
float strength = 0.0075;
vec4 getColor(vec2 pos) {
if (pos.x < 0) pos.x = 0;
if (pos.x < 0.0) pos.x = 0.0;
else if (pos.x > 1.0 - (1.0 / openfl_TextureSize.x)) pos.x = 1.0 - (1.0 / openfl_TextureSize.x);
if (pos.y < 0) pos.y = 0;
if (pos.y < 0.0) pos.y = 0.0;
else if (pos.y > 1.0 - (1.0 / openfl_TextureSize.y)) pos.y = 1.0 - (1.0 / openfl_TextureSize.y);
// return textureCam(bitmap, pos);
return flixel_texture2D(bitmap, pos);
@@ -17,15 +17,18 @@ vec4 getColor(vec2 pos) {
void main() {
// vec2 camPos = getCamPos(openfl_TextureCoordv);
vec2 camPos = openfl_TextureCoordv;
if (camPos.x < 0 || camPos.x > 1 || camPos.y < 0 || camPos.y > 1)
if (camPos.x < 0.0 || camPos.x > 1.0 || camPos.y < 0.0 || camPos.y > 1.0)
return;
vec4 color = getColor(camPos);
float fsteps = steps;
for(float inside = 1; inside < stepsInside+1; inside++) {
for(float inside = 1.0; inside < stepsInside+1.0; inside++) {
for(int i = 0; i < steps; i++) {
float fi = i;
color += getColor(camPos + vec2(strength * (inside / stepsInside) * cos(fi / fsteps * (PI * 2.0)), strength * (inside / stepsInside) * sin(fi / fsteps * (PI * 2.0))));
color += getColor(camPos + vec2(
strength * (inside / stepsInside) * cos(fi / fsteps * (PI * 2.0)),
strength * (inside / stepsInside) * sin(fi / fsteps * (PI * 2.0))
));
}
}
+16 -17
View File
@@ -2,11 +2,11 @@
// Used in charter by waveforms
const vec3 gradient1 = vec3(114./255., 81./255., 135./255);
const vec3 gradient2 = vec3(144./255., 80./255., 186./255);
const vec3 gradient1 = vec3(114.0/255.0, 81.0/255.0, 135.0/255.0);
const vec3 gradient2 = vec3(144.0/255.0, 80.0/255.0, 186.0/255.0);
const vec4 outlinecolor = vec4(vec3(.1), .1);
const vec3 lowdetailcol = vec3(0., 0., 1.);
const vec4 outlinecolor = vec4(0.1);
const vec3 lowdetailcol = vec3(0.0, 0.0, 1.0);
uniform vec2 textureRes;
uniform float pixelOffset;
@@ -20,17 +20,16 @@ uniform bool lowDetail;
float getAmplitude(vec2 pixel) {
float pixelID = floor((pixel.y+pixelOffset)/3.0);
// TODO: INVESTIGATE THE 1.+ AND WHY IT WORKS (SRSLY I GOT NO CLUE) -lunar
vec2 wavePixel = vec2(mod(pixelID,waveformSize.x), 1.0+floor(pixelID/waveformSize.x));
vec4 waveData = texture2D(waveformTexture, wavePixel / waveformSize);
switch (int(mod(wavePixel.x, 3.0))) {
case 0: return waveData.r; break;
case 1: return waveData.g; break;
case 2: return waveData.b; break;
}
return 0.;
int id = int(mod(wavePixel.x, 3.0));
if(id == 0) return waveData.r;
if(id == 1) return waveData.g;
if(id == 2) return waveData.b;
return 0.0;
}
float getAmpWidth(float amplitude) {
@@ -45,26 +44,26 @@ bool inWaveForm(vec2 pixel, float width) {
float getHightlight(float ampwidth) {
float remapCoord = (ampwidth/textureRes.x)/2.0;
float mappedCoord = map(openfl_TextureCoordv.x, remapCoord, 1.0-remapCoord, 0.0, 1.0);
return 1.-(abs(mappedCoord-0.5)*2.0);
return 1.0-(abs(mappedCoord-0.5)*2.0);
}
void outlineWaveform(vec2 pixel, vec2 offset) {
float amplitude = getAmplitude(pixel - offset);
float ampwidth = (1.-amplitude) * textureRes.x;
float ampwidth = (1.0-amplitude) * textureRes.x;
if (!inWaveForm(pixel, ampwidth))
gl_FragColor -= outlinecolor*mix(0.5, .8, amplitude);
gl_FragColor -= outlinecolor*mix(0.5, 0.8, amplitude);
}
void highDetailWaveform(vec2 pixel, float amplitude, float ampwidth) {
vec3 gradientColor = mix(gradient1, gradient2, openfl_TextureCoordv.x);
gradientColor *= pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0;
gradientColor *= pixel.y+pixelOffset>playerPosition ? 0.7 : 1.0;
gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(amplitude), 0.0, 1.0, 0.5, 1.0));
float ampwidthHighlight = getAmpWidth(amplitude*(1.0/3.0));
float ampwidthHighlight = getAmpWidth(amplitude/3.0);
if (inWaveForm(pixel, ampwidthHighlight))
gradientColor = mix(gradientColor, gradientColor * vec3(1.8), map(getHightlight(ampwidthHighlight), 0.0, 1.0, 0.5, 1.0));
gl_FragColor = vec4(vec3(gradientColor * mix(0.5, 0.8, amplitude))*openfl_Alphav, openfl_Alphav);
outlineWaveform(pixel, vec2(0.0, -1.0));
+1 -1
View File
@@ -28,7 +28,7 @@ void main() {
hsv.g = (1.0/3.0) * strength * coords.y;
hsv.r = mod(elapsed + coords.x + coords.y, 1);
hsv.r = mod(elapsed + coords.x + coords.y, 1.0);
gl_FragColor = vec4(hsv2rgb(hsv), color.a);
}
+8
View File
@@ -493,6 +493,14 @@ class Charter extends UIState {
Framerate.codenameBuildField.alpha = 0.4;
}
updateDisplaySprites();
// ! IF YOU EVER WANNA VIEW IN THE FUTURE, JUST USE A FLXSPRITE :D -lunar
/*var dataDisplay:FlxSprite = new FlxSprite().loadGraphic(waveformHandler.waveDatas.get("Voices.ogg"));
dataDisplay.scrollFactor.set(1, 0);
dataDisplay.scale.set(2, 2);
dataDisplay.updateHitbox();
dataDisplay.screenCenter(Y);
dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay);*/
}
override function destroy() {
@@ -60,10 +60,6 @@ class CharterWaveformHandler extends FlxBasic {
waveDatas.set(name, waveData);
return waveData;
// ! IF YOU EVER WANNA VIEW IN THE FUTURE, JUST USE A FLXSPRITE :D -lunar
// var dataDisplay:FlxSprite = new FlxSprite().loadGraphic(waveformHandler.waveDatas.get("Voices.ogg"));
// dataDisplay.cameras = [charterCamera]; dataDisplay.x = -dataDisplay.width; add(dataDisplay);
}
public function generateShader(name:String, sound:FlxSound):CustomShader {