Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I also have a bug...

A topic by BlindseekersOath created Jul 30, 2023 Views: 100 Replies: 16
Viewing posts 1 to 7
Submitted

So, I tried to change the color and intensity of a Unity URP Vignette, but they disable every time I do (this is Octalian). I looked through every script, and nothing was modifying it. Could someone please help me?

Submitted

Hi depending on which version you are working on, my version on Day 4 Implemented a “Heart Beat” system for the post processing, it blends between two profiles on a timer, check both of those profiles or the script controlling them!

Submitted

No, there is no script modifying it.

Submitted

which day 5 version is it?

Submitted

Octalien by Fomni (itch.io)

Submitted

that one has my post processing blending code, it’s in https://github.com/Octr/BLACKTHORN-DAY4/blob/main/Assets/_Game/Scripts/PPManager.cs

Submitted

Here is the code: 

float depthMultiplier = -((pos1.position.y + pos2.position.y) / (pos1.position.y + transform.position.y));

            vignette.color = new ColorParameter(new Color(vignetteColorTop.r * 1-depthMultiplier, vignetteColorTop.g * 1-depthMultiplier , vignetteColorTop.b*1-depthMultiplier));

            vignette.intensity = new ClampedFloatParameter(depthMultiplier, 0, 1);

Submitted (3 edits)

The code you provided has an issue in the second line where you calculate the Color for the vignette.color. The multiplication operation is incorrect due to the missing parentheses around 1 - depthMultiplier. Here’s the corrected version of the code:


float depthMultiplier = -((pos1.position.y + pos2.position.y) / (pos1.position.y + transform.position.y));

vignette.color = new ColorParameter(new Color(vignetteColorTop.r * (1 - depthMultiplier), vignetteColorTop.g * (1 - depthMultiplier), vignetteColorTop.b * (1 - depthMultiplier)));

vignette.intensity = new ClampedFloatParameter(depthMultiplier, 0, 1);


Explanation:

The code calculates the depthMultiplier based on the vertical positions of pos1, pos2, and the current transform (transform.position.y).

It then sets the vignette.color based on the vignetteColorTop with each RGB component multiplied by (1 - depthMultiplier). This effectively darkens the color based on the depthMultiplier value.

Finally, it sets the vignette.intensity to the depthMultiplier, clamped between 0 and 1.

With the parentheses added, the code should work as intended, applying the correct vignette effect based on the depthMultiplier value.

Submitted

I actually saw that there was a missing parenthesis, but didn't think it would do anything. Thank you so much!

Submitted

That doesn't count as comunication, right? If so, please let this pass--I have nowhere else to go!

Submitted

Unfortunetally, that didn't work. What happens is, the little check-mark on the intensity and color of the vignette are unticked, and kept unticked every frame, so I can't enable them. This only happens in-game, and never occurs unless I actually modify one of these values.

Submitted

Submitted

make sure you update both profiles

the game swaps between Normal and Black And White profiles I will check your code again.

Submitted

Okay.

Submitted

Make sure the vignette variable is referencing the correct Vignette component and it’s enabled in the Inspector.

Check that the vignetteColorTop values are within the [0, 1] range for all RGB components.

Verify that the post-processing stack or package is correctly set up in the project, including the Post-Processing Volume, profile, and layer.

Check if there are any error messages in the Unity Console that might give clues about what’s going wrong.

Test with default values for vignetteColorTop and without the vignette.intensity line to isolate potential issues.

Ensure that the depthMultiplier value is calculated correctly and has meaningful values based on the scene setup.

If you still can’t find the issue after rechecking the above points, it might be helpful to provide more context or share additional relevant parts of the code or the Unity project. This way, it would be easier to identify any potential issues that are not apparent in the code snippet alone.

Submitted

Okay, I'll go do those things. Thanks for the help! Without you, I don't know where I would be right now!

Submitted

Well, none of that worked. I have no idea how to fix this. Maybe I'll come back to this one problem later. For now, I guess I should work on the story. Thanks for all of your help!