433{
434 vsh->Clear();
435 vsh->AddTopLine(
GLSLLine(
"layout (location = 0) in vec4 aPos;",
"The world position of the vertex"));
436 vsh->AddTopLine(
GLSLLine(
"layout (location = 1) in vec4 aNorm;",
"The vertex normals"));
437 vsh->AddTopLine(
GLSLLine(
"layout (location = 2) in vec2 aTexCoord;",
"The texture coordinates of the vertex"));
438 vsh->AddTopLine(
GLSLLine(
"layout (location = 3) in vec4 aExtras1;",
"Extra data like generated height, erosion delta, etc."));
439 vsh->AddTopLine(
GLSLLine(
"",
"The Output passed to the Geometry Shader"));
441out DATA
442{
443 float height;
444 vec3 FragPos;
445 vec3 Normal;
446 vec2 TexCoord;
447 vec4 Extras1;
448} data_out;
449)"));
450
453 vsh->AddUniform(
GLSLUniform(
"_TextureBake",
"float",
"0.0f"));
454 vsh->AddUniform(
GLSLUniform(
"_Scale",
"float",
"1.0f"));
455 vsh->AddUniform(
GLSLUniform(
"_Tiled",
"float",
"0.0f"));
456 vsh->AddUniform(
GLSLUniform(
"_NumTiles",
"float",
"0.0f"));
457 vsh->AddUniform(
GLSLUniform(
"_TileX",
"float",
"0.0f"));
458 vsh->AddUniform(
GLSLUniform(
"_TileY",
"float",
"0.0f"));
459
463
464if(_TextureBake == 0.0f)
465 gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0f);
466else
467{
468 if(_Tiled == 0.0f)
469 {
470 gl_Position = vec4(aPos.x/_Scale, aPos.z/_Scale, 0.0f, 1.0f);
471 }
472 else
473 {
474 float factor = _NumTiles / _Scale;
475 gl_Position = vec4(aPos.x * factor + _TileX, aPos.z * factor + _TileY, 0.0f, 1.0f);
476 }
477}
478)"));
479 main.AddLine(GLSLLine("data_out.height = aExtras1.x;",
"The actual generated noise value"));
480 main.AddLine(
GLSLLine(
"data_out.FragPos = vec3(aPos.x, aPos.y, aPos.z);",
"The world position"));
481 main.AddLine(
GLSLLine(
"data_out.Normal = vec3(aNorm.x, aNorm.y, aNorm.z);",
"The vertex normals"));
482 main.AddLine(
GLSLLine(
"data_out.TexCoord = aTexCoord;",
"The texture coordinates"));
483 main.AddLine(
GLSLLine(
"data_out.Extras1 = aExtras1;",
"The texture coordinates"));
484
485
486 vsh->AddFunction(main);
487}