Skip to content

Commit

Permalink
[Forest] Made water ripples a bit more realistic
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosK92 committed Nov 21, 2023
1 parent 2ac43e3 commit a074d7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions data/shaders/common_vertex_operations.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ float4 compute_screen_space_position(Vertex_PosUvNorTan input, uint instance_id,
if (material_vertex_animate_wind()) // vegetation
{
float3 animation_pivot = float3(instance._31, instance._32, instance._33); // position
world_position = vertex_simulation::vegetation::apply_wind(instance_id, world_position, animation_pivot, time);
world_position = vertex_simulation::vegetation::apply_player_bend(world_position, animation_pivot);
world_position = vertex_processing::vegetation::apply_wind(instance_id, world_position, animation_pivot, time);
world_position = vertex_processing::vegetation::apply_player_bend(world_position, animation_pivot);
}
#endif

if (material_vertex_animate_water())
{
world_position = vertex_simulation::water::apply_wave(world_position, time);
world_position = vertex_simulation::water::apply_ripple(world_position, time);
world_position = vertex_processing::water::apply_wave(world_position, time);
world_position = vertex_processing::water::apply_ripple(world_position, time);
}

return mul(float4(world_position, 1.0f), view_projection);
Expand Down
10 changes: 5 additions & 5 deletions data/shaders/common_vertex_processing.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

struct vertex_simulation
struct vertex_processing
{
struct vegetation
{
Expand Down Expand Up @@ -113,7 +113,7 @@ struct vertex_simulation
static const float base_wave_speed = 0.5f;

// interleave 4 waves to have a more complex wave pattern
float3 offset = float3(0.0f, 0.0f, 0.0f);
float3 offset = 0.0f;
for (int i = 0; i < 4; i++)
{
// modulate base wave parameters based on index
Expand Down Expand Up @@ -148,9 +148,9 @@ struct vertex_simulation

static float3 apply_ripple(float3 position_vertex, float time)
{
static const float ripple_speed = 5.0f;
static const float ripple_max_height = 0.5f;
static const float ripple_frequency = 3.0f;
static const float ripple_speed = 2.0f;
static const float ripple_max_height = 0.2f;
static const float ripple_frequency = 5.0f;
static const float ripple_decay_rate = 0.1f;
static const float ripple_decay_after_movement = 2.0f; // time for ripples to decay after movement stops

Expand Down

0 comments on commit a074d7b

Please sign in to comment.