occt-gltf-addon-linux-x64 0.1.1 → 0.1.2
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,29 @@
|
|
|
1
|
+
//! Function computes contribution of directional light source
|
|
2
|
+
//! into global variables Diffuse and Specular (Phong 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
|
+
vec3 aHalf = normalize (aLight + theView);
|
|
16
|
+
|
|
17
|
+
vec3 aFaceSideNormal = theIsFront ? theNormal : -theNormal;
|
|
18
|
+
float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));
|
|
19
|
+
float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));
|
|
20
|
+
|
|
21
|
+
float aSpecl = 0.0;
|
|
22
|
+
if (aNdotL > 0.0)
|
|
23
|
+
{
|
|
24
|
+
aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Diffuse += occLight_Diffuse (theId) * aNdotL * theShadow;
|
|
28
|
+
Specular += occLight_Specular (theId) * aSpecl * theShadow;
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//! Function computes contribution of isotropic point light source
|
|
2
|
+
//! into global variables Diffuse and Specular (Phong 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, occLight_LinearAttenuation (theId), occLight_ConstAttenuation (theId));
|
|
19
|
+
if (anAtten <= 0.0) return;
|
|
20
|
+
aLight /= aDist;
|
|
21
|
+
|
|
22
|
+
vec3 aHalf = normalize (aLight + theView);
|
|
23
|
+
|
|
24
|
+
vec3 aFaceSideNormal = theIsFront ? theNormal : -theNormal;
|
|
25
|
+
float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));
|
|
26
|
+
float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));
|
|
27
|
+
|
|
28
|
+
float aSpecl = 0.0;
|
|
29
|
+
if (aNdotL > 0.0)
|
|
30
|
+
{
|
|
31
|
+
aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten;
|
|
35
|
+
Specular += occLight_Specular(theId) * aSpecl * anAtten;
|
|
36
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// Created on: 2013-10-10
|
|
2
|
+
// Created by: Denis BOGOLEPOV
|
|
3
|
+
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
|
4
|
+
//
|
|
5
|
+
// This file is part of Open CASCADE Technology software library.
|
|
6
|
+
//
|
|
7
|
+
// This library is free software; you can redistribute it and/or modify it under
|
|
8
|
+
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
9
|
+
// by the Free Software Foundation, with special exception defined in the file
|
|
10
|
+
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
11
|
+
// distribution for complete text of the license and disclaimer of any warranty.
|
|
12
|
+
//
|
|
13
|
+
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
14
|
+
// commercial license or contractual agreement.
|
|
15
|
+
|
|
16
|
+
varying vec3 View; //!< Direction to the viewer
|
|
17
|
+
varying vec3 Normal; //!< Vertex normal in view space
|
|
18
|
+
varying vec4 Position; //!< Vertex position in view space.
|
|
19
|
+
varying vec4 PositionWorld; //!< Vertex position in world space
|
|
20
|
+
|
|
21
|
+
vec3 Ambient; //!< Ambient contribution of light sources
|
|
22
|
+
vec3 Diffuse; //!< Diffuse contribution of light sources
|
|
23
|
+
vec3 Specular; //!< Specular contribution of light sources
|
|
24
|
+
|
|
25
|
+
//! Computes contribution of isotropic point light source
|
|
26
|
+
void pointLight (in int theId,
|
|
27
|
+
in vec3 theNormal,
|
|
28
|
+
in vec3 theView,
|
|
29
|
+
in vec3 thePoint)
|
|
30
|
+
{
|
|
31
|
+
vec3 aLight = occLight_Position (theId).xyz;
|
|
32
|
+
if (!occLight_IsHeadlight (theId))
|
|
33
|
+
{
|
|
34
|
+
aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));
|
|
35
|
+
}
|
|
36
|
+
aLight -= thePoint;
|
|
37
|
+
|
|
38
|
+
float aDist = length (aLight);
|
|
39
|
+
aLight = aLight * (1.0 / aDist);
|
|
40
|
+
|
|
41
|
+
float anAtten = 1.0 / (occLight_ConstAttenuation (theId)
|
|
42
|
+
+ occLight_LinearAttenuation (theId) * aDist);
|
|
43
|
+
|
|
44
|
+
vec3 aHalf = normalize (aLight + theView);
|
|
45
|
+
|
|
46
|
+
vec3 aFaceSideNormal = gl_FrontFacing ? theNormal : -theNormal;
|
|
47
|
+
float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));
|
|
48
|
+
float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));
|
|
49
|
+
|
|
50
|
+
float aSpecl = 0.0;
|
|
51
|
+
if (aNdotL > 0.0)
|
|
52
|
+
{
|
|
53
|
+
aSpecl = pow (aNdotH, occMaterial_Shininess (gl_FrontFacing));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Diffuse += occLight_Diffuse (theId).rgb * aNdotL * anAtten;
|
|
57
|
+
Specular += occLight_Specular (theId).rgb * aSpecl * anAtten;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//! Computes contribution of spotlight source
|
|
61
|
+
void spotLight (in int theId,
|
|
62
|
+
in vec3 theNormal,
|
|
63
|
+
in vec3 theView,
|
|
64
|
+
in vec3 thePoint)
|
|
65
|
+
{
|
|
66
|
+
vec3 aLight = occLight_Position (theId).xyz;
|
|
67
|
+
vec3 aSpotDir = occLight_SpotDirection (theId).xyz;
|
|
68
|
+
if (!occLight_IsHeadlight (theId))
|
|
69
|
+
{
|
|
70
|
+
aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));
|
|
71
|
+
aSpotDir = vec3 (occWorldViewMatrix * vec4 (aSpotDir, 0.0));
|
|
72
|
+
}
|
|
73
|
+
aLight -= thePoint;
|
|
74
|
+
|
|
75
|
+
float aDist = length (aLight);
|
|
76
|
+
aLight = aLight * (1.0 / aDist);
|
|
77
|
+
|
|
78
|
+
aSpotDir = normalize (aSpotDir);
|
|
79
|
+
|
|
80
|
+
// light cone
|
|
81
|
+
float aCosA = dot (aSpotDir, -aLight);
|
|
82
|
+
if (aCosA >= 1.0 || aCosA < cos (occLight_SpotCutOff (theId)))
|
|
83
|
+
{
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
float anExponent = occLight_SpotExponent (theId);
|
|
88
|
+
float anAtten = 1.0 / (occLight_ConstAttenuation (theId)
|
|
89
|
+
+ occLight_LinearAttenuation (theId) * aDist);
|
|
90
|
+
if (anExponent > 0.0)
|
|
91
|
+
{
|
|
92
|
+
anAtten *= pow (aCosA, anExponent * 128.0);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
vec3 aHalf = normalize (aLight + theView);
|
|
96
|
+
|
|
97
|
+
vec3 aFaceSideNormal = gl_FrontFacing ? theNormal : -theNormal;
|
|
98
|
+
float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));
|
|
99
|
+
float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));
|
|
100
|
+
|
|
101
|
+
float aSpecl = 0.0;
|
|
102
|
+
if (aNdotL > 0.0)
|
|
103
|
+
{
|
|
104
|
+
aSpecl = pow (aNdotH, occMaterial_Shininess (gl_FrontFacing));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Diffuse += occLight_Diffuse (theId).rgb * aNdotL * anAtten;
|
|
108
|
+
Specular += occLight_Specular (theId).rgb * aSpecl * anAtten;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//! Computes contribution of directional light source
|
|
112
|
+
void directionalLight (in int theId,
|
|
113
|
+
in vec3 theNormal,
|
|
114
|
+
in vec3 theView)
|
|
115
|
+
{
|
|
116
|
+
vec3 aLight = normalize (occLight_Position (theId).xyz);
|
|
117
|
+
if (!occLight_IsHeadlight (theId))
|
|
118
|
+
{
|
|
119
|
+
aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
vec3 aHalf = normalize (aLight + theView);
|
|
123
|
+
|
|
124
|
+
vec3 aFaceSideNormal = gl_FrontFacing ? theNormal : -theNormal;
|
|
125
|
+
float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));
|
|
126
|
+
float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));
|
|
127
|
+
|
|
128
|
+
float aSpecl = 0.0;
|
|
129
|
+
if (aNdotL > 0.0)
|
|
130
|
+
{
|
|
131
|
+
aSpecl = pow (aNdotH, occMaterial_Shininess (gl_FrontFacing));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
Diffuse += occLight_Diffuse (theId).rgb * aNdotL;
|
|
135
|
+
Specular += occLight_Specular (theId).rgb * aSpecl;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//! Computes illumination from light sources
|
|
139
|
+
vec4 computeLighting (in vec3 theNormal,
|
|
140
|
+
in vec3 theView,
|
|
141
|
+
in vec4 thePoint)
|
|
142
|
+
{
|
|
143
|
+
// Clear the light intensity accumulators
|
|
144
|
+
Ambient = occLightAmbient.rgb;
|
|
145
|
+
Diffuse = vec3 (0.0);
|
|
146
|
+
Specular = vec3 (0.0);
|
|
147
|
+
vec3 aPoint = thePoint.xyz / thePoint.w;
|
|
148
|
+
for (int anIndex = 0; anIndex < occLightSourcesCount; ++anIndex)
|
|
149
|
+
{
|
|
150
|
+
int aType = occLight_Type (anIndex);
|
|
151
|
+
if (aType == OccLightType_Direct)
|
|
152
|
+
{
|
|
153
|
+
directionalLight (anIndex, theNormal, theView);
|
|
154
|
+
}
|
|
155
|
+
else if (aType == OccLightType_Point)
|
|
156
|
+
{
|
|
157
|
+
pointLight (anIndex, theNormal, theView, aPoint);
|
|
158
|
+
}
|
|
159
|
+
else if (aType == OccLightType_Spot)
|
|
160
|
+
{
|
|
161
|
+
spotLight (anIndex, theNormal, theView, aPoint);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
vec3 aMatAmbient = occMaterial_Ambient (gl_FrontFacing);
|
|
166
|
+
vec4 aMatDiffuse = occMaterial_Diffuse (gl_FrontFacing);
|
|
167
|
+
vec3 aMatSpecular = occMaterial_Specular(gl_FrontFacing);
|
|
168
|
+
vec3 aMatEmission = occMaterial_Emission(gl_FrontFacing);
|
|
169
|
+
vec3 aColor = Ambient * aMatAmbient.rgb
|
|
170
|
+
+ Diffuse * aMatDiffuse.rgb
|
|
171
|
+
+ Specular * aMatSpecular.rgb
|
|
172
|
+
+ aMatEmission.rgb;
|
|
173
|
+
return vec4 (aColor, aMatDiffuse.a);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//! Entry point to the Fragment Shader
|
|
177
|
+
void main()
|
|
178
|
+
{
|
|
179
|
+
// process clipping planes
|
|
180
|
+
for (int anIndex = 0; anIndex < occClipPlaneCount; ++anIndex)
|
|
181
|
+
{
|
|
182
|
+
vec4 aClipEquation = occClipPlaneEquations[anIndex];
|
|
183
|
+
if (dot (aClipEquation.xyz, PositionWorld.xyz / PositionWorld.w) + aClipEquation.w < 0.0)
|
|
184
|
+
{
|
|
185
|
+
discard;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
vec4 aColor = computeLighting (normalize (Normal), normalize (View), Position);
|
|
190
|
+
occSetFragColor (aColor);
|
|
191
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Created on: 2013-10-10
|
|
2
|
+
// Created by: Denis BOGOLEPOV
|
|
3
|
+
// Copyright (c) 2013-2014 OPEN CASCADE SAS
|
|
4
|
+
//
|
|
5
|
+
// This file is part of Open CASCADE Technology software library.
|
|
6
|
+
//
|
|
7
|
+
// This library is free software; you can redistribute it and/or modify it under
|
|
8
|
+
// the terms of the GNU Lesser General Public License version 2.1 as published
|
|
9
|
+
// by the Free Software Foundation, with special exception defined in the file
|
|
10
|
+
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
11
|
+
// distribution for complete text of the license and disclaimer of any warranty.
|
|
12
|
+
//
|
|
13
|
+
// Alternatively, this file may be used under the terms of Open CASCADE
|
|
14
|
+
// commercial license or contractual agreement.
|
|
15
|
+
|
|
16
|
+
varying vec3 View; //!< Direction to the viewer
|
|
17
|
+
varying vec3 Normal; //!< Vertex normal in view space
|
|
18
|
+
varying vec4 Position; //!< Vertex position in view space
|
|
19
|
+
varying vec4 PositionWorld; //!< Vertex position in world space
|
|
20
|
+
|
|
21
|
+
//! Computes the normal in view space
|
|
22
|
+
vec3 TransformNormal (in vec3 theNormal)
|
|
23
|
+
{
|
|
24
|
+
vec4 aResult = occWorldViewMatrixInverseTranspose
|
|
25
|
+
* occModelWorldMatrixInverseTranspose
|
|
26
|
+
* vec4 (theNormal, 0.0);
|
|
27
|
+
return normalize (aResult.xyz);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//! Entry point to the Vertex Shader
|
|
31
|
+
void main()
|
|
32
|
+
{
|
|
33
|
+
PositionWorld = occModelWorldMatrix * occVertex;
|
|
34
|
+
Position = occWorldViewMatrix * PositionWorld;
|
|
35
|
+
Normal = TransformNormal (occNormal);
|
|
36
|
+
|
|
37
|
+
// Note: The specified view vector is absolutely correct only for the orthogonal projection.
|
|
38
|
+
// For perspective projection it will be approximate, but it is in good agreement with the OpenGL calculations.
|
|
39
|
+
View = vec3 (0.0, 0.0, 1.0);
|
|
40
|
+
|
|
41
|
+
// Do fixed functionality vertex transform
|
|
42
|
+
gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;
|
|
43
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//! Function computes contribution of spotlight source
|
|
2
|
+
//! into global variables Diffuse and Specular (Phong 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
|
+
//! @param theShadow the value from shadow map
|
|
9
|
+
void occSpotLight (in int theId,
|
|
10
|
+
in vec3 theNormal,
|
|
11
|
+
in vec3 theView,
|
|
12
|
+
in vec3 thePoint,
|
|
13
|
+
in bool theIsFront,
|
|
14
|
+
in float theShadow)
|
|
15
|
+
{
|
|
16
|
+
vec3 aLight = occLight_Position (theId) - thePoint;
|
|
17
|
+
|
|
18
|
+
float aDist = length (aLight);
|
|
19
|
+
float aRange = occLight_Range (theId);
|
|
20
|
+
float anAtten = occPointLightAttenuation (aDist, aRange, occLight_LinearAttenuation (theId), occLight_ConstAttenuation (theId));
|
|
21
|
+
if (anAtten <= 0.0) return;
|
|
22
|
+
aLight /= aDist;
|
|
23
|
+
|
|
24
|
+
vec3 aSpotDir = occLight_SpotDirection (theId);
|
|
25
|
+
// light cone
|
|
26
|
+
float aCosA = dot (aSpotDir, -aLight);
|
|
27
|
+
if (aCosA >= 1.0 || aCosA < cos (occLight_SpotCutOff (theId)))
|
|
28
|
+
{
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
float anExponent = occLight_SpotExponent (theId);
|
|
33
|
+
if (anExponent > 0.0)
|
|
34
|
+
{
|
|
35
|
+
anAtten *= pow (aCosA, anExponent * 128.0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
vec3 aHalf = normalize (aLight + theView);
|
|
39
|
+
|
|
40
|
+
vec3 aFaceSideNormal = theIsFront ? theNormal : -theNormal;
|
|
41
|
+
float aNdotL = max (0.0, dot (aFaceSideNormal, aLight));
|
|
42
|
+
float aNdotH = max (0.0, dot (aFaceSideNormal, aHalf ));
|
|
43
|
+
|
|
44
|
+
float aSpecl = 0.0;
|
|
45
|
+
if (aNdotL > 0.0)
|
|
46
|
+
{
|
|
47
|
+
aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten * theShadow;
|
|
51
|
+
Specular += occLight_Specular(theId) * aSpecl * anAtten * theShadow;
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//! Returns point light source attenuation factor
|
|
2
|
+
float occRangedPointLightAttenuation (in float theDistance, in float theRange)
|
|
3
|
+
{
|
|
4
|
+
if (theDistance <= theRange)
|
|
5
|
+
{
|
|
6
|
+
float aResult = theDistance / theRange;
|
|
7
|
+
aResult *= aResult;
|
|
8
|
+
aResult *= aResult;
|
|
9
|
+
aResult = 1.0 - aResult;
|
|
10
|
+
aResult = clamp(aResult, 0.0, 1.0);
|
|
11
|
+
aResult /= max(0.0001, theDistance * theDistance);
|
|
12
|
+
return aResult;
|
|
13
|
+
}
|
|
14
|
+
return -1.0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//! Returns point light source attenuation factor with quadratic attenuation in case of zero range.
|
|
18
|
+
float occPointLightAttenuation (in float theDistance, in float theRange)
|
|
19
|
+
{
|
|
20
|
+
if (theRange == 0.0)
|
|
21
|
+
{
|
|
22
|
+
return 1.0 / max(0.0001, theDistance * theDistance);
|
|
23
|
+
}
|
|
24
|
+
return occRangedPointLightAttenuation (theDistance, theRange);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//! Returns point light source attenuation factor with linear attenuation in case of zero range.
|
|
28
|
+
float occPointLightAttenuation (in float theDistance, in float theRange, in float theLinearAttenuation, in float theConstAttenuation)
|
|
29
|
+
{
|
|
30
|
+
if (theRange == 0.0)
|
|
31
|
+
{
|
|
32
|
+
return 1.0 / (theConstAttenuation + theLinearAttenuation * theDistance);
|
|
33
|
+
}
|
|
34
|
+
return occRangedPointLightAttenuation (theDistance, theRange);
|
|
35
|
+
}
|