[M] water plant shader graph
This commit is contained in:
133
Packages/zzwater/Mats/WaterPlantG.mat
Normal file
133
Packages/zzwater/Mats/WaterPlantG.mat
Normal file
@@ -0,0 +1,133 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: WaterPlantG
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &7309648709844754497
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
8
Packages/zzwater/Mats/WaterPlantG.mat.meta
Normal file
8
Packages/zzwater/Mats/WaterPlantG.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6b6a16215e745d45a276188e760f581
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
138
Packages/zzwater/Mats/water_plant.mat
Normal file
138
Packages/zzwater/Mats/water_plant.mat
Normal file
@@ -0,0 +1,138 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: water_plant
|
||||
m_Shader: {fileID: 4800000, guid: b1f0cdff4e5484686a1fd600c2d2c6b1, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 016ab36f33e35487bb91a3712c78b36e, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _SubFreq: 0.3
|
||||
- _Surface: 0
|
||||
- _SwayFreq: 1.18
|
||||
- _SwayIntensity: 0.129
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
- _TineColor: {r: 0.8773585, g: 0.78201175, b: 0.36832502, a: 1}
|
||||
- _WaterDir: {r: 0.58, g: 0.44, b: -0.42, a: 2.2}
|
||||
- _WindDir: {r: 1, g: 0, b: 1, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &8498174157611730267
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
||||
8
Packages/zzwater/Mats/water_plant.mat.meta
Normal file
8
Packages/zzwater/Mats/water_plant.mat.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2194e0d71139943b4bd966de690495f4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1936
Packages/zzwater/shaders/WaterPlantG.shadergraph
Normal file
1936
Packages/zzwater/shaders/WaterPlantG.shadergraph
Normal file
File diff suppressed because it is too large
Load Diff
10
Packages/zzwater/shaders/WaterPlantG.shadergraph.meta
Normal file
10
Packages/zzwater/shaders/WaterPlantG.shadergraph.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 746c94d4092dee3428d2f89537482562
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
28
Packages/zzwater/shaders/libs/WaveObj.hlsl
Normal file
28
Packages/zzwater/shaders/libs/WaveObj.hlsl
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
//UNITY_SHADER_NO_UPGRADE
|
||||
#ifndef WATER_OBJ_INCLUDE
|
||||
#define WATER_OBJ_INCLUDE
|
||||
|
||||
#ifndef GET_TF_FROM_M
|
||||
#define GET_TF_FROM_M(m) dot(float3(m[0].w, m[1].w, m[2].w),1)
|
||||
#endif
|
||||
|
||||
inline float3 GetObjWaveDisplacement(float3 positionOS, float4 waterDir, float freq, float intensity, float factor)
|
||||
{
|
||||
float3 positionWS = TransformObjectToWorld(positionOS);
|
||||
float objFreq = _Time.y * freq + positionWS.y ;
|
||||
float objPhase = objFreq + GET_TF_FROM_M(GetObjectToWorldMatrix()) * waterDir.w;
|
||||
|
||||
float branchPhase = objPhase + dot(positionOS.xyz,1);
|
||||
|
||||
float offset = sin(objPhase) + cos(branchPhase);
|
||||
|
||||
return normalize(waterDir.xyz) * offset * factor * intensity;
|
||||
}
|
||||
|
||||
void GGetObjWaveDisplacement_float(float3 positionOS, float4 waterDir, float freq, float intensity, float factor, out float3 Out)
|
||||
{
|
||||
Out = GetObjWaveDisplacement(positionOS, waterDir, freq, intensity, factor);
|
||||
}
|
||||
|
||||
#endif //WATER_OBJ_INCLUDE
|
||||
7
Packages/zzwater/shaders/libs/WaveObj.hlsl.meta
Normal file
7
Packages/zzwater/shaders/libs/WaveObj.hlsl.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a46a1e71fdaff524b9227e1bb5d54401
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,41 +3,49 @@ Shader "zzwater/waterPlant"
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_SwayFreq("Sway Frequency", Range(0,10)) = 1.0
|
||||
_SubFreq("sub Frequency", Range(0,100)) = 1.0
|
||||
_SwayIntensity("Sway Intensity", Range(0,2)) = 0.1
|
||||
_WindDir("Wind Direction", Vector) = (1,0,0,0)
|
||||
_TineColor("Tine color", Color) = (1,1,1)
|
||||
_SwayFreq("Sway Frequency", Range(0,5)) = 1.0
|
||||
_SwayIntensity("Sway Intensity", Range(0.05,0.5)) = 0.1
|
||||
_WaterDir("Water Direction", Vector) = (1,0,0,0)
|
||||
// _waterDir.w for wave diff from each other
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"UniversalMaterialType" = "Lit"
|
||||
"IgnoreProjector" = "True"
|
||||
Tags
|
||||
{
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"UniversalMaterialType" = "Unlit"
|
||||
"Queue"="Geometry"
|
||||
"DisableBatching"="False"
|
||||
}
|
||||
LOD 300
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
Tags { "LightMode" = "UniversalForward" }
|
||||
ZCLIP On
|
||||
Name "Universal Forward"
|
||||
|
||||
Tags
|
||||
{
|
||||
// LightMode: <None>
|
||||
}
|
||||
|
||||
// Render State
|
||||
Cull Back
|
||||
Blend One Zero
|
||||
ZTest LEqual
|
||||
ZWrite On
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/zzwater/shaders/libs/WaveObj.hlsl"
|
||||
|
||||
struct Attributes {
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
@@ -45,34 +53,29 @@ Shader "zzwater/waterPlant"
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 normalWS : TEXCOORD1;
|
||||
float4 color : TEXCOORD2;
|
||||
float4 color : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float3 _TineColor;
|
||||
half _SwayFreq;
|
||||
half _SubFreq;
|
||||
half _SwayIntensity;
|
||||
float4 _WindDir;
|
||||
float4 _WaterDir;
|
||||
CBUFFER_END
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
|
||||
// 顶点摆动算法[^1]
|
||||
float3 worldPos = TransformObjectToWorld(v.positionOS.xyz);
|
||||
float phase = worldPos.y * _SwayFreq + _Time.y;
|
||||
float phase2 = phase * _SubFreq;
|
||||
float offset = clamp(sin(phase) + sin(phase2), -1.0, 1.0) * _SwayIntensity * v.color.a;
|
||||
//half offset = sin(phase) * _SwayIntensity * v.color.a;
|
||||
|
||||
// 风方向控制
|
||||
float3 displacement = _WindDir.xyz * offset;
|
||||
v.positionOS.xyz += displacement * 0.1;
|
||||
float3 displacement;
|
||||
v.positionOS.xyz += GetObjWaveDisplacement(v.positionOS, _WaterDir, _SwayFreq, _SwayIntensity, v.color.a);
|
||||
|
||||
o.positionHCS = TransformObjectToHClip(v.positionOS.xyz);
|
||||
o.normalWS = TransformObjectToWorldNormal(v.normalOS);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.color = v.color;
|
||||
return o;
|
||||
@@ -80,15 +83,9 @@ Shader "zzwater/waterPlant"
|
||||
|
||||
half4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
half4 albedo = tex2D(_MainTex, i.uv);
|
||||
half4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||
clip(albedo.a - 0.5);
|
||||
//return half4(i.color.aaa, 1.0);
|
||||
return half4(albedo.rgb, 1.0);
|
||||
//Light mainLight = GetMainLight(TransformWorldToShadowCoord(i.positionHCS));
|
||||
|
||||
// 简易光照模型[^2]
|
||||
//half3 diffuse = mainLight.color * saturate(dot(i.normalWS, mainLight.direction));
|
||||
//return half4(albedo.rgb * diffuse, 1.0);
|
||||
return half4(albedo.rgb * _TineColor, 1.0);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user