Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1387086 Posts in 66512 Topics- by 59064 Members - Latest Member: Vhalenn

January 19, 2021, 04:16:24 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Polygon need help
Pages: [1]
Print
Author Topic: Polygon need help  (Read 447 times)
kayliolpa
TIGBaby
*


View Profile
« on: October 08, 2020, 11:13:43 AM »

Although I've been using Unity for over a decade now, this is very much a n00b question:

How do I prevent GameObjects from disappearing when close to the camera? In particular, when the centre of the object is no longer in the view volume (but other parts of it are)?

This isn't just to do with polygons, since when (say) a cube suffers from this problem it's clear the whole thing disappears at once, not just one triangle at a time. [spam link removed. Sigh.]

(I am aware of the "clipping planes" setting on the Camera, but it doesn't help since the near plane cannot be set below zero. I am not using occlusion culling.)

Any tips?
« Last Edit: October 23, 2020, 05:25:08 AM by ThemsAllTook » Logged
Prinsessa
Level 10
*****


Ava Skoog


View Profile WWW
« Reply #1 on: October 08, 2020, 12:19:46 PM »

Hey! Gomez If I'm understanding the question correctly, maybe what you're interested in is preventing backface culling, i.e. using a "double-sided" shader?
Logged

barta
Level 0
**


View Profile
« Reply #2 on: October 08, 2020, 12:53:20 PM »

i don't recall anything like this in 6 years of using Unity.

try posting some screenshots.
Logged
bateleur
Level 10
*****



View Profile
« Reply #3 on: October 09, 2020, 06:21:48 AM »

The first thing to realise is that the way you describe the problem isn't what's really going on. It's easy to prove: open a new Unity scene and make a plane, then make a Camera with the plane object just behind it. You will still be able to see the plane through the Camera. It looks like this:



However, I have run into related problems a number of times before and there are various things which can cause this effect. My guess would be that your Mesh bounds are wrong, which can be fixed by calling https://docs.unity3d.com/ScriptReference/Mesh.RecalculateBounds.html ...but there are a number of other possibilities.
Logged

InfiniteStateMachine
Level 10
*****



View Profile WWW
« Reply #4 on: October 10, 2020, 04:19:14 PM »

^^^^ bounds is the first thing I thought of too. Totally sounds like a bounds issue. I ran into that right away when I was editing mesh vertex positions.

One thing to note (this may be obvious) is that you have to recalculate the bounds on the meshfilters instance of the mesh and not the mesh if you are holding a reference to it. I guess it does copy-on-assignment.

EX

Mesh mesh = new Mesh();
meshFilter.mesh = mesh;
mesh.RecalculateBounds(); // didn't update bounds
meshfilter.mesh.RecalculateBounds(); // this one worked and properly updated my bounds.
Logged

barta
Level 0
**


View Profile
« Reply #5 on: October 11, 2020, 06:31:56 PM »

Quote
you have to recalculate the bounds on the meshfilters instance of the mesh and not the mesh if you are holding a reference to it. I guess it does copy-on-assignment.

why does this happen?
this has happened to me sometimes but i've never understood how and why.
just curious, i have no formal education in coding.
Logged
InfiniteStateMachine
Level 10
*****



View Profile WWW
« Reply #6 on: October 16, 2020, 01:15:43 PM »

Quote
you have to recalculate the bounds on the meshfilters instance of the mesh and not the mesh if you are holding a reference to it. I guess it does copy-on-assignment.

why does this happen?
this has happened to me sometimes but i've never understood how and why.
just curious, i have no formal education in coding.

Usually for me it happens when I manually change a vertex buffer so that the shape of the object is significantly different.

I think the idea is that when you are just nudging vertices a little bit then you don't want to pay the cost of recalculating bounds (I'm guessing it's O(n) or worse) so they decided not to recalculate the bounds every time the vertex buffer changes. It's up to the programmer to decide when the shape is so different it needs new bounds.
Logged

barta
Level 0
**


View Profile
« Reply #7 on: October 17, 2020, 04:51:31 AM »

sorry i meant the part about having to do it on meshfilter.mesh because it wouldn't work on the mesh if you are holding a reference to it. i don't understand the reason why it wouldn't work.
Logged
InfiniteStateMachine
Level 10
*****



View Profile WWW
« Reply #8 on: October 20, 2020, 12:34:56 PM »

sorry i meant the part about having to do it on meshfilter.mesh because it wouldn't work on the mesh if you are holding a reference to it. i don't understand the reason why it wouldn't work.

EDIT : Started to look into it and I'm not totally sure. Mesh appears to be a class so I would expect them both to be pointing at the same place in memory...

The only thing is mesh.cs appears to be implemented in c/C++ so maybe there's some black magic going on...
« Last Edit: October 20, 2020, 12:41:39 PM by InfiniteStateMachine » Logged

Prinsessa
Level 10
*****


Ava Skoog


View Profile WWW
« Reply #9 on: October 21, 2020, 12:33:28 AM »

Ohh, bounds… I got stuck on "clipping planes". Cheesy
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic