Skip to content

Add multiple post-shader support#6817

Open
metalgearsloth wants to merge 2 commits into
space-wizards:masterfrom
metalgearsloth:2026-07-18-multiple-post
Open

Add multiple post-shader support#6817
metalgearsloth wants to merge 2 commits into
space-wizards:masterfrom
metalgearsloth:2026-07-18-multiple-post

Conversation

@metalgearsloth

@metalgearsloth metalgearsloth commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

This should also fix the performance issue of cycling the render target constantly somewhat.

I also fixed post-shaders stacking their alpha so any transparent entities having it multiplied every time. The most obvious of this on content is ghost outlines messing with their transparency.

So the main issue internally is post-shaders stepping on each other's toes as they get rendered. To get around this we just use an intermediate that gets rendered into and swap between them.

Originally I had the 1 postrendertarget texture and drew a cutout of that but a bunch of content shaders assume they have exact bounds RN so changing that is more of a breaking change.

This should also stop the postshader churn where it recycles it every frame.

This should also fix the performance issue of cycling the render target constantly somewhat.

So the main issue internally is post-shaders stepping on each other's toes as they get rendered. To get around this we just use an intermediate that gets rendered into.
It's definitely not intended that entities like ghosts get their transparency multiplied for every post-shader so this fixes it.

Separate PR as this will be more destructive on content and requires shader code inspection.
Comment on lines +409 to +411
_entityManager.EventBus.RaiseLocalEvent(entry.Uid,
new BeforePostShaderRenderEvent(entry.Sprite, viewport),
false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this raise specific even for every post shader, passing their id, so that content can actually modify specific shader paramters based on it?
See #6719

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or content can just... Access shaders form sprite comp? I guess its fine then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do that.

/// <summary>
/// A post-shader currently applied to this sprite.
/// </summary>
public sealed class PostShaderEntry

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to make it yamlable?

@deltanedas

Copy link
Copy Markdown
Contributor

please make this an api method like RenderSprite is or entity views in UI etc have no way to do post shaders without literally copy pasting everything from engine

@metalgearsloth

Copy link
Copy Markdown
Contributor Author

please make this an api method like RenderSprite is or entity views in UI etc have no way to do post shaders without literally copy pasting everything from engine

example!!!

@deltanedas

Copy link
Copy Markdown
Contributor

evil thing raidercode does for thermal vision "overlay" of shittiest hack known to man where it replaces the shader for every layer of a sprite (completely breaks dwarves btw) then calls RenderEntity and resets it
in an overlay...

@deltanedas

Copy link
Copy Markdown
Contributor

see also this ai slop that will get broken by literally any layer with a shader because UseShader gets overriden in RenderSprite

https://github.com/Goob-Station/Goob-Station/pull/6920/files#diff-c7fba322886990b65ca48e513c299789b4db1d57fb09d4248701ef7a92c2ebb7

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.

3 participants