Bypassing the out of the box shader for a custom one

I have a small pet project I’d like to realize, as a purely academic exercise, not to be released or played by anyone.
Basically I want make a small port of an older game (just a level really) in UE4, and by port I mean exactly that, not in the style of those “game x remade in UE4!” with crazy lightning and effects. I want the game to look the same and play the same. So my plan would be to rip the asset from the Steam version of the game, throw them into UE4, and then use the engine’s scripting, animation and sound tools to handle that stuff, which is invisible to the user.

But, as I said, I want the game to look the same. The game is really old, just basic raw polygons and textures, per pixel lightning (if even that). No amazing lightning, PBR, AO, raytracing, normal mapping even. So instead of trying to force UE4 rendering pipeline to do that, which would never look the same probably, I was thinking about just implementing the shaders from scratch and emulate the look of the game.

Is this doable on UE4? Bypass the UE4 out of the box PBR shaders and make my own lightning calculations, texture mapping and so on. Basically I want to write my own hlsl files and load them in UE4. I know I will be giving up on a ton of optimization, but it really doesn’t matter I think since this thing is so old it really doesn’t need it (and as I said, nobody will play this, so even if it runs at 20fps it’s ok). I know about the Custon Expression node but that still plugs into the PBR shader and I don’t think this is what it is meant to be used for.

1 Like

Hey ZLight, that’s surely doable, but that would require a pretty intensive engine modification.

However, you should be able to find some references on the web where people created their own shading model. That could be a start!

You don’t need to modify the engine at all.

Just make every material you use be “unlit” shading model, and calculate the lighting yourself in the shader graph. You could use a parameter collection for “important” lights, or you could put code in each Actor that finds the closest N lights and configures the shaders on the object appropriately.

Turn off post-process effects like motion blur or bloom or chromatic aberration and so on, and you should be good!

This is the first thing that came to mind, but I didn’t think it would work tbh. It just seems crazy to basically do all the lightning computation of a forward renderer and then feed the result into a deferred shader hahaha But I guess it doesn’t really matter since the unlit shader should basically be just raw color to screen, so technically neither forward nor deferred. (I’m assuming it’s more complex under the hood in this case since the emissive needs to be picked up by the post processing though).

Just one question though, do you think this can be achieved with the custom expression node or should I just use the standard UE4 nodes? I’m kind of more well versed in pure code, so I think it would be a bit easier than using the nodes, but that won’t stop me anyway.

I haven’t tried it yet because I’m swamped with university stuff but I want to get around to it soon!

A custom USF may be a better option here though?

I would do it with just normal material nodes, because I know that will work fine.

Can you find other ways that will work, too? Probably! That’s what’s cool about software; more than one way to skin that cat.