Pixelation/Glitch “Shader” Using Glass
I’ll start right off the bat saying…
This is VERY limited!
Depending on your device, this effect might not work at all!
If the effect does not work for you at high graphics quality, glass might completely lack refractions for you: Glass lacks refraction on certain devices
Because this effect uses the Glass material, any non-opaque object will not be rendered behind it.
Additionally, this effect does not work on Graphics Quality levels lower than 8.
See Limitations for more information.
I discovered this effect by complete accident while messing around with glass, and decided to turn it into a “shader” effect and share it here!
Technical Explanation
Technical Explanation
This effect uses a ridiculously large glass sheet (81,920 x 81,920 studs by default) to clamp the precision of the refraction effect of glass.
To create the massive part, I sized a part to the maximum of 2048x2048 studs, then added a SpecialMesh
to it and used it to stretch it even further, and to have the refraction take effect, I added a Highlight
to it.
Limitations
- Because glass is glass (and we’re on Roblox), any non-opaque object behind the glass shader part will not be rendered. This includes, but is not limited to, transparent parts, decals on transparent parts, particles, and world-space gui objects.
- This effect does not work below Graphics Quality level 8.
- This isn’t a true pixelation shader, and it generates quite a few artifacts.
- Glare from light sources appears on the glass when using
Future
lighting technology orRealistic
lighting style (Unified Lighting), and is visible on all lighting technologies from global illumination.- Not much can be done about glare with Future or Realistic lighting without changing to
Voxel
/ShadowMap
orSoft
lighting style. But you can remove the glare from global illumination by settingLighting.Brightness
to0
at the cost of your entire game being dark.
- Not much can be done about glare with Future or Realistic lighting without changing to
Quick Start Guide
To start, get the latest release from my GitHub repository.
Download and Insert the
.rbxm
file into your desired location.
Initializing and enabling the effectlocal pixelationShader = require(PATH.TO.SHADER_MODULE) pixelationShader.SetEnabled(true)
Changing the strength of the effectpixelationShader.SetStrength(50, 50)
Causing a distortion effectpixelationShader.SetTransparency(2)
API Reference
API Reference
The module is fully typed with auto-completion available, but an API reference can still be handy!
Properties
Active: boolean
Read Only
Indicates whether the shader is currently enabled.
StrengthX: number
Read Only
Indicates the current X pixelation strength.
StrengthY: number
Read Only
Indicates the current Y pixelation strength.
Offset: Vector3
Read Only
Indicates the current glass shader part offset relative to the camera.
Transparency: number
Read Only
Indicates the current glass shader part transparency.
Methods
SetEnabled (enabled: boolean?
): ()
Sets whether the shader effect is enabled or disabled.
SetStrength (strengthX: number?
, strengthY: number?
): ()
Sets the strength of the pixelation effect.
Default Value: 40, 40
SetOffset (offset: Vector3?
): ()
Sets the offset of the glass pixel overlay part relative to the camera.
NOTE: Changing the offset may result in undesirable effects such as ‘pixel shivering’ if not tuned carefully.
Default Value: Vector3 [0.3, 0.3, -0.101]
SetTransparency (transparency: number?
): ()
Sets the Transparency of the glass pixel overlay part.
Values above 1 result produce distortion that may be useful for a ‘nausea’ effect.
Default Value: 1
Although this is quite limited due to the inherent limitations of glass, I’m sharing this here in case anyone can find a use for it.
(my first ever community resource i hope i didnt mess up any formatting)