Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the renderer to use OpenGL directly #3

Open
phrohdoh opened this issue May 8, 2017 · 2 comments
Open

Rewrite the renderer to use OpenGL directly #3

phrohdoh opened this issue May 8, 2017 · 2 comments

Comments

@phrohdoh
Copy link
Member

phrohdoh commented May 8, 2017

Original issue link


Now that the game is rendering delta graphics (see angered-ghandi/OpenAOE#37), there are hundreds of TODO comments being printed out when the game starts up:

...
TODO: skipped 15 instead of drawing the shadow
TODO: skipped 20 instead of drawing the shadow
TODO: skipped 13 instead of drawing the shadow
TODO: skipped 13 instead of drawing the shadow
TODO: skipped 7 instead of drawing the shadow
...

I made it draw yellow instead of skipping, and it looks like several of the delta graphics are nothing but shadows:

missing_shadows

Unfortunately, with the way the SLP crate is currently laid out, it's not going to be easy to correctly implement the actual shadows. In the original game, it'd use the index of the color in the destination pixel buffer to determine the shadow color to draw. We'll need to do something clever here since that's not feasible with OpenGL (at least not with good performance). Might be able to make it look as close to the original as possible using a pixel shader, but being able to use a shader will require a rewrite of the whole render system.

@phrohdoh
Copy link
Member Author

phrohdoh commented May 11, 2017

Some progress has been made over at slp-viewer-opengl (this link will become a 404 after being folded into the engine) which you can see here:

screen shot 2017-05-10 at 7 19 38 pm

I believe that to get the shadows the palette should be changed to be (u8, u8, u8, u8)s where a is, by default, 255 (or would it need to be 0? I can never remember) but otherwise ~140.

@angered-ghandi
Copy link
Contributor

angered-ghandi commented Aug 12, 2017

Alternatively, to maintain a pixel perfectness, you could instead pass a single 512-entry palette to the fragment shader that is a combination of the original 256-color palette, and the 256-color shadow table described in the SLP TODO:
https://github.com/ChariotEngine/Slp/blob/cbd7a8f665cd7538d37ece20cb9568ed94277ed4/src/slp.rs#L345-L352

The trick would be figuring out which palette is the shadow table.

I think taking this approach would make the invalid building placement graphic just work without any additional hacking.

EDIT: You'd also need to modify the SLP crate to return data in a way that's compatible with this--maybe optionally so that the SLP crate could still be used for simple image conversions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants