Giter Site home page Giter Site logo

Comments (7)

huwb avatar huwb commented on May 18, 2024

Hi there,

It should not be uploading any geometry each frame - only per-tile shader params. The geometry should be uploaded once by the OceanBuilder on startup. Unless of course there's some kind of nasty bug thats causing it to upload, let me know!

(For the record, regarding GPU instancing, if my understanding is correct this would reduce the number of drawcalls - I guess once it organises what is visible and what is not, it can draw each tile type in a single call. This would probably reduce ocean draw call count from ~40 to ~5. This is interesting but closes the door to doing additive lighting in multiple forward passes to allow local point lights affecting tiles, so I decided not to act on it.)

Let me know if that answers your question and/or if you're seeing something different.

from crest.

strich avatar strich commented on May 18, 2024

It could be even better with uniform tiles enabled too can't it? With that all tiles are the same except for their transform scale correct?

As for the shading/lighting features - Setting up GPU instancing won't remove any features. If in forward rendering mode the base pass will still benefit from instancing and further passes will automatically fall back to standard drawcalls.

from crest.

huwb avatar huwb commented on May 18, 2024

Yes - perhaps it could be reduced to a one draw call if all tiles were uniform. There are a couple of reasons i moved away from uniform tiles:

  • They overlap and this generates not-insignificant duplicate vertex and pixel shader work
  • I generate an extra strip of tris at the boundary perimeter of the ocean geom which extends the range of the ocean geom to the horizon. This is a simple and efficient solution.

It would be possible to solve the second point by manually generating this geom, or doing away with it completely (might work in some scenarios), or by having two tile types and instancing them separately (so 2-4 draw calls in total depending on how many boundary tile types are needed).

It would be good if it doesnt affect the lighting. The main thing in my mind is that if we have local point lights we'll probably only want each light to affect surrounding tile(s). If this still works with instancing, then I am understimating Unity's instancing :) and thats good to know.

I'm not sure what other problems might be encountered when moving to instancing. Maybe none.

I'm interested in trying this out, but I have other things on my plate that are more interesting and/or pressing right now. Feel free to comment on priority/motivate this. My (possibly wrong) assumption has been that 40 drawcalls is acceptable on console/PC (at least for something that fills a vast chunk of the screen). I'm aware however that the impact of draw calls on mobile is high, or at least it used to be.

from crest.

strich avatar strich commented on May 18, 2024

My (possibly wrong) assumption has been that 40 drawcalls is acceptable on console/PC

I think that is correct, but AFAIK it is a lot of polys to push to the GPU. I'll do some testing tonight to see the impact in reality.

FYI unity will automatically disable instancing on tiles that require the additional lighting. So if the solution is implemented it should be non-destructive to other features.

from crest.

huwb avatar huwb commented on May 18, 2024

Ok let me know. I don't foresee an issue here, the only time geometry is transferred to the GPU is on startup. At runtime it uses the existing vertex/index buffers (i just double checked with renderdoc). And FWIW its a very small amount of geometry, each tile is say 64x64 verts and i think there are < 10 tile types. In my current understanding, there should not be an issue from that point of view, but let me know if I'm overlooking something.

Good to know about the lighting, thanks!

from crest.

huwb avatar huwb commented on May 18, 2024

I just did a perf test on my laptop with a standalone build to check overall performance to make sure nothing is going horribly wrong, the total frame time is under 3.5ms at 1080p which is where i was hoping it to be, considering I've been ramping up the detail setting lately and adding loads of optional shader features which I have all turned on. (this is with quality set to 'simple' which unlocks the vsync, but this does not make the ocean cheaper).

from crest.

huwb avatar huwb commented on May 18, 2024

I will close this for now as I don't have plans to implement instancing in the short term. If i try it i'll post back here. Thanks again for the info!

from crest.

Related Issues (20)

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.