Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WebTide is an ocean simulation based on Jerry Tessendorf's paper, implemented on WebGPU with BabylonJS.

License

NotificationsYou must be signed in to change notification settings

BarthPaleologue/WebTide

Repository files navigation

NodeJS with Webpack

img.png

WebTide is an ocean simulation based onJerry Tessendorf's paper, implemented on WebGPU with BabylonJS.

This was my final project for the INF585 "Computer Animation" course at École Polytechnique. The report is onlineon my blog.

An online demo is availablehere, and the spherical version is availablehere.

Features

  • GPU-based FFT
  • Phillips spectrum
  • JONSWAP spectrum
  • Wave vertices vertical displacement
  • Choppy waves (waves vertices horizontal displacement)
  • Physically based ocean shading
  • Wrapping on a sphere with triplanar mapping
  • Jacobian-based foam

How to use

Using the ocean in your own project is straightforward:

// This is the resolution of the wave spectrum. Bigger is better but slower.consttextureSize=512;// This is the size of the water plane in meters.consttileSize=10;// Define your base spectrumconstinitialSpectrum=newPhillipsSpectrum(textureSize,tileSize,engine);// Create the water materialconstwaterMaterial=newWaterMaterial("waterMaterial",initialSpectrum,scene);// Create a subdivided planeconstwater=MeshBuilder.CreateGround("water",{width:tileSize,height:tileSize,subdivisions:textureSize},scene);// Assign the water material to the planewater.material=waterMaterial;// The method to update the material every framefunctionupdateScene(){constdeltaSeconds=engine.getDeltaTime()/1000;waterMaterial.update(deltaSeconds,light.direction);}// Register the update method to the scenescene.executeWhenReady(()=>{scene.registerBeforeRender(()=>updateScene());engine.runRenderLoop(()=>scene.render());});

You can have a look at the code insrc/ts/minimal.ts for the simplest example possible.

Create your own Spectrum

You might want to use a custom spectrum for your ocean. No worries, I got you covered.

TheWaterMaterial class takes any object that implements theInitialSpectrum interface for theinitialSpectrum parameter.

You can copy and paste the code for the Phillips Spectrum (the typescript class and the wgsl shader code) and start from there.

Related works

I made this simulation using many different resources found online:

Assets used

Run locally

To run the project locally, you need to have Node.js installed. Then, run the following commands:

pnpm installpnpm run serve

If you don't havepnpm installed, you can install it withnpm install -g pnpm.

About

WebTide is an ocean simulation based on Jerry Tessendorf's paper, implemented on WebGPU with BabylonJS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp