Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dyn waves from texture #328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -642,11 +642,11 @@ MonoBehaviour:
_timeProvider: {fileID: 0}
_material: {fileID: 2100000, guid: 9def92ac79181fe41b238e91663f0fad, type: 2}
_layerName: Water
_windDirectionAngle: 0
_gravityMultiplier: 1
_minTexelsPerWave: 3
_minScale: 8
_maxScale: 256
_dropDetailHeightBasedOnWaves: 0.2
_lodDataResolution: 256
_geometryDownSampleFactor: 2
_lodCount: 8
Expand Down Expand Up @@ -861,7 +861,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1680820176
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1029,9 +1029,15 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_spectrum: {fileID: 11400000, guid: 691aad324f2d2be4abf8123c36963da5, type: 2}
_windDirectionAngle: 0
_componentsPerOctave: 8
_weight: 1
_randomSeed: 0
_evaluateSpectrumAtRuntime: 1
_wavelengths: []
_amplitudes: []
_angleDegs: []
_phases: []
_directTowardsPoint: 0
_pointPositionXZ: {x: 0, y: 0}
_pointRadii: {x: 100, y: 200}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class LodDataMgrPersistent : LodDataMgr

float _substepDtPrevious = 1f / 60f;

static int sp_SimDeltaTime = Shader.PropertyToID("_SimDeltaTime");
public static int sp_SimDeltaTime = Shader.PropertyToID("_SimDeltaTime");
static int sp_SimDeltaTimePrev = Shader.PropertyToID("_SimDeltaTimePrev");

protected override void Start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void Draw(CommandBuffer buf, float weight, int isTransition)
if (_renderer && weight > 0f)
{
_materials[isTransition].SetFloat(sp_Weight, weight);
_materials[isTransition].SetFloat(LodDataMgrPersistent.sp_SimDeltaTime, OceanRenderer.Instance.DeltaTimeDynamics);

buf.DrawRenderer(_renderer, _materials[isTransition]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Shader "Crest/Inputs/Dynamic Waves/Add Bump"
Properties
{
_Amplitude( "Amplitude", float ) = 1
_Radius( "Radius", float) = 3
_Radius("Radius", float) = 3
}

SubShader
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Crest Ocean System

// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE)

Shader "Crest/Inputs/Dynamic Waves/Add From Texture"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_Strength( "Strength", float ) = 1
}

SubShader
{
// base simulation runs on the Geometry queue, before this shader.
// this shader adds interaction forces on top of the simulation result.
Blend One One

Pass
{
CGPROGRAM
#pragma vertex Vert
#pragma fragment Frag

#include "UnityCG.cginc"

sampler2D _MainTex;

float4 _MainTex_ST;
float _Strength;
float _SimDeltaTime;

struct Attributes
{
float3 positionOS : POSITION;
float2 uv : TEXCOORD0;
};

struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
};

Varyings Vert(Attributes input)
{
Varyings o;
o.positionCS = UnityObjectToClipPos(input.positionOS);
o.uv = TRANSFORM_TEX(input.uv, _MainTex);
return o;
}

float4 Frag(Varyings input) : SV_Target
{
// Integrate acceleration onto velocity
return float4(0.0, _SimDeltaTime*_Strength*tex2D(_MainTex, input.uv).x, 0.0, 0.0);
}

ENDCG
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.