The adventures of building a web renderer


RE: The adventures of building a web renderer
#7
Merging points efficiently

From my post regarding indexing, you could see how using 'indexes' could help reduce the amount of points.

As an example. Consider a 3D box. I has 8 corners. All lines and triangles use these 8 corners, but a box is constructed by 12 lines and 12 triangles. Each line has 2 points and each triangle has 3. With each point taking 3 numbers, the amount of numbers stored to show a box is:

(12*2 + 12*3)*3 = 180 numbers.

If we store the 8 corner points separately (8*3 = 24 numbers) and simply store offsets/indices, the "*3" from the previous equation can be removed, resulting in:

24 + (12*2 + 12*3) = 84 numbers.

Parts in the LDraw library (especially standard parts) have a lot of common points, so it makes sense to use this trick to save memory, and thereby also rendering time. In our example above we save roughly 50%, so let us take a look at how much we can save in our test model.

I would also like to introduce you to an additional test model. This is the very first LDraw model I ever built. It is quite big (3500+ parts) and is good for stress testing:

[Image: 112.png]


Here are the baseline numbers for just showing triangles and not using our trick to combine points. I call the two models 'Psych' (the blue car) and 'Executor':

Psych: Memory usage: 36.3MB. [color=#000000]Rendering time: 1.039ms. Number of points: [color=#000000]375.432.[/color][/color]
Executor: Memory usage: 862MB. [color=#000000]Rendering time: 1.8185ms. Number of points: [color=#000000]11.333.253.[/color][/color]

[color=#000000][color=#000000]This is what happens when you combine points for the full models:[/color][/color]

[color=#000000][color=#000000]Psych: Memory usage: [color=#000000][color=#000000]16.6MB. Rendering time: [color=#000000]3.121ms. Number of points: [color=#000000]99.687.[/color][/color][/color]
[/color][/color][/color]
Executor: Memory usage: [color=#000000]313MB. Rendering time: [color=#000000]99.495ms. Number of points: [color=#000000]2.700.145.[/color][/color][/color]


[color=#000000][color=#000000][color=#000000]That rendering time is completely unacceptable. Here is what happens when points are only combined for the individual parts (not the full mode:[/color][/color][/color]

[color=#000000][color=#000000][color=#000000][color=#000000][color=#000000]Psych: Memory usage: [color=#000000][color=#000000][color=#000000]20.5MB[/color]. Rendering time: [color=#000000][color=#000000]1.584ms.[/color] Number of points: [color=#000000][color=#000000]100.339[/color].[/color][/color][/color][/color][/color][/color]
[/color][/color][/color]
Executor: Memory usage: [color=#000000][color=#000000]414MB[/color]. Rendering time: [color=#000000][color=#000000]17.096ms[/color]. Number of points: [color=#000000][color=#000000]2.751.714[/color].[/color][/color][/color]



These tradeoffs are much more acceptable. Next up was adding normal lines to the mix.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: The adventures of building a web renderer - by Lasse Deleuran - 2018-11-09, 11:44

Forum Jump:


Users browsing this thread: 3 Guest(s)