How can I create a shader?

So recently I’ve seen some creations people made, which were custom shaders, which completely changed how the game looked! Heres an example I found:

As youcan see they completely changed how the lighting looks, and I was wondering how I can achieve something like this, as it has fascinated me, and I love making random stuff so yeah!

Thanks!
~ Frodev

1 Like

I think it’s mostly ColorCorrection’s contrast combined with highlights.

No contrast:


Contrast 2:

3 Likes

Here’s the documentation for highlights that @thedauser mentions.

There is actually a script for that type of shader, are you talking about colour banding? I have used it before and it’s so cool, I think you can find the model on the dev forum or I linked the model below.

This uses a hacky method to simulate ‘cel shading’ (not true cel shading)
There are two ways to do it, and I’ve tried both:

Method 1

  1. Set the FogColor in Lighting to an extremely high value beyond usual limits. I recommend either Color3 (350 000, 350 000, 350 000) or Color3 (400 000, 400 000, 400 000) depending on how strong you want the effect.

How this works (not confirmed, it’s just a theory)

  • I imagine this works because when setting a lighting value so high, it infringes on the render engine’s limited colour depth and causes a floating point error (when numbers become so large, they run out of bits to accurately store the number.) - causing colours to render in ‘groups’ or ‘bands’. Unrelated example:

Notes

  • This only affects parts and meshparts, but not the Skybox, Particles and other effects. So use this if you wish to have creative control over what this effect affects.
  • BIG con: I found that this effect completely breaks on certain devices without a dedicated (Nvidia or AMD?) GPU, so mobile and some laptop devices will not work with this effect. (Tested devices: Samsung S23 & a laptop with its dedicated GPU disabled)
  • The screen for these non-supporting devices will turn completely black, so if you use this method then use a script to detect what device the player is using and set the FogColor back to 0,0,0 or whatever.
  • Con: You will not be able to use Atmosphere effects as those override the lighting’s fog setting.

Method 2

This one is more complicated, but allows for more creative effects and is more powerful.

  1. Using a script, position an invisible part with a SurfaceGui in front of the camera every render frame.
    • The SurfaceGui will have a grey Color3 (127, 127, 127) Frame with very slight transparency (e.g. 0.05)
  2. Add a ColorCorrection with extremely high Contrast and low Brightness into the Lighting.
    • Contrast: 80
    • Brightness: -1

How this works

  • What this does is equivalent to opening a picture in a photo editor such as Photoshop, decreasing the contrast largely and applying it until the picture is nearly entirely grey, then increasing the contrast largely until the colours return, but due to there being a limited amount of colours per channel (256), they return in ‘bands’ (hence colour banding) due to the limited accuracy at such low contrast level.

Notes

  • This method works with everything in the game world, including Skybox, Particles and SurfaceGuis.
  • This method frees up the Lighting’s Fog so that you can use Atmospheres and Clouds.
  • Con: There is a rendering error associated with this method where transparent parts and particle effects with their origin outside/behind the camera will fail to render properly and become extremely bright. Weigh up if this option is worth it for you!
  • Con: This effect is hard to test while in Studio edit mode, as part of the effect will not be available until in play mode (the grey surfacegui in front of the camera) unless you create a plugin. Therefore, trying to design a map’s colour scheme & lighting will be awkward.

I recommend the second option due to its full coverage of effects, ability to have more detailed post-processing using SurfaceGui ImageLabels and allows you to use Atmospheres.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.