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

Feat: comp_visual_preset #288

Closed
wants to merge 23 commits into from

Conversation

TheEnderek0
Copy link

This is a comp entity that allows users to set presets for tone mapping, fog and color correction, all handled by one entity.

For tone mapping this entity supports setting: AutoExposureMax, AutoExposureMin, Bloom, BloomExponent
For fog: Primary color, Fog Start, Fog End, Fog Max Density, Lerping (for the values specified before)
For CC: Filename (which gets specified as an actual filename, evaluates to: materials/correction/<kv>.raw)

When Apply is fired to this entity, it fires respective IO to specified fog_controller, tonemapper and color_correction entity, as mentioned before it features lerping. It also automatically disables other comp_visual_presets making sure only one is active at a time.

Not specifying cc_filename, tonemapper or fog_controller just disables these features respectively.

Copy link
Owner

@TeamSpen210 TeamSpen210 left a comment

Choose a reason for hiding this comment

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

A couple suggestions with the code. For the fog controller, shouldn't it use the SetFogController input for !player?

transforms/comp_visual_preset.py Outdated Show resolved Hide resolved
if tonemappers:
tonemapper = tonemappers[0]

to_tm_outputs = [
Copy link
Owner

Choose a reason for hiding this comment

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

Using Output with an entity is just a shortcut to using the targetname. Instead of using search(), just use the name directly. Perhaps do the search to check they exist, but if it matches multiple that should be fine. Also not sure why you put them in a list first, just call add_out only if tonemappers are found? Lastly, Output's param parameter calls str() for you.

Copy link
Author

Choose a reason for hiding this comment

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

I guess you could do that, if the tonemapper doesn't exist it just wouldn't fire right?

Copy link
Owner

Choose a reason for hiding this comment

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

Well you could do something like:

for found in vmf.search(name):
    relay_ent.add_out(...)
    break

Just using the for loop iteration to confirm at least one exists.


# Fog Controller

LerpTo = "LerpTo" if vpreset["use_lerp", True] else ""
Copy link
Owner

Choose a reason for hiding this comment

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

You'll want to call srctools.conv_bool on this, so it properly treats "false", "0" etc as false.

vmf: VMF = ctx.vmf
for vpreset in vmf.by_class["comp_visual_preset"]:
vpreset.remove()
LOGGER.log(0, f"Parsing visual preset: {vpreset['targetname']}")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
LOGGER.log(0, f"Parsing visual preset: {vpreset['targetname']}")
LOGGER.debug("Parsing visual preset: {}", vpreset['targetname'])

@TheEnderek0
Copy link
Author

I'll update my code with your suggestions in a bit!

@TheEnderek0
Copy link
Author

Okay I've updated the code with your suggestions, but I don't think firing SetFogController to !player is necessary?
The entity assumes there will be one fog controller active at a time, and it has the master flag checked on.

@vrad-exe
Copy link
Collaborator

vrad-exe commented Jan 9, 2025

Keep in mind !player is only the first player, for MP you have to either do player to target everyone or !activator to target only the player who triggered the input.

Not sure I really see the point of this entity though, if you need to point it at a tonemapper/fog controller entity anyway? Why not just configure the fog controller directly in its own settings and activate that + the tonemapper inputs with a comp_relay?

@TheEnderek0
Copy link
Author

You cannot lerp between fogs with two fog controllers, besides this entity is supposed to be a wrapper around these 3 entities. If you dont find it useful its your case, I found it extremely useful to have.

@TheEnderek0
Copy link
Author

TheEnderek0 commented Jan 15, 2025

Whoops, didn't mean to do that, guess I have to make a clean PR now,
honestly not even sure how these commits got in?
I haven't PR-ed onto dev

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.

4 participants