Video source: https://youtu.be/YWMVWSMluNg
Make sure you are using the most up to date version of Fabric and the correct version of Forge with OptiFine. If using Fabric make sure you have Fabric API installed as well.
Get OptiFabric Mod from Here for 1.18.2
Make sure you put the correct version of OptiFine into the mods folder alongside OptiFabric otherwise it will not work. Watch This video on more information about installing OptiFabric on 1.18.2
For Forge you can just drop the OptiFine jar file into the mods folder. You will need to use the correct version of Forge to get everythning working.
Get This version of Forge (40.0.24) as tested in the video
Now you can test both using the FPS Winter Stress Test Map. Grab the map from Here
Looking for Shaders? Try out Kappa Shaders from Here