Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modcharting Tools #2913

Closed
wants to merge 16 commits into from
Closed

Modcharting Tools #2913

wants to merge 16 commits into from

Conversation

lemz1
Copy link
Contributor

@lemz1 lemz1 commented Jun 25, 2024

Feedback and tips are appreciated.

ADDITIONS

  • Cut sustain trail into multiple slices, which is useful for modcharting
  • Add NotePathModifier interface for specifying the path that the note should follow

TODO

  • Rework sustain trail rendering
  • Add sustain end trail back
  • Fix stuttering when hitting notes (For some reason calling triggerRedraw in the draw method seems to make it stutter)
  • Maybe add a "trail quality" option, which would determine how many segments the trail is cut into
  • Fix downscroll
  • Fix chart editor hold
  • Add modcharting tools (Modcharting will be done via scripts probably)
  • Optimize the shit out of this (The performance doesn't seem to take a hit, but i will try to optimize regardless)

FILE ADDITIONS

assets/shared/images/NOTE_hold_assets.xml

<?xml version="1.0" encoding="utf-8"?>
<TextureAtlas imagePath="NOTE_hold_assets.png">
	<SubTexture name="blue hold end0000" x="157" y="0" width="50" height="64" />
	<SubTexture name="blue hold piece0000" x="105" y="0" width="50" height="87" />
	<SubTexture name="green hold end0000" x="261" y="0" width="50" height="64" />
	<SubTexture name="green hold piece0000" x="209" y="0" width="50" height="87" />
	<SubTexture name="purple hold end0000" x="53" y="0" width="50" height="64" />
	<SubTexture name="purple hold piece0000" x="1" y="0" width="50" height="87" />
	<SubTexture name="red hold end0000" x="365" y="0" width="50" height="64" />
	<SubTexture name="red hold piece0000" x="313" y="0" width="50" height="87" />
</TextureAtlas>

assets/week6/images/weeb/pixelUI/arrowEndsNew.xml

<?xml version="1.0" encoding="utf-8"?>
<TextureAtlas imagePath="arrowEndsNew.png">
	<SubTexture name="blue hold end0000" x="28" y="0" width="7" height="6" />
	<SubTexture name="blue hold piece0000" x="19" y="0" width="7" height="6" />
	<SubTexture name="green hold end0000" x="46" y="0" width="7" height="6" />
	<SubTexture name="green hold piece0000" x="37" y="0" width="7" height="6" />
	<SubTexture name="purple hold end0000" x="10" y="0" width="7" height="6" />
	<SubTexture name="purple hold piece0000" x="1" y="0" width="7" height="6" />
	<SubTexture name="red hold end0000" x="64" y="0" width="7" height="6" />
	<SubTexture name="red hold piece0000" x="55" y="0" width="7" height="6" />
</TextureAtlas>

lets not call triggerRedraw every frame
@lemz1 lemz1 marked this pull request as draft June 25, 2024 22:22
@tposejank
Copy link
Contributor

tposejank commented Jun 26, 2024

use shaders instead...

@charlesisfeline
Copy link

shaders? but what about where the notes go around a certain shape like a square or circle?

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 26, 2024

Fuck no, use shaders instead!

If you are talking about using fragment shaders to do positional effects for sustain trails, then that is just not viable. We would need to create a new camera or bitmap for each sustain trail. Which would be memory and performance intensive.

If you are talking about vertex shaders, then we literally need to create more vertices to do positional effects.

@tposejank
Copy link
Contributor

I've seen the use of shaders in sustains before. But in my opinion, the adding of separated parts to the sustains may complicate it

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 26, 2024

Do you know what type of shaders they were? Meaning fragment or vertex. When people use shaders for sustain effects, i've always only seen fragment shaders. And from looking at their code, it was always kind of weird and limiting

@tposejank
Copy link
Contributor

Fragment is everywhere, I've never seen anyone use vertex. (in the end, everything came out of shadertoy)

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 26, 2024

Hmm, like I said, fragment shaders are limiting, because either you have to apply the effect to all sustain trails, or you need to create a new camera or bitmap for each sustain trails, which is going to be bad for memory usage. I could also imagine that it would be pretty costly for the performance, since you would be going through ~1million pixels for each trail, which is pretty bad in my opinion.

But I guess it depends on what the funkin team thinks is best

@tposejank
Copy link
Contributor

tposejank commented Jun 26, 2024 via email

still work in progress
@KutikiPlayz
Copy link

what kind of modcharts specifically need segmented sustains?
I couldn't imagine a single thing that'd look remotely cool if you segment them again
just use shaders like tpose says
you shouldn't need an entire camera for the sustains anymore since they're one piece, you just need to apply the shader to all the sustains

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 27, 2024

when you use the shader on the sustain itself, the fragment shader will affect the graphic that is used for drawing, meaning you cant do any positional effects

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 27, 2024

to demonstrate what i mean:
I used a shader that adds vec2(0.125, 0.0) to openfl_TextureCoordv

void main() {
    vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv + vec2(0.125, 0.0);
    gl_FragColor = color;
}
sustainTrail.mp4

As you can see it doesnt change the position of the trail, rather it changes where to sample from the hold texture. The reason why i said that we need a camera is because the camera covers the entire screen and if we apply the 0.125 to uv.x then it would offset the entire graphic of the camera, which would be the expected behaviour.

lemz1 and others added 6 commits June 28, 2024 16:11
still needs to be fully implemented
but end pieces work now
this time its alot better
why wasn't this here?
it wont be changable in the menus
@lemz1 lemz1 changed the title New SustainTrail Rendering Method Modcharting Tools Jun 29, 2024
@lemz1 lemz1 closed this Jun 30, 2024
@lemz1
Copy link
Contributor Author

lemz1 commented Jun 30, 2024

closing for now, because i wont work on this for a while

maybe just a few days, but idk

@anysad
Copy link
Contributor

anysad commented Jun 30, 2024

:(

@lemz1
Copy link
Contributor Author

lemz1 commented Jun 30, 2024

reopening this, because i had an issue and maybe while im not working on this pr, someone can find a solution to it.

polymod error: Could not import class funkin.play.notes.modifier.NoteTransform

script:

import funkin.play.notes.modifier.NotePathUtil;
import funkin.play.notes.modifier.NotePathModifier;
import funkin.play.notes.modifier.NoteTransform;
import funkin.play.song.Song;

class CoolModifier implements NotePathModifier
{
  public function new() {}

  public function calculateTransform(time:Float):NoteTransform
  {
    return new NoteTransform(0, time);
  }
}

class HighSong extends Song
{
  var modifier:CoolModifier;

  function new()
  {
    super('high');
  }

  function onCreate(event:ScriptEvent)
  {
    modifier = new CoolModifier();
  }

  // im pretty sure i could just use onNoteIncoming
  function onUpdate(event:UpdateScriptEvent)
  {
    for (note in NotePathUtil.getNotes())
    {
      note.modifier = modifier;
    }
  }
}

@lemz1 lemz1 reopened this Jun 30, 2024
@tposejank
Copy link
Contributor

Cannot import enums/abstracts/whatever in modules

@lemz1
Copy link
Contributor Author

lemz1 commented Jul 2, 2024

i just realized, im pretty sure hscript doesnt support multiple class definitions in a file.
guess i need to rework the modifier stuff

@tposejank
Copy link
Contributor

tposejank commented Jul 2, 2024 via email

@lemz1
Copy link
Contributor Author

lemz1 commented Jul 2, 2024

hmm, maybe its something else then.

currently i have an issue with this:
modifier = new CoolModifier();

im not on my pc right now so i cant give you the exact error, but it was something along the lines of: target class null

i just imagined that the cause of that is having multiple classes in one file.

@lemz1
Copy link
Contributor Author

lemz1 commented Jul 3, 2024

ive tested it out with another script in base funkin:

i get an error here:

var testClass = new TestClass();

error: Could not determine target class for "null" (unknown type?)

full script:

import funkin.graphics.adobeanimate.FlxAtlasSprite;
import funkin.Paths;
import flixel.FlxG;
import funkin.audio.FunkinSound;
import funkin.play.character.MultiSparrowCharacter;
import funkin.play.GameOverSubState;

class TestClass {
	public var cool:Int;

	public function new() {
		cool = 5;
	}
	
	public function print() {
		trace(cool);
	}
}

class BoyfriendCharacter extends MultiSparrowCharacter {
	function new() {
		super('bf');
	}

	override function playAnimation(name:String, restart:Bool, ignoreOther:Bool) {
		if (name == "fakeoutDeath") {
			doFakeoutDeath();
		} else {
			super.playAnimation(name, restart, ignoreOther);
		}

		var testClass = new TestClass();
		testClass.print();
	}

	function doFakeoutDeath():Void {
		FunkinSound.playOnce(Paths.sound("gameplay/gameover/fakeout_death"), 1.0);

		var bfFakeout:FlxAtlasSprite = new FlxAtlasSprite(this.x - 440, this.y - 240, Paths.animateAtlas("characters/bfFakeOut", "shared"));
    FlxG.state.subState.add(bfFakeout);
		bfFakeout.zIndex = 1000;
    bfFakeout.playAnimation('');
		// We don't want people to miss this.
		FlxG.state.subState.mustNotExit = true;
    bfFakeout.anim.onComplete = () -> {
      bfFakeout.visible = false;
      this.visible = true;
			FlxG.state.subState.mustNotExit = false;
      this.playAnimation('firstDeath', true, true);
      // Play the "blue balled" sound. May play a variant if one has been assigned.
      GameOverSubState.playBlueBalledSFX();
    };
    bfFakeout.visible = true;
		this.visible = false;
	}
}

@nebulazorua
Copy link
Contributor

This feels like something fit for mods/frameworks to implement, and not implemented into base code itself

@lemz1
Copy link
Contributor Author

lemz1 commented Jul 7, 2024

i never thought of making this a framework, but i guess that might just be better.

@lemz1 lemz1 closed this Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants