Author Topic: [C++] [software rasterizer] Triangle rasterizer gaps  (Read 18216 times)

0 Members and 1 Guest are viewing this topic.

Offline inc.

  • Contact me @ skype: a5recordings
  • Amiga 1200
  • ****
  • Posts: 276
  • Karma: 25
  • I SPEAK ENGLISH & GERMAN as good as i can :D
    • View Profile
i've tested your exe. windowed not working for each resolution. (maybe caused by the 3 TFT on the PC)

In fullscreen i have 60 Frames @ 640*480
@ 1024*768 only 32 Frames

but no errors in displaying your texture and the sphere. it's working well. maybe a bit slow :)

Specs here:
Windows 7 64bit
24GB RAM
Geforce GTX 950

and i can not see any differents in the resolution between 640*480 &  1024*768. Looks the same.

best
inc
« Last Edit: June 22, 2016 by inc. »
currently coding in PureBasic: GLSL Shader Maker & Editor Tool for further Demo coding usage

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
Well spotted Stonemonkey. Yes I have fixed that code since, but that part was still lying in the fixed point version so thanks for pointing it out.

Thanks for testing inc. What fps would you expect for this scene?

Offline inc.

  • Contact me @ skype: a5recordings
  • Amiga 1200
  • ****
  • Posts: 276
  • Karma: 25
  • I SPEAK ENGLISH & GERMAN as good as i can :D
    • View Profile
At 1024x768, 60 frames should be not a problem nowadays.  ;D
currently coding in PureBasic: GLSL Shader Maker & Editor Tool for further Demo coding usage

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1292
  • Karma: 466
    • View Profile
    • my stuff
What fps would you expect for this scene?
In 1024x768 I get >200fps on an I7.
Not bad but could be improved.

Since your texture (512x256x32) should be completely cached (on a modern CPU), the performance is probably just a matter of instruction counts.
So if you want to make your code faster, we can have a look into your innerloops!

For a start you can use rdtsc to measure how much time you're spending in your texture mapping innerloop and how much in the rest of your code.
« Last Edit: June 28, 2016 by hellfire »
Challenge Trophies Won:

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
Inc I also find my fulllscreen FPS are way less than in windowed mode, not sure why. Im using directdraw 7, it should be faster in fullscreen shouldnt it?

Thanks Hellfire, thats a lot of fps! I think I should put together a more realistic scene first before I end up optimizing the wrong thing. I seem to spend a lot of time in the vector [] operator. Plain arrays would surely not make a difference?

My plan is to:
fix clipping bugs
fix camera movement bug
fake phong+gaurad+environment map + sky box
zbuffer in a 50k polygon scene with overlaps

then optimize  :cheers:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
I don't know if it could help or not but an optimisation I've used is to do blackface culling in model space which means you don't have to transform vertices of culled triangles, it requires another element (in my case) to the triangle structure that is pre-calculated at the time of creating the triangle. It's just the dot product of the triangle normal and the chords of any one of its vertices in model space to get some sort of threshold value for each tri (distance from origin to triangle plane)

Then when rendering the model, transform the camera into model space and just calculate the dot product of the camera chords with the triangle normal and compare the result with the pre-calculated threshold value (which side of triangle plane the camera lies)

There are some limitations with this method if you have dynamic scaling of models during rendering.

« Last Edit: July 01, 2016 by Stonemonkey »

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1292
  • Karma: 466
    • View Profile
    • my stuff
it should be faster in fullscreen shouldnt it?
Fullscreen probably creates a swapchain which enables VSync.

Quote
I seem to spend a lot of time in the vector [] operator. Plain arrays would surely not make a difference?
Not quite sure. Are you using std::vector<> ?
I'm usually using my own containers which have inlined operators.
Since std::vector is a template, your compiler should be clever enough to decide what to inline (at least in release build).
Alternative:
Code: [Select]
Vector3d* src= untransformedVertices.data();
Vector3d* dst= transformedVertices.data();
auto count= untransformedVertices.size();
while (count--)
{
   *dst++= transform( *src++ );
}

Challenge Trophies Won: