TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ OnEvaluate()

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

Implements SNENode.

Definition at line 5 of file ShaderOutputNode.cpp.

6{
7 if (inputPins[0]->IsLinked())
8 {
9 GLSLLine ln("");
10 inputPins[0]->other->Evaluate(GetParams(function, &ln));
11 line->line = ln.line;
12 }
13
14 else
15 {
16 function->AddLine(GLSLLine("vec3 " + VAR("norm") + " = normalize(Normal);"));
17 function->AddLine(GLSLLine("vec3 " + VAR("lightDir") + " = normalize(_LightPosition - FragPos.xyz );"));
18 function->AddLine(GLSLLine("float " + VAR("diff") + " = max(dot(" + VAR("norm") + ", " + VAR("lightDir") + "), 0.0f);"));
19 function->AddLine(GLSLLine("vec3 " + VAR("diffuse") + " = " + VAR("diff") + " * _LightColor;"));
20 function->AddLine(GLSLLine("vec3 " + VAR("result") + " = (vec3(0.2, 0.2, 0.2) + " + VAR("diffuse") + ")" + \
21 " * vec3(" + SDATA(0) + ", " + SDATA(1) + ", " + SDATA(2) + ");"));
22 line->line = VAR("result");
23 }
24}