567{
568 fsh->Clear();
569 fsh->AddTopLine(
GLSLLine(
"out vec4 FragColor;",
"The result of the fragment shader"));
571 fsh->AddTopLine(
GLSLLine(
"in float height;",
"Take the height passed in from the Geometry Shader"));
572 fsh->AddTopLine(
GLSLLine(
"in vec4 FragPos;",
"Take the world position passed in from the Geometry Shader"));
573 fsh->AddTopLine(
GLSLLine(
"in vec4 Extras1;",
"Take the extras 1 passed in from the Geometry Shader"));
574 fsh->AddTopLine(
GLSLLine(
"in vec3 Normal;",
"Take the normal passed in from the Geometry Shader"));
575 fsh->AddTopLine(
GLSLLine(
"in vec2 TexCoord;",
"Take the texture coordinates passed in from the Geometry Shader"));
576 fsh->AddTopLine(
GLSLLine(
"in mat3 TBN;",
"Take the tangent bitangent normal matrix in from the Geometry Shader"));
578 fsh->AddTopLine(
GLSLLine(extraSource));
581 struct DataBlob
582 {
583 float d[32];
584 };
585 )"));
586 fsh->AddTopLine(GLSLLine("const float PI = 3.14159265359;"));
587 fsh->AddTopLine(
GLSLLine(
"const float gamma = 2.2f;"));
588 fsh->AddUniform(
GLSLUniform(
"_LightPosition",
"vec3"));
589 fsh->AddUniform(
GLSLUniform(
"_LightColor",
"vec3"));
590 fsh->AddUniform(
GLSLUniform(
"_LightStrength",
"float"));
591 fsh->AddUniform(
GLSLUniform(
"_CameraPos",
"vec3"));
592 fsh->AddUniform(
GLSLUniform(
"_HMapMinMax",
"vec3"));
593 fsh->AddUniform(
GLSLUniform(
"_TextureBake",
"float",
"0.0f"));
594 fsh->AddUniform(
GLSLUniform(
"_Slot",
"float",
"0.0f"));
595 fsh->AddUniform(
GLSLUniform(
"_Tiled",
"float",
"0.0f"));
596 fsh->AddUniform(
GLSLUniform(
"_NumTiles",
"float",
"0.0f"));
597 fsh->AddUniform(
GLSLUniform(
"_TileX",
"float",
"0.0f"));
598 fsh->AddUniform(
GLSLUniform(
"_TileY",
"float",
"0.0f"));
599 fsh->AddUniform(
GLSLUniform(
"_Textures",
"sampler2DArray"));
600 GLSLSSBO dataBlobs(
"dataBlobs", std::to_string(sharedMemoryManager->ssboBinding),
"These are small data blobs which may be used for nodes, etc.");
601 dataBlobs.AddLine(
GLSLLine(
"DataBlob data[];"));
602 fsh->AddSSBO(dataBlobs);
605 main.AddLine(
GLSLLine(
"vec3 textureBakeSlots[10];"));
608 param.userData1 = &main;
609 param.userData2 = &tmp;
610 shaderNodeEditor->outputNode->Evaluate(param, nullptr);
613 if(_TextureBake == 1.0f)
614 {
615 textureBakeSlots[0] = vec3( (height - _HMapMinMax.x) / (_HMapMinMax.y - _HMapMinMax.x) ); // Slot 0 is reserved for height map
616 FragColor = vec4(textureBakeSlots[int(_Slot)], 1.0f);
617 return;
618 }
619 )"));
621 main.AddLine(
GLSLLine(
"FragColor = vec4(" + tmp.line +
", 1.0f);"));
622 fsh->AddFunction(main);
623}