浏览代码

Fixes for Depth Texture and Normals Texture Nodes

/main
Matt Dean 7 年前
当前提交
d84ea3c2
共有 2 个文件被更改,包括 11 次插入10 次删除
  1. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/DepthTextureNode.cs
  2. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/NormalsTextureNode.cs

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/DepthTextureNode.cs


};
[Title("Input/Scene/Depth Texture")]
public class DepthTextureNode : AbstractMaterialNode, IGenerateProperties, IMayRequireScreenPosition
public class DepthTextureNode : AbstractMaterialNode, IGenerateProperties, IGeneratesBodyCode, IMayRequireScreenPosition
{
const string kUVSlotName = "UV";
const string kOutputSlotName = "Out";

});
}
public override string GetVariableNameForSlot(int slotId)
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
string uvValue = GetSlotValue(UVSlotId, generationMode);
string outputValue = GetSlotValue(OutputSlotId, generationMode);
string methodName = "";
return "Linear01Depth(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(" + GetSlotValue(UVSlotId, GenerationMode.Preview) + ")).r)";
methodName = "Linear01Depth";
break;
return "LinearEyeDepth(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(" + GetSlotValue(UVSlotId, GenerationMode.Preview) + ")).r)";
methodName = "LinearEyeDepth";
break;
visitor.AddShaderChunk(string.Format("{0} _DepthTexture = {1}(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD({2})).r);", precision, methodName, uvValue), true);
visitor.AddShaderChunk(string.Format("{0} {1} = _DepthTexture;", ConvertConcreteSlotValueTypeToString(precision, FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType), GetVariableNameForSlot(OutputSlotId)), true);
}
public bool RequiresScreenPosition()

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Scene/NormalsTextureNode.cs


});
}
/*public override string GetVariableNameForSlot(int slotId)
{
return "";
}*/
string GetFunctionPrototype(string argIn, string argOut)
{
return string.Format("void {0} ({1}4 {2}, out {3} {4})", GetFunctionName(),

string uvValue = GetSlotValue(UVSlotId, generationMode);
string outputValue = GetSlotValue(OutputSlotId, generationMode);
visitor.AddShaderChunk(string.Format("{0}4 _DepthNormalsTexture = tex2D(_CameraDepthNormalsTexture, {1});", precision, uvValue), true);
//visitor.AddShaderChunk(string.Format("{0}4 _DepthNormalsTexture = UNITY_SAMPLE_TEX2D(_CameraDepthNormalsTexture, {1});", precision, uvValue), true);
visitor.AddShaderChunk(string.Format("{0} {1};", ConvertConcreteSlotValueTypeToString(precision, FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType), GetVariableNameForSlot(OutputSlotId)), true);
visitor.AddShaderChunk(GetFunctionCallBody("_DepthNormalsTexture", outputValue), true);
visitor.AddShaderChunk(string.Format("{1} = {1} * {0}3(1.0, 1.0, -1.0);", precision, GetVariableNameForSlot(OutputSlotId)), true);

正在加载...
取消
保存