ogre-python 14.2.3__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. Ogre/Bites.py +14 -0
  2. Ogre/Bullet.py +14 -0
  3. Ogre/Codec_Assimp.dll +0 -0
  4. Ogre/Codec_STBI.dll +0 -0
  5. Ogre/ImGui.py +12 -0
  6. Ogre/Numpy.py +59 -0
  7. Ogre/Ogre.py +12 -0
  8. Ogre/OgreBites.dll +0 -0
  9. Ogre/OgreBullet.dll +0 -0
  10. Ogre/OgreMain.dll +0 -0
  11. Ogre/OgreOverlay.dll +0 -0
  12. Ogre/OgrePaging.dll +0 -0
  13. Ogre/OgreRTShaderSystem.dll +0 -0
  14. Ogre/OgreTerrain.dll +0 -0
  15. Ogre/Overlay.py +14 -0
  16. Ogre/Plugin_DotScene.dll +0 -0
  17. Ogre/Plugin_GLSLangProgramManager.dll +0 -0
  18. Ogre/Plugin_OctreeSceneManager.dll +0 -0
  19. Ogre/Plugin_ParticleFX.dll +0 -0
  20. Ogre/RTShader.py +14 -0
  21. Ogre/RenderSystem_Direct3D11.dll +0 -0
  22. Ogre/RenderSystem_GL.dll +0 -0
  23. Ogre/RenderSystem_GL3Plus.dll +0 -0
  24. Ogre/RenderSystem_GLES2.dll +0 -0
  25. Ogre/RenderSystem_Tiny.dll +0 -0
  26. Ogre/RenderSystem_Vulkan.dll +0 -0
  27. Ogre/SDL2.dll +0 -0
  28. Ogre/Terrain.py +14 -0
  29. Ogre/_Bites.pyd +0 -0
  30. Ogre/_Bullet.pyd +0 -0
  31. Ogre/_ImGui.pyd +0 -0
  32. Ogre/_Ogre.pyd +0 -0
  33. Ogre/_Overlay.pyd +0 -0
  34. Ogre/_RTShader.pyd +0 -0
  35. Ogre/_Terrain.pyd +0 -0
  36. Ogre/__init__.py +2 -0
  37. Ogre/zlib.dll +0 -0
  38. ogre_python-14.2.3.data/data/Media/Main/DefaultShaders.metal +38 -0
  39. ogre_python-14.2.3.data/data/Media/Main/GLSL_GL3Support.glsl +97 -0
  40. ogre_python-14.2.3.data/data/Media/Main/HLSL_SM4Support.hlsl +98 -0
  41. ogre_python-14.2.3.data/data/Media/Main/OgreUnifiedShader.h +183 -0
  42. ogre_python-14.2.3.data/data/Media/Main/Shadow.material +85 -0
  43. ogre_python-14.2.3.data/data/Media/Main/ShadowBlend.frag +11 -0
  44. ogre_python-14.2.3.data/data/Media/Main/ShadowBlend.vert +12 -0
  45. ogre_python-14.2.3.data/data/Media/Main/ShadowExtrudeDirLight.vert +18 -0
  46. ogre_python-14.2.3.data/data/Media/Main/ShadowExtrudeDirLightFinite.vert +22 -0
  47. ogre_python-14.2.3.data/data/Media/Main/ShadowExtrudePointLight.vert +19 -0
  48. ogre_python-14.2.3.data/data/Media/Main/ShadowExtrudePointLightFinite.vert +22 -0
  49. ogre_python-14.2.3.data/data/Media/Main/ShadowVolumeExtude.program +41 -0
  50. ogre_python-14.2.3.data/data/Media/Main/spot_shadow_fade.dds +0 -0
  51. ogre_python-14.2.3.data/data/Media/RTShaderLib/FFPLib_AlphaTest.glsl +45 -0
  52. ogre_python-14.2.3.data/data/Media/RTShaderLib/FFPLib_Fog.glsl +92 -0
  53. ogre_python-14.2.3.data/data/Media/RTShaderLib/FFPLib_Texturing.glsl +144 -0
  54. ogre_python-14.2.3.data/data/Media/RTShaderLib/FFPLib_Transform.glsl +100 -0
  55. ogre_python-14.2.3.data/data/Media/RTShaderLib/RTSLib_IBL.glsl +88 -0
  56. ogre_python-14.2.3.data/data/Media/RTShaderLib/RTSLib_LTC.glsl +114 -0
  57. ogre_python-14.2.3.data/data/Media/RTShaderLib/RTSLib_Lighting.glsl +18 -0
  58. ogre_python-14.2.3.data/data/Media/RTShaderLib/RTSSamplers.material +17 -0
  59. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_CookTorrance.glsl +246 -0
  60. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_DualQuaternion.glsl +172 -0
  61. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_IntegratedPSSM.glsl +183 -0
  62. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_LayeredBlending.glsl +825 -0
  63. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_NormalMap.glsl +125 -0
  64. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_PerPixelLighting.glsl +172 -0
  65. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_TriplanarTexturing.glsl +47 -0
  66. ogre_python-14.2.3.data/data/Media/RTShaderLib/SGXLib_WBOIT.glsl +19 -0
  67. ogre_python-14.2.3.data/data/Media/RTShaderLib/dfgLUTmultiscatter.dds +0 -0
  68. ogre_python-14.2.3.data/data/Media/RTShaderLib/ltc_1.dds +0 -0
  69. ogre_python-14.2.3.data/data/Media/RTShaderLib/ltc_2.dds +0 -0
  70. ogre_python-14.2.3.data/data/Media/Terrain/TerrainSurface.glsl +83 -0
  71. ogre_python-14.2.3.data/data/Media/Terrain/TerrainTransforms.glsl +36 -0
  72. ogre_python-14.2.3.data/data/Media/packs/SdkTrays.zip +0 -0
  73. ogre_python-14.2.3.data/data/Media/packs/profiler.zip +0 -0
  74. ogre_python-14.2.3.data/data/bin/plugins.cfg +27 -0
  75. ogre_python-14.2.3.data/data/bin/resources.cfg +12 -0
  76. ogre_python-14.2.3.dist-info/AUTHORS +312 -0
  77. ogre_python-14.2.3.dist-info/LICENSE +21 -0
  78. ogre_python-14.2.3.dist-info/METADATA +125 -0
  79. ogre_python-14.2.3.dist-info/RECORD +81 -0
  80. ogre_python-14.2.3.dist-info/WHEEL +5 -0
  81. ogre_python-14.2.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,88 @@
1
+ // This file is part of the OGRE project.
2
+ // code adapted from Google Filament
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ vec3 specularDFG(const PixelParams pixel) {
6
+ return mix(pixel.dfg.xxx, pixel.dfg.yyy, pixel.f0);
7
+ }
8
+
9
+ vec3 decodeDataForIBL(const vec4 data) {
10
+ return data.rgb;
11
+ }
12
+
13
+ vec3 Irradiance_RoughnessOne(samplerCube light_iblSpecular, const vec3 n, float iblRoughnessOneLevel) {
14
+ // note: lod used is always integer, hopefully the hardware skips tri-linear filtering
15
+ return decodeDataForIBL(textureCubeLod(light_iblSpecular, n, iblRoughnessOneLevel));
16
+ }
17
+
18
+ vec3 PrefilteredDFG_LUT(sampler2D light_iblDFG, float lod, float NoV) {
19
+ // coord = sqrt(linear_roughness), which is the mapping used by cmgen.
20
+ // OGRE Specific: y is flipped compared to Filament code
21
+ return texture2DLod(light_iblDFG, vec2(NoV, 1.0 - lod), 0.0).rgb;
22
+ }
23
+
24
+ float perceptualRoughnessToLod(float iblRoughnessOneLevel, float perceptualRoughness) {
25
+ // The mapping below is a quadratic fit for log2(perceptualRoughness)+iblRoughnessOneLevel when
26
+ // iblRoughnessOneLevel is 4. We found empirically that this mapping works very well for
27
+ // a 256 cubemap with 5 levels used. But also scales well for other iblRoughnessOneLevel values.
28
+ return iblRoughnessOneLevel * perceptualRoughness * (2.0 - perceptualRoughness);
29
+ }
30
+
31
+ vec3 prefilteredRadiance(samplerCube light_iblSpecular, const vec3 r, float perceptualRoughness, float iblRoughnessOneLevel) {
32
+ float lod = perceptualRoughnessToLod(iblRoughnessOneLevel, perceptualRoughness);
33
+ return decodeDataForIBL(textureCubeLod(light_iblSpecular, r, lod));
34
+ }
35
+
36
+ vec3 getSpecularDominantDirection(const vec3 n, const vec3 r, float roughness) {
37
+ return mix(r, n, roughness * roughness);
38
+ }
39
+
40
+ void evaluateIBL(inout PixelParams pixel,
41
+ in vec3 vNormal,
42
+ in vec3 viewPos,
43
+ in mat4 invViewMat,
44
+ in sampler2D dfgTex,
45
+ in samplerCube iblEnvTex,
46
+ in float iblRoughnessOneLevel,
47
+ in float iblLuminance,
48
+ inout vec3 color)
49
+ {
50
+ vec3 shading_normal = normalize(vNormal);
51
+ vec3 shading_view = -normalize(viewPos);
52
+ float shading_NoV = clampNoV(abs(dot(shading_normal, shading_view)));
53
+
54
+ // the above is currently duplicated with CookTorrance
55
+
56
+ vec3 shading_reflected = reflect(-shading_view, shading_normal);
57
+
58
+ // Pre-filtered DFG term used for image-based lighting
59
+ pixel.dfg = PrefilteredDFG_LUT(dfgTex, pixel.perceptualRoughness, shading_NoV);
60
+
61
+ vec3 E = specularDFG(pixel);
62
+ vec3 r = getSpecularDominantDirection(shading_normal, shading_reflected, pixel.roughness);
63
+
64
+ // OGRE specific: convert r and n back to world space for texture sampling
65
+ r = normalize(mul(invViewMat, vec4(r, 0.0)).xyz);
66
+ r.z *= -1.0;
67
+ shading_normal = normalize(mul(invViewMat, vec4(shading_normal, 0.0)).xyz);
68
+
69
+ // specular layer
70
+ vec3 Fr = E * prefilteredRadiance(iblEnvTex, r, pixel.perceptualRoughness, iblRoughnessOneLevel);
71
+
72
+ vec3 diffuseIrradiance = Irradiance_RoughnessOne(iblEnvTex, shading_normal, iblRoughnessOneLevel);
73
+ vec3 Fd = pixel.diffuseColor * diffuseIrradiance * (1.0 - E);
74
+
75
+ Fr *= iblLuminance;
76
+ Fd *= iblLuminance;
77
+
78
+ // Combine all terms
79
+ // Note: iblLuminance is already premultiplied by the exposure
80
+
81
+ color = pow(color, vec3_splat(2.2)); // gamma to linear
82
+
83
+ color += Fr + Fd;
84
+
85
+ // linear to gamma
86
+ color = pow(color, vec3_splat(1.0/2.2));
87
+ color = saturate(color);
88
+ }
@@ -0,0 +1,114 @@
1
+ // Real-Time Polygonal-Light Shading with Linearly Transformed Cosines
2
+ // by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt
3
+ // code: https://github.com/selfshadow/ltc_code/
4
+ // also: https://github.com/mrdoob/three.js/blob/master/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js
5
+ // adapted for Ogre by Pavel Rojtberg
6
+
7
+ #define LUT_SIZE 64.0
8
+ #define LUT_SCALE ((LUT_SIZE - 1.0)/LUT_SIZE)
9
+ #define LUT_BIAS (0.5/LUT_SIZE)
10
+
11
+ vec3 IntegrateEdgeVec(vec3 v1, vec3 v2)
12
+ {
13
+ float x = dot(v1, v2);
14
+ float y = abs(x);
15
+
16
+ float a = 0.8543985 + (0.4965155 + 0.0145206*y)*y;
17
+ float b = 3.4175940 + (4.1616724 + y)*y;
18
+ float v = a / b;
19
+
20
+ float theta_sintheta = (x > 0.0) ? v : 0.5*inversesqrt(max(1.0 - x*x, 1e-7)) - v;
21
+
22
+ return cross(v1, v2)*theta_sintheta;
23
+ }
24
+
25
+ float LTC_Evaluate(vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4], sampler2D ltc_2)
26
+ {
27
+ vec3 dir = points[0] - P;
28
+ vec3 lightDir = cross(points[1] - points[0], points[3] - points[0]);
29
+ if(dot(dir, lightDir) < 0.0)
30
+ return 0.0;
31
+
32
+ // construct orthonormal basis around N
33
+ vec3 T1, T2;
34
+ T1 = normalize(V - N*dot(V, N));
35
+ T2 = cross(N, T1);
36
+
37
+ // rotate area light in (T1, T2, N) basis
38
+ Minv = mul(Minv, mtxFromRows(T1, T2, N));
39
+
40
+ // polygon
41
+ vec3 L[4];
42
+ L[0] = mul(Minv, points[0] - P);
43
+ L[1] = mul(Minv, points[1] - P);
44
+ L[2] = mul(Minv, points[2] - P);
45
+ L[3] = mul(Minv, points[3] - P);
46
+
47
+ // project rect onto sphere
48
+ L[0] = normalize(L[0]);
49
+ L[1] = normalize(L[1]);
50
+ L[2] = normalize(L[2]);
51
+ L[3] = normalize(L[3]);
52
+
53
+ vec3 vsum = vec3_splat(0.0);
54
+
55
+ vsum += IntegrateEdgeVec(L[0], L[1]);
56
+ vsum += IntegrateEdgeVec(L[1], L[2]);
57
+ vsum += IntegrateEdgeVec(L[2], L[3]);
58
+ vsum += IntegrateEdgeVec(L[3], L[0]);
59
+
60
+ float len = length(vsum);
61
+ float z = vsum.z/len;
62
+
63
+ // clipless approximation: tabulated horizon-clipped sphere
64
+ // visually better than alternatives, but produces artifacts at low roughness values
65
+ vec2 uv = vec2(z*0.5 + 0.5, len);
66
+ uv = uv*LUT_SCALE + LUT_BIAS;
67
+
68
+ float scale = texture2D(ltc_2, uv).w;
69
+ return len*scale;
70
+ }
71
+
72
+ void InitRectPoints(vec3 center, vec3 ex, vec3 ey, out vec3 points[4])
73
+ {
74
+ points[0] = center - ex - ey;
75
+ points[1] = center + ex - ey;
76
+ points[2] = center + ex + ey;
77
+ points[3] = center - ex + ey;
78
+ }
79
+
80
+ void evaluateRectLight(sampler2D ltc_1, sampler2D ltc_2, float roughness, vec3 N, vec3 pos, vec3 lpos, vec3 halfwidth, vec3 halfheight,
81
+ inout vec3 scol, inout vec3 dcol)
82
+ {
83
+ vec3 points[4];
84
+ InitRectPoints(lpos, halfwidth, halfheight, points);
85
+
86
+ vec3 V = -normalize(pos);
87
+
88
+ float ndotv = saturate(dot(N, V));
89
+ vec2 uv = vec2(roughness, sqrt(1.0 - ndotv));
90
+ uv = uv*LUT_SCALE + LUT_BIAS;
91
+
92
+ vec4 t1 = texture2D(ltc_1, uv);
93
+
94
+ mat3 Minv = mtxFromCols(
95
+ vec3(t1.x, 0.0, t1.y),
96
+ vec3( 0.0, 1.0, 0.0),
97
+ vec3(t1.z, 0.0, t1.w)
98
+ );
99
+
100
+ float spec = LTC_Evaluate(N, V, pos, Minv, points, ltc_2);
101
+
102
+ // LTC Fresnel Approximation by Stephen Hill
103
+ // http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
104
+ vec4 t2 = texture2D(ltc_2, uv);
105
+ scol = (scol*t2.x + (1.0 - scol)*t2.y)*spec;
106
+
107
+ mat3 Meye = mat3(
108
+ vec3(1.0, 0.0, 0.0),
109
+ vec3(0.0, 1.0, 0.0),
110
+ vec3(0.0, 0.0, 1.0)
111
+ );
112
+
113
+ dcol *= LTC_Evaluate(N, V, pos, Meye, points, ltc_2);
114
+ }
@@ -0,0 +1,18 @@
1
+ // This file is part of the OGRE project.
2
+ // It is subject to the license terms in the LICENSE file found in the top-level directory
3
+ // of this distribution and at https://www.ogre3d.org/licensing.
4
+ // SPDX-License-Identifier: MIT
5
+
6
+ #define M_PI 3.14159265359
7
+
8
+ float getDistanceAttenuation(const vec3 params, float distance)
9
+ {
10
+ return 1.0 / (params.x + params.y * distance + params.z * distance * distance);
11
+ }
12
+
13
+ float getAngleAttenuation(const vec3 params, const vec3 lightDir, const vec3 toLight)
14
+ {
15
+ float rho = dot(-lightDir, toLight);
16
+ float fSpotE = saturate((rho - params.y) / (params.x - params.y));
17
+ return pow(fSpotE, params.z);
18
+ }
@@ -0,0 +1,17 @@
1
+ sampler Ogre/ShadowSampler
2
+ {
3
+ tex_address_mode border
4
+ tex_border_colour 1 1 1 1
5
+ }
6
+
7
+ sampler Ogre/DepthShadowSampler : Ogre/ShadowSampler
8
+ {
9
+ compare_test on
10
+ comp_func less_equal
11
+ }
12
+
13
+ sampler Ogre/LtcLUTSampler
14
+ {
15
+ filtering point linear point
16
+ tex_address_mode clamp
17
+ }
@@ -0,0 +1,246 @@
1
+ // This file is part of the OGRE project.
2
+ // code adapted from Google Filament
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ #include "RTSLib_Lighting.glsl"
6
+
7
+ #ifdef HAVE_AREA_LIGHTS
8
+ #include "RTSLib_LTC.glsl"
9
+ #endif
10
+
11
+ #ifdef OGRE_GLSLES
12
+ // min roughness such that (MIN_PERCEPTUAL_ROUGHNESS^4) > 0 in fp16 (i.e. 2^(-14/4), rounded up)
13
+ #define MIN_PERCEPTUAL_ROUGHNESS 0.089
14
+ #else
15
+ #define MIN_PERCEPTUAL_ROUGHNESS 0.045
16
+ #endif
17
+
18
+ #define MEDIUMP_FLT_MAX 65504.0
19
+ #define saturateMediump(x) min(x, MEDIUMP_FLT_MAX)
20
+
21
+ #define MIN_N_DOT_V 1e-4
22
+
23
+ struct PixelParams
24
+ {
25
+ vec3 baseColor;
26
+ vec3 diffuseColor;
27
+ float perceptualRoughness;
28
+ float roughness;
29
+ vec3 f0;
30
+ vec3 dfg;
31
+ vec3 energyCompensation;
32
+ };
33
+
34
+ float clampNoV(float NoV) {
35
+ // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"
36
+ return max(NoV, MIN_N_DOT_V);
37
+ }
38
+
39
+ // Computes x^5 using only multiply operations.
40
+ float pow5(float x) {
41
+ float x2 = x * x;
42
+ return x2 * x2 * x;
43
+ }
44
+
45
+ // https://google.github.io/filament/Filament.md.html#materialsystem/diffusebrdf
46
+ float Fd_Lambert() {
47
+ return 1.0 / M_PI;
48
+ }
49
+
50
+ // https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/fresnel(specularf)
51
+ vec3 F_Schlick(const vec3 f0, float f90, float VoH) {
52
+ // Schlick 1994, "An Inexpensive BRDF Model for Physically-Based Rendering"
53
+ return f0 + (f90 - f0) * pow5(1.0 - VoH);
54
+ }
55
+
56
+ vec3 computeDiffuseColor(const vec3 baseColor, float metallic) {
57
+ return baseColor.rgb * (1.0 - metallic);
58
+ }
59
+
60
+ vec3 computeF0(const vec3 baseColor, float metallic, float reflectance) {
61
+ return baseColor.rgb * metallic + (reflectance * (1.0 - metallic));
62
+ }
63
+
64
+ float perceptualRoughnessToRoughness(float perceptualRoughness) {
65
+ return perceptualRoughness * perceptualRoughness;
66
+ }
67
+
68
+ // https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
69
+ float V_SmithGGXCorrelated(float roughness, float NoV, float NoL) {
70
+ // Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"
71
+ float a2 = roughness * roughness;
72
+ // TODO: lambdaV can be pre-computed for all the lights, it should be moved out of this function
73
+ float lambdaV = NoL * sqrt((NoV - a2 * NoV) * NoV + a2);
74
+ float lambdaL = NoV * sqrt((NoL - a2 * NoL) * NoL + a2);
75
+ float v = 0.5 / (lambdaV + lambdaL);
76
+ // a2=0 => v = 1 / 4*NoL*NoV => min=1/4, max=+inf
77
+ // a2=1 => v = 1 / 2*(NoL+NoV) => min=1/4, max=+inf
78
+ // clamp to the maximum value representable in mediump
79
+ return saturateMediump(v);
80
+ }
81
+
82
+ // https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/normaldistributionfunction(speculard)
83
+ float D_GGX(float roughness, float NoH, const vec3 h, const vec3 n) {
84
+ // Walter et al. 2007, "Microfacet Models for Refraction through Rough Surfaces"
85
+
86
+ // In mediump, there are two problems computing 1.0 - NoH^2
87
+ // 1) 1.0 - NoH^2 suffers floating point cancellation when NoH^2 is close to 1 (highlights)
88
+ // 2) NoH doesn't have enough precision around 1.0
89
+ // Both problem can be fixed by computing 1-NoH^2 in highp and providing NoH in highp as well
90
+
91
+ // However, we can do better using Lagrange's identity:
92
+ // ||a x b||^2 = ||a||^2 ||b||^2 - (a . b)^2
93
+ // since N and H are unit vectors: ||N x H||^2 = 1.0 - NoH^2
94
+ // This computes 1.0 - NoH^2 directly (which is close to zero in the highlights and has
95
+ // enough precision).
96
+ // Overall this yields better performance, keeping all computations in mediump
97
+ #ifdef OGRE_GLSLES
98
+ vec3 NxH = cross(n, h);
99
+ float oneMinusNoHSquared = dot(NxH, NxH);
100
+ #else
101
+ float oneMinusNoHSquared = 1.0 - NoH * NoH;
102
+ #endif
103
+
104
+ float a = NoH * roughness;
105
+ float k = roughness / (oneMinusNoHSquared + a * a);
106
+ float d = k * k * (1.0 / M_PI);
107
+ return saturateMediump(d);
108
+ }
109
+
110
+ vec3 evaluateLight(
111
+ in vec3 vNormal,
112
+ in vec3 viewPos,
113
+ in vec4 lightPos,
114
+ in vec3 lightColor,
115
+ in vec4 pointParams,
116
+ in vec4 vLightDirView,
117
+ in vec4 spotParams,
118
+ in PixelParams pixel)
119
+ {
120
+ vec3 vLightView = lightPos.xyz;
121
+ float fLightD = 0.0;
122
+
123
+ if (lightPos.w != 0.0)
124
+ {
125
+ vLightView -= viewPos; // to light
126
+ fLightD = length(vLightView);
127
+
128
+ if(fLightD > pointParams.x)
129
+ return vec3_splat(0.0);
130
+ }
131
+
132
+ vLightView = normalize(vLightView);
133
+
134
+ vec3 vNormalView = normalize(vNormal);
135
+ float NoL = saturate(dot(vNormalView, vLightView));
136
+
137
+ if(NoL <= 0.0)
138
+ return vec3_splat(0.0); // not lit by this light
139
+
140
+ // https://google.github.io/filament/Filament.md.html#toc5.6.2
141
+ float f90 = saturate(dot(pixel.f0, vec3_splat(50.0 * 0.33)));
142
+
143
+ vec3 vView = -normalize(viewPos);
144
+
145
+ // https://google.github.io/filament/Filament.md.html#materialsystem/standardmodelsummary
146
+ vec3 h = normalize(vView + vLightView);
147
+ float NoH = saturate(dot(vNormalView, h));
148
+ float NoV = clampNoV(abs(dot(vNormalView, vView)));
149
+
150
+ float V = V_SmithGGXCorrelated(pixel.roughness, NoV, NoL);
151
+ vec3 F = F_Schlick(pixel.f0, f90, NoH);
152
+ float D = D_GGX(pixel.roughness, NoH, h, vNormalView);
153
+
154
+ vec3 Fr = (D * V) * F;
155
+ vec3 Fd = pixel.diffuseColor * Fd_Lambert();
156
+
157
+ // https://google.github.io/filament/Filament.md.html#materialsystem/improvingthebrdfs/energylossinspecularreflectance
158
+ vec3 color = NoL * lightColor * (Fr * pixel.energyCompensation + Fd);
159
+
160
+ color *= getDistanceAttenuation(pointParams.yzw, fLightD);
161
+
162
+ if(spotParams.w != 0.0)
163
+ {
164
+ color *= getAngleAttenuation(spotParams.xyz, vLightDirView.xyz, vLightView);
165
+ }
166
+
167
+ return color;
168
+ }
169
+
170
+ void PBR_MakeParams(in vec3 baseColor, in vec2 mrParam, inout PixelParams pixel)
171
+ {
172
+ baseColor = pow(baseColor, vec3_splat(2.2));
173
+ pixel.baseColor = baseColor;
174
+
175
+ float perceptualRoughness = mrParam.x;
176
+ // Clamp the roughness to a minimum value to avoid divisions by 0 during lighting
177
+ pixel.perceptualRoughness = clamp(perceptualRoughness, MIN_PERCEPTUAL_ROUGHNESS, 1.0);
178
+ // Remaps the roughness to a perceptually linear roughness (roughness^2)
179
+ pixel.roughness = perceptualRoughnessToRoughness(pixel.perceptualRoughness);
180
+
181
+ float metallic = saturate(mrParam.y);
182
+ pixel.f0 = computeF0(baseColor, metallic, 0.04);
183
+ pixel.diffuseColor = computeDiffuseColor(baseColor, metallic);
184
+
185
+ pixel.dfg = vec3_splat(0.5); // use full f0 for energy compensation
186
+ pixel.energyCompensation = vec3_splat(0.0); // will be set later
187
+ }
188
+
189
+ #if LIGHT_COUNT > 0
190
+ void PBR_Lights(
191
+ #ifdef SHADOWLIGHT_COUNT
192
+ in float shadowFactor[SHADOWLIGHT_COUNT],
193
+ #endif
194
+ #ifdef HAVE_AREA_LIGHTS
195
+ in sampler2D ltcLUT1,
196
+ in sampler2D ltcLUT2,
197
+ #endif
198
+ in vec3 vNormal,
199
+ in vec3 viewPos,
200
+ in vec4 ambient,
201
+ in vec4 lightPos[LIGHT_COUNT],
202
+ in vec4 lightColor[LIGHT_COUNT],
203
+ in vec4 pointParams[LIGHT_COUNT],
204
+ in vec4 vLightDirView[LIGHT_COUNT],
205
+ in vec4 spotParams[LIGHT_COUNT],
206
+ in PixelParams pixel,
207
+ inout vec3 vOutColour)
208
+ {
209
+ vOutColour = pow(vOutColour, vec3_splat(2.2)); // gamma to linear
210
+
211
+ // Energy compensation for multiple scattering in a microfacet model
212
+ // See "Multiple-Scattering Microfacet BSDFs with the Smith Model"
213
+ pixel.energyCompensation = 1.0 + pixel.f0 * (1.0 / pixel.dfg.y - 1.0);
214
+
215
+ for(int i = 0; i < LIGHT_COUNT; i++)
216
+ {
217
+ #ifdef HAVE_AREA_LIGHTS
218
+ if(spotParams[i].w == 2.0)
219
+ {
220
+ // rect area light
221
+ vec3 dcol = pixel.diffuseColor;
222
+ vec3 scol = pixel.f0;
223
+ evaluateRectLight(ltcLUT1, ltcLUT2, pixel.roughness, normalize(vNormal), viewPos,
224
+ lightPos[i].xyz, spotParams[i].xyz, pointParams[i].xyz, scol, dcol);
225
+ vOutColour += lightColor[i].xyz * (scol + dcol) * 4.0;
226
+ continue;
227
+ }
228
+ #endif
229
+ vec3 lightVal = evaluateLight(vNormal, viewPos, lightPos[i], lightColor[i].xyz, pointParams[i], vLightDirView[i], spotParams[i],
230
+ pixel);
231
+
232
+ #ifdef SHADOWLIGHT_COUNT
233
+ if(i < SHADOWLIGHT_COUNT)
234
+ lightVal *= shadowFactor[i];
235
+ #endif
236
+ vOutColour += lightVal;
237
+ }
238
+
239
+ vOutColour += pixel.baseColor * pow(ambient.rgb, vec3_splat(2.2));
240
+
241
+ // linear to gamma
242
+ vOutColour = pow(vOutColour, vec3_splat(1.0/2.2));
243
+
244
+ vOutColour = saturate(vOutColour);
245
+ }
246
+ #endif
@@ -0,0 +1,172 @@
1
+ /*
2
+ -----------------------------------------------------------------------------
3
+ This source file is part of OGRE
4
+ (Object-oriented Graphics Rendering Engine)
5
+ For the latest info, see http://www.ogre3d.org
6
+
7
+ Copyright (c) 2000-2014 Torus Knot Software Ltd
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+ -----------------------------------------------------------------------------
26
+ */
27
+
28
+ //These functions are based on dqs.cg from http://isg.cs.tcd.ie/kavanl/dq/
29
+ /* dqs.cg
30
+
31
+ Dual quaternion skinning vertex shaders (no shading computations)
32
+
33
+ Version 1.0.3, November 1st, 2007
34
+
35
+ Copyright (C) 2006-2007 University of Dublin, Trinity College, All Rights
36
+ Reserved
37
+
38
+ This software is provided 'as-is', without any express or implied
39
+ warranty. In no event will the author(s) be held liable for any damages
40
+ arising from the use of this software.
41
+
42
+ Permission is granted to anyone to use this software for any purpose,
43
+ including commercial applications, and to alter it and redistribute it
44
+ freely, subject to the following restrictions:
45
+
46
+ 1. The origin of this software must not be misrepresented; you must not
47
+ claim that you wrote the original software. If you use this software
48
+ in a product, an acknowledgment in the product documentation would be
49
+ appreciated but is not required.
50
+ 2. Altered source versions must be plainly marked as such, and must not be
51
+ misrepresented as being the original software.
52
+ 3. This notice may not be removed or altered from any source distribution.
53
+
54
+ Author: Ladislav Kavan, kavanl@cs.tcd.ie
55
+
56
+ */
57
+
58
+ //-----------------------------------------------------------------------------
59
+ // Program Name: SGXLib_DualQuaternion
60
+ // Program Desc: Dual quaternion skinning functions.
61
+ // Program Type: Vertex shader
62
+ // Language: GLSL
63
+ //-----------------------------------------------------------------------------
64
+
65
+ #if defined(OGRE_HLSL) || defined(OGRE_CG)
66
+ // this is technically wrong, thats why we dont put it into OgreUnifiedShader.h
67
+ #define mat2x4 float2x4
68
+ #define mat3x4 float3x4
69
+ #endif
70
+
71
+ //-----------------------------------------------------------------------------
72
+ void SGX_BlendWeight(in float blendWgt, in mat2x4 dualQuaternion, out mat2x4 vOut)
73
+ {
74
+ vOut = blendWgt*dualQuaternion;
75
+ }
76
+
77
+ //-----------------------------------------------------------------------------
78
+ void SGX_BlendWeight(in float blendWgt, in mat3x4 scaleShearMatrix, out mat3x4 vOut)
79
+ {
80
+ vOut = blendWgt*scaleShearMatrix;
81
+ }
82
+
83
+ //-----------------------------------------------------------------------------
84
+ // Adjusts the sign of a dual quaternion depending on its orientation to the root dual quaternion
85
+ void SGX_AntipodalityAdjustment(in mat2x4 dq0, in mat2x4 dq1,out mat2x4 dq2)
86
+ {
87
+ //Accurate antipodality handling. For speed increase, remove the following line,
88
+ //though, the results will only be valid for rotations less than 180 degrees.
89
+ dq2 = (dot(dq0[0], dq1[0]) < 0.0) ? dq1 * -1.0 : dq1;
90
+ }
91
+
92
+ //-----------------------------------------------------------------------------
93
+ void SGX_CalculateBlendPosition(in vec3 position, in mat2x4 blendDQ, out vec4 vOut)
94
+ {
95
+ vec3 blendPosition = position + 2.0*cross(blendDQ[0].yzw, cross(blendDQ[0].yzw, position) + blendDQ[0].x*position);
96
+ vec3 trans = 2.0*(blendDQ[0].x*blendDQ[1].yzw - blendDQ[1].x*blendDQ[0].yzw + cross(blendDQ[0].yzw, blendDQ[1].yzw));
97
+ blendPosition += trans;
98
+
99
+ vOut = vec4(blendPosition, 1.0);
100
+ }
101
+
102
+ //-----------------------------------------------------------------------------
103
+ void SGX_CalculateBlendNormal(in vec3 normal, in mat2x4 blendDQ, out vec3 vOut)
104
+ {
105
+ vOut = normal + 2.0*cross(blendDQ[0].yzw, cross(blendDQ[0].yzw, normal) + blendDQ[0].x*normal);
106
+ }
107
+
108
+ //-----------------------------------------------------------------------------
109
+ void SGX_AdjointTransposeMatrix(in mat3x4 M, out mat3 vOut)
110
+ {
111
+ mat3 atM;
112
+ atM[0][0] = M[2][2] * M[1][1] - M[1][2] * M[2][1];
113
+ atM[0][1] = M[1][2] * M[2][0] - M[1][0] * M[2][2];
114
+ atM[0][2] = M[1][0] * M[2][1] - M[2][0] * M[1][1];
115
+
116
+ atM[1][0] = M[0][2] * M[2][1] - M[2][2] * M[0][1];
117
+ atM[1][1] = M[2][2] * M[0][0] - M[0][2] * M[2][0];
118
+ atM[1][2] = M[2][0] * M[0][1] - M[0][0] * M[2][1];
119
+
120
+ atM[2][0] = M[1][2] * M[0][1] - M[0][2] * M[1][1];
121
+ atM[2][1] = M[1][0] * M[0][2] - M[1][2] * M[0][0];
122
+ atM[2][2] = M[0][0] * M[1][1] - M[1][0] * M[0][1];
123
+
124
+ vOut = atM;
125
+ }
126
+
127
+ //-----------------------------------------------------------------------------
128
+ void blendBonesDQ(mat2x4 bones_dq[BONE_COUNT], vec4 indices, vec4 weights, out mat2x4 blendDQ)
129
+ {
130
+ blendDQ = bones_dq[int(indices.x)] * weights.x;
131
+ mat2x4 dqi;
132
+ #ifdef CORRECT_ANTIPODALITY
133
+ mat2x4 dq0 = blendDQ;
134
+ #endif
135
+ #if WEIGHT_COUNT > 1
136
+ dqi = bones_dq[int(indices.y)] * weights.y;
137
+ # ifdef CORRECT_ANTIPODALITY
138
+ SGX_AntipodalityAdjustment(dq0, dqi, dqi);
139
+ # endif
140
+ blendDQ += dqi;
141
+ #endif
142
+ #if WEIGHT_COUNT > 2
143
+ dqi = bones_dq[int(indices.z)] * weights.z;
144
+ # ifdef CORRECT_ANTIPODALITY
145
+ SGX_AntipodalityAdjustment(dq0, dqi, dqi);
146
+ # endif
147
+ blendDQ += dqi;
148
+ #endif
149
+ #if WEIGHT_COUNT > 3
150
+ dqi = bones_dq[int(indices.w)] * weights.w;
151
+ # ifdef CORRECT_ANTIPODALITY
152
+ SGX_AntipodalityAdjustment(dq0, dqi, dqi);
153
+ # endif
154
+ blendDQ += dqi;
155
+ #endif
156
+
157
+ blendDQ /= length(blendDQ[0]); // normalise dual quaternion
158
+ }
159
+
160
+ void blendBonesMat3x4(mat3x4 bones_mat[BONE_COUNT], vec4 indices, vec4 weights, out mat3x4 blendMat)
161
+ {
162
+ blendMat = bones_mat[int(indices.x)] * weights.x;
163
+ #if WEIGHT_COUNT > 1
164
+ blendMat += bones_mat[int(indices.y)] * weights.y;
165
+ #endif
166
+ #if WEIGHT_COUNT > 2
167
+ blendMat += bones_mat[int(indices.z)] * weights.z;
168
+ #endif
169
+ #if WEIGHT_COUNT > 3
170
+ blendMat += bones_mat[int(indices.w)] * weights.w;
171
+ #endif
172
+ }