0031275: Visualization, TKOpenGl - handle normal-map texture with Path-Tracing
[occt.git] / src / Shaders / PBREnvBaking.vs
CommitLineData
67312b79 1THE_SHADER_OUT vec3 ViewDirection; //!< direction of fetching from environment cubemap
2
3uniform int uCurrentSide; //!< current side of cubemap
4uniform int uYCoeff; //!< coefficient of Y controlling horizontal flip of cubemap
5uniform int uZCoeff; //!< coefficient of Z controlling vertical flip of cubemap
6
7const mat2 cubemapDirectionMatrices[6] = mat2[]
8(
9 mat2 ( 0, -1, -1, 0),
10 mat2 ( 0, 1, -1, 0),
11 mat2 ( 0, 1, 1, 0),
12 mat2 ( 0, 1, -1, 0),
13 mat2 ( 1, 0, 0, -1),
14 mat2 (-1, 0, 0, -1)
15);
16
17//! Generates environment map fetching direction considering current index of side.
18vec3 cubemapBakingViewDirection (in int theSide,
19 in vec2 theScreenCoord)
20{
21 int anAxis = theSide / 2;
22 vec3 aDirection = vec3(0.0);
23 aDirection[anAxis] = float(-(int(theSide) % 2) * 2 + 1);
24 theScreenCoord = cubemapDirectionMatrices[theSide] * theScreenCoord;
25 aDirection[(anAxis + 1) % 3] = theScreenCoord.x;
26 aDirection[(anAxis + 2) % 3] = theScreenCoord.y;
27 return aDirection;
28}
29
30void main()
31{
32 ViewDirection = cubemapBakingViewDirection (uCurrentSide, occVertex.xy);
33 ViewDirection = cubemapVectorTransform (ViewDirection, uYCoeff, uZCoeff);
34 gl_Position = vec4 (occVertex.xy, 0.0, 1.0);
35}