Git Product home page Git Product logo

Comments (10)

najak3d avatar najak3d commented on July 18, 2024

For me, FrustumCulling BUG exists for all scenes. The math "looks right" but for some reason isn't working for me. The computer shader's "signed_point_dist()" method isn't returning what I'd expect.

I tried toggling each Point's xyz (e.g. (-x, y, z), then (x, y, -z) then (z, y, x) ,etc) -- so see if maybe this was caused by some confusion of axes/polarity.

I'm using UNity3d 2021.3.1f16 as well as 2022.2.1f1. Both exhibit the same issue with Frustum culling.

from gpuinstance.

mkrebser avatar mkrebser commented on July 18, 2024

I'm not able to repro this (in unity 2021.1). When I open the scenes the camera works as expected.
eg, in crowddemo I am changing fov, near plane, far plane.

What are your camera settings/other changes to get it into this state?

To increase FPS, you can create less complex LODs. eg, all the least detailed LODs in in the skinned mesh characters will have around 200 vertices or less. They look horrible up-close- but far away it isn't noticeable

from gpuinstance.

najak3d avatar najak3d commented on July 18, 2024

I've narrowed it down to the 'cameraFrustum' Buffer. For some reason, the values we are setting in C# are not the same values being read by the Compute Shader.

I reduced the "outside_frustum_count()" method down to ONLY checking against the "Near" plane (meaning anything frontwards at all from camera would show up).... and this fails miserably.

To validate the rest of the logic, I then HARD-CODED the 2 values in the shader to the NearCenter and NearNormal that I'm setting in the C# from startup -- and THIS WORKS. Which leads me to conclude that the 'cameraFrustum' buffer is somehow corrupting the values.

I'm new to Unity Shader customizing/debugging -- so my methods here might be crude/ancient. I'm going to do some googling for tutorials for better methods to debug a compute shader, other than my very manual method. Mainly, I want to know what values are being read from this buffer.... all I've done so far is validate that "these values are NOT what I set from C#".

from gpuinstance.

najak3d avatar najak3d commented on July 18, 2024

I've found a few links on debugging shaders - what is your preferred method? (VStudio, or Unity RenderDocIntegration, or other?)

I tried to simply set values from the ComputeShader into a new RWBuffer called "cameraFrustum2" and read it back in C#... but for some reason this is failing inside your "instancemesh.compute" shader (note: it works if I create a separate shader that only does this; so not sure what it is about your compute shader that makes this not work for me).

from gpuinstance.

najak3d avatar najak3d commented on July 18, 2024

FIXED - via trial/error/experimentation.

For my setup, it only works if 'cameraFrustumBuffer' is a RWStructuredBuffer, instead of plain 'Buffer'.

RWStructuredBuffer cameraFrustumBuffer; //camera frustum buffer

When it's just a 'Buffer', the "Vector3.X" value becomes ALL values.... so if X = 1, then the Vec3 is (1, 1, 1). So my Plane Normals were either (x, x, x) or (-x, -x, -x).... yz values totally lost/ignored.

So the fix was literally just "one word change" from "Buffer" to "RWStructuredBuffer".

from gpuinstance.

najak3d avatar najak3d commented on July 18, 2024

Also confirmed that "StructuredBuffer" also works (the "RW" is not required here).

from gpuinstance.

mkrebser avatar mkrebser commented on July 18, 2024

I've done some digging, it seems Buffer doesn't support vector types on some platforms (like most AMD GPUs for example) (which would explain why I cannot reproduce this issue 💯 )

StructuredBuffer should suffice instead (We don't need RW on this buffer since the entire buffer gets set before the kernel is invoked)

Wanna make a pull request?

from gpuinstance.

najak3d avatar najak3d commented on July 18, 2024

you wrote: "Wanna make a pull request?"

I haven't cloned your repo and am not set up for that here yet. For this "fix" it's only a 1 word change... making that one line read as:

StructuredBuffer<float3> cameraFrustumBuffer;

So my preference is for you to just make this first change on my behalf.

from gpuinstance.

mkrebser avatar mkrebser commented on July 18, 2024

pushed fix, thanks for finding this issue and troubleshooting

from gpuinstance.

najak3d avatar najak3d commented on July 18, 2024

It's just a small thing compared to what you have already done for the rest of us!

from gpuinstance.

Related Issues (17)

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.