Code Monkey home page Code Monkey logo

osu-framework-font's People

Contributors

andy840119 avatar dependabot[bot] avatar webfreak001 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

osu-framework-font's Issues

Implement SingleShaderBufferedDrawNode

Separate issue #159

Because it might only have single shader in the karaoke project, so it should be OK to use SingleShaderBufferedDrawNode as default in the karaoke sprite text and lyric sprite text.
Also, it can solve the FrameBuffer recycle issue.

Fix the case that might let position text cannot get the position.

Fix the case that might let position text cannot get the position:

  • has no main text.
  • text in the position text is null or empty.
  • start and end index is out of range.
  • end index is larger than start index.
  • text with ...

How to fix that:

  • Move GetFixedPositionText into PositionTextFormatter.
  • GetFixedPositionTexts should only fix the duplicated value and move it inside applyPositionTextToBuilder.

Where to add the test:

  • maybe TestSceneLyricSpriteTextCharacterPosition -> rename is required

Fix outline shader issue by pre-calculate some params.

lowp vec4 outline(sampler2D tex, int radius, mediump vec2 texCoord, mediump vec2 texSize, mediump vec4 colour)
{
	float angle = 0.0;
	float outlineAlpha = 0.0;
	
	for (int i = 0; i < SAMPLES; i++)
	{
		angle += 1.0 / (float(SAMPLES) / 2.0) * PI;

		// todo: might need to adjust step samples amount to fill the inner side.
		// but it will cause lots of performance issue if make step samples larger.
		// so should find a better algorithm to fill inner colour.
		for (int j = 1; j <= STEP_SAMPLES; j++)
		{
			vec2 testPoint = texCoord - vec2(sin(angle), cos(angle)) * (float(radius) * (1.0 / j)) / texSize;
			float sampledAlpha = texture2D(tex, testPoint).a;
			outlineAlpha = max(outlineAlpha, sampledAlpha);
		}
	}

	mediump vec4 ogCol = texture2D(tex, texCoord);
	vec4 outlineCol = mix(vec4(0.0), colour, outlineAlpha);

	return mix(outlineCol, ogCol, ogCol.a);
}

Here's the shader and it can see that sin(angle), cos(angle)) runs lots of time on every frame (maybe run draw_width * draw_height * SAMPLES(2) * STEP_SAMPLES(128) times in each frame)
Maybe it can be calculated at the beginning.
Not really sure has someting like void init(void) before void main(void) and only run one time.

Clean-up code.

What's should be clean-up:

  • remove unneed param or include in shader.
  • make internal shader test separate, one shader one test class.
  • param prefix name should be same, e.g: should named g_size or m_size.

Interact with shader.

Those things might need shader support:

  • sprite text.
  • karaoke text.

also notice that should be able to support multi shader eventually.

Change the time-tag param type in the karaoke sprite text.

We use IReadOnlyDictionary<TextIndex, double> TimeTags for passing the time-tags to the karaoke sprite text.
But the transform will need to sort by time.
.
So the interface might be IReadOnlyDictionary<double, TextIndex> TimeTags or IReadOnlyList<TimeTag>
Maybe the first one might be better because it will prevent the duplicated time.

Not restrict time-tag should ordered by time and index.

Because should not be possible to let the lyric crash.
Also for supporting some cool effect(like reversing).
So there's no need to sort by time and index, should just need to sort by time. in the RefreshStateTransforms.

Fix the case that shader might compile error in osx.

Error:

osu.Framework.Graphics.Shaders.Shader+PartCompilationFailedException: A osu.Framework.Graphics.Shaders.ShaderPart failed to compile: sh_CRT.fs:
ERROR: 0:58: 'f' : syntax error: syntax error
   at osu.Framework.Graphics.Shaders.ShaderPart.Compile()
   at osu.Framework.Graphics.Shaders.Shader.CompileInternal()
   at osu.Framework.Graphics.Shaders.Shader.compile()
   at osu.Framework.Threading.ScheduledDelegate.RunTaskInternal()
   at osu.Framework.Threading.ScheduledDelegate.RunTask()
   at osu.Framework.Graphics.OpenGL.GLWrapper.Reset(Vector2 size)
   at osu.Framework.Platform.GameHost.DrawFrame()
   at osu.Framework.Threading.GameThread.processFrame()
--- End of stack trace from previous location ---
   at osu.Framework.Platform.GameHost.<>c__DisplayClass120_0.<abortExecutionFromException>b__0()
   at osu.Framework.Threading.ScheduledDelegate.RunTaskInternal()
   at osu.Framework.Threading.Scheduler.Update()
   at osu.Framework.Threading.GameThread.processFrame()
   at osu.Framework.Threading.GameThread.RunSingleFrame()
   at osu.Framework.Platform.ThreadRunner.RunMainLoop()
   at osu.Framework.Platform.GameHost.windowUpdate()
   at osu.Framework.Platform.SDL2DesktopWindow.Run()
   at osu.Framework.Platform.GameHost.Run(Game game)
   at osu.Framework.Font.Tests.Program.Main(String[] args) in /Volumes/Data/Github/karaoke-dev/osu-framework-font/osu.Framework.Font.Tests/Program.cs:line 21

It might by caused by "compile error", not "file not found"

Stabilize step shader change.

What's should be modified after #45 merged:

  • outline and shadow shader should not need to render the original texture.
  • create a shader to render origin texture (or add a property in outline shader)?
  • fix all the shader test cases.

Add delta transformer for the first and last time-tag.

Inspired from #157
Because still have some spacing in the first lyric's left side if contains draw extra spacing.
So should add delta with that.

image
We should deal with those extra sizing.

  • It might be available if apply the shadow effect.
  • Extra sizing does not include outline.

Implement font outline.

The safety way is to calculate outline texture, not in render.
See how this demo works.
.
Edit :
oops this demo seems cannot use because it's slow and not perfect.
image

Fix left-side shader showing before first time-tag time.

image
Should not show the yellow area.
.
What's should be fixed:

  • write something like IHasExtraSize or IAffectRelativePosition to let KaraokeSpriteText able to adjust the position.'
  • Add this property to OutlineShader only. Maybe will added in the StepShader also(for able to sum the outline)
  • Not really sure is there any way to change the lyric sprite size? Or is there any way to change the draw size?

Also, should write a test scene:

  • Maybe named TestSceneKaraokeSpriteTextWithTimeTags
  • Show the lyric with single or multi outline.
  • Able to change the clock time.
  • Should prevent clear the expired transformers.
  • Able to adjust the scale.

Should add center time-tag inside every input time-tag in the input list.

Inspired from #157
Should make something like the image below:
image
If not add the end time-tag before the next time-tag, will let the lyric effect moving faster because moving position will include that spacing.
This issue might be noticed if the character spacing become larger.

How to implement:

  • Make internal static function to calculate the value that need to be insert between every input time-tag.
  • Write a test case to check calculating result.

Implement real-time calculate ComputeScreenSpaceDrawQuad in KaraokeSpriteText

As title, missing the calculation in the KaraokeSpriteText

protected override Quad ComputeScreenSpaceDrawQuad()
{
    // make draw size become bigger (for not masking the shader).
    var newRectangle = DrawRectangle.Scale(2);
    return ToScreenSpace(newRectangle);
}

It should be the union value of:

  • Shaders
  • LeftLyricTextShaders
  • RightLyricTextShaders

Fix sizing calculation issue in the shader.

image
In this demo implemented in the #172
It's easy to show that border size is not same as what render result is.

It's caused because osu!framework is not pixel perfect framework.
Means size 10 is not means 10 pixel in the screen.

So there's two way to fix that.

  • all sizing-related params in the shade should be converted as what osu-framework using.
  • should adjust the size in the ComputeCharacterDrawRectangle. here's the sample to get the size matching to the render size: originalCharacterDrawRectangle.Inflate(Math.Max(Radius * 88f / 256f, 0));

Fix performance issue.

image
Fix the case that DrawableNode and DrawCells frequency changed if need to update shader in every frame.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.