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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Voroz

Pages: 1 [2] 3 4 ... 9
16
General / Re: Help with some trig math
« on: October 25, 2015, 02:57:41 am »
Another question. This code calls tan, cos, sin 500 times per frame which is a bit costly. Will the Transformpoint work better performance wise? Or should i attempt to implement a sine / cosine table, or is there a better fast and accurate way?

17
General / Re: Help with some trig math
« on: October 25, 2015, 01:45:01 am »
Alright it works now. I didn't realize that cos and sin takes radians in c++. On the calculator it takes degrees.
Edited first post with working code.

18
General / Re: Help with some trig math
« on: October 25, 2015, 01:39:33 am »
I found something with debugger.

actualVertexPosition.x = length*cosf(actualVertexAngle);
actualVertexPosition.y = length*sinf(actualVertexAngle);

These give me the wrong values.
for example length*sinf(actualVertexAngle); gives me ~7.75 as answer when length is 87 and degree is 135. Calculator gives me ~62 as answer which, if you think about it, should be the correct one.

19
General / Re: Help with some trig math
« on: October 25, 2015, 01:05:28 am »
I think getTransform and transformPoint could help you.
Ok. I'm not sure how i'm supposed to use those but even if i did i'd still like to know what's wrong with my code. I edited my post with some updated code, but it's still not working.

20
General / Help with some trig math
« on: October 24, 2015, 11:34:47 pm »
Hi. I'm trying to render some stuff faster with help of a vertexarray. Problem is that when i get the 4 vertexes of my sf::RectangleShapes i get the positions without rotation applied. Also the positions are given without accounting for my setOrigin. So i did some trigonometry to try and get what i wanted: This is the code:

class cVertexRendering{
    public:
    void addRect(sf::RectangleShape Rect){
        for (int i = 0; i < Rect.getPointCount(); i++){
            float x = Rect.getPoint(i).x - Rect.getSize().x/2;
            float y = Rect.getPoint(i).y - Rect.getSize().y/2;
            float length = sqrt(powf(x, 2) + powf(y, 2));

            float actualVertexAngle;
            actualVertexAngle = atan2f(y, x);
            //Convert to 0-360 from -180 +180
            if (actualVertexAngle < 0){
                actualVertexAngle += 2*PI;
            }
            //Add rect rotation
            actualVertexAngle += DEGTORAD*Rect.getRotation();

            sf::Vector2f actualVertexPosition;
            actualVertexPosition.x = length*cosf(actualVertexAngle);
            actualVertexPosition.y = length*sinf(actualVertexAngle);
            sf::Vertex vertex = sf::Vertex(sf::Vector2f(Rect.getPosition().x + actualVertexPosition.x,
                                                        Rect.getPosition().y + actualVertexPosition.y),
                                                        Rect.getFillColor());
            vertexArray.append(vertex);
        }
    };
    sf::VertexArray getVertexArray(){
        return vertexArray;
    }
    void clear(){
        vertexArray.clear();
    }
    private:
    sf::VertexArray vertexArray = sf::VertexArray(sf::Quads);
}vertexRendering;

What happens is that i get almost a triangular shape instead of the rectangle shape that's supposed to happen. Also the rotation doesn't match. Any idea where i go wrong? been looking at this for hours.

21
General / Re: Need some help optimizing rendering speed.
« on: October 15, 2015, 12:04:12 am »
well i connect the hulls that block light of LTBL with Box2d. I don't know if it'd act different when using shadows cast by hulls though. Anyway i need to get some sleep now. Have a good night!

22
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 11:44:58 pm »
well i just did a simple loop for testing:

//Lights
ls.SetView(lightView);
if (counttest == 4){
    counttest = 0;
    ls.RenderLights();
}
counttest += 1;

ls.RenderLightTexture();

I don't think i can post pictures of it blinking, but the entire area that's supposed to be dark goes normal bright color and then back to dark etc.

edit: not a loop, i mean a counter. Tired

23
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 11:42:11 pm »
You are here asking for performance solutions, i give you one.
True, but i was actually mostly looking to optimize the rendering part without making the rendering slower..

I could easily make the app run in 5000 fps but only render 1 time per second, but i don't think that would be better. It's kind of the same thing here but only with the lights. It would be a good solution though ofcourse as a lower graphics option.

24
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 11:36:00 pm »
I tried updating every 4 frames and it made the entire shader blink. epilepsy! (yes i only did it for ls.RenderLights(), not the texture.)

25
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 11:23:55 pm »
I didn't see the part where you recommended to set it to 4-7 for 60 fps apps. Well that will ofcourse give better performance, but lights will only update at 8-15 fps. I don't think i want to make that sacrifice, atleast not now. Maybe if i really need to sometime i might concider making it run slightly slower.

26
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 11:16:08 pm »
But there's no point of those extra fps if your fps is already high. And if your fps isn't high then you can't do it anymore. Sure you can get extreme pointless fps by limiting draw calls but you'll need atleast 60 per second, which is the same you'd get if you actually have 60 fps. So really it seems useless :).

edit: if i wasn't clear enough what i mean is that you automatically limit draw calls by getting lower fps, and when your fps is high you don't need to limit them.

27
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 10:33:50 pm »
wont that make it so lights are lagging behind moving objects though?, and not moving as smoothly. I can see that it might work for lights that aren't moving, but that's not the case on my lights.

28
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 09:53:25 pm »
Probably.

Also keep in mind that FPS is non-linear. It's normal to get a fast drop in the higher FPS area, that alone does not implicate that it will also fall as fast in the lower regions.
Additionally, all your FPS measurements are useless if you're running things in debug mode.
I've been using release mode when testing. Ok i guess it's not so bad then if you don't lose frames as fast when you have lower fps. I'll look into how to make much fewers draw calls thanks :).

29
General / Re: Need some help optimizing rendering speed.
« on: October 14, 2015, 09:43:20 pm »
Well i guess i might be optimizing things a bit early. Just wanted to test if i could do something with the rendering to increase performance.

I have about 800-900 fps when not doing anything special in my game, and i get 200 fps as the lowest when i shoot many bullets. This is because every bullet has a small light effect from LTBL1, and that thing eats up all my frames! :(

But i think i went and optimized the wrong way since i do alot of draw calls but not much batching. I draw very many RectangleShapes. 454 of them actually. If i remove all those draw calls i gain 70 something fps. Could i see that kind of performance increase if i do what you said and "batch all the quads into one vertex array".

Edit: oh, and i have a gtx 570, and an i7 3770k processor oc'd to 4,5 ghz.


30
General / Need some help optimizing rendering speed.
« on: October 14, 2015, 07:47:58 pm »
So i created a class on my own to attempt to reduce batch calls to optimize speed of my application. This is the class:
(click to show/hide)

I noticed that i don't gain any speed by doing this since i already separate most of my textures when drawing them. It seems that to gain speed i should reduce draw calls since i quite rarely swap texture in comparison to calling draw.
What can i do to optimize my rendering? This is my rendering code. Replace renderList.add() with app.draw(), and that's what i started with before i made the class:
(click to show/hide)

Just interested in how you're supposed to do the rendering because what i have i've mostly come up with on my own.

Pages: 1 [2] 3 4 ... 9