16 this->
setName(
"surface_renderer");
20 this->inColor()->tagOptional(
true);
22 this->inNormal()->tagOptional(
true);
23 this->inNormalIndex()->tagOptional(
true);
24 this->inTexCoord()->tagOptional(
true);
25 this->inTexCoordIndex()->tagOptional(
true);
28 this->inColorTexture()->tagOptional(
true);
29 this->inBumpMap()->tagOptional(
true);
61 mVertexColor.create(GL_SHADER_STORAGE_BUFFER, GL_DYNAMIC_DRAW);
62 mNormal.create(GL_SHADER_STORAGE_BUFFER, GL_DYNAMIC_DRAW);
63 mTexCoord.create(GL_SHADER_STORAGE_BUFFER, GL_DYNAMIC_DRAW);
67 SURFACE_VERT,
sizeof(SURFACE_VERT),
68 SURFACE_FRAG,
sizeof(SURFACE_FRAG),
69 SURFACE_GEOM,
sizeof(SURFACE_GEOM));
146 auto triSet = this->inTriangleSet()->constDataPtr();
147 auto indices = triSet->getTriangles();
148 auto vertices = triSet->getPoints();
153 if (this->varColorMode()->getValue() == EColorMode::CM_Vertex &&
154 !this->inColor()->isEmpty() &&
155 this->inColor()->getDataPtr()->size() == vertices.size())
157 auto colors = this->inColor()->getData();
162 if (this->varUseVertexNormal()->getValue())
166 if (this->inNormal()->isEmpty()) {
168 auto normals = triSet->getVertexNormals();
173 mNormal.load(this->inNormal()->constData());
175 if (!this->inNormalIndex()->isEmpty())
183 if (!this->inTexCoord()->isEmpty()) {
184 mTexCoord.load(this->inTexCoord()->constData());
187 if (!this->inTexCoordIndex()->isEmpty()) {
194 if (!inColorTexture()->isEmpty()) {
195 mColorTexture.load(inColorTexture()->constData());
198 if (!inBumpMap()->isEmpty()) {
199 mBumpMap.load(inBumpMap()->constData());
219 printf(
"GLSurfaceVisualModule: Unknown render mode!\n");
231 auto color = this->varBaseColor()->getValue();
232 pbr.color = { color.r, color.g, color.b };
233 pbr.metallic = this->varMetallic()->getValue();
234 pbr.roughness = this->varRoughness()->getValue();
235 pbr.alpha = this->varAlpha()->getValue();
240 mShaderProgram->setInt(
"uVertexNormal", this->varUseVertexNormal()->getValue());
241 mShaderProgram->setInt(
"uColorMode", this->varColorMode()->currentKey());
262 glActiveTexture(GL_TEXTURE10);
263 glBindTexture(GL_TEXTURE_2D, 0);
264 glActiveTexture(GL_TEXTURE11);
265 glBindTexture(GL_TEXTURE_2D, 0);
268 if (mColorTexture.isValid()) mColorTexture.bind(GL_TEXTURE10);
269 if (mBumpMap.isValid()) mBumpMap.bind(GL_TEXTURE11);
279 glEnableVertexAttribArray(0);
280 glVertexAttribIPointer(0, 1, GL_INT,
sizeof(
int), (
void*)0);
284 glEnableVertexAttribArray(1);
285 glVertexAttribIPointer(1, 1, GL_INT,
sizeof(
int), (
void*)0);
289 glDisableVertexAttribArray(1);
290 glVertexAttribI4i(1, -1, -1, -1, -1);
295 glEnableVertexAttribArray(2);
296 glVertexAttribIPointer(2, 1, GL_INT,
sizeof(
int), (
void*)0);
300 glDisableVertexAttribArray(2);
301 glVertexAttribI4i(2, -1, -1, -1, -1);
static Program * createProgramSPIRV(const void *vs, size_t vs_len, const void *fs, size_t fs_len, const void *gs=0, size_t gs_len=0)