NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/sources/libs/ds3d/glprocess/gl_script.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef DS3D_GLPROCESS_GL_SCRIPT_H
19 #define DS3D_GLPROCESS_GL_SCRIPT_H
20 
21 #include "ds3d/common/hpp/frame.hpp"
22 
23 #include "ds3d/glprocess/gl_program.h"
24 #include "ds3d/glprocess/gl_buf.h"
25 
26 #define GLSL_VERSION "#version 300 es\n"
27 
28 namespace ds3d { namespace gl {
29 
30 static const std::string kImageTextureVertexScript = {
31  // GLSL_VERSION
32  "precision mediump float;\n"
33  "layout (location = 0) in vec3 inVert;\n"
34  "layout (location = 1) in vec2 inTexCoord;\n"
35  "uniform mat4 mvp;\n"
36  "\n"
37  "out vec2 TexCoord;\n"
38  "\n"
39  "void main()\n"
40  "{\n"
41  " gl_Position = mvp * vec4(inVert, 1.0);\n"
42  " TexCoord = vec2(inTexCoord.x, inTexCoord.y);\n"
43  "}\n"};
44 
45 static const std::string kImageTextureFragmentScript = {
46  // GLSL_VERSION
47  "precision mediump float;\n"
48  "in vec2 TexCoord;\n"
49  "out vec4 FragColor;\n"
50  "uniform sampler2D imageTexture;\n"
51  "\n"
52  "void main()\n"
53  "{\n"
54  " vec2 finalCoord = vec2(TexCoord.x, 1.0 - TexCoord.y);\n"
55  " FragColor = texture(imageTexture, finalCoord);\n"
56  "}\n"};
57 
58 
59 static const std::string kLidarVertexScript = {
60  // GLSL_VERSION
61  // "#define PointType vec4 \n"
62  "precision mediump float;\n"
63  "layout (location = 0) in PointType point;\n"
64  "uniform mat4 mvp;\n"
65  "\n"
66  "void main()\n"
67  "{\n"
68  " gl_Position = mvp * vec4(point.x, point.y, point.z, 1.0);\n"
69  "}\n"};
70 
71 const std::string kLidarZRangeVertexScript = {
72  // GLSL_VERSION
73  // "#define PointType vec4 \n"
74  // "#define Z_RANGE \n"
75  // "#define Y_RANGE \n"
76  // "#define X_RANGE \n"
77  "precision mediump float;\n"
78  "layout (location = 0) in PointType point;\n"
79  "uniform mat4 mvp;\n"
80  "uniform vec2 xyzRange[3];\n"
81  "\n"
82  "void main()\n"
83  "{\n"
84  " gl_Position = mvp * vec4(point.xyz, 1.0f);\n"
85  "#ifdef Z_RANGE \n"
86  " if (point.z < xyzRange[2].x || point.z > xyzRange[2].y) { \n"
87  " gl_Position = vec4(2.0f, 2.0f, 2.0f, 1.0f);\n"
88  " }\n"
89  "#endif \n"
90  "#ifdef Y_RANGE \n"
91  " if (point.y < xyzRange[1].x || point.y > xyzRange[1].y) { \n"
92  " gl_Position = vec4(2.0f, 2.0f, 2.0f, 1.0f);\n"
93  " }\n"
94  "#endif \n"
95  "#ifdef X_RANGE \n"
96  " if (point.x < xyzRange[0].x || point.x > xyzRange[0].y) { \n"
97  " gl_Position = vec4(2.0f, 2.0f, 2.0f, 1.0f);\n"
98  " }\n"
99  "#endif \n"
100  "}\n"};
101 
102 static const std::string kLidarFragmentScript = {
103  "\n"
104  // GLSL_VERSION
105  "precision mediump float;\n"
106  "out vec4 FragColor;\n"
107  "uniform vec4 color;\n"
108  "\n"
109  "void main()\n"
110  "{\n"
111  " FragColor = color;\n"
112  "}\n"};
113 
114 
115 static const std::string kLidarBboxVertexScript = {
116  // GLSL_VERSION
117  "precision mediump float;\n"
118  "layout (location = 0) in vec3 vert;\n"
119  "layout (location = 1) in vec4 color;\n"
120  "uniform mat4 mvp;\n"
121  "out vec4 fColor;\n"
122  "\n"
123  "void main()\n"
124  "{\n"
125  " gl_Position = mvp * vec4(vert.x, vert.y, vert.z, 1.0);\n"
126  " fColor = color;\n"
127  "}\n"};
128 
129 static const std::string kLidarBboxFragmentScript = {
130  "\n"
131  // GLSL_VERSION
132  "precision mediump float;\n"
133  "in vec4 fColor;\n"
134  "out vec4 FragColor;\n"
135  "\n"
136  "void main()\n"
137  "{\n"
138  " FragColor = fColor;\n"
139  "}\n"};
140 
141 
142 }} // namespace ds3d::gl
143 
144 #endif
ds3d::gl::kLidarZRangeVertexScript
const std::string kLidarZRangeVertexScript
Definition: sources/libs/ds3d/glprocess/gl_script.h:71
ds3d::gl::kLidarBboxVertexScript
static const std::string kLidarBboxVertexScript
Definition: sources/libs/ds3d/glprocess/gl_script.h:115
ds3d::gl::kLidarFragmentScript
static const std::string kLidarFragmentScript
Definition: sources/libs/ds3d/glprocess/gl_script.h:102
ds3d::gl::kImageTextureVertexScript
static const std::string kImageTextureVertexScript
Definition: sources/libs/ds3d/glprocess/gl_script.h:30
ds3d::gl::kLidarVertexScript
static const std::string kLidarVertexScript
Definition: sources/libs/ds3d/glprocess/gl_script.h:59
ds3d::gl::kImageTextureFragmentScript
static const std::string kImageTextureFragmentScript
Definition: sources/libs/ds3d/glprocess/gl_script.h:45
ds3d
Definition: includes/ds3d/common/abi_dataprocess.h:25
ds3d::gl::kLidarBboxFragmentScript
static const std::string kLidarBboxFragmentScript
Definition: sources/libs/ds3d/glprocess/gl_script.h:129