Git Product home page Git Product logo

2dgrassshaderdemo's Issues

better performance

I find that there are for loop, and in some situations, we can add break to make better performance. at least for your situation, add break does not affect the result
image
I think only in few situations this will cause influence

Bug or float equals problem?

Wonderful project. I always think using shader to do dynamic grass, this give me good ideas. When i follow your instructions, i found one problem:
image
you use float equals, and i find this is not safe. if use
if dist / 255.0 == texture(tex, uv).r
the result will be wrong
image
and use
if (abs(dist / 255.0 - texture(tex, uv).r) < 0.0000001), the result will be correct. Maybe for float, use equal is not safe

Viewport Problem and using sprite directly

Hello, I found that using viewport had many problems, for example, when i use environment and
canvasmodulate, or using character camera2D. So I decided to realize your method using sprite directly. Now I almost finished it.

image
I setup the scene as following , without any viewport.
image
I realized following fuctions:

  1. can generate grass in any positions , not limited by environment and camera2d
  2. can dynamically interacted with mouse go generate new height grass
  3. can have wind and noise like yours
  4. can have the right "grass hide some portion of character" effect

All in all, without viewport I can realize all your functions, and viewport have many limitions. So Why you use viewport and not sprite directly???

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.