Page 1 of 1

### [2.1] Dynamic geometry - dynamic quantity of vertices

Posted: Sun Oct 28, 2018 4:53 am
I am trying to get to the point where I can have a changing amount of vertices. I have a feeling I will need to go through the initialisation each time I change the quantity. For now I am not changing the quantity of vertices and just trying to get it to work.

Questions:
(1) Do I need to reinitialise if I change the quantity of vertices originally declared?
(2) Would it work to initially declare an arbitrary number of vertices but just leave unused ones zeroed?
(3) Related to it not working yet - are the normals critical as far as seeing something rendered?

### Re: [2.1] Dynamic geometry - dynamic quantity of vertices

Posted: Sun Oct 28, 2018 10:24 am
OK I made some progress (after a fair amount of time hassling).

It looks like it works to declare an arbitrary number and just use them or not.
For normals I set all of them to 1 since I am doing lines. If I used a lower number like 0.57 they either didn't appear of flickered.

### Re: [2.1] Dynamic geometry - dynamic quantity of vertices

Posted: Sun Oct 28, 2018 3:47 pm
Create your vertex & index buffers big enough to hold the maximum number of elements you expect them to contain (if you later need more, you'll need to recreate the buffers and the VertexArrayObject)

Once you've done that, use VertexArrayObject::setPrimitiveRange to limit how many vertices/indices you're actually using from the buffer.
Related to it not working yet - are the normals critical as far as seeing something rendered?
Yes. PBS requires normals, however Unlit does not.

### Re: [2.1] Dynamic geometry - dynamic quantity of vertices

Posted: Sun Oct 28, 2018 6:32 pm
I'll have to check but I'm probably using PBS. So far I'm just drawing lines.

(1) Is there a particular value I should use for normals? I know it is often calculated.
(2) Maybe I should look into how to change to unlit.

### Re: [2.1] Dynamic geometry - dynamic quantity of vertices

Posted: Sun Oct 28, 2018 8:13 pm
Slicky wrote:
Sun Oct 28, 2018 6:32 pm
(1) Is there a particular value I should use for normals? I know it is often calculated.
No. It has to be unit-length for proper PBR, but that's all.

For flat shading it's often calculated as (v0 - v1).crossProduct( (v0 - v2) );
Smooth shading tends to average the normals to make its smooth look, but there could be other algorithms.

For non-PBR scenarios, the value of the normal depends on what you're trying to achieve.

### Re: [2.1] Dynamic geometry - dynamic quantity of vertices

Posted: Mon Oct 29, 2018 5:07 pm
I got unlit working it wasn't too much of a change. The PBS version had black lines probably no material and my bad normals.