Merge pull request #963 from Azaezel/alpha41/terrainNormSafety

terrain safeties
This commit is contained in:
Brian Roberts 2023-02-15 15:48:11 -06:00 committed by GitHub
commit c1d417806a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -250,7 +250,7 @@ void TerrainBaseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentLis
{
Var* inNormal = (Var*)LangElement::find("normal");
meta->addStatement(
new GenOp(" @.z = dot( normalize( vec3( @.x, @.y, 0 ) ), vec3( 0, 1, 0 ) );\r\n",
new GenOp(" @.z = abs(dot( normalize( vec3( @.x, @.y, 0.0001 ) ), vec3( 0, 1, 0 ) ));\r\n",
outTex, inNormal, inNormal));
meta->addStatement(
new GenOp(" @.w = 1.0 - dot( normalize( @.xyz ), vec3( 0, 0, 1 ) );\r\n",
@ -1300,7 +1300,7 @@ void TerrainHeightMapBlendGLSL::processPix(Vector<ShaderComponent*>& componentLi
{
Var* detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", idx));
Var* detailH = (Var*)LangElement::find(String::ToString("detailH%d", idx));
meta->addStatement(new GenOp(" @ = (@-@.x)/(@.y-@.x);\r\n", detailH, detailH, heightRange, heightRange, heightRange));
meta->addStatement(new GenOp(" @ = (@-@.x)/(@.y-@.x)-@.x;\r\n", detailH, detailH, heightRange, heightRange, heightRange));
}
meta->addStatement(new GenOp("\r\n"));

View file

@ -305,7 +305,7 @@ void TerrainBaseMapFeatHLSL::processVert(Vector<ShaderComponent*>& componentList
{
Var* inNormal = (Var*)LangElement::find("normal");
meta->addStatement(
new GenOp(" @.z = dot( normalize( float3( @.x, @.y, 0 ) ), float3( 0, 1, 0 ) );\r\n",
new GenOp(" @.z = abs(dot( normalize( float3( @.x, @.y, 0.0001 ) ), float3( 0, 1, 0 ) ));\r\n",
outTex, inNormal, inNormal));
meta->addStatement(
new GenOp(" @.w = 1.0 - dot( normalize( @.xyz ), float3( 0, 0, 1 ) );\r\n",
@ -1381,7 +1381,7 @@ void TerrainHeightMapBlendHLSL::processPix(Vector<ShaderComponent*>& componentLi
{
Var* detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", idx));
Var* detailH = (Var*)LangElement::find(String::ToString("detailH%d", idx));
meta->addStatement(new GenOp(" @ = (@-@.x)/(@.y-@.x);\r\n", detailH, detailH, heightRange, heightRange, heightRange));
meta->addStatement(new GenOp(" @ = (@-@.x)/(@.y-@.x)-@.x;\r\n", detailH, detailH, heightRange, heightRange, heightRange, heightRange));
}
meta->addStatement(new GenOp("\r\n"));
}