occt-gltf-addon-linux-x64 0.1.1 → 0.1.3
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.
- package/LICENSE_LGPL_21.txt +502 -0
- package/OCCT_LGPL_EXCEPTION.txt +10 -0
- package/README.md +2 -2
- package/index.js +63 -1
- package/lib/libTKBO.so.8.0.0 +0 -0
- package/lib/libTKBRep.so.8.0.0 +0 -0
- package/lib/libTKBin.so.8.0.0 +0 -0
- package/lib/libTKBinL.so.8.0.0 +0 -0
- package/lib/libTKBinTObj.so.8.0.0 +0 -0
- package/lib/libTKBinXCAF.so.8.0.0 +0 -0
- package/lib/libTKBool.so.8.0.0 +0 -0
- package/lib/libTKCAF.so.8.0.0 +0 -0
- package/lib/libTKCDF.so.8.0.0 +0 -0
- package/lib/libTKDE.so.8.0.0 +0 -0
- package/lib/libTKDECascade.so.8.0.0 +0 -0
- package/lib/libTKDEIGES.so.8.0.0 +0 -0
- package/lib/libTKDEOBJ.so.8.0.0 +0 -0
- package/lib/libTKDEPLY.so.8.0.0 +0 -0
- package/lib/libTKDESTEP.so.8.0.0 +0 -0
- package/lib/libTKDESTL.so.8.0.0 +0 -0
- package/lib/libTKDEVRML.so.8.0.0 +0 -0
- package/lib/libTKExpress.so.8.0.0 +0 -0
- package/lib/libTKFeat.so.8.0.0 +0 -0
- package/lib/libTKFillet.so.8.0.0 +0 -0
- package/lib/libTKG2d.so.8.0.0 +0 -0
- package/lib/libTKG3d.so.8.0.0 +0 -0
- package/lib/libTKGeomAlgo.so.8.0.0 +0 -0
- package/lib/libTKGeomBase.so.8.0.0 +0 -0
- package/lib/libTKHLR.so.8.0.0 +0 -0
- package/lib/libTKHelix.so.8.0.0 +0 -0
- package/lib/libTKLCAF.so.8.0.0 +0 -0
- package/lib/libTKMath.so.8.0.0 +0 -0
- package/lib/libTKMesh.so.8.0.0 +0 -0
- package/lib/libTKOffset.so.8.0.0 +0 -0
- package/lib/libTKPrim.so.8.0.0 +0 -0
- package/lib/libTKRWMesh.so.8.0.0 +0 -0
- package/lib/libTKService.so.8.0.0 +0 -0
- package/lib/libTKShHealing.so.8.0.0 +0 -0
- package/lib/libTKStd.so.8.0.0 +0 -0
- package/lib/libTKStdL.so.8.0.0 +0 -0
- package/lib/libTKTObj.so.8.0.0 +0 -0
- package/lib/libTKTopAlgo.so.8.0.0 +0 -0
- package/lib/libTKV3d.so.8.0.0 +0 -0
- package/lib/libTKVCAF.so.8.0.0 +0 -0
- package/lib/libTKXCAF.so.8.0.0 +0 -0
- package/lib/libTKXMesh.so.8.0.0 +0 -0
- package/lib/libTKXSBase.so.8.0.0 +0 -0
- package/lib/libTKXml.so.8.0.0 +0 -0
- package/lib/libTKXmlL.so.8.0.0 +0 -0
- package/lib/libTKXmlTObj.so.8.0.0 +0 -0
- package/lib/libTKXmlXCAF.so.8.0.0 +0 -0
- package/lib/libTKernel.so.8.0.0 +0 -0
- package/lib/libdraco.so.1 +0 -0
- package/lib/libtbb.so.2 +0 -0
- package/lib/libtbbmalloc.so.2 +0 -0
- package/lib/libtbbmalloc_proxy.so.2 +0 -0
- package/occt_gltf_addon.node +0 -0
- package/package.json +6 -2
- package/resources/BOPAlgo/BOPAlgo.msg +129 -0
- package/resources/BOPAlgo/FILES +1 -0
- package/resources/DrawResources/CURVES.tcl +38 -0
- package/resources/DrawResources/CheckCommands.tcl +1206 -0
- package/resources/DrawResources/DrawDefault +130 -0
- package/resources/DrawResources/DrawPlugin +64 -0
- package/resources/DrawResources/DrawTK.tcl +623 -0
- package/resources/DrawResources/FILES +16 -0
- package/resources/DrawResources/Geometry.tcl +96 -0
- package/resources/DrawResources/InitEnvironment.tcl +50 -0
- package/resources/DrawResources/Move.tcl +85 -0
- package/resources/DrawResources/OCC_logo.png +0 -0
- package/resources/DrawResources/PROFIL.tcl +726 -0
- package/resources/DrawResources/SCAN.tcl +192 -0
- package/resources/DrawResources/SURFACES.tcl +35 -0
- package/resources/DrawResources/StandardCommands.tcl +451 -0
- package/resources/DrawResources/StandardViews.tcl +284 -0
- package/resources/DrawResources/TKTopTest.tcl +27 -0
- package/resources/DrawResources/TestCommands.tcl +2969 -0
- package/resources/DrawResources/Vector.tcl +402 -0
- package/resources/DrawResources/dfb_attribns.gif +0 -0
- package/resources/DrawResources/dfb_attribute.gif +0 -0
- package/resources/DrawResources/dfb_folder.gif +0 -0
- package/resources/DrawResources/dftree.tcl +381 -0
- package/resources/DrawResources/lamp.ico +0 -0
- package/resources/SHMessage/FILES +2 -0
- package/resources/SHMessage/SHAPE.fr +267 -0
- package/resources/SHMessage/SHAPE.us +267 -0
- package/resources/Shaders/Declarations.glsl +276 -0
- package/resources/Shaders/DeclarationsImpl.glsl +121 -0
- package/resources/Shaders/Display.fs +157 -0
- package/resources/Shaders/FILES +27 -0
- package/resources/Shaders/LightShadow.glsl +48 -0
- package/resources/Shaders/PBRCookTorrance.glsl +20 -0
- package/resources/Shaders/PBRDirectionalLight.glsl +20 -0
- package/resources/Shaders/PBRDistribution.glsl +9 -0
- package/resources/Shaders/PBREnvBaking.fs +226 -0
- package/resources/Shaders/PBREnvBaking.vs +55 -0
- package/resources/Shaders/PBRFresnel.glsl +36 -0
- package/resources/Shaders/PBRGeometry.glsl +13 -0
- package/resources/Shaders/PBRIllumination.glsl +28 -0
- package/resources/Shaders/PBRPointLight.glsl +27 -0
- package/resources/Shaders/PBRSpotLight.glsl +45 -0
- package/resources/Shaders/PathtraceBase.fs +993 -0
- package/resources/Shaders/PhongDirectionalLight.glsl +29 -0
- package/resources/Shaders/PhongPointLight.glsl +36 -0
- package/resources/Shaders/PhongShading.fs +191 -0
- package/resources/Shaders/PhongShading.vs +43 -0
- package/resources/Shaders/PhongSpotLight.glsl +52 -0
- package/resources/Shaders/PointLightAttenuation.glsl +35 -0
- package/resources/Shaders/RaytraceBase.fs +1236 -0
- package/resources/Shaders/RaytraceBase.vs +12 -0
- package/resources/Shaders/RaytraceRender.fs +134 -0
- package/resources/Shaders/RaytraceSmooth.fs +80 -0
- package/resources/Shaders/SkydomBackground.fs +300 -0
- package/resources/Shaders/TangentSpaceNormal.glsl +17 -0
- package/resources/StdResource/FILES +6 -0
- package/resources/StdResource/MigrationSheet.txt +21 -0
- package/resources/StdResource/Plugin +52 -0
- package/resources/StdResource/Standard +25 -0
- package/resources/StdResource/StandardLite +22 -0
- package/resources/StdResource/TObj +17 -0
- package/resources/StdResource/XCAF +50 -0
- package/resources/TObj/FILES +1 -0
- package/resources/TObj/TObj.msg +85 -0
- package/resources/Textures/1d_elevation.rgb +0 -0
- package/resources/Textures/2d_MatraDatavision.rgb +0 -0
- package/resources/Textures/2d_alienskin.rgb +0 -0
- package/resources/Textures/2d_aluminum.rgb +0 -0
- package/resources/Textures/2d_blue_rock.rgb +0 -0
- package/resources/Textures/2d_bluewhite_paper.rgb +0 -0
- package/resources/Textures/2d_brushed.rgb +0 -0
- package/resources/Textures/2d_bubbles.rgb +0 -0
- package/resources/Textures/2d_bumps.rgb +0 -0
- package/resources/Textures/2d_cast.rgb +0 -0
- package/resources/Textures/2d_chess.rgba +0 -0
- package/resources/Textures/2d_chipbd.rgb +0 -0
- package/resources/Textures/2d_clouds.rgb +0 -0
- package/resources/Textures/2d_flesh.rgb +0 -0
- package/resources/Textures/2d_floor.rgb +0 -0
- package/resources/Textures/2d_galvnisd.rgb +0 -0
- package/resources/Textures/2d_grass.rgb +0 -0
- package/resources/Textures/2d_knurl.rgb +0 -0
- package/resources/Textures/2d_maple.rgb +0 -0
- package/resources/Textures/2d_marble.rgb +0 -0
- package/resources/Textures/2d_mottled.rgb +0 -0
- package/resources/Textures/2d_rain.rgb +0 -0
- package/resources/Textures/2d_rock.rgb +0 -0
- package/resources/Textures/FILES +31 -0
- package/resources/Textures/env_clouds.rgb +0 -0
- package/resources/Textures/env_cv.rgb +0 -0
- package/resources/Textures/env_lines.rgb +0 -0
- package/resources/Textures/env_medit.rgb +0 -0
- package/resources/Textures/env_pearl.rgb +0 -0
- package/resources/Textures/env_road.rgb +0 -0
- package/resources/Textures/env_sky1.rgb +0 -0
- package/resources/Textures/env_sky2.rgb +0 -0
- package/resources/UnitsAPI/CurrentUnits +74 -0
- package/resources/UnitsAPI/FILES +4 -0
- package/resources/UnitsAPI/MDTVBaseUnits +70 -0
- package/resources/UnitsAPI/MDTVCurrentUnits +74 -0
- package/resources/UnitsAPI/Units.dat +481 -0
- package/resources/XRResources/FILES +10 -0
- package/resources/XRResources/occtvr_actions.json +225 -0
- package/resources/XRResources/occtvr_bindings_generic.json +87 -0
- package/resources/XRResources/occtvr_bindings_holographic_hmd.json +18 -0
- package/resources/XRResources/occtvr_bindings_index_hmd.json +18 -0
- package/resources/XRResources/occtvr_bindings_rift.json +18 -0
- package/resources/XRResources/occtvr_bindings_touch.json +160 -0
- package/resources/XRResources/occtvr_bindings_vive.json +18 -0
- package/resources/XRResources/occtvr_bindings_vive_controller.json +139 -0
- package/resources/XRResources/occtvr_bindings_vive_cosmos.json +18 -0
- package/resources/XRResources/occtvr_bindings_vive_pro.json +18 -0
- package/resources/XSMessage/FILES +2 -0
- package/resources/XSMessage/XSTEP.fr +1026 -0
- package/resources/XSMessage/XSTEP.us +1023 -0
- package/resources/XSTEPResource/FILES +2 -0
- package/resources/XSTEPResource/IGES +65 -0
- package/resources/XSTEPResource/STEP +68 -0
- package/resources/XmlOcafResource/FILES +11 -0
- package/resources/XmlOcafResource/XmlOcaf.xsd +131 -0
- package/resources/XmlOcafResource/XmlOcaf_SmallTypes.xsd +217 -0
- package/resources/XmlOcafResource/XmlOcaf_TDF.xsd +33 -0
- package/resources/XmlOcafResource/XmlOcaf_TDataStd.xsd +230 -0
- package/resources/XmlOcafResource/XmlOcaf_TDataStd_Name.xsd +37 -0
- package/resources/XmlOcafResource/XmlOcaf_TDocStd.xsd +37 -0
- package/resources/XmlOcafResource/XmlOcaf_TFunction.xsd +38 -0
- package/resources/XmlOcafResource/XmlOcaf_TNaming.xsd +128 -0
- package/resources/XmlOcafResource/XmlOcaf_TNaming_NamedShape.xsd +97 -0
- package/resources/XmlOcafResource/XmlOcaf_TPrsStd.xsd +42 -0
- package/resources/XmlOcafResource/XmlXcaf.xsd +109 -0
- package/resources/samples/tcl/ANC101.tcl +282 -0
- package/resources/samples/tcl/DataExchangeDemo.tcl +85 -0
- package/resources/samples/tcl/MBBGehauseRohteil.tcl +268 -0
- package/resources/samples/tcl/ModelingDemo.tcl +120 -0
- package/resources/samples/tcl/Penrose.tcl +87 -0
- package/resources/samples/tcl/Readme.txt +4 -0
- package/resources/samples/tcl/VisualizationDemo.tcl +162 -0
- package/resources/samples/tcl/bottle.tcl +115 -0
- package/resources/samples/tcl/cad.tcl +63 -0
- package/resources/samples/tcl/cpu.tcl +327 -0
- package/resources/samples/tcl/cutter.tcl +91 -0
- package/resources/samples/tcl/dimensions.tcl +83 -0
- package/resources/samples/tcl/drill.tcl +147 -0
- package/resources/samples/tcl/logo2019.tcl +89 -0
- package/resources/samples/tcl/markers.tcl +76 -0
- package/resources/samples/tcl/materials.tcl +75 -0
- package/resources/samples/tcl/pathtrace_ball.tcl +79 -0
- package/resources/samples/tcl/pathtrace_cube.tcl +85 -0
- package/resources/samples/tcl/pathtrace_materials.tcl +229 -0
- package/resources/samples/tcl/pencil.tcl +64 -0
- package/resources/samples/tcl/raytrace.tcl +44 -0
- package/resources/samples/tcl/snowflake.tcl +161 -0
- package/resources/samples/tcl/spheres.tcl +148 -0
- package/resources/samples/tcl/vis_pbr_spheres.tcl +94 -0
- package/resources/samples/tcl/xde.tcl +47 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#ifdef ADAPTIVE_SAMPLING
|
|
2
|
+
|
|
3
|
+
#extension GL_ARB_shader_image_load_store : require
|
|
4
|
+
|
|
5
|
+
#extension GL_ARB_shader_image_size : enable
|
|
6
|
+
|
|
7
|
+
//! OpenGL image used for accumulating rendering result.
|
|
8
|
+
volatile restrict layout(r32f) uniform image2D uRenderImage;
|
|
9
|
+
|
|
10
|
+
//! OpenGL image storing variance of sampled pixels blocks.
|
|
11
|
+
volatile restrict layout(r32i) uniform iimage2D uVarianceImage;
|
|
12
|
+
|
|
13
|
+
//! Scale factor used to quantize visual error (float) into signed integer.
|
|
14
|
+
uniform float uVarianceScaleFactor;
|
|
15
|
+
|
|
16
|
+
//! Screen space tile size.
|
|
17
|
+
uniform ivec2 uTileSize;
|
|
18
|
+
|
|
19
|
+
#else // ADAPTIVE_SAMPLING
|
|
20
|
+
|
|
21
|
+
//! Input image.
|
|
22
|
+
uniform sampler2D uInputTexture;
|
|
23
|
+
|
|
24
|
+
//! Ray tracing depth image.
|
|
25
|
+
uniform sampler2D uDepthTexture;
|
|
26
|
+
|
|
27
|
+
#endif // ADAPTIVE_SAMPLING
|
|
28
|
+
|
|
29
|
+
//! Number of accumulated frames.
|
|
30
|
+
uniform int uAccumFrames;
|
|
31
|
+
|
|
32
|
+
//! Is debug mode enabled for importance screen sampling.
|
|
33
|
+
uniform int uDebugAdaptive;
|
|
34
|
+
|
|
35
|
+
//! Exposure value for tone mapping.
|
|
36
|
+
uniform float uExposure;
|
|
37
|
+
|
|
38
|
+
#ifdef TONE_MAPPING_FILMIC
|
|
39
|
+
|
|
40
|
+
//! White point value for filmic tone mapping.
|
|
41
|
+
uniform float uWhitePoint;
|
|
42
|
+
|
|
43
|
+
#endif // TONE_MAPPING
|
|
44
|
+
|
|
45
|
+
//! Output pixel color.
|
|
46
|
+
out vec4 OutColor;
|
|
47
|
+
|
|
48
|
+
//! RGB weight factors to calculate luminance.
|
|
49
|
+
#define LUMA vec3 (0.2126f, 0.7152f, 0.0722f)
|
|
50
|
+
|
|
51
|
+
// =======================================================================
|
|
52
|
+
// function : ToneMappingFilmic
|
|
53
|
+
// purpose :
|
|
54
|
+
// =======================================================================
|
|
55
|
+
vec4 ToneMappingFilmic(vec4 theColor, float theWhitePoint)
|
|
56
|
+
{
|
|
57
|
+
vec4 aPackColor = vec4 (theColor.rgb, theWhitePoint);
|
|
58
|
+
vec4 aFilmicCurve = 1.425f * aPackColor + vec4 (0.05f);
|
|
59
|
+
vec4 aResultColor = (aPackColor * aFilmicCurve + vec4 (0.004f)) / (aPackColor * (aFilmicCurve + vec4 (0.55f)) + vec4 (0.0491f)) - vec4 (0.0821f);
|
|
60
|
+
return vec4 (aResultColor.rgb / aResultColor.www, 1.0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// =======================================================================
|
|
64
|
+
// function : main
|
|
65
|
+
// purpose :
|
|
66
|
+
// =======================================================================
|
|
67
|
+
void main (void)
|
|
68
|
+
{
|
|
69
|
+
#ifndef ADAPTIVE_SAMPLING
|
|
70
|
+
|
|
71
|
+
vec4 aColor = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0);
|
|
72
|
+
|
|
73
|
+
#ifdef PATH_TRACING
|
|
74
|
+
float aDepth = aColor.w; // path tracing uses averaged depth
|
|
75
|
+
#else
|
|
76
|
+
float aDepth = texelFetch (uDepthTexture, ivec2 (gl_FragCoord.xy), 0).r;
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
gl_FragDepth = aDepth;
|
|
80
|
+
|
|
81
|
+
#else // ADAPTIVE_SAMPLING
|
|
82
|
+
|
|
83
|
+
ivec2 aPixel = ivec2 (gl_FragCoord.xy);
|
|
84
|
+
|
|
85
|
+
vec4 aColor = vec4 (0.0);
|
|
86
|
+
|
|
87
|
+
// fetch accumulated color and total number of samples
|
|
88
|
+
aColor.x = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 0,
|
|
89
|
+
2 * aPixel.y + 0)).x;
|
|
90
|
+
aColor.y = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 1,
|
|
91
|
+
2 * aPixel.y + 0)).x;
|
|
92
|
+
aColor.z = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 1,
|
|
93
|
+
2 * aPixel.y + 1)).x;
|
|
94
|
+
aColor.w = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 0,
|
|
95
|
+
2 * aPixel.y + 1)).x;
|
|
96
|
+
|
|
97
|
+
// calculate normalization factor
|
|
98
|
+
float aSampleWeight = 1.f / max (1.0, aColor.w);
|
|
99
|
+
|
|
100
|
+
// calculate averaged depth value
|
|
101
|
+
gl_FragDepth = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 2,
|
|
102
|
+
2 * aPixel.y + 1)).x * aSampleWeight;
|
|
103
|
+
|
|
104
|
+
// calculate averaged radiance for all samples and even samples only
|
|
105
|
+
float aHalfRad = imageLoad (uRenderImage, ivec2 (3 * aPixel.x + 2,
|
|
106
|
+
2 * aPixel.y + 0)).x * aSampleWeight * 2.f;
|
|
107
|
+
|
|
108
|
+
float aAverRad = dot (aColor.rgb, LUMA) * aSampleWeight;
|
|
109
|
+
|
|
110
|
+
// apply our 'tone mapping' operator (gamma correction and clamping)
|
|
111
|
+
aHalfRad = min (1.f, sqrt (aHalfRad));
|
|
112
|
+
aAverRad = min (1.f, sqrt (aAverRad));
|
|
113
|
+
|
|
114
|
+
// calculate visual error
|
|
115
|
+
float anError = (aAverRad - aHalfRad) * (aAverRad - aHalfRad);
|
|
116
|
+
|
|
117
|
+
// accumulate visual error to current block; estimated error is written only
|
|
118
|
+
// after the first 40 samples and path length has reached 10 bounces or more
|
|
119
|
+
imageAtomicAdd (uVarianceImage, aPixel / uTileSize,
|
|
120
|
+
int (mix (uVarianceScaleFactor, anError * uVarianceScaleFactor, aColor.w > 40.f)));
|
|
121
|
+
|
|
122
|
+
if (uDebugAdaptive == 0) // normal rendering
|
|
123
|
+
{
|
|
124
|
+
aColor = vec4 (aColor.rgb * aSampleWeight, 1.0);
|
|
125
|
+
}
|
|
126
|
+
else // showing number of samples
|
|
127
|
+
{
|
|
128
|
+
vec2 aRatio = vec2 (1.f, 1.f);
|
|
129
|
+
#ifdef GL_ARB_shader_image_size
|
|
130
|
+
aRatio = vec2 (imageSize (uRenderImage)) / vec2 (3.f * 512.f, 2.f * 512.f);
|
|
131
|
+
#endif
|
|
132
|
+
aColor = vec4 (0.5f * aColor.rgb * aSampleWeight + vec3 (0.f, sqrt (aRatio.x * aRatio.y) * aColor.w / uAccumFrames * 0.35f, 0.f), 1.0);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#endif // ADAPTIVE_SAMPLING
|
|
136
|
+
|
|
137
|
+
#ifdef PATH_TRACING
|
|
138
|
+
|
|
139
|
+
aColor *= pow (2.0, uExposure);
|
|
140
|
+
|
|
141
|
+
#ifdef TONE_MAPPING_FILMIC
|
|
142
|
+
aColor = ToneMappingFilmic (aColor, uWhitePoint);
|
|
143
|
+
#endif // TONE_MAPPING
|
|
144
|
+
|
|
145
|
+
#ifdef THE_SHIFT_sRGB
|
|
146
|
+
// apply gamma correction (we use gamma = 2)
|
|
147
|
+
OutColor = vec4 (sqrt (aColor.rgb), 0.f);
|
|
148
|
+
#else
|
|
149
|
+
OutColor = vec4 (aColor.rgb, 0.f);
|
|
150
|
+
#endif
|
|
151
|
+
|
|
152
|
+
#else // not PATH_TRACING
|
|
153
|
+
|
|
154
|
+
OutColor = aColor;
|
|
155
|
+
|
|
156
|
+
#endif
|
|
157
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
srcinc:::Declarations.glsl
|
|
2
|
+
srcinc:::DeclarationsImpl.glsl
|
|
3
|
+
srcinc:::LightShadow.glsl
|
|
4
|
+
srcinc:::PBRCookTorrance.glsl
|
|
5
|
+
srcinc:::PBRDirectionalLight.glsl
|
|
6
|
+
srcinc:::PBRDistribution.glsl
|
|
7
|
+
srcinc:::PBREnvBaking.fs
|
|
8
|
+
srcinc:::PBREnvBaking.vs
|
|
9
|
+
srcinc:::PBRFresnel.glsl
|
|
10
|
+
srcinc:::PBRGeometry.glsl
|
|
11
|
+
srcinc:::PBRIllumination.glsl
|
|
12
|
+
srcinc:::PBRPointLight.glsl
|
|
13
|
+
srcinc:::PBRSpotLight.glsl
|
|
14
|
+
srcinc:::PhongShading.fs
|
|
15
|
+
srcinc:::PhongShading.vs
|
|
16
|
+
srcinc:::PhongDirectionalLight.glsl
|
|
17
|
+
srcinc:::PhongPointLight.glsl
|
|
18
|
+
srcinc:::PhongSpotLight.glsl
|
|
19
|
+
srcinc:::PointLightAttenuation.glsl
|
|
20
|
+
srcinc:::Display.fs
|
|
21
|
+
srcinc:::RaytraceBase.fs
|
|
22
|
+
srcinc:::RaytraceRender.fs
|
|
23
|
+
srcinc:::PathtraceBase.fs
|
|
24
|
+
srcinc:::RaytraceBase.vs
|
|
25
|
+
srcinc:::RaytraceSmooth.fs
|
|
26
|
+
srcinc:::TangentSpaceNormal.glsl
|
|
27
|
+
srcinc:::SkydomBackground.fs
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#if (__VERSION__ >= 120)
|
|
2
|
+
//! Coefficients for gathering close samples for antialiasing.
|
|
3
|
+
//! Use only with decent OpenGL (array constants cannot be initialized with GLSL 1.1 / GLSL ES 1.1)
|
|
4
|
+
const vec2 occPoissonDisk16[16] = vec2[](
|
|
5
|
+
vec2(-0.94201624,-0.39906216), vec2( 0.94558609,-0.76890725), vec2(-0.09418410,-0.92938870), vec2( 0.34495938, 0.29387760),
|
|
6
|
+
vec2(-0.91588581, 0.45771432), vec2(-0.81544232,-0.87912464), vec2(-0.38277543, 0.27676845), vec2( 0.97484398, 0.75648379),
|
|
7
|
+
vec2( 0.44323325,-0.97511554), vec2( 0.53742981,-0.47373420), vec2(-0.26496911,-0.41893023), vec2( 0.79197514, 0.19090188),
|
|
8
|
+
vec2(-0.24188840, 0.99706507), vec2(-0.81409955, 0.91437590), vec2( 0.19984126, 0.78641367), vec2( 0.14383161,-0.14100790)
|
|
9
|
+
);
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
//! Function computes directional and spot light shadow attenuation (1.0 means no shadow).
|
|
13
|
+
float occLightShadow (in sampler2D theShadow,
|
|
14
|
+
in int theId,
|
|
15
|
+
in vec3 theNormal)
|
|
16
|
+
{
|
|
17
|
+
vec4 aPosLightSpace = PosLightSpace[occLight_Index(theId)];
|
|
18
|
+
vec3 aLightDir = occLight_Position (theId);
|
|
19
|
+
vec3 aProjCoords = (aPosLightSpace.xyz / aPosLightSpace.w);
|
|
20
|
+
#ifdef THE_ZERO_TO_ONE_DEPTH
|
|
21
|
+
aProjCoords.xy = aProjCoords.xy * 0.5 + vec2 (0.5);
|
|
22
|
+
#else
|
|
23
|
+
aProjCoords = aProjCoords * 0.5 + vec3 (0.5);
|
|
24
|
+
#endif
|
|
25
|
+
float aCurrentDepth = aProjCoords.z;
|
|
26
|
+
if (aProjCoords.x < 0.0 || aProjCoords.x > 1.0
|
|
27
|
+
|| aProjCoords.y < 0.0 || aProjCoords.y > 1.0
|
|
28
|
+
|| aCurrentDepth > 1.0)
|
|
29
|
+
{
|
|
30
|
+
return 1.0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
vec2 aTexelSize = vec2 (occShadowMapSizeBias.x);
|
|
34
|
+
float aBias = max (occShadowMapSizeBias.y * (1.0 - dot (theNormal, aLightDir)), occShadowMapSizeBias.y * 0.1);
|
|
35
|
+
#if (__VERSION__ >= 120)
|
|
36
|
+
float aShadow = 0.0;
|
|
37
|
+
for (int aPosIter = 0; aPosIter < 16; ++aPosIter)
|
|
38
|
+
{
|
|
39
|
+
float aClosestDepth = occTexture2D (theShadow, aProjCoords.xy + occPoissonDisk16[aPosIter] * aTexelSize).r;
|
|
40
|
+
aShadow += (aCurrentDepth - aBias) > aClosestDepth ? 1.0 : 0.0;
|
|
41
|
+
}
|
|
42
|
+
return 1.0 - aShadow / 16.0;
|
|
43
|
+
#else
|
|
44
|
+
float aClosestDepth = occTexture2D (theShadow, aProjCoords.xy).r;
|
|
45
|
+
float aShadow = (aCurrentDepth - aBias) > aClosestDepth ? 1.0 : 0.0;
|
|
46
|
+
return 1.0 - aShadow;
|
|
47
|
+
#endif
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//! Calculates Cook-Torrance BRDF.
|
|
2
|
+
vec3 occPBRCookTorrance (in vec3 theView,
|
|
3
|
+
in vec3 theLight,
|
|
4
|
+
in vec3 theNormal,
|
|
5
|
+
in vec3 theBaseColor,
|
|
6
|
+
in float theMetallic,
|
|
7
|
+
in float theRoughness,
|
|
8
|
+
in float theIOR)
|
|
9
|
+
{
|
|
10
|
+
vec3 aHalf = normalize (theView + theLight);
|
|
11
|
+
float aCosV = max(dot(theView, theNormal), 0.0);
|
|
12
|
+
float aCosL = max(dot(theLight, theNormal), 0.0);
|
|
13
|
+
float aCosH = max(dot(aHalf, theNormal), 0.0);
|
|
14
|
+
float aCosVH = max(dot(aHalf, theView), 0.0);
|
|
15
|
+
vec3 aCookTorrance = occPBRDistribution (aCosH, theRoughness)
|
|
16
|
+
* occPBRGeometry (aCosV, aCosL, theRoughness)
|
|
17
|
+
* occPBRFresnel (theBaseColor, theMetallic, theIOR, aCosVH);
|
|
18
|
+
aCookTorrance /= 4.0;
|
|
19
|
+
return aCookTorrance;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//! Function computes contribution of directional light source
|
|
2
|
+
//! into global variable DirectLighting (PBR shading).
|
|
3
|
+
//! @param theId light source index
|
|
4
|
+
//! @param theNormal surface normal
|
|
5
|
+
//! @param theView view direction
|
|
6
|
+
//! @param theIsFront front/back face flag
|
|
7
|
+
//! @param theShadow shadow attenuation
|
|
8
|
+
void occDirectionalLight (in int theId,
|
|
9
|
+
in vec3 theNormal,
|
|
10
|
+
in vec3 theView,
|
|
11
|
+
in bool theIsFront,
|
|
12
|
+
in float theShadow)
|
|
13
|
+
{
|
|
14
|
+
vec3 aLight = occLight_Position (theId);
|
|
15
|
+
theNormal = theIsFront ? theNormal : -theNormal;
|
|
16
|
+
DirectLighting += occPBRIllumination (theView, aLight, theNormal,
|
|
17
|
+
BaseColor, Metallic, Roughness, IOR,
|
|
18
|
+
occLight_Specular (theId),
|
|
19
|
+
occLight_Intensity(theId)) * theShadow;
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//! Calculates micro facet normals distribution.
|
|
2
|
+
float occPBRDistribution (in float theCosH,
|
|
3
|
+
in float theRoughness)
|
|
4
|
+
{
|
|
5
|
+
float aDistribution = theRoughness * theRoughness;
|
|
6
|
+
aDistribution = aDistribution / (theCosH * theCosH * (aDistribution * aDistribution - 1.0) + 1.0);
|
|
7
|
+
aDistribution = INV_PI * aDistribution * aDistribution;
|
|
8
|
+
return aDistribution;
|
|
9
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
THE_SHADER_IN vec3 ViewDirection; //!< direction of fetching from environment cubemap
|
|
2
|
+
|
|
3
|
+
#if (__VERSION__ >= 120)
|
|
4
|
+
uniform int uSamplesNum; //!< number of samples in Monte-Carlo integration
|
|
5
|
+
#else
|
|
6
|
+
const int uSamplesNum = 256;
|
|
7
|
+
#endif
|
|
8
|
+
uniform samplerCube uEnvMap; //!< source of baking (environment cubemap)
|
|
9
|
+
|
|
10
|
+
#ifdef THE_TO_BAKE_DIFFUSE
|
|
11
|
+
uniform int uYCoeff; //!< coefficient of Y controlling horizontal flip of cubemap
|
|
12
|
+
uniform int uZCoeff; //!< coefficient of Z controlling vertical flip of cubemap
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
#ifdef THE_TO_BAKE_SPECULAR
|
|
16
|
+
uniform int uCurrentLevel; //!< current level of specular IBL map (ignored in case of diffuse map's processing)
|
|
17
|
+
uniform float uEnvSolidAngleSource; //!< source solid angle sample computed from one edge's size of source environment map's zero mipmap level
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
//! Returns coordinates of point theNumber from Hammersley point set having size theSize.
|
|
21
|
+
vec2 hammersley (in int theNumber,
|
|
22
|
+
in int theSize)
|
|
23
|
+
{
|
|
24
|
+
int aDenominator = 2;
|
|
25
|
+
int aNumber = theNumber;
|
|
26
|
+
float aVanDerCorput = 0.0;
|
|
27
|
+
for (int i = 0; i < 32; ++i)
|
|
28
|
+
{
|
|
29
|
+
if (aNumber > 0)
|
|
30
|
+
{
|
|
31
|
+
aVanDerCorput += mod(float(aNumber), 2.0) / float(aDenominator);
|
|
32
|
+
aNumber /= 2;
|
|
33
|
+
aDenominator *= 2;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return vec2(float(theNumber) / float(theSize), aVanDerCorput);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//! This function does importance sampling on hemisphere surface using GGX normal distribution function
|
|
40
|
+
//! in tangent space (positive z axis is surface normal direction).
|
|
41
|
+
vec3 importanceSample (in vec2 theHammersleyPoint,
|
|
42
|
+
in float theRoughness)
|
|
43
|
+
{
|
|
44
|
+
float aPhi = PI_2 * theHammersleyPoint.x;
|
|
45
|
+
theRoughness *= theRoughness;
|
|
46
|
+
theRoughness *= theRoughness;
|
|
47
|
+
float aCosTheta = sqrt((1.0 - theHammersleyPoint.y) / (1.0 + (theRoughness - 1.0) * theHammersleyPoint.y));
|
|
48
|
+
float aSinTheta = sqrt(1.0 - aCosTheta * aCosTheta);
|
|
49
|
+
return vec3(aSinTheta * cos(aPhi),
|
|
50
|
+
aSinTheta * sin(aPhi),
|
|
51
|
+
aCosTheta);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//! This function uniformly generates samples on whole sphere.
|
|
55
|
+
vec3 sphereUniformSample (in vec2 theHammersleyPoint)
|
|
56
|
+
{
|
|
57
|
+
float aPhi = PI_2 * theHammersleyPoint.x;
|
|
58
|
+
float aCosTheta = 2.0 * theHammersleyPoint.y - 1.0;
|
|
59
|
+
float aSinTheta = sqrt(1.0 - aCosTheta * aCosTheta);
|
|
60
|
+
return vec3(aSinTheta * cos(aPhi),
|
|
61
|
+
aSinTheta * sin(aPhi),
|
|
62
|
+
aCosTheta);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//! Transforms resulted sampled direction from tangent space to world space considering the surface normal.
|
|
66
|
+
vec3 fromTangentSpace (in vec3 theVector,
|
|
67
|
+
in vec3 theNormal)
|
|
68
|
+
{
|
|
69
|
+
vec3 anUp = (abs(theNormal.z) < 0.999) ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
|
70
|
+
vec3 anX = normalize(cross(anUp, theNormal));
|
|
71
|
+
vec3 anY = cross(theNormal, anX);
|
|
72
|
+
return anX * theVector.x + anY * theVector.y + theNormal * theVector.z;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#ifdef THE_TO_BAKE_DIFFUSE
|
|
76
|
+
#if (__VERSION__ >= 120)
|
|
77
|
+
const float aSHBasisFuncCoeffs[9] = float[9]
|
|
78
|
+
(
|
|
79
|
+
0.282095 * 0.282095,
|
|
80
|
+
0.488603 * 0.488603,
|
|
81
|
+
0.488603 * 0.488603,
|
|
82
|
+
0.488603 * 0.488603,
|
|
83
|
+
1.092548 * 1.092548,
|
|
84
|
+
1.092548 * 1.092548,
|
|
85
|
+
1.092548 * 1.092548,
|
|
86
|
+
0.315392 * 0.315392,
|
|
87
|
+
0.546274 * 0.546274
|
|
88
|
+
);
|
|
89
|
+
const float aSHCosCoeffs[9] = float[9]
|
|
90
|
+
(
|
|
91
|
+
3.141593,
|
|
92
|
+
2.094395,
|
|
93
|
+
2.094395,
|
|
94
|
+
2.094395,
|
|
95
|
+
0.785398,
|
|
96
|
+
0.785398,
|
|
97
|
+
0.785398,
|
|
98
|
+
0.785398,
|
|
99
|
+
0.785398
|
|
100
|
+
);
|
|
101
|
+
#else
|
|
102
|
+
uniform float aSHBasisFuncCoeffs[9];
|
|
103
|
+
uniform float aSHCosCoeffs[9];
|
|
104
|
+
#endif
|
|
105
|
+
|
|
106
|
+
//! Bakes diffuse IBL map's spherical harmonics coefficients.
|
|
107
|
+
vec3 bakeDiffuseSH()
|
|
108
|
+
{
|
|
109
|
+
int anId = int(gl_FragCoord.x);
|
|
110
|
+
float aCoef;
|
|
111
|
+
#if (__VERSION__ >= 120)
|
|
112
|
+
aCoef = aSHCosCoeffs[anId] * aSHBasisFuncCoeffs[anId];
|
|
113
|
+
#else
|
|
114
|
+
if (anId == 0) { aCoef = aSHCosCoeffs[0] * aSHBasisFuncCoeffs[0]; }
|
|
115
|
+
else if (anId == 1) { aCoef = aSHCosCoeffs[1] * aSHBasisFuncCoeffs[1]; }
|
|
116
|
+
else if (anId == 2) { aCoef = aSHCosCoeffs[2] * aSHBasisFuncCoeffs[2]; }
|
|
117
|
+
else if (anId == 3) { aCoef = aSHCosCoeffs[3] * aSHBasisFuncCoeffs[3]; }
|
|
118
|
+
else if (anId == 4) { aCoef = aSHCosCoeffs[4] * aSHBasisFuncCoeffs[4]; }
|
|
119
|
+
else if (anId == 5) { aCoef = aSHCosCoeffs[5] * aSHBasisFuncCoeffs[5]; }
|
|
120
|
+
else if (anId == 6) { aCoef = aSHCosCoeffs[6] * aSHBasisFuncCoeffs[6]; }
|
|
121
|
+
else if (anId == 7) { aCoef = aSHCosCoeffs[7] * aSHBasisFuncCoeffs[7]; }
|
|
122
|
+
else { aCoef = aSHCosCoeffs[8] * aSHBasisFuncCoeffs[8]; }
|
|
123
|
+
#endif
|
|
124
|
+
vec3 aRes = vec3 (0.0);
|
|
125
|
+
for (int aSampleIter = 0; aSampleIter < uSamplesNum; ++aSampleIter)
|
|
126
|
+
{
|
|
127
|
+
vec2 aHammersleyPoint = hammersley (aSampleIter, uSamplesNum);
|
|
128
|
+
vec3 aDir = sphereUniformSample (aHammersleyPoint);
|
|
129
|
+
|
|
130
|
+
vec3 aVal = occTextureCube (uEnvMap, cubemapVectorTransform (aDir, uYCoeff, uZCoeff)).rgb;
|
|
131
|
+
#if (__VERSION__ >= 120)
|
|
132
|
+
float aFunc[9];
|
|
133
|
+
aFunc[0] = 1.0;
|
|
134
|
+
|
|
135
|
+
aFunc[1] = aDir.x;
|
|
136
|
+
aFunc[2] = aDir.y;
|
|
137
|
+
aFunc[3] = aDir.z;
|
|
138
|
+
|
|
139
|
+
aFunc[4] = aDir.x * aDir.z;
|
|
140
|
+
aFunc[5] = aDir.y * aDir.z;
|
|
141
|
+
aFunc[6] = aDir.x * aDir.y;
|
|
142
|
+
|
|
143
|
+
aFunc[7] = 3.0 * aDir.z * aDir.z - 1.0;
|
|
144
|
+
aFunc[8] = aDir.x * aDir.x - aDir.y * aDir.y;
|
|
145
|
+
|
|
146
|
+
aRes += aVal * aFunc[anId];
|
|
147
|
+
#else
|
|
148
|
+
if (anId == 0) { aRes += aVal * 1.0; }
|
|
149
|
+
else if (anId == 1) { aRes += aVal * aDir.x; }
|
|
150
|
+
else if (anId == 2) { aRes += aVal * aDir.y; }
|
|
151
|
+
else if (anId == 3) { aRes += aVal * aDir.z; }
|
|
152
|
+
else if (anId == 4) { aRes += aVal * (aDir.x * aDir.z); }
|
|
153
|
+
else if (anId == 5) { aRes += aVal * (aDir.y * aDir.z); }
|
|
154
|
+
else if (anId == 6) { aRes += aVal * (aDir.x * aDir.y); }
|
|
155
|
+
else if (anId == 7) { aRes += aVal * (3.0 * aDir.z * aDir.z - 1.0); }
|
|
156
|
+
else { aRes += aVal * (aDir.x * aDir.x - aDir.y * aDir.y); }
|
|
157
|
+
#endif
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return 4.0 * aRes * aCoef / float(uSamplesNum);
|
|
161
|
+
}
|
|
162
|
+
#endif
|
|
163
|
+
|
|
164
|
+
#ifdef THE_TO_BAKE_SPECULAR
|
|
165
|
+
//! Computes a single sample for specular IBL map.
|
|
166
|
+
vec4 specularMapSample (in vec3 theNormal,
|
|
167
|
+
in float theRoughness,
|
|
168
|
+
in int theNumber,
|
|
169
|
+
in int theSize)
|
|
170
|
+
{
|
|
171
|
+
vec2 aHammersleyPoint = hammersley (theNumber, theSize);
|
|
172
|
+
vec3 aHalf = importanceSample (aHammersleyPoint, occRoughness (theRoughness));
|
|
173
|
+
float aHdotV = aHalf.z;
|
|
174
|
+
aHalf = fromTangentSpace (aHalf, theNormal);
|
|
175
|
+
vec3 aLight = -reflect (theNormal, aHalf);
|
|
176
|
+
float aNdotL = dot (aLight, theNormal);
|
|
177
|
+
if (aNdotL > 0.0)
|
|
178
|
+
{
|
|
179
|
+
float aSolidAngleSample = 1.0 / (float(theSize) * (occPBRDistribution (aHdotV, theRoughness) * 0.25 + 0.0001) + 0.0001);
|
|
180
|
+
float aLod = (theRoughness == 0.0) ? 0.0 : 0.5 * log2 (aSolidAngleSample / uEnvSolidAngleSource);
|
|
181
|
+
return vec4 (occTextureCubeLod (uEnvMap, aLight, aLod).rgb * aNdotL, aNdotL);
|
|
182
|
+
}
|
|
183
|
+
return vec4 (0.0);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
//! Bakes specular IBL map.
|
|
187
|
+
vec3 bakeSpecularMap (in vec3 theNormal,
|
|
188
|
+
in float theRoughness)
|
|
189
|
+
{
|
|
190
|
+
vec4 aResult = vec4(0.0);
|
|
191
|
+
if (theRoughness == 0.0)
|
|
192
|
+
{
|
|
193
|
+
aResult = specularMapSample (theNormal, theRoughness, 0, 1);
|
|
194
|
+
}
|
|
195
|
+
else
|
|
196
|
+
{
|
|
197
|
+
for (int aSampleIter = 0; aSampleIter < uSamplesNum; ++aSampleIter)
|
|
198
|
+
{
|
|
199
|
+
aResult += specularMapSample (theNormal, theRoughness, aSampleIter, uSamplesNum);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return aResult.xyz / aResult.w;
|
|
203
|
+
}
|
|
204
|
+
#endif
|
|
205
|
+
|
|
206
|
+
void main()
|
|
207
|
+
{
|
|
208
|
+
vec3 aViewDirection = normalize (ViewDirection);
|
|
209
|
+
#ifdef THE_TO_BAKE_DIFFUSE
|
|
210
|
+
vec4 aRes = vec4 (bakeDiffuseSH(), 1.0);
|
|
211
|
+
#ifdef THE_TO_PACK_FLOAT
|
|
212
|
+
int aCompIndex = int(gl_FragCoord.y);
|
|
213
|
+
float aComp = aCompIndex == 0 ? aRes.x : (aCompIndex == 1 ? aRes.y : aRes.z);
|
|
214
|
+
int aFixedPrec = int(aComp * 2147483647.0);
|
|
215
|
+
int aFixedDiv1 = aFixedPrec / 256;
|
|
216
|
+
int aFixedDiv2 = aFixedDiv1 / 256;
|
|
217
|
+
int aFixedDiv3 = aFixedDiv2 / 256;
|
|
218
|
+
vec4 aPacked = vec4(float(aFixedPrec), float(aFixedDiv1), float(aFixedDiv2), float(aFixedDiv3));
|
|
219
|
+
aRes = fract (aPacked * (1.0 / 256.0));
|
|
220
|
+
#endif
|
|
221
|
+
occFragColor = aRes;
|
|
222
|
+
#else
|
|
223
|
+
float aRoughness = float(uCurrentLevel) / float(occNbSpecIBLLevels - 1);
|
|
224
|
+
occFragColor = vec4 (bakeSpecularMap (aViewDirection, aRoughness), 1.0);
|
|
225
|
+
#endif
|
|
226
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
THE_SHADER_OUT vec3 ViewDirection; //!< direction of fetching from environment cubemap
|
|
2
|
+
|
|
3
|
+
uniform int uCurrentSide; //!< current side of cubemap
|
|
4
|
+
uniform int uYCoeff; //!< coefficient of Y controlling horizontal flip of cubemap
|
|
5
|
+
uniform int uZCoeff; //!< coefficient of Z controlling vertical flip of cubemap
|
|
6
|
+
|
|
7
|
+
void main()
|
|
8
|
+
{
|
|
9
|
+
vec3 aDir;
|
|
10
|
+
vec2 aCoord;
|
|
11
|
+
if (uCurrentSide == 0)
|
|
12
|
+
{
|
|
13
|
+
aCoord = mat2( 0,-1,-1, 0) * occVertex.xy;
|
|
14
|
+
aDir.x = 1.0;
|
|
15
|
+
aDir.y = aCoord.x;
|
|
16
|
+
aDir.z = aCoord.y;
|
|
17
|
+
}
|
|
18
|
+
else if (uCurrentSide == 1)
|
|
19
|
+
{
|
|
20
|
+
aCoord = mat2( 0, 1,-1, 0) * occVertex.xy;
|
|
21
|
+
aDir.x = -1.0;
|
|
22
|
+
aDir.y = aCoord.x;
|
|
23
|
+
aDir.z = aCoord.y;
|
|
24
|
+
}
|
|
25
|
+
else if (uCurrentSide == 2)
|
|
26
|
+
{
|
|
27
|
+
aCoord = mat2( 0, 1, 1, 0) * occVertex.xy;
|
|
28
|
+
aDir.x = aCoord.y;
|
|
29
|
+
aDir.y = 1.0;
|
|
30
|
+
aDir.z = aCoord.x;
|
|
31
|
+
}
|
|
32
|
+
else if (uCurrentSide == 3)
|
|
33
|
+
{
|
|
34
|
+
aCoord = mat2( 0, 1,-1, 0) * occVertex.xy;
|
|
35
|
+
aDir.x = aCoord.y;
|
|
36
|
+
aDir.y = -1.0;
|
|
37
|
+
aDir.z = aCoord.x;
|
|
38
|
+
}
|
|
39
|
+
else if (uCurrentSide == 4)
|
|
40
|
+
{
|
|
41
|
+
aCoord = mat2( 1, 0, 0,-1) * occVertex.xy;
|
|
42
|
+
aDir.x = aCoord.x;
|
|
43
|
+
aDir.y = aCoord.y;
|
|
44
|
+
aDir.z = 1.0;
|
|
45
|
+
}
|
|
46
|
+
else //if (uCurrentSide == 5)
|
|
47
|
+
{
|
|
48
|
+
aCoord = mat2(-1, 0, 0,-1) * occVertex.xy;
|
|
49
|
+
aDir.x = aCoord.x;
|
|
50
|
+
aDir.y = aCoord.y;
|
|
51
|
+
aDir.z = -1.0;
|
|
52
|
+
}
|
|
53
|
+
ViewDirection = cubemapVectorTransform (aDir, uYCoeff, uZCoeff);
|
|
54
|
+
gl_Position = vec4 (occVertex.xy, 0.0, 1.0);
|
|
55
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//! Functions to calculate fresnel coefficient and approximate zero fresnel value.
|
|
2
|
+
vec3 occPBRFresnel (in vec3 theBaseColor,
|
|
3
|
+
in float theMetallic,
|
|
4
|
+
in float theIOR)
|
|
5
|
+
{
|
|
6
|
+
theIOR = (1.0 - theIOR) / (1.0 + theIOR);
|
|
7
|
+
theIOR *= theIOR;
|
|
8
|
+
vec3 f0 = vec3(theIOR);
|
|
9
|
+
f0 = mix (f0, theBaseColor.rgb, theMetallic);
|
|
10
|
+
return f0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
vec3 occPBRFresnel (in vec3 theBaseColor,
|
|
14
|
+
in float theMetallic,
|
|
15
|
+
in float theIOR,
|
|
16
|
+
in float theCosVH)
|
|
17
|
+
{
|
|
18
|
+
vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);
|
|
19
|
+
theCosVH = 1.0 - theCosVH;
|
|
20
|
+
theCosVH *= theCosVH;
|
|
21
|
+
theCosVH *= theCosVH * theCosVH * theCosVH * theCosVH;
|
|
22
|
+
return f0 + (vec3 (1.0) - f0) * theCosVH;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
vec3 occPBRFresnel (in vec3 theBaseColor,
|
|
26
|
+
in float theMetallic,
|
|
27
|
+
in float theRoughness,
|
|
28
|
+
in float theIOR,
|
|
29
|
+
in float theCosV)
|
|
30
|
+
{
|
|
31
|
+
vec3 f0 = occPBRFresnel (theBaseColor, theMetallic, theIOR);
|
|
32
|
+
theCosV = 1.0 - theCosV;
|
|
33
|
+
theCosV *= theCosV;
|
|
34
|
+
theCosV *= theCosV * theCosV * theCosV * theCosV;
|
|
35
|
+
return f0 + (max(vec3(1.0 - theRoughness), f0) - f0) * theCosV;
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//! Calculates geometry factor for Cook-Torrance BRDF.
|
|
2
|
+
float occPBRGeometry (in float theCosV,
|
|
3
|
+
in float theCosL,
|
|
4
|
+
in float theRoughness)
|
|
5
|
+
{
|
|
6
|
+
float k = theRoughness + 1.0;
|
|
7
|
+
k *= 0.125 * k;
|
|
8
|
+
float g1 = 1.0;
|
|
9
|
+
g1 /= theCosV * (1.0 - k) + k;
|
|
10
|
+
float g2 = 1.0;
|
|
11
|
+
g2 /= theCosL * (1.0 - k) + k;
|
|
12
|
+
return g1 * g2;
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//! Calculates direct illumination using Cook-Torrance BRDF.
|
|
2
|
+
vec3 occPBRIllumination (in vec3 theView,
|
|
3
|
+
in vec3 theLight,
|
|
4
|
+
in vec3 theNormal,
|
|
5
|
+
in vec4 theBaseColor,
|
|
6
|
+
in float theMetallic,
|
|
7
|
+
in float theRoughness,
|
|
8
|
+
in float theIOR,
|
|
9
|
+
in vec3 theLightColor,
|
|
10
|
+
in float theLightIntensity)
|
|
11
|
+
{
|
|
12
|
+
vec3 aHalf = normalize (theView + theLight);
|
|
13
|
+
float aCosVH = max(dot(theView, aHalf), 0.0);
|
|
14
|
+
vec3 aFresnel = occPBRFresnel (theBaseColor.rgb, theMetallic, theIOR, aCosVH);
|
|
15
|
+
vec3 aSpecular = occPBRCookTorrance (theView,
|
|
16
|
+
theLight,
|
|
17
|
+
theNormal,
|
|
18
|
+
theBaseColor.rgb,
|
|
19
|
+
theMetallic,
|
|
20
|
+
theRoughness,
|
|
21
|
+
theIOR);
|
|
22
|
+
vec3 aDiffuse = vec3(1.0) - aFresnel;
|
|
23
|
+
aDiffuse *= 1.0 - theMetallic;
|
|
24
|
+
aDiffuse *= INV_PI;
|
|
25
|
+
aDiffuse *= theBaseColor.rgb;
|
|
26
|
+
aDiffuse = mix (vec3(0.0), aDiffuse, theBaseColor.a);
|
|
27
|
+
return (aDiffuse + aSpecular) * theLightColor * theLightIntensity * max(0.0, dot(theLight, theNormal));
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//! Function computes contribution of isotropic point light source
|
|
2
|
+
//! into global variable DirectLighting (PBR shading).
|
|
3
|
+
//! @param theId light source index
|
|
4
|
+
//! @param theNormal surface normal
|
|
5
|
+
//! @param theView view direction
|
|
6
|
+
//! @param thePoint 3D position (world space)
|
|
7
|
+
//! @param theIsFront front/back face flag
|
|
8
|
+
void occPointLight (in int theId,
|
|
9
|
+
in vec3 theNormal,
|
|
10
|
+
in vec3 theView,
|
|
11
|
+
in vec3 thePoint,
|
|
12
|
+
in bool theIsFront)
|
|
13
|
+
{
|
|
14
|
+
vec3 aLight = occLight_Position (theId) - thePoint;
|
|
15
|
+
|
|
16
|
+
float aDist = length (aLight);
|
|
17
|
+
float aRange = occLight_Range (theId);
|
|
18
|
+
float anAtten = occPointLightAttenuation (aDist, aRange);
|
|
19
|
+
if (anAtten <= 0.0) return;
|
|
20
|
+
aLight /= aDist;
|
|
21
|
+
|
|
22
|
+
theNormal = theIsFront ? theNormal : -theNormal;
|
|
23
|
+
DirectLighting += occPBRIllumination (theView, aLight, theNormal,
|
|
24
|
+
BaseColor, Metallic, Roughness, IOR,
|
|
25
|
+
occLight_Specular (theId),
|
|
26
|
+
occLight_Intensity(theId) * anAtten);
|
|
27
|
+
}
|