TechSpot

Having problems with Minecraft GLSL Shaders on a high-end PC!

By Paradoxianism
Dec 16, 2011
Post New Reply
  1. Goodday,

    I'm sure you've heard of Minecraft. I recently started using some GLSL Shaders, and absolutely love them! Now.. it does bring one problem forward though, and I find it quite weird.
    I'm using these shaders (Can't post links due to low post count yet, search on google), [V1.0.0] GLSL SHADERS (DOF, BUMP MAPPING, WAVING WHEAT AND MORE!)

    So that's Depth of Field, Bloom, Motion Blur, and something called Crossprocess.
    This is the script in there, not sure if it is useful to you.
    Code:
    // More realistic depth-of-field by Azraeil.
        // Bloom shader by CosmicSpore 
        #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
    Problem
    Now to the problem, When I put them on, I feel somekind of a delay, and lag. With an FPS of 40, when I turn DoF and Crossprocess off, I have the same FPS, but with less delay. (I've seen the game run at 300-600 FPS with GLSL Shaders off (This was by putting the Optifine options rather low though, but still far Render distance etc.), that's why I find it so weird.) The optifine I'm using, is the one that let's you use more than one core.

    I'm pretty convinced that it isn't my pc. I feel like that chance is pretty damn low:
    - Intel i7 2600K running @4.2 GHz. --> Watercooled.
    - Radeon HD6990
    - Gigabyte G1 Sniper2 Motherboard
    - Corsair Vengeance 16GB RAM
    - OCZ Vertex 3 MAX IOPS 240GB
    - Silverstone Strider 1500 Watt
    - Windows 7 Ultimate 64-bit
    --> And the resolution I'm playing at is 2560x1440 (But I'm not sure wheter Minecraft changes in resolution?)

    Now I'm just wondering wheter this is normal or not, because I have no idea, how intensive those settings would be. And if my pc SHOULD be running it smoother, please tell me how.

    Thanks in advance!
    - Paradoxianism
     
  2. Paradoxianism

    Paradoxianism TS Member Topic Starter

    Alright, since I am unable to edit my previous post, I shall reply.
    After 4'ish months I still haven't gotten a reply, to my annoyance, so that's why I'm bumping it.

    The same problem, still, only the mod has been updates: Sonic Ether's Unbelievable Shaders v1.2.5 v08 [compatible with Minecraft 1.2.5]http://www.minecraftforum.net/topic...le-shaders-glsl-shaders-dynamic-shadows-more/If anyone knows a possible solution, tell me.

    Kind regards,
    - Paradoxianism
     
  3. Paradoxianism

    Paradoxianism TS Member Topic Starter

  4. tj11112129

    tj11112129 TS Rookie

    On my machine, I am getting around 40-70 FPS average, and I notice a bit of a delay as well, which I can't seem to make go away. I noticed around rainforest biomes or areas with a lot of stuff it tends to slow down, but in areas where there's not a lot going on it can pass 100fps.

    Running Minecraft with 4gb of allocated memory.

    Decreasing the render distance seems to help a little too.

    Just very recently got into GLSL textures myself, and I'm not too knowledgeable in programming (I'm surprised I can get half this stuff to work sometimes)

    I have a 3770k @4.3ghz with a gtx 670 and 8gb of memory.

    Don't know if this helps you or answers anything, but I just thought I would try ;)
     
  5. Ranger12

    Ranger12 TS Guru Posts: 641   +118

    I also use the glsl shaders from time to time. I also run the multicore version of optifine. I don't often run the GLSL shader mod because it is very buggy. I can't fix you're problem but I can say that the GLSL shaders is a mod and it is inherently buggy and perhaps inefficient as far as system resources go. I havent talked to anyone who said that the glsl mod ran perfectly smooth for them even when they were running high end hardware (core i7, gtx 680). I have a feeling that it will always be a bit buggy no matter the hardware.
     


Add New Comment

TechSpot Members
Login or sign up for free,
it takes about 30 seconds.
You may also...


Get complete access to the TechSpot community. Join thousands of technology enthusiasts that contribute and share knowledge in our forum. Get a private inbox, upload your own photo gallery and more.