|
10 | 10 | uniform sampler2D m_AfflictionAlphaMap; |
11 | 11 | #endif |
12 | 12 | #ifdef AFFLICTIONALBEDOMAP |
13 | | - uniform sampler2D m_SplatAlbedoMap ; |
| 13 | + uniform sampler2D m_SplatAlbedoMap; |
14 | 14 | #endif |
15 | 15 | #ifdef AFFLICTIONNORMALMAP |
16 | | - uniform sampler2D m_SplatNormalMap ; |
| 16 | + uniform sampler2D m_SplatNormalMap; |
17 | 17 | #endif |
18 | 18 | #ifdef AFFLICTIONROUGHNESSMETALLICMAP |
19 | 19 | uniform sampler2D m_SplatRoughnessMetallicMap; |
|
30 | 30 | uniform vec3 m_TileLocation; |
31 | 31 | #endif |
32 | 32 |
|
33 | | - |
34 | 33 | uniform int m_AfflictionSplatScale; |
35 | 34 | uniform float m_AfflictionRoughnessValue; |
36 | 35 | uniform float m_AfflictionMetallicValue; |
37 | 36 | uniform float m_AfflictionEmissiveValue; |
38 | 37 | uniform vec4 m_AfflictionEmissiveColor; |
39 | 38 |
|
40 | | - |
41 | | - |
42 | | - |
43 | 39 | vec4 afflictionVector; |
44 | 40 | float noiseHash; |
45 | 41 | float livelinessValue; |
46 | 42 | float afflictionValue; |
47 | 43 | int afflictionMode = 1; |
48 | 44 |
|
49 | | - |
50 | | - //temporarily here, move triplanar import + define back to .frag shader soon: |
51 | | - |
52 | 45 | vec4 desaturate(vec4 albedo, float deathVar){ |
53 | | - |
54 | 46 | vec3 gray = vec3(dot(vec3(0.2126,0.7152,0.0722), albedo.rgb)); |
55 | 47 | albedo = vec4(mix(albedo.rgb, gray, deathVar), 0.0); |
56 | 48 |
|
57 | 49 | return albedo; |
58 | 50 | } |
59 | | - |
60 | 51 | vec3 alterLiveliness(vec3 color, float liveVal, int mode){ |
61 | 52 |
|
62 | 53 | float deathVar = (1.0 - (liveVal)); |
|
73 | 64 | color.g -= color.g*hueVar; |
74 | 65 | color.b -= color.b*hueVar * 5.0 ; |
75 | 66 |
|
76 | | - |
77 | 67 | color = desaturate(vec4(color, 1.0), deathVar).rgb; |
78 | 68 |
|
79 | 69 | } |
80 | 70 |
|
81 | | - |
82 | | - |
83 | 71 | return color; |
84 | 72 |
|
85 | 73 | } |
86 | 74 |
|
87 | 75 |
|
88 | 76 | vec3 alterLiveliness(vec3 color, float livelinessValue){ |
89 | 77 |
|
90 | | - |
91 | 78 | float deathVar = (1.0 - (livelinessValue)); |
92 | 79 |
|
93 | 80 | float hueVar = (deathVar) * 0.34; |
94 | 81 | color.r += color.r*hueVar * 1.8; |
95 | 82 | color.g -= color.g*hueVar; |
96 | 83 | color.b -= color.b*hueVar*5.0 ; |
97 | 84 |
|
98 | | - |
99 | 85 | color = desaturate(vec4(color, 1.0), deathVar).rgb; |
100 | 86 |
|
101 | | - |
102 | 87 | return color; |
103 | 88 | } |
104 | 89 |
|
|
135 | 120 |
|
136 | 121 | float deathVar = 1.0 - livelinessValue; |
137 | 122 |
|
138 | | - |
139 | 123 | float hueVar = (deathVar); |
140 | 124 | albedo.r += albedo.r*hueVar * 1.2; |
141 | 125 | albedo.g += albedo.g*hueVar; |
142 | 126 | albedo.b -= albedo.b*hueVar*3.14 ; |
143 | 127 |
|
144 | 128 | albedo = desaturate(albedo, deathVar * 1.7); |
145 | 129 |
|
146 | | - |
147 | | - |
148 | 130 | return albedo; |
149 | 131 | } |
150 | 132 |
|
151 | 133 | vec3 desaturateVec(vec3 albedo, float deathVar){ |
152 | | - |
153 | 134 | vec3 gray = vec3(dot(vec3(0.2126,0.7152,0.0722), albedo.rgb)); |
154 | 135 | albedo = mix(albedo, gray, deathVar); |
155 | 136 |
|
|
160 | 141 |
|
161 | 142 | float deathVar = 1.0 - livelinessValue; |
162 | 143 |
|
163 | | - |
164 | 144 | float hueVar = (deathVar); |
165 | 145 | albedo.r += albedo.r*hueVar * 1.2; |
166 | 146 | albedo.g += albedo.g*hueVar; |
167 | 147 | albedo.b -= albedo.b*hueVar*3.14 ; |
168 | 148 |
|
169 | 149 | albedo = desaturateVec(albedo, deathVar * 1.7); |
170 | 150 |
|
171 | | - |
172 | | - |
173 | 151 | return albedo; |
174 | 152 | } |
175 | 153 |
|
176 | | - |
177 | | - |
178 | 154 | //AFFLICTION METHODS |
179 | 155 |
|
180 | 156 | //adjusts the affliction value for the best visual representation (since 0.0 - 1.0 is not as visually linear as it is numerically) |
181 | 157 | float getAdjustedAfflictionVar(float afflictionVar){ |
182 | | - |
183 | 158 | float adjustedVar = afflictionVar; |
184 | 159 | if(afflictionVar > 0.02){ |
185 | 160 | adjustedVar = mix(0.02, 0.53, afflictionVar); |
|
192 | 167 | } |
193 | 168 |
|
194 | 169 | float getAfflictionEdgeTaper(float noiseVar, float afflictionVar){ |
195 | | - |
196 | 170 | float amt = noiseVar - (0.4 * afflictionVar) - .04; |
197 | 171 |
|
198 | 172 | if(amt <= 0.05){ |
199 | 173 | amt = 0.05; |
200 | 174 | } |
201 | | - |
202 | | - |
203 | 175 | return amt; |
204 | 176 | } |
205 | 177 |
|
206 | 178 | vec4 alterAfflictionColor(float afflictionVar, vec4 albedo, vec4 afflictionAlbedo, float noiseVar){ |
207 | | - |
208 | 179 | float originalAlpha = albedo.a; |
209 | 180 |
|
210 | 181 | float edgeTaper = getAfflictionEdgeTaper(noiseVar, afflictionVar); |
|
217 | 188 | float edgeDiff = noiseVar - afflictionVar; |
218 | 189 | edgeDiff = edgeDiff / afflictionVar; |
219 | 190 |
|
220 | | - |
221 | 191 | albedo.rgba = mix(afflictionAlbedo.rgba, albedo.rgba, edgeDiff); |
222 | 192 | } |
223 | 193 | else{ |
224 | | - |
225 | 194 | albedo.rgba = mix(albedo.rgba, afflictionAlbedo.rgba, afflictionVar); |
226 | 195 | } |
227 | 196 |
|
|
230 | 199 |
|
231 | 200 | return albedo; |
232 | 201 | } |
233 | | - vec4 alterAfflictionGlow(float afflictionVar, vec4 emissive, vec4 afflictionGlowColor, float noiseVar){ |
234 | | - |
235 | | - |
| 202 | + vec4 alterAfflictionGlow(float afflictionVar, vec4 emissive, vec4 afflictionGlowColor, float noiseVar){ |
236 | 203 | emissive = mix(emissive, afflictionGlowColor, afflictionVar); |
237 | 204 |
|
238 | 205 | return emissive; |
239 | 206 | } |
240 | 207 |
|
241 | 208 | float alterAfflictionEmissiveIntensity(float afflictionVar, float emissiveIntensity, float afflictionEmissiveIntensity, float noiseVar){ |
242 | | - |
243 | | - |
244 | 209 | emissiveIntensity = mix(emissiveIntensity, afflictionEmissiveIntensity, afflictionVar); |
245 | 210 |
|
246 | 211 | return emissiveIntensity; |
247 | 212 | } |
248 | 213 |
|
249 | 214 | vec3 alterAfflictionNormals(float afflictionVar, vec3 normal, vec3 afflictionNormal, float noiseVar){ |
250 | | - |
251 | 215 | vec3 originalNorm = normal; |
252 | 216 |
|
253 | 217 | float edgeTaper = getAfflictionEdgeTaper(noiseVar, afflictionVar); |
|
269 | 233 | } |
270 | 234 |
|
271 | 235 | vec3 alterAfflictionNormalsForTerrain(float afflictionVar, vec3 normal, vec3 afflictionNormal, float noiseVar, vec3 worldNorm){ |
272 | | - |
273 | | - |
274 | 236 | float edgeTaper = getAfflictionEdgeTaper(noiseVar, afflictionVar); |
275 | | - |
276 | | - |
277 | 237 | vec3 blendedNormal = normal; |
278 | 238 |
|
279 | 239 | float blendValue = afflictionVar; |
|
294 | 254 | blendAmt = min(1.0, blendAmt); |
295 | 255 |
|
296 | 256 | blendValue = blendAmt; |
297 | | - |
298 | 257 | } |
299 | 258 |
|
300 | 259 | afflictionNormal = calculateTangentsAndApplyToNormals(afflictionNormal, worldNorm); |
|
324 | 283 | } |
325 | 284 |
|
326 | 285 | float alterAfflictionRoughness(float afflictionVar, float originalRoughness, float afflictionRoughness, float noiseVar){ |
327 | | - |
328 | | - |
329 | 286 | float edgeTaper = getAfflictionEdgeTaper(noiseVar, afflictionVar); |
330 | 287 | if(afflictionVar >= noiseVar){ |
331 | 288 | originalRoughness = afflictionRoughness; |
|
345 | 302 | } |
346 | 303 |
|
347 | 304 | float alterAfflictionMetallic(float afflictionVar, float originalMetallic, float afflictionMetallic, float noiseVar){ |
348 | | - |
349 | | - |
350 | 305 | float edgeTaper = getAfflictionEdgeTaper(noiseVar, afflictionVar); |
351 | 306 | if(afflictionVar >= noiseVar){ |
352 | 307 | originalMetallic = afflictionMetallic; |
|
370 | 325 | void AfflictionLib_readAfflictionVector(){ |
371 | 326 | #ifdef AFFLICTIONTEXTURE |
372 | 327 |
|
373 | | - afflictionVector = vec4(1.0, 0.0, 1.0, 0.0); //r channel is sturation, g channel is affliction splat texture intensity, b and a unused (might use b channel for wetness eventually) |
374 | | - |
| 328 | + afflictionVector = vec4(1.0, 0.0, 1.0, 0.0); //r channel is saturation, g channel is affliction splat texture intensity, b and a unused (might use b channel for wetness eventually) |
375 | 329 |
|
376 | 330 | #ifdef TILELOCATION |
377 | 331 | //subterrains that are not centred in tile or equal to tile width in total size need to have m_TileWidth pre-set. (tileWidth is the x,z dimesnions that the AfflictionAlphaMap represents).. |
|
404 | 358 |
|
405 | 359 | TriPlanarUtils_calculateBlending(surface.geometryNormal); |
406 | 360 |
|
407 | | - |
408 | | - #ifdef AFFLICTIONTEXTURE |
409 | | - |
410 | | - |
| 361 | + #ifdef AFFLICTIONTEXTURE |
411 | 362 | vec4 afflictionAlbedo; |
412 | 363 |
|
413 | 364 | float newAfflictionScale = m_AfflictionSplatScale; |
|
448 | 399 | float afflictionRoughness = m_AfflictionRoughnessValue; |
449 | 400 | float afflictionAo = 1.0; |
450 | 401 |
|
451 | | - |
452 | 402 | vec4 afflictionEmissive = m_AfflictionEmissiveColor; |
453 | 403 | float afflictionEmissiveIntensity = m_AfflictionEmissiveValue; |
454 | 404 |
|
|
503 | 453 | } |
504 | 454 |
|
505 | 455 | #endif |
506 | | - |
507 | | - |
508 | 456 | } |
509 | | - |
510 | 457 | #endif |
511 | 458 |
|
512 | 459 |
|
|
0 commit comments