1
尋找將表面着色器轉換爲片段着色器的幫助。最終將紋理渲染到Unity3D Rendertexture。謝謝!將表面着色器轉換爲片段着色器
表面着色器輸出噪聲和基於https://scrawkblog.com/2013/05/18/gpu-gems-to-unity-improved-perlin-noise/
這是我期待轉換的表面材質:從reddit的
Shader "Noise/Diffuse3D"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color("Color", Color) = (1,1,1,1)
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
#pragma target 3.0
#pragma glsl
#include "ImprovedPerlinNoise3D.cginc"
sampler2D _MainTex;
fixed4 _Color;
struct Input
{
float2 uv_MainTex;
float3 noiseUV;
};
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
//o.noiseUV = v.vertex.xyz; //use model space, not world space for noise uvs
// v.vertex is the input vertex in the vertex shader
//float3 worldPos = mul(_Object2World, v.vertex).xyz;
o.noiseUV = mul(_Object2World, v.vertex).xyz;
}
void surf(Input IN, inout SurfaceOutput o)
{
//uncomment this for fractal noise
//float n = fBm(IN.noiseUV, 4);
//uncomment this for turbulent noise
float n = turbulence(IN.noiseUV, 4);
//uncomment this for ridged multi fractal
//float n = ridgedmf(IN.noiseUV, 4, 1.0);
o.Albedo = _Color.rgb * n;
o.Alpha = _Color.a;
}
ENDCG
}
FallBack "Diffuse"
}