统一网格有黑点



你好,我在YouTube上关注了塞巴斯蒂安联盟制作的关于程序生成的视频系列,我关注了他的整个视频系列,但是就我而言,网格中有黑点,仅在水域区域。我正在为那些想知道的人使用全局模式,也使用 unity 2019.4.6f1。我想摆脱黑点已经尝试建立和运行,黑点就在那里。

链接到他的意甲是:https://www.youtube.com/watch?v=wbpMiKiSKm8&list=PLFt_AvWsXl0eBW2EiBtl_sxmDtSgZBxB3 我已经在GitHub上下载了他的项目,他似乎没有问题,这是他的GitHub页面:https://github.com/SebLague/Procedural-Landmass-Generation 这里还有一张图片->这里

我正在为地形创建自己的自定义着色器,这里是

Shader "Custom/terrain"
{   
// this properties will be added to our meshMaterial
Properties {
testTexture("Texture", 2D) = "white"{}
testScale("Scale", Float) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
const static int maxLayerCount = 8;
const static float epsilon = 1E-4;
int layerCount;
// float3 because of RGB
float3 baseColors[maxLayerCount];
float baseStartHeights[maxLayerCount];
float baseBlends[maxLayerCount];
float baseColorStrength[maxLayerCount];
float baseTextureScales[maxLayerCount];
float minHeight;
float maxHeight;
sampler2D testTexture;
float testScale;
UNITY_DECLARE_TEX2DARRAY(baseTextures);
struct Input {
float3 worldPos;
float worldNormal;
};
// float a is min value, float b is max value and value is current value 
float inverseLerp(float a, float b, float value) {
// saturate means clamp the value between 0 and 1 
return saturate((value - a)/(b - a));
}
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)

float3 triplanar(float3 worldPos, float scale, float3 blendAxis, int textureIndex) {
float3 scaledWorldPos = worldPos / scale;
// tripleaner mapping 
float3 xProjection = UNITY_SAMPLE_TEX2DARRAY(baseTextures, 
float3(scaledWorldPos.y, scaledWorldPos.z, textureIndex)) * blendAxis.x;
float3 yProjection = UNITY_SAMPLE_TEX2DARRAY(baseTextures, 
float3(scaledWorldPos.x, scaledWorldPos.z, textureIndex)) * blendAxis.y;
float3 zProjection = UNITY_SAMPLE_TEX2DARRAY(baseTextures, 
float3(scaledWorldPos.x, scaledWorldPos.y, textureIndex)) * blendAxis.z;
return xProjection + yProjection + zProjection;
}
// this function will be called for every pixel that our mesh is visible
// we want to set the color at that surface 
void surf (Input IN, inout SurfaceOutputStandard o) {
float heightPercent = inverseLerp(minHeight, maxHeight, IN.worldPos.y);
float3 blendAxis = abs(IN.worldNormal);
blendAxis /= blendAxis.x + blendAxis.y + blendAxis.z;
for (int i = 0; i < layerCount; i++) { 
float drawStrength = inverseLerp(-baseBlends[i]/2 - epsilon, baseBlends[i]/2, (heightPercent - baseStartHeights[i]));
float3 baseColor = baseColors[i] * baseColorStrength[i];
float3 textureColor = triplanar(IN.worldPos, baseTextureScales[i], blendAxis, i) * (1-baseColorStrength[i]);
// if drawStrength is 0 then we would set color to black 
// but what we want is that if drawstength is 0 
// then we want to use the same color, albedo * 1 + 0 will be same (what we want)
o.Albedo = o.Albedo * (1-drawStrength) + (baseColor + textureColor) * drawStrength;
}
}
ENDCG
}
FallBack "Diffuse"
}

所以我认为问题出在代码上,但我将我的代码与 GitHub 上提供的塞巴斯蒂安联盟代码进行了比较,那里什么都没有,但问题结果是我们用来分配基本高度的动画曲线。只要确保它的星星略低于零,这就是我所知道的解决方案

Github链接: https://github.com/SebLague/Procedural-Landmass-Generation/tree/master/Proc%20Gen%20E21

最新更新