freeciv / freeciv-web

Freeciv-web is an Open Source strategy game implemented in HTML5 and WebGL, which can be played online against other players, or in single player mode against AI opponents.
Other
2.01k stars 335 forks source link

Water shader #50

Closed lmoureaux closed 7 years ago

lmoureaux commented 7 years ago

I'd like to admire the Sun being reflected by animated waves.

This can be either vertex+fragment or fragment only. Rivers could use the same logic without waves.

ghost commented 7 years ago

I have added a water shader based on the Three.js webgl_shaders_ocean example: https://threejs.org/examples/webgl_shaders_ocean.html

It is only available to the high quality graphics setting since it will require a good graphics card.

https://github.com/freeciv/freeciv-web/commit/67458bdf0ffc88ef9bbe9dfcf579d9a96bd98f4e

I'm leaving this issue open still, as there could be some tuning and improvements to be made to the water shader still. Perhaps you have some suggestions Louis?

lmoureaux commented 7 years ago

Is it CPU- or GPU-bound ?

ghost commented 7 years ago

The current rendering in Freeciv-web WebGL is limited by the CPU (one core is running on 100%) on my computer. I'm not sure how to monitor GPU-usage. Perhaps I'll implement some kind of way to benchmark the WebGL performance in Freeciv-web so we can compare the performance impact of various rendering features.

lmoureaux commented 7 years ago

On Linux with Intel IGPs, you can use intel-gpu-tools (run the tools as root). GPU vendors make various programs for Windows.

ghost commented 7 years ago

CPU usage is 100% on one core, while GPU usage is never more than 35%, when testing the game on high quality, on Windows 10 with a NVIDIA GeForce GTX 780 Ti graphics card at 3840x2160. So the game is definitely CPU-bound. It runs in JavaScript in a browser after all. Perhaps some profiling can find things to improve.

lmoureaux commented 7 years ago

Closing this because we have a great water shader now. Performance discussion goes to #56. #57 opened about shader for lower resolutions.