more indirect light for clouds

and other minor tweaks
This commit is contained in:
Xonk
2023-05-03 21:29:53 -04:00
parent a082f263bd
commit 52466e8e35
11 changed files with 106 additions and 81 deletions

View File

@ -145,7 +145,7 @@
// --- WEATHER/SKY ---
#define Puddles // yes
#define sky_mieg 0.80 //[0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0 ]
#define sky_coefficientRayleighR 5.8 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
#define sky_coefficientRayleighG 1.35 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0 ]
@ -218,7 +218,7 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8
//#define SHADOW_FRUSTRUM_CULLING // BROKEN IN 1.17+. If enabled, removes most of the blocks during shadow rendering that would not cast shadows on the player field of view. Improves performance but can be sometimes incorrect and causes flickering shadows on distant occluders
const int shadowMapResolution = 2048; //Will probably crash at 16 384 [512 768 1024 1536 2048 3172 4096 8192 16384]
const float shadowDistance = 69.; //[32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 ] Not linear at all when shadowDistanceRenderMul is set to -1.0, 175.0 is enough for 40 render distance
const float shadowDistance = 69.; // [32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193. 194. 195. 196. 197. 198. 199. 200. 201. 202. 203. 204. 205. 206. 207. 208. 209. 210. 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223. 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234. 235. 236. 237. 238. 239. 240. 241. 242. 243. 244. 245. 246. 247. 248. 249. 250. 251. 252. 253. 254. 255. 256.] Not linear at all when shadowDistanceRenderMul is set to -1.0, 175.0 is enough for 40 render distance
const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase shadow draw distance when set to -1.0, at the cost of performance
#define Variable_Penumbra_Shadows //Makes the shadows more blurry the more distant they are to objects (costs fps)
#define VPS_Search_Samples 4 //The number of samples used to find occluders [4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32]
@ -258,18 +258,19 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] Can help to increase sh
#define SUN_MICROFACET_SPECULAR // If enabled will use realistic rough microfacet model, else will just reflect the sun. No performance impact.
#define USE_QUARTER_RES_DEPTH // Uses a quarter resolution depth buffer to raymarch screen space reflections, improves performance but may introduce artifacts
#ifdef Specular_Reflections
#define Puddles // yes
#endif
// --- CLOUDS ---
#define VOLUMETRIC_CLOUDS // if you don't like the noise on the default cloud settings, turn up the cloud samples. if that hurts performance too much, turn down the clouds quality.
#define CLOUDS_SHADOWS // Casts shadows from clouds on the world
#ifndef VOLUMETRIC_CLOUDS
#undef CLOUDS_SHADOWS
#endif
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL
#ifndef CLOUDS_SHADOWS
#undef VL_CLOUDS_SHADOWS
#ifdef VOLUMETRIC_CLOUDS
#define CLOUDS_SHADOWS // Casts shadows from clouds on the world
#ifdef CLOUDS_SHADOWS
#define VL_CLOUDS_SHADOWS // Casts shadows from clouds on VL
#endif
#endif
#define Cumulus // a layer of puffy clouds up yonder.

View File

@ -27,7 +27,7 @@ float MaxCumulusHeight = CumulusHeight + 100;
float AltostratusHeight = 2000;
float rainCloudwetness = rainStrength;
float cloud_movement = frameTimeCounter;
float cloud_movement = frameTimeCounter * 0;
//3D noise from 2d texture
float densityAtPos(in vec3 pos){
@ -133,17 +133,24 @@ vec3 Cloud_lighting(
vec3 sunContributionMulti,
vec3 moonContribution,
float AmbientShadow,
int cloudType
int cloudType,
vec3 pos
){
float coeeff = -30;
// float powder = 1.0 - exp((CloudShape*CloudShape) * -800);
float powder = 1.0 - exp(CloudShape * coeeff/3);
float lesspowder = powder*0.4+0.6;
vec3 skyLighting = SkyColors * exp(SkyShadowing * AmbientShadow * coeeff/2 ) * lesspowder ;
vec3 skyLighting = SkyColors;
#ifdef Altostratus
skyLighting += sunContributionMulti * 5.0 * exp(SunShadowing * -3) * clamp(Alto_coverage * (1-Alto_density),0,1);
#endif
skyLighting *= exp(SkyShadowing * AmbientShadow * coeeff/2 ) * lesspowder ;
if(cloudType == 1){
coeeff = -10;
coeeff = -3;
skyLighting = SkyColors * exp(SkyShadowing * coeeff/15) * lesspowder;
}
@ -152,7 +159,8 @@ vec3 Cloud_lighting(
vec3 moonLighting = exp(MoonShadowing * coeeff / 3) * moonContribution * powder;
return skyLighting + moonLighting + sunLighting ;
return skyLighting + moonLighting + sunLighting ;
// return sunLighting;
}
//Mie phase function
@ -215,6 +223,7 @@ vec4 renderClouds(
////// lighitng stuff
float shadowStep = 200.;
vec3 dV_Sun = normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep;
vec3 dV_Sun_small = dV_Sun/shadowStep;
float SdotV = dot(sunVec,normalize(FragPosition));
@ -248,13 +257,14 @@ vec4 renderClouds(
float Sunlight = 0.0;
float MoonLight = 0.0;
for (int j=0; j < self_shadow_samples; j++){
vec3 shadowSamplePos = progress_view + dV_Sun * (1+j+Dither.y/2)*0.15;
for (int j=0; j < 3; j++){
vec3 shadowSamplePos = progress_view + (dV_Sun * 0.15) * (1 + Dither.y/2 + j);
float shadow = GetCumulusDensity(shadowSamplePos, 0) * Cumulus_density;
Sunlight += shadow;
Sunlight += shadow / (1 + j);
MoonLight += shadow;
}
@ -267,7 +277,7 @@ vec4 renderClouds(
#endif
float ambientlightshadow = 1.0-clamp(exp((progress_view.y - (MaxCumulusHeight + CumulusHeight)*0.5) / 100.0),0.0,1.0);
vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0);
vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0, progress_view);
vec3 Sint = (S - S * exp(-mult*muE)) / muE;
color += max(muE*Sint*total_extinction,0.0);
@ -295,7 +305,7 @@ vec4 renderClouds(
float shadow = GetAltostratusDensity(shadowSamplePos_high) * Alto_density;
Sunlight += shadow;
}
vec3 S = Cloud_lighting(altostratus, altostratus, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, 1, 1);
vec3 S = Cloud_lighting(altostratus, altostratus, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, 1, 1, progress_view_high);
vec3 Sint = (S - S * exp(-20*altostratus)) / altostratus;
color += max(altostratus*Sint*total_extinction,0.0);
@ -360,4 +370,16 @@ float GetCloudShadow_VLFOG(vec3 WorldPos){
shadow *= clamp(((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y)/100,0.0,1.0) ;
return shadow;
}
float GetAltoOcclusion(vec3 eyePlayerPos){
vec3 playerPos = eyePlayerPos + cameraPosition;
playerPos.y += 0.05;
float shadow;
vec3 lowShadowStart = playerPos + normalize(vec3(0,1,0)) * max((MaxCumulusHeight + CumulusHeight)*0.433 - playerPos.y,0.0) ;
shadow = GetCumulusDensity(lowShadowStart,0) * cloudDensity;
shadow = clamp(exp(shadow * -1),0.0,1.0);
return shadow;
}