ogre-python 14.5.0__cp314-cp314-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.
- Ogre/Bites.py +14 -0
- Ogre/Bullet.py +14 -0
- Ogre/Codec_Assimp.dll +0 -0
- Ogre/Codec_STBI.dll +0 -0
- Ogre/HighPy.py +389 -0
- Ogre/ImGui.py +12 -0
- Ogre/Numpy.py +80 -0
- Ogre/Ogre.py +12 -0
- Ogre/OgreBites.dll +0 -0
- Ogre/OgreBullet.dll +0 -0
- Ogre/OgreMain.dll +0 -0
- Ogre/OgreOverlay.dll +0 -0
- Ogre/OgrePaging.dll +0 -0
- Ogre/OgreRTShaderSystem.dll +0 -0
- Ogre/OgreTerrain.dll +0 -0
- Ogre/Overlay.py +14 -0
- Ogre/Plugin_DotScene.dll +0 -0
- Ogre/Plugin_GLSLangProgramManager.dll +0 -0
- Ogre/Plugin_OctreeSceneManager.dll +0 -0
- Ogre/Plugin_ParticleFX.dll +0 -0
- Ogre/RTShader.py +14 -0
- Ogre/RenderSystem_Direct3D11.dll +0 -0
- Ogre/RenderSystem_GL.dll +0 -0
- Ogre/RenderSystem_GL3Plus.dll +0 -0
- Ogre/RenderSystem_GLES2.dll +0 -0
- Ogre/RenderSystem_Tiny.dll +0 -0
- Ogre/RenderSystem_Vulkan.dll +0 -0
- Ogre/SDL2.dll +0 -0
- Ogre/Terrain.py +14 -0
- Ogre/_Bites.pyd +0 -0
- Ogre/_Bullet.pyd +0 -0
- Ogre/_ImGui.pyd +0 -0
- Ogre/_Ogre.pyd +0 -0
- Ogre/_Overlay.pyd +0 -0
- Ogre/_RTShader.pyd +0 -0
- Ogre/_Terrain.pyd +0 -0
- Ogre/__init__.py +2 -0
- Ogre/zlib.dll +0 -0
- ogre_python-14.5.0.data/data/Media/Main/DefaultShaders.metal +38 -0
- ogre_python-14.5.0.data/data/Media/Main/GLSL_GL3Support.glsl +110 -0
- ogre_python-14.5.0.data/data/Media/Main/HLSL_SM4Support.hlsl +124 -0
- ogre_python-14.5.0.data/data/Media/Main/OgreUnifiedShader.h +201 -0
- ogre_python-14.5.0.data/data/Media/Main/Shadow.material +85 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowBlend.frag +11 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowBlend.vert +12 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudeDirLight.vert +18 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudeDirLightFinite.vert +22 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudePointLight.vert +19 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowExtrudePointLightFinite.vert +22 -0
- ogre_python-14.5.0.data/data/Media/Main/ShadowVolumeExtude.program +41 -0
- ogre_python-14.5.0.data/data/Media/Main/spot_shadow_fade.dds +0 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_AlphaTest.glsl +45 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_Fog.glsl +92 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_Texturing.glsl +150 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/FFPLib_Transform.glsl +100 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_Colour.glsl +16 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_IBL.glsl +90 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_LTC.glsl +114 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSLib_Lighting.glsl +18 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/RTSSamplers.material +18 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_CookTorrance.glsl +238 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_DualQuaternion.glsl +172 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_IntegratedPSSM.glsl +198 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_LayeredBlending.glsl +825 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_NormalMap.glsl +125 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_PerPixelLighting.glsl +183 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_TriplanarTexturing.glsl +47 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/SGXLib_WBOIT.glsl +19 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/dfgLUTmultiscatter.dds +0 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/ltc_1.dds +0 -0
- ogre_python-14.5.0.data/data/Media/RTShaderLib/ltc_2.dds +0 -0
- ogre_python-14.5.0.data/data/Media/Terrain/TerrainSurface.glsl +91 -0
- ogre_python-14.5.0.data/data/Media/Terrain/TerrainTransforms.glsl +36 -0
- ogre_python-14.5.0.data/data/Media/packs/SdkTrays.zip +0 -0
- ogre_python-14.5.0.data/data/Media/packs/profiler.zip +0 -0
- ogre_python-14.5.0.data/data/bin/plugins.cfg +27 -0
- ogre_python-14.5.0.data/data/bin/resources.cfg +12 -0
- ogre_python-14.5.0.dist-info/METADATA +148 -0
- ogre_python-14.5.0.dist-info/RECORD +83 -0
- ogre_python-14.5.0.dist-info/WHEEL +5 -0
- ogre_python-14.5.0.dist-info/licenses/AUTHORS +313 -0
- ogre_python-14.5.0.dist-info/licenses/LICENSE +21 -0
- ogre_python-14.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,238 @@
|
|
|
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, float32_t 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 f32vec3 vNormal,
|
|
112
|
+
in vec3 viewPos,
|
|
113
|
+
in f32vec4 lightPos,
|
|
114
|
+
in vec3 lightColor,
|
|
115
|
+
in vec4 pointParams,
|
|
116
|
+
in vec4 vLightDirView,
|
|
117
|
+
in vec4 spotParams,
|
|
118
|
+
in PixelParams pixel)
|
|
119
|
+
{
|
|
120
|
+
f32vec3 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
|
+
f32vec3 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
|
+
pixel.baseColor = baseColor;
|
|
173
|
+
|
|
174
|
+
float perceptualRoughness = mrParam.x;
|
|
175
|
+
// Clamp the roughness to a minimum value to avoid divisions by 0 during lighting
|
|
176
|
+
pixel.perceptualRoughness = clamp(perceptualRoughness, MIN_PERCEPTUAL_ROUGHNESS, 1.0);
|
|
177
|
+
// Remaps the roughness to a perceptually linear roughness (roughness^2)
|
|
178
|
+
pixel.roughness = perceptualRoughnessToRoughness(pixel.perceptualRoughness);
|
|
179
|
+
|
|
180
|
+
float metallic = saturate(mrParam.y);
|
|
181
|
+
pixel.f0 = computeF0(baseColor, metallic, 0.04); // using fixed IOR of 1.5 as per glTF spec
|
|
182
|
+
pixel.diffuseColor = computeDiffuseColor(baseColor, metallic);
|
|
183
|
+
|
|
184
|
+
pixel.dfg = vec3_splat(0.5); // use full f0 for energy compensation
|
|
185
|
+
pixel.energyCompensation = vec3_splat(0.0); // will be set later
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
#if LIGHT_COUNT > 0
|
|
189
|
+
void PBR_Lights(
|
|
190
|
+
#ifdef SHADOWLIGHT_COUNT
|
|
191
|
+
in float shadowFactor[SHADOWLIGHT_COUNT],
|
|
192
|
+
#endif
|
|
193
|
+
#ifdef HAVE_AREA_LIGHTS
|
|
194
|
+
in sampler2D ltcLUT1,
|
|
195
|
+
in sampler2D ltcLUT2,
|
|
196
|
+
#endif
|
|
197
|
+
in vec3 vNormal,
|
|
198
|
+
in vec3 viewPos,
|
|
199
|
+
in vec4 ambient,
|
|
200
|
+
in f32vec4 lightPos[LIGHT_COUNT],
|
|
201
|
+
in f32vec4 lightColor[LIGHT_COUNT],
|
|
202
|
+
in f32vec4 pointParams[LIGHT_COUNT],
|
|
203
|
+
in f32vec4 vLightDirView[LIGHT_COUNT],
|
|
204
|
+
in f32vec4 spotParams[LIGHT_COUNT],
|
|
205
|
+
in PixelParams pixel,
|
|
206
|
+
inout vec3 vOutColour)
|
|
207
|
+
{
|
|
208
|
+
// Energy compensation for multiple scattering in a microfacet model
|
|
209
|
+
// See "Multiple-Scattering Microfacet BSDFs with the Smith Model"
|
|
210
|
+
pixel.energyCompensation = 1.0 + pixel.f0 * (1.0 / pixel.dfg.y - 1.0);
|
|
211
|
+
|
|
212
|
+
for(int i = 0; i < LIGHT_COUNT; i++)
|
|
213
|
+
{
|
|
214
|
+
#ifdef HAVE_AREA_LIGHTS
|
|
215
|
+
if(spotParams[i].w == 2.0)
|
|
216
|
+
{
|
|
217
|
+
// rect area light
|
|
218
|
+
vec3 dcol = pixel.diffuseColor;
|
|
219
|
+
vec3 scol = pixel.f0;
|
|
220
|
+
evaluateRectLight(ltcLUT1, ltcLUT2, pixel.roughness, normalize(vNormal), viewPos,
|
|
221
|
+
lightPos[i].xyz, spotParams[i].xyz, pointParams[i].xyz, scol, dcol);
|
|
222
|
+
vOutColour += lightColor[i].xyz * (scol + dcol) * 4.0;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
#endif
|
|
226
|
+
vec3 lightVal = evaluateLight(vNormal, viewPos, lightPos[i], lightColor[i].xyz, pointParams[i], vLightDirView[i], spotParams[i],
|
|
227
|
+
pixel);
|
|
228
|
+
|
|
229
|
+
#ifdef SHADOWLIGHT_COUNT
|
|
230
|
+
if(i < SHADOWLIGHT_COUNT)
|
|
231
|
+
lightVal *= shadowFactor[i];
|
|
232
|
+
#endif
|
|
233
|
+
vOutColour += lightVal;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
vOutColour += pixel.baseColor * pow(ambient.rgb, vec3_splat(2.2));
|
|
237
|
+
}
|
|
238
|
+
#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
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
// Program Name: SGXLib_IntegratedPSSM
|
|
29
|
+
// Program Desc: Integrated PSSM functions.
|
|
30
|
+
// Program Type: Vertex/Pixel shader
|
|
31
|
+
// Language: GLSL
|
|
32
|
+
//-----------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
#ifdef PSSM_ARRAY_TEXTURE
|
|
35
|
+
# ifdef PSSM_SAMPLE_CMP
|
|
36
|
+
#define SAMPLER_TYPE sampler2DArrayShadow
|
|
37
|
+
# else
|
|
38
|
+
#define SAMPLER_TYPE sampler2DArray
|
|
39
|
+
# endif
|
|
40
|
+
#define PSSM_LAYER_ARG(x) x,
|
|
41
|
+
#else
|
|
42
|
+
# ifdef PSSM_SAMPLE_CMP
|
|
43
|
+
#define SAMPLER_TYPE sampler2DShadow
|
|
44
|
+
# else
|
|
45
|
+
#define SAMPLER_TYPE sampler2D
|
|
46
|
+
# endif
|
|
47
|
+
#define PSSM_LAYER_ARG(x)
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
// default to 2x2 PCF
|
|
51
|
+
#ifndef PCF_XSAMPLES
|
|
52
|
+
#define PCF_XSAMPLES 2.0
|
|
53
|
+
#endif
|
|
54
|
+
|
|
55
|
+
//-----------------------------------------------------------------------------
|
|
56
|
+
#ifdef SHADOWLIGHT_COUNT
|
|
57
|
+
void SGX_ApplyShadowFactor_Modulative(in vec4 ambient,
|
|
58
|
+
in float fShadowFactor[SHADOWLIGHT_COUNT],
|
|
59
|
+
inout vec4 diffCol
|
|
60
|
+
#ifdef USE_SPECULAR
|
|
61
|
+
, inout vec4 specCol
|
|
62
|
+
#endif
|
|
63
|
+
)
|
|
64
|
+
{
|
|
65
|
+
float shadowFactor = fShadowFactor[0];
|
|
66
|
+
for(int i = 1; i < SHADOWLIGHT_COUNT; ++i)
|
|
67
|
+
shadowFactor *= fShadowFactor[i];
|
|
68
|
+
|
|
69
|
+
diffCol.rgb = mix(ambient.rgb, diffCol.rgb, shadowFactor);
|
|
70
|
+
|
|
71
|
+
#ifdef USE_SPECULAR
|
|
72
|
+
specCol.rgb *= shadowFactor;
|
|
73
|
+
#endif
|
|
74
|
+
}
|
|
75
|
+
#endif
|
|
76
|
+
//-----------------------------------------------------------------------------
|
|
77
|
+
#ifdef PSSM_SAMPLE_COLOUR
|
|
78
|
+
void SGX_ShadowPCF4(in SAMPLER_TYPE shadowMap, in vec4 shadowMapPos, in vec2 invTexSize, PSSM_LAYER_ARG(in float layer) out float c)
|
|
79
|
+
{
|
|
80
|
+
# ifdef PSSM_ARRAY_TEXTURE
|
|
81
|
+
c = texture2DArray(shadowMap, vec3(shadowMapPos.xy/shadowMapPos.w, layer)).x;
|
|
82
|
+
# else
|
|
83
|
+
c = texture2DProj(shadowMap, shadowMapPos).x;
|
|
84
|
+
# endif
|
|
85
|
+
}
|
|
86
|
+
#else
|
|
87
|
+
float sampleDepth(in SAMPLER_TYPE shadowMap, vec2 uv, PSSM_LAYER_ARG(in float layer) float depth)
|
|
88
|
+
{
|
|
89
|
+
#ifdef PSSM_ARRAY_TEXTURE
|
|
90
|
+
// we can assume PSSM_SAMPLE_CMP is always defined when using array textures
|
|
91
|
+
return shadow2D(shadowMap, vec4(uv, layer, depth));
|
|
92
|
+
#elif defined(PSSM_SAMPLE_CMP)
|
|
93
|
+
# if defined(OGRE_GLSL) && OGRE_GLSL < 130
|
|
94
|
+
return shadow2D(shadowMap, vec3(uv, depth)).r;
|
|
95
|
+
# else
|
|
96
|
+
return shadow2D(shadowMap, vec3(uv, depth));
|
|
97
|
+
# endif
|
|
98
|
+
#else
|
|
99
|
+
return (depth <= texture2D(shadowMap, uv).r) ? 1.0 : 0.0;
|
|
100
|
+
#endif
|
|
101
|
+
}
|
|
102
|
+
void SGX_ShadowPCF4(in SAMPLER_TYPE shadowMap, in f32vec4 shadowMapPos, in vec2 invTexSize, PSSM_LAYER_ARG(in float layer) out float c)
|
|
103
|
+
{
|
|
104
|
+
shadowMapPos = shadowMapPos / shadowMapPos.w;
|
|
105
|
+
#if !defined(OGRE_REVERSED_Z) && !defined(OGRE_HLSL) && !defined(VULKAN)
|
|
106
|
+
shadowMapPos.z = shadowMapPos.z * 0.5 + 0.5; // convert -1..1 to 0..1
|
|
107
|
+
#endif
|
|
108
|
+
vec2 uv = shadowMapPos.xy;
|
|
109
|
+
|
|
110
|
+
// depth must be clamped to support floating-point depth formats. This is to avoid comparing a
|
|
111
|
+
// value from the depth texture (which is never greater than 1.0) with a greater-than-one
|
|
112
|
+
// comparison value (which is possible with floating-point formats).
|
|
113
|
+
float depth = clamp(shadowMapPos.z, 0.0, 1.0);
|
|
114
|
+
|
|
115
|
+
c = 0.0;
|
|
116
|
+
float scale = 1.0;
|
|
117
|
+
float offset = (PCF_XSAMPLES / 2.0 - 0.5) * scale;
|
|
118
|
+
for (float y = -offset; y <= offset; y += scale)
|
|
119
|
+
for (float x = -offset; x <= offset; x += scale)
|
|
120
|
+
c += sampleDepth(shadowMap, uv + invTexSize * vec2(x, y), PSSM_LAYER_ARG(layer) depth);
|
|
121
|
+
|
|
122
|
+
c /= PCF_XSAMPLES * PCF_XSAMPLES;
|
|
123
|
+
}
|
|
124
|
+
#endif
|
|
125
|
+
|
|
126
|
+
//-----------------------------------------------------------------------------
|
|
127
|
+
void SGX_ComputeShadowFactor_PSSM3(in float32_t fDepth,
|
|
128
|
+
in vec4 vSplitPoints,
|
|
129
|
+
in vec4 lightPosition0,
|
|
130
|
+
in SAMPLER_TYPE shadowMap0,
|
|
131
|
+
in vec2 invShadowMapSize0,
|
|
132
|
+
#if PSSM_NUM_SPLITS > 2
|
|
133
|
+
in vec4 lightPosition1,
|
|
134
|
+
in SAMPLER_TYPE shadowMap1,
|
|
135
|
+
in vec2 invShadowMapSize1,
|
|
136
|
+
#endif
|
|
137
|
+
#if PSSM_NUM_SPLITS > 3
|
|
138
|
+
in vec4 lightPosition2,
|
|
139
|
+
in SAMPLER_TYPE shadowMap2,
|
|
140
|
+
in vec2 invShadowMapSize2,
|
|
141
|
+
#endif
|
|
142
|
+
in vec4 lightPosition3,
|
|
143
|
+
in SAMPLER_TYPE shadowMap3,
|
|
144
|
+
in vec2 invShadowMapSize3,
|
|
145
|
+
out float oShadowFactor
|
|
146
|
+
#ifdef DEBUG_PSSM
|
|
147
|
+
, out vec4 oDiffuse
|
|
148
|
+
#endif
|
|
149
|
+
)
|
|
150
|
+
{
|
|
151
|
+
#if !defined(OGRE_REVERSED_Z) && !defined(OGRE_HLSL) && !defined(VULKAN)
|
|
152
|
+
vSplitPoints = vSplitPoints * 0.5 + 0.5; // convert -1..1 to 0..1
|
|
153
|
+
#endif
|
|
154
|
+
|
|
155
|
+
#ifdef OGRE_REVERSED_Z
|
|
156
|
+
vSplitPoints = vec4_splat(1.0) - vSplitPoints;
|
|
157
|
+
fDepth = 1.0 - fDepth;
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
if (fDepth <= vSplitPoints.x)
|
|
161
|
+
{
|
|
162
|
+
SGX_ShadowPCF4(shadowMap0, lightPosition0, invShadowMapSize0, PSSM_LAYER_ARG(0.0) oShadowFactor);
|
|
163
|
+
#ifdef DEBUG_PSSM
|
|
164
|
+
oDiffuse.r += 1.0;
|
|
165
|
+
#endif
|
|
166
|
+
}
|
|
167
|
+
#if PSSM_NUM_SPLITS > 2
|
|
168
|
+
else if (fDepth <= vSplitPoints.y)
|
|
169
|
+
{
|
|
170
|
+
SGX_ShadowPCF4(shadowMap1, lightPosition1, invShadowMapSize1, PSSM_LAYER_ARG(1.0) oShadowFactor);
|
|
171
|
+
#ifdef DEBUG_PSSM
|
|
172
|
+
oDiffuse.g += 1.0;
|
|
173
|
+
#endif
|
|
174
|
+
}
|
|
175
|
+
#endif
|
|
176
|
+
#if PSSM_NUM_SPLITS > 3
|
|
177
|
+
else if (fDepth <= vSplitPoints.z)
|
|
178
|
+
{
|
|
179
|
+
SGX_ShadowPCF4(shadowMap2, lightPosition2, invShadowMapSize2, PSSM_LAYER_ARG(2.0) oShadowFactor);
|
|
180
|
+
#ifdef DEBUG_PSSM
|
|
181
|
+
oDiffuse.r += 1.0;
|
|
182
|
+
oDiffuse.g += 1.0;
|
|
183
|
+
#endif
|
|
184
|
+
}
|
|
185
|
+
#endif
|
|
186
|
+
else if (fDepth <= vSplitPoints.w)
|
|
187
|
+
{
|
|
188
|
+
SGX_ShadowPCF4(shadowMap3, lightPosition3, invShadowMapSize3, PSSM_LAYER_ARG(float(PSSM_NUM_SPLITS - 1)) oShadowFactor);
|
|
189
|
+
#ifdef DEBUG_PSSM
|
|
190
|
+
oDiffuse.b += 1.0;
|
|
191
|
+
#endif
|
|
192
|
+
}
|
|
193
|
+
else
|
|
194
|
+
{
|
|
195
|
+
// behind far distance
|
|
196
|
+
oShadowFactor = 1.0;
|
|
197
|
+
}
|
|
198
|
+
}
|