Nahte27
FTW Member
- Total Posts : 1582
- Reward points : 0
- Joined: 2009/03/20 14:13:46
- Location: Oklahoma
- Status: offline
- Ribbons : 9
GLSL shaders have been released for Minecraft 1.0! What does that mean? It means modders can now tap into OpenGL and add features like Depth of Field, High Quality Bloom, Color Correction, Motion Blur, and FXAA. And I'm going to show you how to add all 5 enhancements! First, screenshots! FYI, when taking a screenshot with these features, FXAA, Motion Blur and the Improved Lighting don't show up. So the final result should look more dramatic than these, and without the jaggies. Also, my TexturePack is called DefaultEx and you can get a 1.0 compatible version here: LINK Alright, so here is how to get these effects. Also, not every part is necessary. If you just want FXAA, do Part 1. If you just want the basic effects, do Part 2. If you want the whole enchilada, do parts 1-4. Part 5 is just how to turn effects on and off and tweak the motion blur level. Part 1, FXAA (Nvidia Cards with new-ish drivers only) - Download Nvidia Inspector from HERE
- Add javaw.exe to the Nvidia Control Panel profiles. It's default location is "C:/Program Files(x86)/java/jre6(could be slightly different)/bin/javaw"
- Open Nvidia Inspector
- Click Dirver Profile Settings (little tool button to the right)
- Find and select javaw.exe in the drop down menu at the top.
- Scroll down, and second from the bottom there is an option labeled "Toggle FXAA on or off." Click the drop down menu and select "0x00000001.
- Click "Apply Changes in the top right corner
- Exit Nvidia Inspector and run Minecraft!
- Run Minecraft and test! There should be no more jagged edges. Also,depending on your driver version, there may be a small green square in the top left corner. That's fine, as it just means FXAA is working. If you have Nvidia's latest drivers, the square may not be there, but that doesn't mean FXAA isn't working.
Part 2, install GLSL - Backup your Minecraft files! The default location is "C:/Users/[USERNAME]/AppData/Roaming/Minecraft" If you have other mods installed, there is a chance this could mess them up. However, it shouldn't mess with common mods such as high-res textures, or better grass.
- Go here: LINK
- Read the directions, and download and run the patcher. It'll modify your Minecraft file to allow custom graphics scripts. It'll also install a default script that enables Depth of Field, and Bloom only (I think, don't really remember).
- That's it! Test Minecraft and see if you notice the new effects.
Part 3, Installing custom scripts - If you don't have 7-zip, download and install it (other archive manager may work)
- Navigate to your Minecraft folder and open the bin folder. There should be a Jar file just called "minecraft" Right click it, and use 7-zip to open it. When you patched it with the GLSL patcher, it created a folder here called "shaders." This folder is where all the scripts go. There are lots of places online where you can download custom scripts for different effects. Just make sure they are Minecraft 1.0 compatible. When you downloaded the installer for GLSL shaders, it came with a few extra scripts to mess with.
Part 4, Installing my custom script for all 4 effects - In the GLSL installer, there should be an alternative shaders folder. Under that, there's one called "Motion Sickness." This is a test version of Motion Blur. Install those scripts in the Minecraft script folder from part 3.
- There's one file in the shaders folder called "final.fsh" Open it with notepad (an alternative such as Notepad++ is preferred).
- Delete ALL the text, and paste this code:
// More realistic depth-of-field by Azraeil. // Bloom shader by CosmicSpore (http://myheroics.wordpress.com/2008/09/04/glsl-bloom-shader/) #version 120 //To disable an effect place 2 slashes before it's line #define DOF #define BLOOM #define CROSSPROCESS // If you want a higher quality blur for DOF, remove the forward slashes from the following line: #define USE_HIGH_QUALITY_BLUR uniform sampler2D gcolor; uniform sampler2D gdepth; uniform sampler2D composite; uniform float aspectRatio; uniform float near; uniform float far; varying vec4 texcoord; #ifdef DOF // HYPERFOCAL = (Focal Distance ^ 2)/(Circle of Confusion * F Stop) + Focal Distance const float HYPERFOCAL = 3.132; const float PICONSTANT = 3.14159; float getDepth(vec2 coord); vec4 getBlurredColor(); vec4 getSample(vec2 coord, vec2 aspectCorrection); vec4 getSampleWithBoundsCheck(vec2 offset); #endif #ifdef BLOOM const float BLOOM_AMOUNT = 4; #endif float samples = 0.0; vec2 space; void main() { vec4 color = texture2D(composite, texcoord.st); #ifdef DOF float depth = getDepth(texcoord.st); float cursorDepth = getDepth(vec2(0.5, 0.5)); // foreground blur = 1/2 background blur. Blur should follow exponential pattern until cursor = hyperfocal -- Cursor before hyperfocal // Blur should go from 0 to 1/2 hyperfocal then clear to infinity -- Cursor @ hyperfocal. // hyperfocal to inifity is clear though dof extends from 1/2 hyper to hyper -- Cursor beyond hyperfocal float mixAmount = 0.0; if (depth < cursorDepth) { mixAmount = clamp(2.0 * ((clamp(cursorDepth, 0.0, HYPERFOCAL) - depth) / (clamp(cursorDepth, 0.0, HYPERFOCAL))), 0.0, 1.0); } else if (cursorDepth == HYPERFOCAL) { mixAmount = 0.0; } else { mixAmount = 1.0 - clamp((((cursorDepth * HYPERFOCAL) / (HYPERFOCAL - cursorDepth)) - (depth - cursorDepth)) / ((cursorDepth * HYPERFOCAL) / (HYPERFOCAL - cursorDepth)), 0.0, 1.0); } if (mixAmount != 0.0) { color = mix(color, getBlurredColor(), mixAmount); } #endif #ifdef BLOOM int j; int i; vec4 sum = vec4(0); float count = 0; for( i= -4 ;i < 4; i++) { for (j = -3; j < 3; j++) { vec2 coord = texcoord.st + vec2(j,i) * 0.004; if(coord.x > 0 && coord.x < 1 && coord.y > 0 && coord.y < 1){ sum += texture2D(composite, coord) * BLOOM_AMOUNT; count += 1; } } } sum = sum / vec4(count); if (color.r < 0.3) { color += sum*sum*0.012; } else { if (color.r < 0.5) { color += sum*sum*0.009; } else { color += sum*sum*0.0075; } } #endif #ifdef CROSSPROCESS color.r = color.r*1.3+0.01; color.g = color.g*1.2; color.b = color.b*0.75+0.10; //SEPIA //color.r = (color.r + color.b + color.g)/3; //color.g = (color.r + color.b + color.g)/3; //color.b = (color.r + color.b + color.g)/3; #endif gl_FragColor = texture2D(composite, texcoord.st); gl_FragColor = color; } #ifdef DOF float getDepth(vec2 coord) { return 2.0 * near * far / (far + near - (2.0 * texture2D(gdepth, coord).x - 1.0) * (far - near)); } vec4 getBlurredColor() { vec4 blurredColor = vec4(0.0); float depth = getDepth(texcoord.xy); vec2 aspectCorrection = vec2(1.0, aspectRatio) * 0.005; vec2 ac0_4 = 0.4 * aspectCorrection; // 0.4 #ifdef USE_HIGH_QUALITY_BLUR vec2 ac0_4x0_4 = 0.4 * ac0_4; // 0.16 vec2 ac0_4x0_7 = 0.7 * ac0_4; // 0.28 #endif vec2 ac0_29 = 0.29 * aspectCorrection; // 0.29 #ifdef USE_HIGH_QUALITY_BLUR vec2 ac0_29x0_7 = 0.7 * ac0_29; // 0.203 vec2 ac0_29x0_4 = 0.4 * ac0_29; // 0.116 #endif vec2 ac0_15 = 0.15 * aspectCorrection; // 0.15 vec2 ac0_37 = 0.37 * aspectCorrection; // 0.37 #ifdef USE_HIGH_QUALITY_BLUR vec2 ac0_15x0_9 = 0.9 * ac0_15; // 0.135 vec2 ac0_37x0_9 = 0.37 * ac0_37; // 0.1369 #endif vec2 lowSpace = texcoord.st; vec2 highSpace = 1.0 - lowSpace; space = vec2(min(lowSpace.s, highSpace.s), min(lowSpace.t, highSpace.t)); if (space.s >= ac0_4.s && space.t >= ac0_4.t) { blurredColor += texture2D(composite, texcoord.st + vec2(0.0, ac0_4.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_4.s, 0.0)); blurredColor += texture2D(composite, texcoord.st + vec2(0.0, -ac0_4.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_4.s, 0.0)); #ifdef USE_HIGH_QUALITY_BLUR blurredColor += texture2D(composite, texcoord.st + vec2(ac0_4x0_7.s, 0.0)); blurredColor += texture2D(composite, texcoord.st + vec2(0.0, -ac0_4x0_7.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_4x0_7.s, 0.0)); blurredColor += texture2D(composite, texcoord.st + vec2(0.0, ac0_4x0_7.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_4x0_4.s, 0.0)); blurredColor += texture2D(composite, texcoord.st + vec2(0.0, -ac0_4x0_4.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_4x0_4.s, 0.0)); blurredColor += texture2D(composite, texcoord.st + vec2(0.0, ac0_4x0_4.t)); #endif blurredColor += texture2D(composite, texcoord.st + vec2(ac0_29.s, -ac0_29.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_29.s, ac0_29.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_29.s, ac0_29.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_29.s, -ac0_29.t)); #ifdef USE_HIGH_QUALITY_BLUR blurredColor += texture2D(composite, texcoord.st + vec2(ac0_29x0_7.s, ac0_29x0_7.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_29x0_7.s, -ac0_29x0_7.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_29x0_7.s, ac0_29x0_7.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_29x0_7.s, -ac0_29x0_7.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_29x0_4.s, ac0_29x0_4.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_29x0_4.s, -ac0_29x0_4.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_29x0_4.s, ac0_29x0_4.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_29x0_4.s, -ac0_29x0_4.t)); #endif blurredColor += texture2D(composite, texcoord.st + vec2(ac0_15.s, ac0_37.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_37.s, ac0_15.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_37.s, -ac0_15.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_15.s, -ac0_37.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_15.s, ac0_37.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_37.s, ac0_15.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_37.s, -ac0_15.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_15.s, -ac0_37.t)); #ifdef USE_HIGH_QUALITY_BLUR blurredColor += texture2D(composite, texcoord.st + vec2(ac0_15x0_9.s, ac0_37x0_9.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_37x0_9.s, ac0_15x0_9.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_37x0_9.s, -ac0_15x0_9.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_15x0_9.s, -ac0_37x0_9.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_15x0_9.s, ac0_37x0_9.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_37x0_9.s, ac0_15x0_9.t)); blurredColor += texture2D(composite, texcoord.st + vec2(-ac0_37x0_9.s, -ac0_15x0_9.t)); blurredColor += texture2D(composite, texcoord.st + vec2(ac0_15x0_9.s, -ac0_37x0_9.t)); #endif #ifdef USE_HIGH_QUALITY_BLUR blurredColor /= 41.0; #else blurredColor /= 16.0; #endif } else { blurredColor += getSampleWithBoundsCheck(vec2(0.0, ac0_4.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_4.s, 0.0)); blurredColor += getSampleWithBoundsCheck(vec2(0.0, -ac0_4.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_4.s, 0.0)); #ifdef USE_HIGH_QUALITY_BLUR blurredColor += getSampleWithBoundsCheck(vec2(ac0_4x0_7.s, 0.0)); blurredColor += getSampleWithBoundsCheck(vec2(0.0, -ac0_4x0_7.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_4x0_7.s, 0.0)); blurredColor += getSampleWithBoundsCheck(vec2(0.0, ac0_4x0_7.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_4x0_4.s, 0.0)); blurredColor += getSampleWithBoundsCheck(vec2(0.0, -ac0_4x0_4.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_4x0_4.s, 0.0)); blurredColor += getSampleWithBoundsCheck(vec2(0.0, ac0_4x0_4.t)); #endif blurredColor += getSampleWithBoundsCheck(vec2(ac0_29.s, -ac0_29.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_29.s, ac0_29.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_29.s, ac0_29.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_29.s, -ac0_29.t)); #ifdef USE_HIGH_QUALITY_BLUR blurredColor += getSampleWithBoundsCheck(vec2(ac0_29x0_7.s, ac0_29x0_7.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_29x0_7.s, -ac0_29x0_7.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_29x0_7.s, ac0_29x0_7.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_29x0_7.s, -ac0_29x0_7.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_29x0_4.s, ac0_29x0_4.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_29x0_4.s, -ac0_29x0_4.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_29x0_4.s, ac0_29x0_4.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_29x0_4.s, -ac0_29x0_4.t)); #endif blurredColor += getSampleWithBoundsCheck(vec2(ac0_15.s, ac0_37.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_37.s, ac0_15.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_37.s, -ac0_15.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_15.s, -ac0_37.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_15.s, ac0_37.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_37.s, ac0_15.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_37.s, -ac0_15.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_15.s, -ac0_37.t)); #ifdef USE_HIGH_QUALITY_BLUR blurredColor += getSampleWithBoundsCheck(vec2(ac0_15x0_9.s, ac0_37x0_9.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_37x0_9.s, ac0_15x0_9.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_37x0_9.s, -ac0_15x0_9.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_15x0_9.s, -ac0_37x0_9.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_15x0_9.s, ac0_37x0_9.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_37x0_9.s, ac0_15x0_9.t)); blurredColor += getSampleWithBoundsCheck(vec2(-ac0_37x0_9.s, -ac0_15x0_9.t)); blurredColor += getSampleWithBoundsCheck(vec2(ac0_15x0_9.s, -ac0_37x0_9.t)); #endif blurredColor /= samples; } return blurredColor; } vec4 getSampleWithBoundsCheck(vec2 offset) { vec2 coord = texcoord.st + offset; if (coord.s <= 1.0 && coord.s >= 0.0 && coord.t <= 1.0 && coord.t >= 0.0) { samples += 1.0; return texture2D(composite, coord); } else { return vec4(0.0); } } #endif
- Save (make sure it's still a .fsh) and close 7-zip
- Run Minecraft. You should notice all 4 features (DoF, Motion Blur, Bloom, Color Correction).
Part 5, Tweaking to your liking - To turn off Depth of Field, Bloom, or Color Correction, all you need to do is open the "final.fsh" from the last part and add 2 slashes in front of one of these lines
#define DOF #define BLOOM #define CROSSPROCESS - To add more motion blur, or to tone it down, you need to go to your shaders folder again, and open Composite.fsh. There will be a line in there somewhere, that looks like this:
vec2 velocity = (currentPosition - previousPosition).st * 0.05; That number at the end of the line (0.05) is how much motion blur there is. I set it in the middle, but it'll go anywhere between 0.01 (very little blur) and 0.1 (lots of blur). And that's it! Keep in mind that Minecraft is very picky, and something may not work for someone for seemingly no reason. It's still buggy, and if it just doesn't work for you, then you may have to wait until an update to the GLSL shaders.
|