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

Make custom shaders can be use in HUDs #2931

Closed
4 tasks done
Flandreqwq opened this issue Aug 2, 2023 · 7 comments
Closed
4 tasks done

Make custom shaders can be use in HUDs #2931

Flandreqwq opened this issue Aug 2, 2023 · 7 comments
Labels
type: feature request Feature request.
Milestone

Comments

@Flandreqwq
Copy link

Terms

  • I'm using the very latest version of ItemsAdder and its dependencies.
  • I already searched on this Github page to check if the same suggestion was already reported.
  • I already searched on the plugin wiki to know if the feature is already implemented.
  • I already searched on the Discord server to know if anyone already has a solution for this or if the feature was already suggested.

Discord tag (optional)

芙兰朵露·斯卡蕾特#4453

Describe the solution you'd like

Just add a HUDs configuration option that allows the HUD to be rendered to a specific color for the custom shader to work.

Is your feature request related to a problem?

Because HUDs are essentially actionbar messages, there are text shadows without modifying the shaders.
(The thirst bar example on wiki doesn't have text shadows, but text shadows appear when I create a HUD myself.)

Describe alternatives you've considered

No alternative comes to mind for the time being.

Additional context

image

@Flandreqwq Flandreqwq added the type: feature request Feature request. label Aug 2, 2023
@LoneDev6
Copy link
Collaborator

LoneDev6 commented Aug 2, 2023

Which shader are you using?

@Flandreqwq
Copy link
Author

Which shader are you using?

A shader that can remove the text shadows by using a specific color. At the same time, it is compatible with ItemsAdder's text effects. (This shader is not my original. I'll show it below)

@Flandreqwq
Copy link
Author

`#version 150
#moj_import <fog.glsl>

in vec3 Position;
in vec4 Color;
in vec2 UV0;
in ivec2 UV2;

uniform sampler2D Sampler0,Sampler2;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform mat3 IViewRotMat;
uniform float GameTime;
uniform int FogShape;
uniform vec2 ScreenSize;

out float vertexDistance;
flat out vec4 vertexColor;
out vec2 texCoord0;

void main(){
vec4 vertex = vec4(Position, 1.0);
vertexDistance = fog_distance(ModelViewMat, IViewRotMat * Position, FogShape);
texCoord0 = UV0;
if (Color.xyz == vec3(255., 255., 254.) / 255.) {
gl_Position = ProjMat * ModelViewMat * vertex;
vertexColor = ((.6 + .6 * cos(6. * (gl_Position.x + GameTime * 1000.) + vec4(0, 23, 21, 1))) + vec4(0., 0., 0., 1.)) * texelFetch(Sampler2, UV2 / 16, 0);
} else if(Color.xyz == vec3(255., 255., 253.) / 255.) {
gl_Position = ProjMat * ModelViewMat * vertex;
vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0);
gl_Position.y = gl_Position.y + sin(GameTime * 12000. + (gl_Position.x * 6)) / 150.;
} else if (Color.xyz == vec3(255., 255., 252.) / 255.) {
gl_Position = ProjMat * ModelViewMat * vertex;
vertexColor = ((.6 + .6 * cos(6. * (gl_Position.x + GameTime * 1000.) + vec4(0, 23, 21, 1))) + vec4(0., 0., 0., 1.)) * texelFetch(Sampler2, UV2 / 16, 0);
gl_Position.y = gl_Position.y + sin(GameTime12000. + (gl_Position.x6)) / 150.;
} else if (Color.xyz == vec3(255., 255., 251.) / 255.) {
vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0);
float vertexId = mod(gl_VertexID, 4.0);
if (vertex.z <= 0.) {
if (vertexId == 3. || vertexId == 0.) vertex.y += cos(GameTime * 12000. / 4) * 0.1;
vertex.y += max(cos(GameTime12000. / 4) * 0.1, 0.);
} else {
if (vertexId == 3. || vertexId == 0.) vertex.y -= cos(GameTime * 12000. / 4) * 3;
vertex.y -= max(cos(GameTime
12000. / 4) * 4, 0.);
}
gl_Position = ProjMat * ModelViewMat * vertex;
} else if (Color.xyz == vec3(255., 254., 254.) / 255.) {
float vertexId = mod(gl_VertexID, 4.0);
if (vertex.z <= 0.) {
if (vertexId == 3. || vertexId == 0.) vertex.y += cos(GameTime * 12000. / 4) * 0.1;
vertex.y += max(cos(GameTime12000. / 4) * 0.1, 0.);
} else {
if (vertexId == 3. || vertexId == 0.) vertex.y -= cos(GameTime * 12000. / 4) * 3;
vertex.y -= max(cos(GameTime
12000. / 4) * 4, 0.);
}
vertexColor = ((.6 + .6 * cos(6. * (gl_Position.x + GameTime * 1000.) + vec4(0, 23, 21, 1))) + vec4(0., 0., 0., 1.)) * texelFetch(Sampler2, UV2 / 16, 0);
gl_Position = ProjMat * ModelViewMat * vertex;
} else if (Color.xyz == vec3(255., 254., 253.) / 255.) {
vertexColor = ColortexelFetch(Sampler2, UV2 / 16, 0);
vertex.y+= 1;
vertex.x+= 1;
gl_Position = ProjMat * ModelViewMat * vertex;
} else {
vertexColor = Color
texelFetch(Sampler2, UV2 / 16, 0);
gl_Position = ProjMat * ModelViewMat * vertex;
}
if (Position.z == 0.0
&& gl_Position.x >= 0.94
&& gl_Position.y >= -0.35
&& vertexColor.g == 84.0/255.0
&& vertexColor.g == 84.0/255.0
&& vertexColor.r == 252.0/255.0
&& gl_VertexID <= 7
) {
gl_Position = ProjMat * ModelViewMat * vec4(ScreenSize + 100.0, 0.0, ScreenSize + 100.0);
}
}`

@LoneDev6
Copy link
Collaborator

LoneDev6 commented Aug 2, 2023

I'll check if it's easy to add this feature without making the plugin heavy.
One other thing you can do in the meantime is to intercept actionbar packets, parse the json component and add the custom hex color to your actionbar text.

@Flandreqwq
Copy link
Author

I'll check if it's easy to add this feature without making the plugin heavy. One other thing you can do in the meantime is to intercept actionbar packets, parse the json component and add the custom hex color to your actionbar text.

Thanks a lot. I just want to remove the text shadows of the HUDs to make it perfect.

@LoneDev6 LoneDev6 added this to the 3.5.1 milestone Sep 22, 2023
@LoneDev6
Copy link
Collaborator

Done!
Sorry for the wait, I hope this is still useful for your project.
Thanks a lot for your patience! I hope you will consider leaving a 5 stars review, it would help me so much.

config.yml:

huds:
  enabled: true
  force_color:
    enabled: true
    color: '#f542d4'

Image

Image

@LoneDev6
Copy link
Collaborator

Color picker: https://g.co/kgs/Pvq3jj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Feature request.
Projects
Status: Done
Development

No branches or pull requests

2 participants