Code Monkey home page Code Monkey logo

watersurface's Introduction

Interactive Water Surface

A React Three Fiber component for water surface with realistic reflections, with additional interactive FX.

image

Installation

  1. Make sure you have all dependencies installed first:
npm i three @react-three/fiber @react-three/drei @funtech-inc/use-shader-fx @types/three
  1. Then copy/download the /WaterSurface directory to your project. Could be done by clone the repo.
WaterSurface
|_InteractiveFX
|_Water
|_...
  1. Copy/Download assets files in /public to your /public.
/public
|_water
|_fx

Usage

Import components from the directory just copied above. There are 2 type of components: WaterSurface & InteractiveFX. All of them are listed below:

WaterSurface

WaterSurface type component will be the water shader plane that reflects your scene and apply distortion effects.

⚠️ The implementation is Planar Reflection, therefore it could be expensive in medium and complex scene.

<WaterSurfaceSimple />

WaterSurfaceSimple

Simple water surface using 1 normal map distortion, imported from public/water/simple/waternormals.jpeg.

This is the three.js Water implementation.

type Props = {
  width?: number;
  length?: number;
  dimensions?: number;
  waterColor?: number;
  position?: [number, number, number];
  distortionScale?: number;
  fxDistortionFactor?: number;
  fxDisplayColorAlpha?: number;
  fxMixColor?: number | string;
  children?: React.ReactNode;
};

WaterSurfaceComplex

Complex Water Surface using 2 normal map distortion, imported from public/water/complex/Water_1_M_Normal.jpg & public/water/complex/Water_2_M_Normal.jpg.

This is the three.js Water2 implementation.

type Props = {
  children?: React.ReactNode;
  position?: [number, number, number];
  width?: number;
  length?: number;
  color?: number | string;
  scale?: number;
  flowDirection?: Vector2 | [number, number];
  flowSpeed?: number;
  dimensions?: number;
  reflectivity?: number;
  fxDistortionFactor?: number;
  fxDisplayColorAlpha?: number;
};

(Will have support for refraction in near future!)

InteractiveFX

IntertiveFX type component will be the additional effects apply on the WaterSurface type. This can be added as children component of the WaterSurface component.

<WaterSurfaceComplex>
  <FluidFX />
</WaterSurfaceComplex>

RippleFX

Cheap ripple effect using image texture as distortion on water surface.

An implementation of @funtech-inc/use-shader-fx useRipple hook.

type Props = {
  frequency?: number;
  rotation?: number;
  fadeout_speed?: number;
	scale?: number;
	alpha?: number;
};

Make sure you have smoke.png at public/fx/smoke.png first before using this.

FluidFX

Fluid simulation effect with customizable colors that distort water surface reflection.

An implementation of @funtech-inc/use-shader-fx useFluid hook.

type Props = {
	densityDissipation?: number;
	velocityDissipation?: number;
	velocityAcceleration?: number;
	pressureDissipation?: number;
	splatRadius?: number;
	curlStrength?: number;
	pressureIterations?: number;
	fluidColor?: (velocity: Vector2) => Vector3;
};

watersurface's People

Contributors

nhtoby311 avatar

Stargazers

Kyle L. McGregor avatar Joevin avatar Minakami avatar Jeffrey Castellano avatar Bharat Dangar avatar EryetChen avatar Vince Speelman avatar  avatar Yogesh Bhatt avatar Steve Martin avatar Nikita Fedotov avatar  avatar Sudhir Yadav avatar neoko avatar Cyango avatar RhysJosmin avatar Tao Jianhang avatar Prakhar Dubey avatar Yi Zhe Ang avatar Amo Wu avatar Bob avatar ps++ avatar Dale Watson avatar Jake Chvatal avatar  avatar Mathieu K avatar Loïc Laudet avatar Liam_wu avatar Kevin Beck avatar Sikriti Dakua avatar Liu Zijian avatar Yoga Ardli Ardetya avatar 某个大叔 avatar SuddenDevelopment avatar freab mesfin avatar Yoni B avatar 地虎降天龙.hawk avatar Georgiana Marcu avatar Krtolica Vujadin avatar 阿邦 avatar pratik vakil avatar Shunya Koide avatar Joey Figaro avatar Denis Aleshin avatar Wayne Dahlberg avatar Marcin avatar shalom.js avatar Shree avatar Kris Hom avatar Guillaume Dumoulin avatar Travis Arnold avatar susiwen8 avatar sean tai avatar Ruan Azevedo avatar Silas Reinagel avatar Shawn Xie avatar Corey Benson avatar Takuma Hashimoto avatar Andreas Janotta avatar  avatar  avatar Romain Herault avatar

Watchers

 avatar

watersurface's Issues

Update use shader fx to v1.1.13

With addition of adjustable dpr in FBO of useFluid, there should be a corresponding prop for FluidFX, so it can offer better performance option

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.