Jump to content
  • Advertisement
  • entries
  • comments
  • views

NLE: Unnamed Engine. Entry #5: I see the Light!

Sign in to follow this  


Well, we have a bunch of things to talk about this week! So lets shed some light on the subjects and get going!

The Shader System.

First of all, I've replaced the old [font='courier new']ShaderProgram[/font] class with a system/component for entities, allowing entities to hold their own shaders. I've, of course, named this the [font='courier new']ShaderSys[/font], and it's primary job as of now is to check which is the active shader program, switch to a different shader program if need be, and to compile shader files into a shader program. It's also now extendable, allowing for easy upgrades biggrin.png

The system before only allowed one shader program for the entire app, and, as we all know, that's usually not a good idea. While it was possible to switch between two [font='courier new']ShaderProgram[/font] objects, doing so was asking for a bit of trouble (I would explain, but that's another article I'm unwilling to write).

Because of this, the [font='courier new']RenderSys[/font] had to be updated to use the [font='courier new']ShaderSys[/font]'s new functionality, This was pretty easy, but I may end up changing it. Currently what's happening is this:
For each shader program:
- use that shader program.
- for each mesh attached to render:
+-- check if it's using that shader, if it is, render it.

While that's all fine and dandy, it COULD be sped up, by a few ways, BUT as the wise people say,
"Premature optimization is the root of all evil."
Also, another one of my fave quotes:
"Rules of optimization:
1) Don't do it.
2) Experts only: Don't do it, yet."

The Light System.

Yes, I've finally done it. I finally decided it's time to see the light... (Okay, last Light pun, promise)
The [font='courier new']LightSys[/font] was the main reason for my to make the [font='courier new']ShaderSys[/font] and now well... things are a bit more beautiful. As a picture is worth a thousand words, here's two thousand words of before/after:

[size=2]Btw, the white ball is above the sky-blue platform.

It's pretty standard to use,
[font='courier new']AttachLamp(entity);[/font]
[font='courier new']Loop:
Delete everything;

Right now, it only supports a single light, so doing multiple [font='courier new']AttachLamp()[/font]'s will do nothing, the first light will be the one chosen. As of currently it also only supports a point light as well. The [font='courier new']LightSys[/font] will be updated when I need the other types of lights.

Bug Season

Yay for mosquitoes and blackflies! They're about as annoying, if not more so, than computer bugs! And I got two bug reports to report, thankfully they're fixed already smile.png
I took a while to find this one out: Unnamed Engine has the ability to still be able to play a game, even if there are assets it can't find. It will replace missing assets with "default" ugly as hell ones. Thats good and dandy right? That is, if it worked!
Default texture works...Default shaders worked...Default model....was missing...took me a while to hunt down what went wrong, and I finally got at it, which showed a new bug (yes, it showed a new one, it didn't create it)! Yay!! T.T

[font='courier new']ComponentManager[/font] ([font='courier new']CM[/font]) is the thing that connects Components with Entities...All good right? Well, apparently it had the ability to also "manage" [font='courier new']NULL[/font] components...What does this lead to?
Game asks the [font='courier new']MeshSys[/font] for a Model, Model not found, so a model was created. Awesome.
Game asks for another Model, that model wasn't found, so a model was...not created, because we already had our default model, saving memory!! Yay! Oh wait, so it just passed [font='courier new']NULL[/font] to the [font='courier new']CM[/font]? <--bug

[font='courier new']RenderSys[/font] then asks the [font='courier new']CM[/font] for model #2, you know, the [font='courier new']NULL[/font] one...
[font='courier new']CM[/font] happily gives it a [font='courier new']NULL[/font] model... <---BUG
[font='courier new']RenderSys[/font], assuming it's a valid model, tries to render it...SEGFAULT <-- Another Bug!

So now, [font='courier new']CM[/font] now refuses [font='courier new']NULL[/font] components, and therefore can't give out [font='courier new']NULL[/font] components (2 weeks later, it gives out another [font='courier new']NULL[/font], just you wait and see!). And now the [font='courier new']RenderSys[/font] checks to see if it's been given a [font='courier new']NULL[/font] component, and then just ignores it.

Last but certainly not least.

While I was doing the [font='courier new']ShaderSys[/font], I decided to rename my haphazard shader names to something... a bit more easier. Any variable that will be inputed to the Vertex Shader is now prefixed with vs_, and Fragment Shader is now fs_.

Simple little things like that, really makes it a joy to program, why?
cause you're not trying to remember if the variable is [font='courier new']IhEaRtCaKe[/font] or if it's [font='courier new']iHeArTcAkE[/font];
And...If anyone had a variable called that, and I saw it, they would suffer... A Lot.

Lesson here: Make all your variables make sense, readable, and in some standardized format that's everywhere in the project. Having one cpp file that uses camelCase when the rest use CamelCase can really make life hell for a few seconds!

Anyhow, that's it, that's all, for this week smile.png

Have fun, don't stop doing what you love smile.png
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!