XML is shit.. but when everyone eats shit, then I guess that shit starts tasting good, and most (?) people now just looove it !
Oh, but it's human-readable ! Yes, a string of hex values is also human readable..
C++ is pretty much shit as well.. but there was no alternative and I had to move on from 'C' ..sigh..
But if could be fixed.. all you need is a time machine and an hacked-up Terminator handy.
Unity/Unreal Engine/OMG-I-Just-Want-to-Make-a-Game Tool... are just a way to be somebody's bitch. One either is a developer or is a user.. if you use Unity/WhateverEngine, then you're a devuser.
OK, it's not all so black or white.. that's true, in fact Unity is just brown 8) (..conceptually, because I wouldn't know the first thing about those canned engines).
The engine companies don't want you to make games.. they just want people to waste money and depend on them (aka "being a bitch of").
So, man-up and write your code !! And don't start crying about how hard it is, or how long it takes on how you don't want to "reinvent the wheel" (the lamest meme of all).. it's all about you learning how to get things done.
Men wearing hats indoor, because they just want to look cooler.. are another category of "people that ought to be strangled in front of their children" (cit.)
Useless fedora hats or those condom-looking condom-hats that are so popular in Japan.. they just look lame.. especially if I'm sitting behind you and trying to look ahead !
Men should really not wear shorts.. and sandals, and baggy t-shirts. Just dress properly, nobody wants to see your legs !
Also I don't really care about your t-shirt.. if you want to send a message, leave a suicide note and jump off a building. I'll be reading the news 8)
I've developed a full-on hate for TV now. Before it was the commercials, so loud and in your face. Now it's 99% of what's on. Serial TV which you have to learn to like. Guns guns guns and more guns. Or lots of knives and gang yakuza beatings if you're in Japan.
The sad thing is that the American serial TV are rather realistic.. people just like to shoot at each other, they like crime, murder and so they think that it's cool to actually do it (death is exciting !)
Inability to separate human instincts and curiosity from reality is a very dangerous thing.. and not all cultures are at the same abstraction level on that.
So, TV is shittier than ever and luckily we don't need it anymore. Dear TV, please die soon !
Politics is... ahhhh... what can I say. I'm constantly amazed on how people can reason on one side and the act completely dumb on the other.
Politics is a reflection of people's inability or unwillingness to be consistently coherent and logical.
People that want to become game designers because they are good at games and know all about them.. are simply doomed to fail.
You don't wake up one morning and become a movie director and not everyone in the movie industry can be a damned director ! Some will become directors.. just not you ;)
And, that's it for now.. (^_^)
v5.kazzuya.com
なんとかニャンコ
Thursday, January 12, 2012
Thursday, December 29, 2011
I Still Blog You !
I've been meaning to write a free-style blog post in a while.
The past blog posts have been too focused on mobile game dev and marketing.
A lot of things that one used to gather in a blog post, nowadays end up scattered around Twitter and Facebook (I have FB setup so that my tweets end up in there as well).
Most of the pictures I take are also by cell phone and they end up on Twitter (see the recent images gallery.. but what if I want to see all of them ? mumble mumble !)
As 2011 wraps up, I'm still going forward as an independent mobile games developer. Holding on, but it's certainly a struggle.
Without a monthly salary and with the marketing and PR of your own games in your own hands, anything that you do or don't do has an effect to you being able to live well or struggle to pay the rent (which I now realize is so expensive !).
At the same time, the marketing stuff is so up in the air. Does writing a post in some message board or a tweet somewhere actually make a difference ?
I've seen that having a natural connection to the Italian market (friends and family and translating a game to Italian) does have an effect. My latest game Fractal Combat sold relatively well in Italy and was high in the charts there for the first couple of weeks of the release.
On the other hand, how does one have an effect on the biggest market, the American one ?
Does advertisement space make a difference ? If it does, it's not in the immediate, because it's really hard to correlate any increase in sales when spending hundreds of dollars in ads space.
Ads are tricky, I like to believe that there is a meaning behind spending money on those. The meaning would be that the game gets noticed in some way and that there is some potential butterfly effect.
Otherwise, if one sees the cost of an ad, and the people that click on the ad, then if all the people that click through the ad, actually buy the 99 cents game (extremely unlikely), one would simply make back the initial investment.
So, ads must serve a secondary purpose.. maybe some sort of reinforcement of a brand of a game name that may translate into a purchase at some point.
Maybe one has to launch a heavy campaign that generates interest on all relevant sites all at once in a short window of time.. Or maybe they are just useless 8)
I don't like these things, because they are chaotic and practically impossible to predict !
This is the exact opposite of programming, where everything goes by the rules, and time isn't unstoppable (when programming, one gets virtually infinite chances to try all possible ways to do something in the exact same state).
Then there are the usual problems of working by yourself at home.. mostly discipline. On one side, I practically work every single day, on the other side, it's hard not to give into distractions and focus is really hard to obtain.. also because I have to do some much work that I wouldn't normally like to do !
Recently I've been trying to broadcast some sessions of programming/stage editing.
Nothing special, actually, mostly boring, because it all seems to happen at a rather slow pace. This is the mostly boring programming bits, when stuff just needs to be done. But knowing that someone may be watching (live or later on), keeps me on my toes.
So far, this has helped to prevent me from stepping off and grab a snack or get lost in some strange corner of the Internet.. or maybe do some other interesting programming, that however isn't what I'm supposed to be working on 8)
So, well, this blog post ended up being about work as well.. but it's a post nonetheless !
Have fun !
The past blog posts have been too focused on mobile game dev and marketing.
A lot of things that one used to gather in a blog post, nowadays end up scattered around Twitter and Facebook (I have FB setup so that my tweets end up in there as well).
Most of the pictures I take are also by cell phone and they end up on Twitter (see the recent images gallery.. but what if I want to see all of them ? mumble mumble !)
As 2011 wraps up, I'm still going forward as an independent mobile games developer. Holding on, but it's certainly a struggle.
Without a monthly salary and with the marketing and PR of your own games in your own hands, anything that you do or don't do has an effect to you being able to live well or struggle to pay the rent (which I now realize is so expensive !).
At the same time, the marketing stuff is so up in the air. Does writing a post in some message board or a tweet somewhere actually make a difference ?
I've seen that having a natural connection to the Italian market (friends and family and translating a game to Italian) does have an effect. My latest game Fractal Combat sold relatively well in Italy and was high in the charts there for the first couple of weeks of the release.
On the other hand, how does one have an effect on the biggest market, the American one ?
Does advertisement space make a difference ? If it does, it's not in the immediate, because it's really hard to correlate any increase in sales when spending hundreds of dollars in ads space.
Ads are tricky, I like to believe that there is a meaning behind spending money on those. The meaning would be that the game gets noticed in some way and that there is some potential butterfly effect.
Otherwise, if one sees the cost of an ad, and the people that click on the ad, then if all the people that click through the ad, actually buy the 99 cents game (extremely unlikely), one would simply make back the initial investment.
So, ads must serve a secondary purpose.. maybe some sort of reinforcement of a brand of a game name that may translate into a purchase at some point.
Maybe one has to launch a heavy campaign that generates interest on all relevant sites all at once in a short window of time.. Or maybe they are just useless 8)
I don't like these things, because they are chaotic and practically impossible to predict !
This is the exact opposite of programming, where everything goes by the rules, and time isn't unstoppable (when programming, one gets virtually infinite chances to try all possible ways to do something in the exact same state).
Then there are the usual problems of working by yourself at home.. mostly discipline. On one side, I practically work every single day, on the other side, it's hard not to give into distractions and focus is really hard to obtain.. also because I have to do some much work that I wouldn't normally like to do !
Recently I've been trying to broadcast some sessions of programming/stage editing.
Nothing special, actually, mostly boring, because it all seems to happen at a rather slow pace. This is the mostly boring programming bits, when stuff just needs to be done. But knowing that someone may be watching (live or later on), keeps me on my toes.
So far, this has helped to prevent me from stepping off and grab a snack or get lost in some strange corner of the Internet.. or maybe do some other interesting programming, that however isn't what I'm supposed to be working on 8)
So, well, this blog post ended up being about work as well.. but it's a post nonetheless !
Have fun !
Wednesday, November 9, 2011
Android sales improving for Final Freeway
Almost one year after the release, the Android sales for Final Freeway are finally improving !
The Android Market has improved a lot since I initially complained about it. In addition to the web interface (as I noted in a previous post), it's now possible to set different prices for different currencies, to have well rounded numbers for every currency.
But the main difference in terms of visibility and sales was the introduction of the racing category. Since that, sales improved 5-10 times and we're now consistently selling more than 20 copies per day. Which is not amazing, but certainly promising.
Here is a simple graph of the Google Checkout monthly payouts for Final Freeway for Android.
The Android Market has improved a lot since I initially complained about it. In addition to the web interface (as I noted in a previous post), it's now possible to set different prices for different currencies, to have well rounded numbers for every currency.
But the main difference in terms of visibility and sales was the introduction of the racing category. Since that, sales improved 5-10 times and we're now consistently selling more than 20 copies per day. Which is not amazing, but certainly promising.
Here is a simple graph of the Google Checkout monthly payouts for Final Freeway for Android.

We released on the Android Market towards the end of December 2010 and reached a first sales peak in January. Probably mostly due to the fact that the game was a new release.
Sales then went flat for a while, and at that point we were pretty much disappointed.. until the racing category was introduced and the game started showing in there, floating between the 12th and 16th position.
I'm not sure how one does get to a fairly high position to start with. The game has not been featured on the Android Market front page, so no help there.. but it's a fairly popular game on iOS.
It also somewhat helped when I decided to try to put FF for iOS free for one day (I'll talk about this in a future post), because that gave a spike of visibility to the game in general. Two platforms can help each other's sales.
What about piracy? The 1.0 of FF for Android is still out there, but not the latest updates, where we put a little bit more effort into protection.
One nice thing about Android is that the protection scheme can somewhat be customized (more checks, etc.) and my guess is that any customization will throw off the "drive-by crackers" that will crack anything that is crackable with some default script.. but they won't put any effort into cracking a single game. At least not one that isn't hugely popular 8)
Let's just hope that it stays like that...
So, iOS remains the main platform, but future ports to Android seem to be more meaningful now.
We've also been considering moving to in-app purchases for Android. Putting on the market the game for free, but with most of the features and/or content to be unlocked with the in-app purchase system.
However it's possible that that won't make a big difference in actual sales.
The big business of in-app purchases seems to be around addiction and gambling schemes.. not simply making something free form the start and asking to pay a one-time fee later.
We're considering those things.. but it's not a sure bet. The big hope is still to have a better market and ideally being able to be featured on the Android Market's front page at least for future titles.. ..speaking of gambling ! eh !
Monday, September 5, 2011
First month of Fractal Combat's sales
I've been thinking about posting an update on the situation with my independent game business, but it's hard to sit down and decide what to write.
For example, I wrote a long post a week ago and then scrapped it.. 8)
Fractal Combat so far is doing OK, only OK. Mostly because after the first 2-3 weeks of sale, I've all but stopped marketing it and focused on producing the first update.
This was due mostly to the lukewarm reviews from the likes of TouchArcade, 148Apps and PocketGamer, which got me worried that other review sites may start to copycat those reviews.. which are not entirely negative, but are also not very positive (accusing a cheap mobile game of being too repetitive? Yeah, sorry! 148Apps giving it 3/5 on graphics? Yeah, right!).
Admittedly, some of the potential weaknesses were known.. but I just didn't have the time. The game was complete and I needed to sell it as quickly as possible to stay in business (it's not just me, but I'm the one that depends fully on this 8).
There are no bugs or missing features.. but of course on iOS it's a given that there are going to be updates to improve on the original release and I counted on that (users do, so should I).
A few days after the release, Apple featured it in a decent spot, and that lasted about 2 weeks, which is good, but not good enough.
The game initially sold for $1.99 and is now $0.99. I regret not having lowered the price as soon as it was featured, because I'm guessing that sales volume (or lack thereof) is what makes a game worth keeping in the featured list or not.
Nevertheless the game is still doing quite well in Italy !
That's due to a few factors.. one of them is the specialized sites' reviews. Frankly, reviews are subjective by definition. I have some communication channels with some Italian sites and journalists, and that helped me a great deal to get some fair coverage.
Having any kind of dialogue makes it possible to address potential complaints and to ensure that some things will be fixed or explain why the game is in a certain way.. the reasoning behind it. Not having a communication channel means that your game is one out of many in the App Store, and you're in the hands of some unknown reviewer that my love it or may hate it.
The moral is that PR matters a lot, especially in the context of independent mobile games facing competition from big budget games down selling for $0.99 a month later.
Having coverage in any country is great.. but having coverage in the much larger US market would be even nicer 8)
Now, a few words about piracy: I've been looking at the Game Center's leaderboards entries to estimate a "piracy ratio". GC is tightly integrated in iOS and Fractal Combat posts leaderboards entries automatically, so anyone that has GC activated (most players?) and that plays the game, will show up in the leaderboards.
I can then compare that number of users with the number of copies sold to guess how many copies out there weren't paid for.
Based on that, on the first few days, it was a staggering 9:1 in favor of pirated games, but that was mostly due to some extra exposure in the piracy circle (would you believe that it was an Italian "script adult" getting the cracked version up on the most popular iOS pirate site ?)
After a month, the ratio now is more like 2:1, meaning that for every 2 users on the leaderboard, one copy of the game was sold.
Now for some sales figures.. here is a chart of the first month. The initial larger sale is in coincidence with being featured in the New&Noteworthy games section (games only, not overall) on App Stores world-wide.
Unlike for Final Freeway, there is no spike for the TouchArcade review this time. Probably because the review wasn't quite an endorsement. We got 3.5 (out of 5).. but it sounded more like a 2.5.
And, that's the story so far, but it's not the end of it 8)
In the meantime, Final Freeway on iOS keeps on selling (one year later !) enough to keep me afloat, and the Android version is slowly taking advantage of its placement in the new racing category in the Android Market. Currently selling about 1-copy per hour, and placed 14th in the racing category. But it's too early to draw conclusions on that.
And now, back to work!
For example, I wrote a long post a week ago and then scrapped it.. 8)
Fractal Combat so far is doing OK, only OK. Mostly because after the first 2-3 weeks of sale, I've all but stopped marketing it and focused on producing the first update.
This was due mostly to the lukewarm reviews from the likes of TouchArcade, 148Apps and PocketGamer, which got me worried that other review sites may start to copycat those reviews.. which are not entirely negative, but are also not very positive (accusing a cheap mobile game of being too repetitive? Yeah, sorry! 148Apps giving it 3/5 on graphics? Yeah, right!).
Admittedly, some of the potential weaknesses were known.. but I just didn't have the time. The game was complete and I needed to sell it as quickly as possible to stay in business (it's not just me, but I'm the one that depends fully on this 8).
There are no bugs or missing features.. but of course on iOS it's a given that there are going to be updates to improve on the original release and I counted on that (users do, so should I).
A few days after the release, Apple featured it in a decent spot, and that lasted about 2 weeks, which is good, but not good enough.
The game initially sold for $1.99 and is now $0.99. I regret not having lowered the price as soon as it was featured, because I'm guessing that sales volume (or lack thereof) is what makes a game worth keeping in the featured list or not.
Nevertheless the game is still doing quite well in Italy !
That's due to a few factors.. one of them is the specialized sites' reviews. Frankly, reviews are subjective by definition. I have some communication channels with some Italian sites and journalists, and that helped me a great deal to get some fair coverage.
Having any kind of dialogue makes it possible to address potential complaints and to ensure that some things will be fixed or explain why the game is in a certain way.. the reasoning behind it. Not having a communication channel means that your game is one out of many in the App Store, and you're in the hands of some unknown reviewer that my love it or may hate it.
The moral is that PR matters a lot, especially in the context of independent mobile games facing competition from big budget games down selling for $0.99 a month later.
Having coverage in any country is great.. but having coverage in the much larger US market would be even nicer 8)
Now, a few words about piracy: I've been looking at the Game Center's leaderboards entries to estimate a "piracy ratio". GC is tightly integrated in iOS and Fractal Combat posts leaderboards entries automatically, so anyone that has GC activated (most players?) and that plays the game, will show up in the leaderboards.
I can then compare that number of users with the number of copies sold to guess how many copies out there weren't paid for.
Based on that, on the first few days, it was a staggering 9:1 in favor of pirated games, but that was mostly due to some extra exposure in the piracy circle (would you believe that it was an Italian "script adult" getting the cracked version up on the most popular iOS pirate site ?)
After a month, the ratio now is more like 2:1, meaning that for every 2 users on the leaderboard, one copy of the game was sold.
Now for some sales figures.. here is a chart of the first month. The initial larger sale is in coincidence with being featured in the New&Noteworthy games section (games only, not overall) on App Stores world-wide.
Unlike for Final Freeway, there is no spike for the TouchArcade review this time. Probably because the review wasn't quite an endorsement. We got 3.5 (out of 5).. but it sounded more like a 2.5.
And, that's the story so far, but it's not the end of it 8)
In the meantime, Final Freeway on iOS keeps on selling (one year later !) enough to keep me afloat, and the Android version is slowly taking advantage of its placement in the new racing category in the Android Market. Currently selling about 1-copy per hour, and placed 14th in the racing category. But it's too early to draw conclusions on that.
And now, back to work!
Wednesday, August 3, 2011
The Thunderbirds are Go!
This time around with the new Blogger interface.. nice and clean, if white (not my first choice).
What really matters though is to have a properly working "undo" that hopefully works across auto-saves (used to be really easy to delete a whole post and then have it auto-saved blank !).
Fractal Combat 1.0 has been submitted to Apple and now I'm just waiting for the approval.
As I said in the related blog post, I hope that people will enjoy the game more than us doing it.
This "I enjoyed so much doing the game" mantra seems BS to me. If it were true, then it wouldn't be a job!
I'm definitely looking forward to enjoy positive comments of people that like the game, and I'm certainly looking forward to see how well the game sells.
I expect decent sales, enough to keep me afloat, but I don't envision spectacular sales, mostly because FC isn't your typical cute mobile game, like those that sell by the gazillion and turn into cultural phenomena.
Hopefully some major sites will find the time to review the game. Hopefully Apple will place the game in some noteworthy kind of spot like it happened with Final Freeway.
That's a really big deal and also one of the reasons why I wanted to give enough of the so called "polish".
In the meantime I keep seeing people trying to jump into game development.
I'm very conscious of the fact that things evolve and that what was the rule before isn't (and probably shouldn't be) the rule now... but what is it with all those people rushing onto some game engine to offload all the "difficult" bits of development ?
First of all and engine/framework don't do any miracles, there is hard work to put in there as well, secondly, people like that miss out much of the fun and a chance to learn some basic skills, a deeper understanding on how things work.
For example, can engine programmers really just go on with Direct3D, OpenGL and shading languages? That's incredibly limiting.
One may say that the same way that assembly isn't the norm for game dev anymore, low level programming isn't also necessary anymore. I'm not so sure.. but time will tell.
In the end, I guess that one can achieve the same things in many ways.. and for me to say that, in order to make good games, one should become a good programmer with deeper understanding of how computers work, it is probably just a selfish point of view (and I'm no electronics expert myself).. but I've got to believe in something.. have a way of going about 8)
I think that's enough rants for now !
...let's go back to waiting for Apple's review...
Thursday, July 14, 2011
PRRRR
As I'm approaching the end of development of the next game.. I'm staring to test the waters about PR.
That time has finally come again, when one has to switch from logic and creativity to charm and communication skills. Something that I don't like.. but that is necessary to sell games to keep the boat floating.
The first disappointments are coming already. Some sites are already ignoring my pleas to have my lowly game grace their glorious web pages. Answering a simple "yes" or "no" is just too time consuming. Chances are that Steve Job is more likely to answer to users than certain popular sites are likely to answer to an independent developer.
It's a tough nut to swallow, but there is nothing I can't do about it. Or is there ?
Perhaps the best PR investment I could have done, would have been a few thousands of dollars to fly to GDC or E3, to meet press sites and show my face.
In person, I probably have less charm than through email, but physical presence always makes a difference.. and that could help.
Still that's far from ideal.. but I need to expose my game to potential buyers, and so I need to get out of my world of logic and force myself to become a little bit of a salesman.
I hate it.. but it's just how life is.. ..so, let's suck it up ! 8)
Sunday, June 26, 2011
Optimizing shaders on iPad/iPhone (iOS 4)
UPDATE: The shader compiler coming with iOS 5 seems a lot more reliable. From early tests, some flaky behavior has disappeared (e.g. missing light sources are there again).
What follows is related to iOS 4...
----------------------------------------------------
In the past 2 days I dedicated some time to optimize the shaders in The Fractal.
I quite dislike the concept of "vertex shader", so I initially set lighting up to use only pixel (or fragment) shaders.
I eventually scrapped that and moved the lighting at the vertex shader level.. which gave an incredible speedup, especially on 1st gen iPad, but also on iPhone 4.
In fact, WWDC 2011 talks (I won't link it, as you need a developer account to see them anyway) on OpenGL ES seem very focused on pushing per-pixel lighting on iPad 2, almost implying that you must have been nuts to do that on any device before that.
Truth to be told, I could generally afford per-pixel lighting, because most of the screen is generally covered with a terrain with baked lighting. But when a huge monster filled the screen, the frame rate would suddenly drop.
At any rate, before switching to per-vertex lighting, I did some performance tests at the per-pixel level to better get a sense of what is slow and what is fast.
As a foreword, I have to say that conditionals and for-loops with non-constant values in shaders are considered to be a big performance penalty, and should be avoided as much as possible. But some conditionals help to keep the code (and the coder) sane.. as opposed to generating hundreds of combinations of shaders for every possible expected case.
The following tests were made on an original iPad, running iOS 4.3.3 (the iOS version determines how a shader gets compiled, as I'm compiling shaders at run-time).
These are not exhaustive tests and it's quite possible that I got something wrong. In fact, normally is the compiler that is right and the programmer that is wrong.
That's right.. a loop with
I must be dreaming ? But there is a strange work-around. When declaring the uniform variable, I tried this:
But it can be reverted by specifying "lowp" in the iterating variable too:
So, practically the for-loop with an uniform value, other than being twice as slow, is completely unreliable ...at least in my tests, and in the pixel shader.
Back to the "active" flag. There is an important difference that will kill performance in the shaders.
In C/C++ I prefer the following equivalent form, to avoid extra indenting:
..but before that I tried this:
This was slower. Not twice as slow, more like 25% slower (I don't remember the exact figure).
..breaks the conditional and the second light is gone again !
Note that not specying "== true" is theoretically equivalent, but it's actually different (as in, "it doesn't work" 8).
And this:
..is, again, theoretically equivalent but it actually gives some funky shader blocking artifacts:
..which kind of reminds me of the early(er) stages of my REYES renderer:
...ahh ..sometimes I miss working on that.. but things aren't so different now, in a sense 8)
wooooo
ADDENDUM: By running the same shaders on iPad and OpenGL on PC. I have verified that the "if" conditional is indeed not guaranteed to skip the "false" case, even in the vertex shader.
So, for my point lights loop, I must set-up those lights' colors to be null.. because
What follows is related to iOS 4...
----------------------------------------------------
In the past 2 days I dedicated some time to optimize the shaders in The Fractal.
I quite dislike the concept of "vertex shader", so I initially set lighting up to use only pixel (or fragment) shaders.
I eventually scrapped that and moved the lighting at the vertex shader level.. which gave an incredible speedup, especially on 1st gen iPad, but also on iPhone 4.
In fact, WWDC 2011 talks (I won't link it, as you need a developer account to see them anyway) on OpenGL ES seem very focused on pushing per-pixel lighting on iPad 2, almost implying that you must have been nuts to do that on any device before that.
Truth to be told, I could generally afford per-pixel lighting, because most of the screen is generally covered with a terrain with baked lighting. But when a huge monster filled the screen, the frame rate would suddenly drop.
At any rate, before switching to per-vertex lighting, I did some performance tests at the per-pixel level to better get a sense of what is slow and what is fast.
As a foreword, I have to say that conditionals and for-loops with non-constant values in shaders are considered to be a big performance penalty, and should be avoided as much as possible. But some conditionals help to keep the code (and the coder) sane.. as opposed to generating hundreds of combinations of shaders for every possible expected case.
The following tests were made on an original iPad, running iOS 4.3.3 (the iOS version determines how a shader gets compiled, as I'm compiling shaders at run-time).
These are not exhaustive tests and it's quite possible that I got something wrong. In fact, normally is the compiler that is right and the programmer that is wrong.
Looping through a list of light sources
A simple for-loop may seem the way to go:// *SLOW*
for (int i=0; i < u_PntLightsN; ++i)
{
[...]
}
..but in fact, it's about twice as slow as the alternative:// *FAST*
for (int i=0; i < DE3_MAX_PNT_LIGHTS; ++i)
{
if ( u_PntLights[i].isActive )
{
[...]
}
}
Having an "active" flag per-light, while keeping the loop fixed (to 5 lights) is faster and more reliable.That's right.. a loop with
u_PntLightsN set to 2, would still only pick 1 light source (?!)I must be dreaming ? But there is a strange work-around. When declaring the uniform variable, I tried this:
lowp int u_PntLightsN..and suddenly I had 2 lights affecting the model again 8)
But it can be reverted by specifying "lowp" in the iterating variable too:
for (lowp int i=0; i < u_PntLightsN; ++i)..and magically, it's only 1 light showing up, again.
So, practically the for-loop with an uniform value, other than being twice as slow, is completely unreliable ...at least in my tests, and in the pixel shader.
Back to the "active" flag. There is an important difference that will kill performance in the shaders.
In C/C++ I prefer the following equivalent form, to avoid extra indenting:
// *SLOW*
if ( ! u_PntLights[i].isActive )
continue;
// do something
..but that's sensibly slower than the original version:// *FAST*
if ( u_PntLights[i].isActive )
{
// do something
}
If one considers how shading engines work, this makes perfect sense. Of course, the compiler could pick up the equivalency of the operation, but it doesn't, and it's good to keep that in mind.Conditionals that didn't help
This is the final version that I ended up using..// *FAST* (..relatively)
for (int i=0; i < DE3_MAX_PNT_LIGHTS; ++i)
{
if ( u_PntLights[i].isActive )
{
// NOTE: CS stands for Camera Space
vec3 posToLightPos = u_PntLights[i].posCS - posCS;
vec3 lightDirCS = normalize( posToLightPos );
float NdotL = dot( norCS, lightDirCS );
// NOTE: ooRadiusSqr is 1 / radiusSqr
float att =
1.0 -
clamp(
dot( posToLightPos, posToLightPos ) *
u_PntLights[i].ooRadiusSqr,
0.0,
1.0 );
accLightCol += max( NdotL, 0.0 ) * att * u_PntLights[i].col;
}
}
..but before that I tried this:
// *SLOW*
float NdotL = dot( norCS, lightDirCS );
if ( NdotL > 0 )
{
float att =
1.0 -
clamp(
dot( posToLightPos, posToLightPos ) *
u_PntLights[i].ooRadiusSqr,
0.0,
1.0 );
accLightCol += NdotL * att * u_PntLights[i].col;
}
The "max( NdotL, 0.0 )" at the end is gone, and "if ( NDotL > 0 )" is introduced to skip a bunch of calculations.This was slower. Not twice as slow, more like 25% slower (I don't remember the exact figure).
Conditionals on LSD
And now, for something spooky. Here are a few variations that will all give strange results: // *BAD*
if ( u_PntLights[i].isActive == true )
{
}
..breaks the conditional and the second light is gone again !
Note that not specying "== true" is theoretically equivalent, but it's actually different (as in, "it doesn't work" 8).
And this:
// *BAD*
if ( u_PntLights[i].isActive == false )
continue;
..is, again, theoretically equivalent but it actually gives some funky shader blocking artifacts:
..which kind of reminds me of the early(er) stages of my REYES renderer:
...ahh ..sometimes I miss working on that.. but things aren't so different now, in a sense 8)
wooooo
ADDENDUM: By running the same shaders on iPad and OpenGL on PC. I have verified that the "if" conditional is indeed not guaranteed to skip the "false" case, even in the vertex shader.
So, for my point lights loop, I must set-up those lights' colors to be null.. because
if ( u_PntLights[i].isActive ) ..is only a hint !
Subscribe to:
Posts (Atom)







