TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ OnEvaluate()

void ShaderTextureNode::OnEvaluate ( GLSLFunction function,
GLSLLine line 
)
overridevirtual

Implements SNENode.

Definition at line 21 of file ShaderTextureNode.cpp.

22{
23 handler->AddFunction(GetTriplanarBlendFunction());
24 function->AddLine(GLSLLine("vec3 " + VAR("tex") + ";", "Variable to store the result"));
25 function->AddLine(GLSLLine("if(" + SDATA(4) + " == 1.0)", "If triplanar mapping is enabled"));
26 function->AddLine(GLSLLine("{", ""));
27 function->AddLine(GLSLLine(""
28 "\tvec3 " + VAR("blending") + " = getTriplanarBlend(Normal);\n"
29 "\t\tvec3 " + VAR("xaxis") + " = texture(_Textures, vec3(FragPos.yz * " + SDATA(0) + " + vec2(" + SDATA(1) + ", " + SDATA(2) + "), " + STR(zCoord) + ")).rgb;\n"
30 "\t\tvec3 " + VAR("yaxis") + " = texture(_Textures, vec3(FragPos.xz * " + SDATA(0) + " + vec2(" + SDATA(1) + ", " + SDATA(2) + "), " + STR(zCoord) + ")).rgb;\n"
31 "\t\tvec3 " + VAR("zaxis") + " = texture(_Textures, vec3(FragPos.xy * " + SDATA(0) + " + vec2(" + SDATA(1) + ", " + SDATA(2) + "), " + STR(zCoord) + ")).rgb;\n"
32 "\t" + VAR("tex") + " = " + VAR("blending") + ".x * " + VAR("xaxis") + " + " + VAR("blending") + ".y * " + VAR("yaxis") + " + " + VAR("blending") + ".z * " + VAR("zaxis") + ";\n"
33 , ""));
34 function->AddLine(GLSLLine("}", ""));
35 function->AddLine(GLSLLine("else", "If texture is not triplanar mapped just sample texture normally"));
36 function->AddLine(GLSLLine("{", ""));
37 function->AddLine(GLSLLine(""
38 "\t" + VAR("tex") + " = texture(_Textures, vec3(TexCoord * " + SDATA(0) + " + vec2(" + SDATA(1) + ", " + SDATA(2) + "), " + STR(zCoord) + ")).rgb;\n"));
39 function->AddLine(GLSLLine("}", ""));
40 line->line = VAR("tex");
41}