Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/shaders/ltc_lib.glsl
| /** | /** | ||||
| * Adapted from : | * Adapted from : | ||||
| * Real-Time Polygonal-Light Shading with Linearly Transformed Cosines. | * Real-Time Polygonal-Light Shading with Linearly Transformed Cosines. | ||||
| * Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. | * Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt. | ||||
| * ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016) 35(4), 2016. | * ACM Transactions on Graphics (Proceedings of ACM SIGGRAPH 2016) 35(4), 2016. | ||||
| * Project page: https://eheitzresearch.wordpress.com/415-2/ | * Project page: https://eheitzresearch.wordpress.com/415-2/ | ||||
| **/ | */ | ||||
| #define USE_LTC | #define USE_LTC | ||||
| #ifndef UTIL_TEX | #ifndef UTIL_TEX | ||||
| #define UTIL_TEX | #define UTIL_TEX | ||||
| uniform sampler2DArray utilTex; | uniform sampler2DArray utilTex; | ||||
| #define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0) | #define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0) | ||||
| #endif /* UTIL_TEX */ | #endif /* UTIL_TEX */ | ||||
| Show All 12 Lines | #else | ||||
| return max((form_factor * form_factor + avg_dir_z) / (form_factor + 1.0), 0.0); | return max((form_factor * form_factor + avg_dir_z) / (form_factor + 1.0), 0.0); | ||||
| #endif | #endif | ||||
| } | } | ||||
| /** | /** | ||||
| * An extended version of the implementation from | * An extended version of the implementation from | ||||
| * "How to solve a cubic equation, revisited" | * "How to solve a cubic equation, revisited" | ||||
| * http://momentsingraphics.de/?p=105 | * http://momentsingraphics.de/?p=105 | ||||
| **/ | */ | ||||
| vec3 solve_cubic(vec4 coefs) | vec3 solve_cubic(vec4 coefs) | ||||
| { | { | ||||
| /* Normalize the polynomial */ | /* Normalize the polynomial */ | ||||
| coefs.xyz /= coefs.w; | coefs.xyz /= coefs.w; | ||||
| /* Divide middle coefficients by three */ | /* Divide middle coefficients by three */ | ||||
| coefs.yz /= 3.0; | coefs.yz /= 3.0; | ||||
| float A = coefs.w; | float A = coefs.w; | ||||
| ▲ Show 20 Lines • Show All 266 Lines • Show Last 20 Lines | |||||