[1.7] Give your server a distinct visual style with custom shaders, no client mod needed!

Discussion in 'Resources' started by jtjj222, Nov 10, 2013.

Thread Status:
Not open for further replies.
  1. @jtjj222 Could you make a Java tutorial?
     
  2. Offline

    totokaka

    there is rally no need for another Java tutorial, just Google for one.

    Also, jtjj222, any update on a new tutorial?
     
  3. Offline

    jtjj222

    totokaka School has been keeping me busy, and on the side I've been learning haskell. What would you want in the second tutorial?
     
  4. Offline

    joehot2000

    How would i do this for entities only?
    I would like to give entities motion blur, but not blocks.
     
  5. Offline

    jtjj222

    joehot2000 Unfortunately, the Minecraft renderer isn't sophisticated enough to allow shaders to do that. Cross your fingers for that capability in the next update :p
     
  6. Offline

    totokaka

    I really don't know. To be honest I haven't even tested this tutorial. I just think it's interesting reading =)
     
  7. Offline

    anselwithmac

    Hey man! Please please release the motion blur you created, and teach us how to install this. I wanted motion blur for a long time, and I don't quite understand how to code this, I only know how to code javascript. Please make a post on motion blur, so I can copy and paste you data. If you need some motivation, Ill be happy to make a video about it, and release it with full credit to you. This motion blur stuff will get big fast!

    So how about it? Motion blur for the people? Ill make the Tut video, if you teach me how to do this! Happy new years ;) I am exited
     
  8. Offline

    jtjj222

    anselwithmac
    It is actually a little sickening to have on all the time. A client mod would need to be developed to automatically enable/disable it when you begin/end sprinting or falling.

    Here is the resource pack. It uses render targets (check in the post json file for the effect) to give the shader a sampler for the previous frame, then combines the image. It could also have a blur step on the previous frame, but I omitted it for clarity in the code (seeing as I will be using it in a tutorial).
     

    Attached Files:

  9. Offline

    anselwithmac


    thanks man! Ill go ahead and look at it, you can expect a rep once soon! :p Funny how you say "Mod" because like I said, I can code java :p cheers!

    EDIT: Awesome! I gave it a look, its soooo easy to enable, I read the tut so I have a bit of an understanding. It look awesome, its Alllmost usable at all times! is there a way to turn it down even more?

    Why I ask is... I come from a community called mcpvp.com they are super heavy inphrphics design and quality of play. I also have access and regularly speak with the head adminds of these GIANT servers. I wouldn't call my self a big deal, but I want to make YOU a big deal with your rare shader talent!! Cant wait to see where you go!

    All it needs a a little faster decay, and its set :)
     
  10. Offline

    Phasesaber

    This is amazing!
    I already am making my own! :D

    Code:java
    1. #version 120
    2.  
    3. uniform sampler2D DiffuseSampler;
    4.  
    5. varying vec2 texCoord;
    6.  
    7. void main() {
    8. vec4 CurrTexel = texture2D(DiffuseSampler, texCoord);
    9.  
    10. //Saturated Cool Thing:
    11. // CurrTexel.x = (CurrTexel.x * 0.3588) + (CurrTexel.y * 0.7044) + (CurrTexel.z * 0.1368);
    12. // CurrTexel.y = (CurrTexel.x * 0.2990) + (CurrTexel.y * 0.5870) + (CurrTexel.z * 0.1140);
    13. // CurrTexel.z = (CurrTexel.x * 0.2392) + (CurrTexel.y * 0.4696) + (CurrTexel.z * 0.0912);
    14.  
    15.  
    16. CurrTexel.x = (CurrTexel.x * 0.0001) + (CurrTexel.y * 0.0001) + (CurrTexel.z * 0.5001);
    17. CurrTexel.y = (CurrTexel.x * 1.0001) + (CurrTexel.y * 1.0001) + (CurrTexel.z * 0.5001);
    18. CurrTexel.z = (CurrTexel.x * 0.0001) + (CurrTexel.y * 0.0001) + (CurrTexel.z * 0.5001);
    19.  
    20. CurrTexel*=vec4(1.2,1.1,1,1);
    21.  
    22. gl_FragColor = CurrTexel;
    23. }
     
  11. Offline

    DogeDev

    Well done :O
     
  12. Offline

    jtjj222

    Phasesaber Pics or it didn't happen :p
    I'm glad to see some of the awesome shaders coming along, and I hope this gives mojang more incentive to extend the shaders api.
     
  13. Offline

    Icyene

    Wonderful tutorial. Hopefully in the not-so-distant future we'll be able to write per-entity shaders.

    My small contribution to this thread, a bloom shader:

    Code:C
    1.  
    2. uniform sampler2D DiffuseSampler;
    3. varying vec2 texCoord;
    4.  
    5. void main() {
    6. float samples = 4;
    7.  
    8. vec4 fragment = vec4(0);
    9.  
    10. for (int x = -samples; x < samples; x++) {
    11. for (int y = -samples; y < samples; y++) {
    12. fragment += texture2D(DiffuseSampler, texCoord + vec2(x, y) * 0.004) * 0.15;
    13. }
    14. }
    15.  
    16. vec4 sample = texture2D(DiffuseSampler, texCoord);
    17.  
    18. float green = sample.g; // Green is most visible to the human eye
    19. float modifier = green * 0.01; // / 100
    20.  
    21. gl_FragColor = sum * sum * modifier + sample;
    22. }
    23.  


    One suggestion on your shaders:

    In your grayscale shader, you perform:
    Code:C
    1.  
    2. float brightness = (CurrTexel.x + CurrTexel.y + CurrTexel.z)/3.0;
    3. CurrTexel.r = brightness;
    4. CurrTexel.y = brightness;
    5. CurrTexel.z = brightness;
    6.  


    This can be optimized by using a swizzle mask on the ryz components (though I assume you meant the rgb variant there: yz doesn't make much sense in context) and setting them all at once:

    Code:C
    1.  
    2. float brightness = (CurrTexel.x + CurrTexel.y + CurrTexel.z) / 3.0;
    3. CurrTexel.xyz = vec3(brightness);
    4.  


    Additionally, through the use of the dot function the addition too can be optimized:

    Code:C
    1.  
    2. float brightness = dot(CurrTexel.xyz, vec3(1.0)) / 3.0;
    3.  


    Due to how often dot products are required in shaders they tend to be heavily optimized and faster than chained addition.

    And finally, if we were to be really picky we can substitute the expensive division with a multiplication.

    Code:C
    1.  
    2. float brightness = dot(CurrTexel.xyz, vec3(1.0)) * 0.33;
    3. CurrTexel.xyz = vec3(brightness);
    4.  


    Though small improvements, since the operations are done thousands of times per frame, they are worth the more obtuse code.
     
Thread Status:
Not open for further replies.

Share This Page