SHARE
TWEET

Euphoria's Bug Fixes and Improvements for SEUS

euphoria4949 May 20th, 2014 (edited) 22,026 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         ### Euphoria's Bug Fixes and Improvements For Sonic Ethers Unbelievable Shaders (SEUS) ###
  2.  
  3. This guide is based on SEUS 10.1 Ultra DOF. But will work for most versions of SEUS. If you are using a different version, the line numbers will mostly likely be slightly different, but you can easily press "Ctrl F" then search to find the correct lines. Simples :)
  4.  
  5.     ### Link to me on the Minecraftforums: http://www.minecraftforum.net/members/euphoria4949 ###
  6.  
  7. This guide took me a long time to put together, testing and tweaking over and over and over... So please don't take credit for my work.
  8. If you used my guide and found it helpful, please share it so everyone can enjoy SEUS shaders.
  9.    
  10. Please read carefully, and always use the brilliant and Free "Notepad++" to edit any files for any mod or game. Standard Microsoft Notepad will make it difficult for you to navigate.
  11.  
  12. -----------------------------------------------------------------------------------------------------
  13.     ##### CRASHING / LITTLE BOXES IN THE BOTTOM LEFT CORNER OF THE SCREEN / ERROR MESSAGES / BLACK SCREEN / #####
  14. -----------------------------------------------------------------------------------------------------
  15.  
  16. LAPTOP AND NOTEBOOK USERS: (PC & MAC Guide below)
  17. -----------------------------------------------------------------------------------------------------
  18. Open your Nvidia or AMD Control Panel and set the "Preferred Graphics Processor" to Nvidia or AMD. (Not Auto or Intel)
  19. Do this "Globally", not just for Minecraft.exe.
  20. If you do not have either an Nvidia or AMD Control Panel then please read the guide below for: PC USERS.
  21.  
  22. -----------------------------------------------------------------------------------------------------  
  23. PC USERS: (MAC Guide below)
  24. -----------------------------------------------------------------------------------------------------
  25. The descriptions and instructions for this shader mod, that you were supposed to read "BEFORE" installing it, very clearly say:
  26. "You need a modern and very powerful Graphics Card to run a shader."
  27. "Intel HD Graphics are Not compatible with SEUS."
  28.  
  29. If you are "Not" using Intel HD and "Do" have a proper dedicated Nvidia or AMD graphics card but you still get the black screen, crashing or errors, then please skip the next paragraph.
  30.  
  31.     Intel HD Graphics are not designed for modern high-end games because they are "Not" a Graphics Card, they are an "iGPU". This means it's a small part of your Processor/CPU that just "Acts" like (Pretends) to be a Graphics Card.
  32. Intel HD is extremely weak and has many issues due to buggy drivers and Intel's refusal to conform with industry standards. Intel HD is designed to give you enough graphical power to watch a movie, YouTube video or play a basic game like Candy Crush or Farmville on Facebook, not for running extremely complex and ultra demanding graphical applications, like shaders.
  33. Shaders like SEUS need more graphical power to run them, than it takes to run big AAA games like, GTA5, Fallout 4 or The Witcher 3 on Ultra settings!
  34.  
  35. For people "Not" using Intel HD, one of the following is the cause of the issue:
  36. 1# - Your PC's graphics card is not powerful enough or is too old. The mods description clearly says you need a "Modern and very powerful graphics card"
  37. 2# - Your graphics card driver is out of date. Update it to the latest version from your manufactures website.
  38. 3# - The wrong or an out dated version of the GLSL Shader Core mod is installed.
  39. 4# - You have mod installed or a setting that is causing an incompatibility.
  40.  
  41. Feel free to post on the SEUS thread if you want more info about whether your graphics card (Nvidia or AMD/ATI) is compatible.
  42. There are some very basic and low-end Shaders available on Minecraft.net forum that might work with old or low powered cards and Intel HD.
  43.  
  44. -------------------------------------------------  
  45. MAC USERS:
  46. -----------------------------------------------------------------------------------------------------
  47. If you had read the mods description you would have seen that it clearly says: "The author of SEUS Shader-pack has no access to a Mac, so is unable to provide Mac support"
  48.  
  49. -----------------------------------------------------------------------------------------------------
  50.     ##### LINES IN THE CLOUDS/SKY FIX #####
  51. -----------------------------------------------------------------------------------------------------
  52.  
  53. Force Disable Anisotropic Filtering in your Nvidia or AMD Control Panel.
  54.  
  55. -----------------------------------------------------------------------------------------------------
  56.     ##### INVISIBLE RAIN AND SNOW FIX #####
  57. -----------------------------------------------------------------------------------------------------
  58.    
  59. Open: "gbuffers_weather.fsh",
  60. Line 13:
  61. Delete: "discard;"
  62.  
  63. -----------------------------------------------------------------------------------------------------
  64.     ##### RAINING INSIDE COVER/THROUGH BLOCKS FIX #####
  65. -----------------------------------------------------------------------------------------------------
  66.  
  67. Open: "gbuffers_weather.vsh",
  68. Delete everything on line 9
  69.  
  70. -----------------------------------------------------------------------------------------------------
  71.     ##### HOW TO ENABLE PUDDLES/WET GROUND AND SURFACES WHEN RAINING #####
  72. -----------------------------------------------------------------------------------------------------
  73.    
  74. Open: "gbuffers_terrain.fsh",
  75. Change line 333 to this:
  76. spec.g += max(0.0f, clamp((wet * 1.0f + 0.2f), 0.0f, 1.0f) - (1.0f - w) * 1.0f);
  77.  
  78. -----------------------------------------------------------------------------------------------------
  79.     ##### ENHANCED FOG WHEN RAINING #####
  80. -----------------------------------------------------------------------------------------------------
  81.    
  82. Open: "final.fsh"
  83. Line 621:
  84. Change "0.023f" to "0.066f" for best effect.
  85.  
  86. -----------------------------------------------------------------------------------------------------
  87.     ##### REDUCED SUN BRIGHTNESS (CORONA) #####
  88. -----------------------------------------------------------------------------------------------------
  89.  
  90. Open: "composite.fsh"
  91. Line 1059,
  92. Change the entry "7.0f" to a lower number to reduce the suns corona brightness. (5.5f - 6.0f Seems good)
  93.  
  94. -----------------------------------------------------------------------------------------------------
  95.     ##### LIGHTING TWEAKS (INCREASE/DECREASE BRIGHTNESS) #####
  96. -----------------------------------------------------------------------------------------------------  
  97.  
  98. Open: "composite.fsh",
  99. All Lighting parameters start at line "2225",
  100. To reduce the brightness of a source, reduce the corresponding value,
  101. To increase the brightness, increase the value.  
  102.  
  103. + final.sunlight            * 0.65f
  104. + final.skylight            * 0.05f    
  105. + final.nolight             * 0.0005f
  106. + final.bouncedSunlight     * 0.005f
  107. + final.scatteredSunlight   * 0.02f
  108. + final.scatteredUpLight    * 0.0015f
  109. + final.torchlight          * 5.0f  
  110. + final.glow.lava           * 8.6f
  111. + final.glow.glowstone      * 1.1f  
  112. + final.glow.fire           * 0.025f
  113. + final.glow.torch          * 1.15f
  114. + final.heldLight           * 0.05f
  115.  
  116. -----------------------------------------------------------------------------------------------------
  117.     ##### HOW TO ADD WAVING CARROTS, POTATOES & NETHER WART #####
  118. -----------------------------------------------------------------------------------------------------
  119.  
  120. Open: "gbuffers_terrain.vsh",
  121. Add the following to lines 50, 51 and 52. Press enter to make room if you have to:
  122. Line 50: #define WAVING_CARROTS
  123. Line 51: #define WAVING_NETHER_WART
  124. Line 52: #define WAVING_POTATOES
  125.  
  126. Now add the following to line 192. Again Press enter to make room if you have to:
  127. Line 192, add: || mc_Entity.x == 115.0f  //Nether Wart
  128.  
  129. Now add the following to line 209. Again Press enter to make room if you have to:
  130. Line 209, add:
  131.     //WAVING_CARROTS
  132.     if (mc_Entity.x == 141.0) {
  133.         materialIDs = max(materialIDs, 2.0f);
  134.         waveCoeff = 1.0f;
  135.     }
  136.  
  137.     //WAVING_POTATOES
  138.     if (mc_Entity.x == 142.0) {
  139.         materialIDs = max(materialIDs, 2.0f);
  140.         waveCoeff = 1.0f;
  141.     }
  142.  
  143. *** END OF CODE *** DO NOT COPY THIS ***
  144.  
  145. Now Open: "shadow.vsh"
  146. Add the following code to the "//Grass" section starting line 122:
  147. || mc_Entity.x == 141.0f //Carrots
  148. || mc_Entity.x == 115.0f //Nether Wart
  149. || mc_Entity.x == 142.0f //Potatoes
  150.  
  151. -----------------------------------------------------------------------------------------------------
  152.     ##### HOW TO ENABLE POM (PARALLAX OCCLUSION MAPPING - AKA 3D TEXTURES) #####
  153. -----------------------------------------------------------------------------------------------------
  154.    
  155. WARNING! POM can be buggy and require a lot of tweaking for some people, depending on your PC hardware, drivers plus MC version, texture pack and mods installed.
  156. If you are not good with coding or don't have a lot of time and patience to learn it, do "NOT" enable POM.
  157.  
  158. Open: "gbuffers_terrain.fsh",
  159. Line 24:
  160. Delete the // at the beginning of the line.
  161.  
  162. -----------------------------------------------------------------------------------------------------
  163.     ##### HOW TO ENABLE PARALLAX (3D) WATER AND INCREASE WAVE SIZE #####
  164. -----------------------------------------------------------------------------------------------------
  165.  
  166. WARNING! POM (3D) Water can be extremely taxing on GPU power, do "NOT" enable it unless you have a very modern and powerful graphics card. Recommended minimum Nvidia GTX 680/770 or AMD 7970/R9-290.
  167.      
  168. Open: "gbuffers_water.fsh",
  169. Line 293:
  170. Delete the // at the beginning of the line.
  171. Line 3: Increases the wave height, 0.30f or 0.35f for best effect.
  172.  
  173. -----------------------------------------------------------------------------------------------------
  174.     ##### INCREASE OR DECREASE THE AMOUNT OF MOTION BLUR #####
  175. -----------------------------------------------------------------------------------------------------
  176.    
  177. Open: "final.fsh"
  178. Line 309:
  179. To increase the amount of blur, change "0.12f;" to any number up to a maximum of "0.60f;".
  180.  
  181. -----------------------------------------------------------------------------------------------------
  182.     ##### HOW TO ENABLE 3D VOLUMETRIC CLOUDS #####
  183. -----------------------------------------------------------------------------------------------------
  184.    
  185. Open: "composite.fsh"
  186. Line 2256:
  187. Delete the "//" at the beginning of the line.
  188.  
  189. -----------------------------------------------------------------------------------------------------
  190.     ##### BETTER LOOKING AND OPTIMISED 3D VOLUMETRIC CLOUDS #####
  191. -----------------------------------------------------------------------------------------------------
  192.        
  193. Open: "composite.fsh"
  194. Copy and Paste the follow code over Lines 1422 to 1915: (YOU MUST PASTE "OVER" THE ORIGINAL CODE, "DON'T" JUST ADD IT TO THE ORIGINAL CODE!):
  195.    
  196. vec4 CloudColor(in vec4 worldPosition, in float sunglow, in vec3 worldLightVector)
  197. {
  198.  
  199.         float cloudHeight = 400.0f;
  200.         float cloudDepth  = 120.0f;
  201.         float cloudUpperHeight = cloudHeight + (cloudDepth / 2.0f);
  202.         float cloudLowerHeight = cloudHeight - (cloudDepth / 2.0f);
  203.  
  204.         if (worldPosition.y < cloudLowerHeight || worldPosition.y > cloudUpperHeight)
  205.                 return vec4(0.0f);
  206.         else
  207.         {
  208.  
  209.                 vec3 p = worldPosition.xyz / 150.0f;
  210.  
  211.                        
  212.  
  213.                 float t = frameTimeCounter * 1.0f;
  214.                           //t *= 0.001;
  215.                 p.x -= t * 0.01f;
  216.  
  217.                 // p += (Get3DNoise(p * 1.0f + vec3(0.0f, t * 0.01f, 0.0f)) * 2.0f - 1.0f) * 0.3f;
  218.  
  219.                 vec3 p1 = p * vec3(1.0f, 0.5f, 1.0f)  + vec3(0.0f, t * 0.01f, 0.0f);
  220.                 float noise  =  Get3DNoise(p * vec3(1.0f, 0.5f, 1.0f) + vec3(0.0f, t * 0.01f, 0.0f));   p *= 3.0f;      p.x -= t * 0.057f;      vec3 p2 = p;
  221.                           noise += (1.0f - abs(Get3DNoise(p) * 3.0f - 1.0f)) * 0.20f;                           p *= 3.0f;      p.xz -= t * 0.05f;      vec3 p3 = p;
  222.                           noise += (1.0f - abs(Get3DNoise(p) * 3.0f - 1.0f)) * 0.075f;                          p *= 3.0f;      p.xz -= t * 0.05f;
  223.                           noise += (1.0f - abs(Get3DNoise(p) * 3.0f - 1.0f)) * 0.05f;
  224.                           noise /= 1.2f;
  225.  
  226.  
  227.  
  228.                 const float lightOffset = 0.35f;
  229.  
  230.  
  231.                 float heightGradient = clamp(( - (cloudLowerHeight - worldPosition.y) / (cloudDepth * 1.0f)), 0.0f, 1.0f);
  232.                 float heightGradient2 = clamp(( - (cloudLowerHeight - (worldPosition.y + worldLightVector.y * lightOffset * 30.0f)) / (cloudDepth * 1.0f)), 0.0f, 1.0f);
  233.  
  234.                 float cloudAltitudeWeight = 1.0f - clamp(distance(worldPosition.y, cloudHeight) / (cloudDepth / 2.0f), 0.0f, 1.0f);
  235.                           cloudAltitudeWeight = pow(cloudAltitudeWeight, mix(0.2f, 0.6f, rainStrength));
  236.                           cloudAltitudeWeight *= 1.0f - heightGradient;
  237.  
  238.                 float cloudAltitudeWeight2 = 1.0f - clamp(distance(worldPosition.y + worldLightVector.y * lightOffset * 30.0f, cloudHeight) / (cloudDepth / 2.0f), 0.0f, 1.0f);
  239.                           cloudAltitudeWeight2 = pow(cloudAltitudeWeight2, mix(0.2f, 0.6f, rainStrength));
  240.                           cloudAltitudeWeight2 *= 1.0f - heightGradient2;
  241.  
  242.                 noise *= cloudAltitudeWeight;
  243.  
  244.                 //cloud edge
  245.                 float coverage = 0.8f;
  246.                           coverage = mix(coverage, 1.05f, rainStrength);
  247.                 float density = 0.65f;
  248.                 noise = clamp(noise - (1.0f - coverage), 0.0f, 1.0f - density) / (1.0f - density);
  249.                 //noise = GetCoverage(coverage, density, noise);
  250.  
  251.                 //float sunProximity = pow(sunglow, 1.0f);
  252.                 //float propigation = mix(15.0f, 9.0f, sunProximity);
  253.  
  254.  
  255.                 // float directLightFalloff = pow(heightGradient, propigation);
  256.                 //        directLightFalloff += pow(heightGradient, propigation / 2.0f);
  257.                 //        directLightFalloff /= 2.0f;
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.                 //float sundiff = -Get3DNoise(p1 + worldLightVector.xyz * lightOffset) * cloudAltitudeWeight2;
  265.                           //sundiff += -(1.0f - abs(Get3DNoise(p2 + worldLightVector.xyz * lightOffset) * 1.0f - 0.5f)) * 0.4f * cloudAltitudeWeight2;
  266.                           //sundiff += -(1.0f - abs(Get3DNoise(p3 + worldLightVector.xyz * lightOffset) * 3.0f - 1.0f)) * 0.035f * cloudAltitudeWeight2;
  267.                 float sundiff = Get3DNoise(p1 + worldLightVector.xyz * lightOffset);
  268.                           sundiff += (1.0f - abs(Get3DNoise(p2 + worldLightVector.xyz * lightOffset) * 1.0f - 0.5f)) * 0.4f;
  269.                           sundiff *= 1.1f;
  270.                           sundiff *= cloudAltitudeWeight2;
  271.                           //sundiff += (1.0f - abs(Get3DNoise(p3 + worldLightVector.xyz * lightOffset) * 3.0f - 1.0f)) * 0.075f * cloudAltitudeWeight2;
  272.                           sundiff = -GetCoverage(coverage * 1.0f, 0.0f, sundiff);
  273.                 float firstOrder        = pow(clamp(sundiff * 1.0f + 1.15f, 0.0f, 1.0f), 56.0f);
  274.                           //firstOrder  *= pow(clamp(1.3f - noise, 0.0f, 1.0f), 12.0f);
  275.                 float secondOrder       = pow(clamp(sundiff * 1.0f + 1.1f, 0.0f, 1.0f), 11.0f);
  276.  
  277.                           //directLightFalloff *= mix(  clamp(pow(noise, 1.2f) * 1.0f, 0.0f, 1.0f),     clamp(pow(1.0f - noise, 10.3f), 0.0f, 0.5f),    pow(sunglow, 1.2f));
  278.  
  279.  
  280.  
  281.  
  282.                 float directLightFalloff = mix(firstOrder, secondOrder, 0.5f);
  283.                 //float directLightFalloff = firstOrder;
  284.                 float anisoBackFactor = mix(clamp(pow(noise, 1.6f) * 2.5f, 0.0f, 1.0f), 1.0f, pow(sunglow, 1.0f));
  285.  
  286.                           directLightFalloff *= anisoBackFactor;
  287.                           directLightFalloff *= mix(11.5f, 1.0f, pow(sunglow, 0.5f));
  288.                
  289.  
  290.  
  291.  
  292.                 vec3 colorDirect = colorSunlight * 1.55f;
  293.                          colorDirect = mix(colorDirect, colorDirect * vec3(0.5f, 0.7f, 1.0f), timeMidnight);
  294.                 //colorDirect *= 1.0f + pow(sunglow, 10.0f) * 0.0f * pow(directLightFalloff, 1.0f);
  295.                 colorDirect *= 1.0f + pow(sunglow, 2.0f) * 100.0f * pow(directLightFalloff, 1.1f) * (1.0f - rainStrength);
  296.                 //colorDirect *= mix(1.0f, (clamp(pow(1.1f - noise, 50.09f) * 1.0f, 0.0f, 1.0f)) * 5.0f + 1.0f, pow(sunglow, 1.5f));
  297.  
  298.  
  299.                 vec3 colorAmbient = mix(colorSkylight, colorSunlight * 2.0f, vec3(heightGradient * 0.0f)) * 0.03f;
  300.                          //colorAmbient *= vec3(0.5f, 0.7f, 1.0f);
  301.                          colorAmbient *= mix(1.0f, 0.3f, timeMidnight);
  302.                          colorAmbient = mix(colorAmbient, colorAmbient * 3.0f + colorSunlight * 0.05f, vec3(clamp(pow(1.0f - noise, 12.0f) * 1.0f, 0.0f, 1.0f)));
  303.                          colorAmbient *= heightGradient * heightGradient + 0.1f;
  304.  
  305.                  vec3 colorBounced = colorBouncedSunlight * 0.1f;
  306.                          colorBounced *= pow((1.0f - heightGradient), 8.0f);
  307.  
  308.  
  309.                 directLightFalloff *= 1.0f - rainStrength * 0.7f;
  310.  
  311.                 // //cloud shadows
  312.                 // vec4 shadowPosition = shadowModelView * (worldPosition - vec4(cameraPosition, 0.0f));
  313.                 // shadowPosition = shadowProjection * shadowPosition;
  314.                 // shadowPosition /= shadowPosition.w;
  315.  
  316.                 // float dist = sqrt(shadowPosition.x * shadowPosition.x + shadowPosition.y * shadowPosition.y);
  317.                 // float distortFactor = (1.0f - SHADOW_MAP_BIAS) + dist * SHADOW_MAP_BIAS;
  318.                 // shadowPosition.xy *= 1.0f / distortFactor;
  319.                 // shadowPosition = shadowPosition * 0.5f + 0.5f;
  320.  
  321.                 // float sunlightVisibility = shadow2D(shadow, vec3(shadowPosition.st, shadowPosition.z)).x;
  322.                 // directLightFalloff *= sunlightVisibility;
  323.  
  324.                 vec3 color = mix(colorAmbient, colorDirect, vec3(min(1.0f, directLightFalloff)));
  325.                          //color += colorBounced;
  326.                      //color = colorAmbient;
  327.                      //color = colorDirect * directLightFalloff;
  328.                          //color *= clamp(pow(noise, 0.1f), 0.0f, 1.0f);
  329.  
  330.                 color *= 1.0f;
  331.  
  332.                 //color *= mix(1.0f, 0.4f, timeMidnight);
  333.  
  334.                 vec4 result = vec4(color.rgb, noise);
  335.  
  336.                 return result;
  337.         }
  338. }
  339.  
  340. void    CalculateClouds (inout vec3 color, inout SurfaceStruct surface)
  341. {
  342.         //if (texcoord.s < 0.5f && texcoord.t < 0.5f)
  343.         //{
  344.                 surface.cloudAlpha = 0.0f;
  345.  
  346.                 vec2 coord = texcoord.st * 2.0f;
  347.  
  348.                 vec4 worldPosition = gbufferModelViewInverse * surface.screenSpacePosition;
  349.                          worldPosition.xyz += cameraPosition.xyz;
  350.  
  351.                 float cloudHeight = 100.0f;
  352.                 float cloudDepth  = 400.0f;
  353.                 float cloudDensity = 1.0f;
  354.  
  355.                 float startingRayDepth = far - 5.0f;
  356.  
  357.                 float rayDepth = startingRayDepth;
  358.                           //rayDepth += CalculateDitherPattern1() * 0.09f;
  359.                           //rayDepth += texture2D(noisetex, texcoord.st * (viewWidth / noiseTextureResolution, viewHeight / noiseTextureResolution)).x * 0.1f;
  360.                           //rayDepth += CalculateDitherPattern2() * 0.1f;
  361.                 float rayIncrement = far / 11.0f;
  362.  
  363.                           rayDepth += CalculateDitherPattern1() * rayIncrement;
  364.  
  365.                 int i = 0;
  366.  
  367.                 vec3 cloudColor = colorSunlight;
  368.                 vec4 cloudSum = vec4(0.0f);
  369.                          cloudSum.rgb = colorSkylight * 0.2f;
  370.                          cloudSum.rgb = color.rgb;
  371.  
  372.                 float sunglow = CalculateSunglow(surface);
  373.  
  374.                 float cloudDistanceMult = 500.0f / far;
  375.  
  376.  
  377.                 float surfaceDistance = length(worldPosition.xyz - cameraPosition.xyz);
  378.  
  379.                 while (rayDepth > 0.0f)
  380.                 {
  381.                         //determine worldspace ray position
  382.                         vec4 rayPosition = GetCloudSpacePosition(texcoord.st, rayDepth, cloudDistanceMult);
  383.  
  384.                         float rayDistance = length((rayPosition.xyz - cameraPosition.xyz) / cloudDistanceMult);
  385.  
  386.                         vec4 proximity =  CloudColor(rayPosition, sunglow, surface.worldLightVector);
  387.                                  proximity.a *= cloudDensity;
  388.  
  389.                                  //proximity.a *=  clamp(surfaceDistance - rayDistance, 0.0f, 1.0f);
  390.                                  if (surfaceDistance < rayDistance * cloudDistanceMult && !surface.mask.sky)
  391.                                         proximity.a = 0.0f;
  392.  
  393.                         //cloudSum.rgb = mix( cloudSum.rgb, proximity.rgb, vec3(min(1.0f, proximity.a * cloudDensity)) );
  394.                         //cloudSum.a += proximity.a * cloudDensity;
  395.                         color.rgb = mix(color.rgb, proximity.rgb, vec3(min(1.0f, proximity.a * cloudDensity)));
  396.  
  397.                         surface.cloudAlpha += proximity.a;
  398.  
  399.                         //Increment ray
  400.                         rayDepth -= rayIncrement;
  401.                         i++;
  402.  
  403.                          // if (rayDepth * cloudDistanceMult  < ((cloudHeight - (cloudDepth * 0.5)) - cameraPosition.y))
  404.                          // {
  405.                          //     break;
  406.                          // }
  407.                 }
  408.  
  409.                 //color.rgb = mix(color.rgb, cloudSum.rgb, vec3(min(1.0f, cloudSum.a * 20.0f)));
  410.                 //color.rgb = cloudSum.rgb;
  411. }
  412.  
  413. vec4 CloudColor(in vec4 worldPosition, in float sunglow, in vec3 worldLightVector, in float altitude, in float thickness)
  414. {
  415.  
  416.         float cloudHeight = altitude;
  417.         float cloudDepth  = thickness;
  418.         float cloudUpperHeight = cloudHeight + (cloudDepth / 2.0f);
  419.         float cloudLowerHeight = cloudHeight - (cloudDepth / 2.0f);
  420.  
  421.         worldPosition.xz /= 1.0f + max(0.0f, length(worldPosition.xz - cameraPosition.xz) / 3000.0f);
  422.  
  423.         vec3 p = worldPosition.xyz / 300.0f;
  424.  
  425.                
  426.  
  427.        
  428.         float t = frameTimeCounter * 1.0f;
  429.                   //t *= 0.001;
  430.         p.x -= t * 0.01f;
  431.  
  432.          p += (Get3DNoise(p * 1.0f + vec3(0.0f, t * 0.01f, 0.0f)) * 2.0f - 1.0f) * 0.3f;
  433.  
  434.         vec3 p1 = p * vec3(1.0f, 0.5f, 1.0f)  + vec3(0.0f, t * 0.01f, 0.0f);
  435.         float noise  =  Get3DNoise(p * vec3(1.0f, 0.5f, 1.0f) + vec3(0.0f, t * 0.01f, 0.0f));   p *= 2.0f;      p.x -= t * 0.057f;      vec3 p2 = p;
  436.                   noise += (1.0f - abs(Get3DNoise(p) * 1.0f - 0.5f)) * 0.15f;                                           p *= 3.0f;      p.xz -= t * 0.035f;     vec3 p3 = p;
  437.                   noise += (1.0f - abs(Get3DNoise(p) * 3.0f - 0.0f)) * 0.045f;                                          p *= 3.0f;      p.xz -= t * 0.035f;     vec3 p4 = p;
  438.                   noise += (1.0f - abs(Get3DNoise(p) * 3.0f - 0.0f)) * 0.015f;                                          p *= 3.0f;      p.xz -= t * 0.035f;
  439.                   noise += ((Get3DNoise(p))) * 0.015f;                                                                                          p *= 3.0f;
  440.                   noise += ((Get3DNoise(p))) * 0.006f;
  441.                   noise /= 1.175f;
  442.  
  443.  
  444.  
  445.         const float lightOffset = 0.2f;
  446.  
  447.  
  448.         float heightGradient = clamp(( - (cloudLowerHeight - worldPosition.y) / (cloudDepth * 1.0f)), 0.0f, 1.0f);
  449.         float heightGradient2 = clamp(( - (cloudLowerHeight - (worldPosition.y + worldLightVector.y * lightOffset * 50.0f)) / (cloudDepth * 1.0f)), 0.0f, 1.0f);
  450.  
  451.         float cloudAltitudeWeight = 1.0f;
  452.  
  453.         float cloudAltitudeWeight2 = 1.0f;
  454.  
  455.         noise *= cloudAltitudeWeight;
  456.  
  457.         //cloud edge
  458.         float coverage = 0.39f;
  459.                   coverage = mix(coverage, 0.77f, rainStrength);
  460.  
  461.                   float dist = length(worldPosition.xz - cameraPosition.xz);
  462.                   coverage *= max(0.0f, 1.0f - dist / 40000.0f);
  463.         float density = 0.8f;
  464.         noise = GetCoverage(coverage, density, noise);
  465.  
  466.  
  467.  
  468.  
  469.         float sundiff = Get3DNoise(p1 + worldLightVector.xyz * lightOffset);
  470.                   sundiff += Get3DNoise(p2 + worldLightVector.xyz * lightOffset / 2.0f) * 0.15f;      
  471.                                                 float largeSundiff = sundiff;
  472.                                                       largeSundiff = -GetCoverage(coverage, 0.0f, largeSundiff * 1.3f);
  473.                   sundiff += Get3DNoise(p3 + worldLightVector.xyz * lightOffset / 5.0f) * 0.045f;
  474.                   sundiff += Get3DNoise(p4 + worldLightVector.xyz * lightOffset / 8.0f) * 0.015f;
  475.                   sundiff *= 1.3f;
  476.                   sundiff *= cloudAltitudeWeight2;
  477.                   sundiff = -GetCoverage(coverage * 1.0f, 0.0f, sundiff);
  478.         float firstOrder        = pow(clamp(sundiff * 1.0f + 1.1f, 0.0f, 1.0f), 12.0f);
  479.         float secondOrder       = pow(clamp(largeSundiff * 1.0f + 0.9f, 0.0f, 1.0f), 3.0f);
  480.  
  481.  
  482.  
  483.         float directLightFalloff = mix(firstOrder, secondOrder, 0.1f);
  484.         float anisoBackFactor = mix(clamp(pow(noise, 1.6f) * 2.5f, 0.0f, 1.0f), 1.0f, pow(sunglow, 1.0f));
  485.  
  486.                   directLightFalloff *= anisoBackFactor;
  487.                   directLightFalloff *= mix(11.5f, 1.0f, pow(sunglow, 0.5f));
  488.        
  489.  
  490.  
  491.         vec3 colorDirect = colorSunlight * 0.815f;
  492.                  colorDirect = mix(colorDirect, colorDirect * vec3(0.2f, 0.5f, 1.0f), timeMidnight);
  493.                  colorDirect *= 1.0f + pow(sunglow, 2.0f) * 300.0f * pow(directLightFalloff, 1.1f) * (1.0f - rainStrength);
  494.  
  495.  
  496.         vec3 colorAmbient = mix(colorSkylight, colorSunlight * 2.0f, vec3(heightGradient * 0.0f + 0.15f)) * 0.36f;
  497.                  colorAmbient *= mix(1.0f, 0.3f, timeMidnight);
  498.                  colorAmbient = mix(colorAmbient, colorAmbient * 3.0f + colorSunlight * 0.05f, vec3(clamp(pow(1.0f - noise, 12.0f) * 1.0f, 0.0f, 1.0f)));
  499.                  colorAmbient *= heightGradient * heightGradient + 0.1f;
  500.  
  501.          vec3 colorBounced = colorBouncedSunlight * 0.1f;
  502.                  colorBounced *= pow((1.0f - heightGradient), 8.0f);
  503.  
  504.  
  505.         directLightFalloff *= 1.0f;
  506.         //directLightFalloff += pow(Get3DNoise(p3), 2.0f) * 0.05f + pow(Get3DNoise(p4), 2.0f) * 0.015f;
  507.  
  508.         vec3 color = mix(colorAmbient, colorDirect, vec3(min(1.0f, directLightFalloff)));
  509.  
  510.         color *= 1.0f;
  511.  
  512.         vec4 result = vec4(color.rgb, noise);
  513.  
  514.         return result;
  515.        
  516. }
  517.  
  518. vec4 CloudColor2(in vec4 worldPosition, in float sunglow, in vec3 worldLightVector, in float altitude, in float thickness, const bool isShadowPass)
  519. {
  520.  
  521.         float cloudHeight = altitude;
  522.         float cloudDepth  = thickness;
  523.         float cloudUpperHeight = cloudHeight + (cloudDepth / 2.0f);
  524.         float cloudLowerHeight = cloudHeight - (cloudDepth / 2.0f);
  525.  
  526.         worldPosition.xz /= 1.0f + max(0.0f, length(worldPosition.xz - cameraPosition.xz) / 9001.0f);
  527.  
  528.         vec3 p = worldPosition.xyz / 75.0f;
  529.  
  530.                
  531.  
  532.         float t = frameTimeCounter * 1.0f;
  533.                   t *= 0.4;
  534.  
  535.  
  536.          p += (Get3DNoise(p * 2.0f + vec3(0.0f, t * 0.01f, 0.0f)) * 2.0f - 1.0f) * 0.10f;
  537.  
  538.           p.x -= (Get3DNoise(p * 0.125f + vec3(0.0f, t * 0.01f, 0.0f)) * 2.0f - 1.0f) * 1.2f;
  539.         // p.xz -= (Get3DNoise(p * 0.0525f + vec3(0.0f, t * 0.01f, 0.0f)) * 2.0f - 1.0f) * 1.7f;
  540.  
  541.  
  542.         p.x *= 0.25f;
  543.         p.x -= t * 0.01f;
  544.  
  545.         vec3 p1 = p * vec3(1.0f, 0.5f, 1.0f)  + vec3(0.0f, t * 0.01f, 0.0f);
  546.         float noise  =  Get3DNoise(p * vec3(1.0f, 0.5f, 1.0f) + vec3(0.0f, t * 0.01f, 0.0f));   p *= 2.0f;      p.x -= t * 0.017f;      p.z += noise * 1.35f;   p.x += noise * 0.5f;                                                                    vec3 p2 = p;
  547.                   noise += (2.0f - abs(Get3DNoise(p) * 2.0f - 0.0f)) * (0.25f);                                         p *= 3.0f;      p.xz -= t * 0.005f;     p.z += noise * 1.35f;   p.x += noise * 0.5f;    p.x *= 3.0f;    p.z *= 0.55f;   vec3 p3 = p;
  548.                          p.z -= (Get3DNoise(p * 0.25f + vec3(0.0f, t * 0.01f, 0.0f)) * 2.0f - 1.0f) * 0.4f;
  549.                   noise += (3.0f - abs(Get3DNoise(p) * 3.0f - 0.0f)) * (0.035f);                                        p *= 3.0f;      p.xz -= t * 0.005f;                                                                                                                                                                     vec3 p4 = p;
  550.                   noise += (3.0f - abs(Get3DNoise(p) * 3.0f - 0.0f)) * (0.025f);                                        p *= 3.0f;      p.xz -= t * 0.005f;
  551.                   if (!isShadowPass)
  552.                   {
  553.                                 noise += ((Get3DNoise(p))) * (0.039f);                                                                                          p *= 3.0f;
  554.                                  noise += ((Get3DNoise(p))) * (0.024f);
  555.                   }
  556.                   noise /= 1.575f;
  557.  
  558.         //cloud edge
  559.         float rainy = mix(wetness, 1.0f, rainStrength);
  560.                   //rainy = 0.0f;
  561.         float coverage = 0.55f + rainy * 0.35f;
  562.                   //coverage = mix(coverage, 0.97f, rainStrength);
  563.  
  564.                   float dist = length(worldPosition.xz - cameraPosition.xz);
  565.                   coverage *= max(0.0f, 1.0f - dist / mix(10000.0f, 3000.0f, rainStrength));
  566.         float density = 0.0f;
  567.  
  568.         if (isShadowPass)
  569.         {
  570.                 return vec4(GetCoverage(coverage + 0.2f, density + 0.2f, noise));
  571.         }
  572.         else
  573.         {
  574.  
  575.                 noise = GetCoverage(coverage, density, noise);
  576.                 noise = noise * noise * (3.0f - 2.0f * noise);
  577.  
  578.                 const float lightOffset = 0.2f;
  579.  
  580.  
  581.  
  582.                 float sundiff = Get3DNoise(p1 + worldLightVector.xyz * lightOffset);
  583.                           sundiff += (2.0f - abs(Get3DNoise(p2 + worldLightVector.xyz * lightOffset / 2.0f) * 2.0f - 0.0f)) * (0.55f);        
  584.                                                         float largeSundiff = sundiff;
  585.                                                               largeSundiff = -GetCoverage(coverage, 0.0f, largeSundiff * 1.3f);
  586.                           sundiff += (3.0f - abs(Get3DNoise(p3 + worldLightVector.xyz * lightOffset / 5.0f) * 3.0f - 0.0f)) * (0.065f);
  587.                           sundiff += (3.0f - abs(Get3DNoise(p4 + worldLightVector.xyz * lightOffset / 8.0f) * 3.0f - 0.0f)) * (0.025f);
  588.                           sundiff /= 1.5f;
  589.                           sundiff = -GetCoverage(coverage * 1.0f, 0.0f, sundiff);
  590.                 float secondOrder       = pow(clamp(sundiff * 1.00f + 1.35f, 0.0f, 1.0f), 7.0f);
  591.                 float firstOrder        = pow(clamp(largeSundiff * 1.1f + 1.56f, 0.0f, 1.0f), 3.0f);
  592.  
  593.  
  594.  
  595.                 float directLightFalloff = secondOrder;
  596.                 float anisoBackFactor = mix(clamp(pow(noise, 1.6f) * 2.5f, 0.0f, 1.0f), 1.0f, pow(sunglow, 1.0f));
  597.  
  598.                           directLightFalloff *= anisoBackFactor;
  599.                           directLightFalloff *= mix(11.5f, 1.0f, pow(sunglow, 0.5f));
  600.                
  601.  
  602.  
  603.                 vec3 colorDirect = colorSunlight * 0.915f;
  604.                          colorDirect = mix(colorDirect, colorDirect * vec3(0.2f, 0.5f, 1.0f), timeMidnight);
  605.                          colorDirect *= 1.0f + pow(sunglow, 2.0f) * 100.0f * pow(directLightFalloff, 1.1f) * (1.0f - rainStrength);
  606.                          // colorDirect *= 1.0f + pow(1.0f - sunglow, 2.0f) * 30.0f * pow(directLightFalloff, 1.1f) * (1.0f - rainStrength);
  607.  
  608.  
  609.                 vec3 colorAmbient = mix(colorSkylight, colorSunlight * 2.0f, vec3(0.15f)) * 0.04f;
  610.                          colorAmbient *= mix(1.0f, 0.3f, timeMidnight);
  611.                          colorAmbient *= mix(1.0f, ((1.0f - noise) + 0.5f) * 1.4f, rainStrength);
  612.                          // colorAmbient = mix(colorAmbient, colorAmbient * 3.0f + colorSunlight * 0.05f, vec3(clamp(pow(1.0f - noise, 12.0f) * 1.0f, 0.0f, 1.0f)));
  613.  
  614.  
  615.                 directLightFalloff *= 1.0f - rainStrength * 0.75f;
  616.  
  617.  
  618.                 //directLightFalloff += (pow(Get3DNoise(p3), 2.0f) * 0.5f + pow(Get3DNoise(p3 * 1.5f), 2.0f) * 0.25f) * 0.02f;
  619.                 //directLightFalloff *= Get3DNoise(p2);
  620.  
  621.                 vec3 color = mix(colorAmbient, colorDirect, vec3(min(1.0f, directLightFalloff)));
  622.  
  623.                 color *= 1.0f;
  624.  
  625.                 // noise *= mix(1.0f, 5.0f, sunglow);
  626.  
  627.                 vec4 result = vec4(color, noise);
  628.  
  629.                 return result;
  630.         }
  631.        
  632. }
  633.  
  634. void CloudPlane(inout SurfaceStruct surface)
  635. {
  636.         //Initialize view ray
  637.         vec4 worldVector = gbufferModelViewInverse * (-GetScreenSpacePosition(texcoord.st, 1.0f));
  638.  
  639.         surface.viewRay.dir = normalize(worldVector.xyz);
  640.         surface.viewRay.origin = vec3(0.0f);
  641.  
  642.         float sunglow = CalculateSunglow(surface);
  643.  
  644.  
  645.  
  646.         float cloudsAltitude = 1200.0f;
  647.         float cloudsThickness = 200.0f;
  648.  
  649.         float cloudsUpperLimit = cloudsAltitude + cloudsThickness * 0.5f;
  650.         float cloudsLowerLimit = cloudsAltitude - cloudsThickness * 0.5f;
  651.  
  652.         float density = 1.0f;
  653.  
  654.         if (cameraPosition.y < cloudsLowerLimit)
  655.         {
  656.                 float planeHeight = cloudsUpperLimit;
  657.  
  658.                 float stepSize = 25.5f;
  659.                 planeHeight -= cloudsThickness * 0.85f;
  660.                 //planeHeight += CalculateDitherPattern1() * stepSize;
  661.                 //planeHeight += CalculateDitherPattern() * stepSize;
  662.  
  663.                 //while(planeHeight > cloudsLowerLimit)
  664.                 ///{
  665.                         Plane pl;
  666.                         pl.origin = vec3(0.0f, cameraPosition.y - planeHeight, 0.0f);
  667.                         pl.normal = vec3(0.0f, 1.0f, 0.0f);
  668.  
  669.                         Intersection i = RayPlaneIntersectionWorld(surface.viewRay, pl);
  670.  
  671.                         if (i.angle < 0.0f)
  672.                         {
  673.                                 if (i.distance < surface.linearDepth || surface.mask.sky)
  674.                                 {
  675.                                          vec4 cloudSample = CloudColor2(vec4(i.pos.xyz * 0.5f + vec3(30.0f), 1.0f), sunglow, surface.worldLightVector, cloudsAltitude, cloudsThickness, false);
  676.                                                  cloudSample.a = min(1.0f, cloudSample.a * density);
  677.  
  678.                                         surface.sky.albedo.rgb = mix(surface.sky.albedo.rgb, cloudSample.rgb, cloudSample.a);
  679.  
  680.                                         cloudSample = CloudColor2(vec4(i.pos.xyz * 0.65f + vec3(10.0f) + vec3(i.pos.z * 0.5f, 0.0f, 0.0f), 1.0f), sunglow, surface.worldLightVector, cloudsAltitude, cloudsThickness, false);
  681.                                         cloudSample.a = min(1.0f, cloudSample.a * density);
  682.  
  683.                                         surface.sky.albedo.rgb = mix(surface.sky.albedo.rgb, cloudSample.rgb, cloudSample.a);
  684.  
  685.                                 }
  686.                         }
  687.  
  688.         }
  689. }  
  690.  
  691.     ##### END OF CODE! DO "NOT" COPY THIS #####
  692.  
  693. -----------------------------------------------------------------------------------------------------
  694.     ##### OPTIONAL DISABLE 2D CLOUDS #####
  695. -----------------------------------------------------------------------------------------------------
  696.  
  697. Open "composite1.fsh",
  698. Line 1234:
  699. Change that line to read this: //CloudPlane(surface);
  700.  
  701. -----------------------------------------------------------------------------------------------------
  702.     ##### END #####
  703. -----------------------------------------------------------------------------------------------------
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top