How can i make colorcorrection in specific areas?

Im making a game, with snowy and sunny areas. In the snowy areas there is colorcorrection that should make it look colder. In the sunny areas no colorcorrection but i need help with that.

I only want in a specific area (soon several areas) colorcorrection enabled but the outside of the area disabled

I dont know how to script it.

I have looked up several times i didnt find anything. I tried having one brick in that area that turns correction on and several outside the area to disable it, but soon i need to add several of those areas with colorcorrection enabled, so it would be too much because i scripted the touch script in startergui.

4 Likes

Hint


You will need:

  • LocalScript
  • Method of detecting the player’s location or area

The script will change the properties of it once you enter the areas and so on. If you decide to use a loop, use an appropriate rate of the loop.

Why LocalScript?
You don’t want all players to see the same, so you want everyone to have different visuals based on location.

6 Likes

Use a LocalScript to detect the location of a player and then change the lighting in either the Lighting service or the CurrentCamera.

To detect the player’s location you could either use a loop to continuously check their position, or you could have CanCollide = false parts which change the lighting when touched.

For changing the ColourCorrectionEffect you could either have hardcoded properties in scripts (not reccomended) or have pre-made ColourCorrectionEffects in ReplicatedStorage, and simply :Clone() these to or copy their properties over to the player’s client. The advantage of this is that it’s easier to test and change effects in updates to your game.

EDIT
@REALTimothy0812 proposed an interesting solution of raycasting downwards which would work brilliantly if you were using clearly defined biomes as you wouldn’t have to hardcode Region3s, however @colbert2677 makes the point that

which might not be relevant to your game, but the idea behind it could be.

Using Region3s to define areas is (I think) computationally the cheapest, however you would have to hard-code regions which is definitely not a scalable idea and would make updates an absolute nightmare if your game isn’t on a map rotation

So, you want to store your ‘Snowy’ colorCorrection somewhere that the client can get it.

To check if the character is in the snowy area, you could do the following:

  • Raycast downwards and see if the material is snow or the part is name something special (Name snowy parts snow?)
  • Use region3 to determine if the player is in the area

Once you determine when the character is in that snowy area, clone the colorCorrection into the player’s Camera or lighting. When they are not in the snowy area, if there is a colorCorrection destroy it.

1 Like

HINT
Use Region3 to detect what biome you are in and make a LocalScript that adds the color correction, blur, etc.

1 Like

I wouldn’t downcast based on material. There can be snow in regions which aren’t the “snowy area”, which then you could get a snowy effect in an unrelated area.

What you can do instead is set up an invisible “map” below the visible area and check if the character’s coordinates (not their Y or vertical) are within that area.

I meant to make parts in the snowy area special, like naming them snow or something. The other solution would be to make a part and check if the position of the player is in it. I meant check for a unique aspect of that region, as it might be easier than setting up a region. It all depends on the map.

I recommend building walls out of single parts outlining each biome. There will neutral zones in between the walls of one biome and the next but it is better than region3 or running a while loop.
The walls can be tall, invisible, non collidable, and use the Touched event in local scripts to detect what wall the player is touching and using that to change biomes.

I would recommend periodically updating a function which finds the two closest biomes to the player, and then lerp the colorcorrections between the two regions based on the distance between.

Regarding the loop, I suggest having a RunService.Heartbeat function running in a LocalScript and storing the last time the loop ran, and if the delta between the current time and the last time is greater than 0.2 seconds then it runs the function

isn’t that a bit costly on performance?

not at all, I do it in massive game files (300k+ studs) without seeing any sort of performance drops.

I’m a huge open world fanatic

1 Like

Oh ok. I think I might try that in one of my games, but that’s good for op