Page 6 of 11

Re: Idea: Play Plasma from another engine

PostPosted: Sun Jul 29, 2018 1:45 pm
by Sirius
Hah, yeah I understand how much of a mess this can be... I can upload a few shaders for reference if you want, but don't expect them to be standard vert/frag shaders, as they aren't actually GLSL. They are ShaderLab, which Unity then compiles to GLSL/HLSL (I will provide the generated GLSL scripts too). And since Unity supports tons of platforms and rendering options, the generated GLSL shaders can be rather... big.

I don't know how Plasma does its rendering, but I suppose it's heavily relying on multiple passes (one per layer) using very generic pre-written shaders ? Personally I simply write one single-pass shader per material (similar materials can share the same shader though, but all the notion of layer is gone), so it's rather different.

Also, I didn't write any code to handle lighting - I just specify my shader uses lambertian lighting, and Unity's shader library does all the tedious light computations (really useful to me since they generate correct code for forward/deferred/pixel/vertex lighting). This library is free to download too, so it's a pretty useful reference.

So yeah, I'll provide soon a few SL scripts, the generated GLSL shaders and a link to Unity's shader library. I hope it won't be too cumbersome for what you intend to do.

Re: Idea: Play Plasma from another engine

PostPosted: Sun Jul 29, 2018 4:14 pm
by Sirius
Double post ! Got some neat stuff...

Namely: buoys !
Show Spoiler

Should be good for boats, or those floating whatchacallit buoy lights...
Or you could do like the above, a floating bridge you have to walk on ! :D

Also, I ran a small benchmark to test the water's performance... Unity vs Plasma !
  • Both scenes were running in the same resolution, with approximately the same visual quality, and more-or-less same content: a gigantic ocean, a few meshes, a sky.
  • Plasma was rendering only shadeless meshes.
  • Unity was handicapped by having to render said meshes with dynamic lighting along with shadows for the sun, ALONG with the two improvements I added this morning: underwater distortion and edge blending.
  • Unity was further handicapped by having ~20 buoys on the water, which means running a copy of the water simulation on the CPU (but the CPU isn't maxed out, so it doesn't impact framerate much anyway).
  • And the obvious: the Plasma simulation is coded in C++ and shader assembly, the Unity one is in C# and GLSL, which is theoretically less optimized.
There are also smaller differences like Unity missing an avatar, but those are really minor AFAIK.

  • Plasma: 150 frames per second average
  • Unity: 230 (!!) frames per second average
Booyeah ! So, yeah, I think we can say Unity far outperforms Plasma in this case... ;)
(although to be perfectly honest, Plasma's frame timing is very odd, so it may vary from computer to computer, depending on drivers...)

I'm really glad, because it bodes well for the rest of the project. I was worried putting Uru in Unity would impact performances negatively. So far it seems it increases framerate instead :shock: I should benchmark the Relto in both engines to see if it's consistent...

EDIT: couldn't resist building the scene and running it on my Android phone. Water simulation works perfectly, runs at 60fps (capped by vsync).

Re: Idea: Play Plasma from another engine

PostPosted: Mon Jul 30, 2018 8:22 am
by Sirius
Here you go Paradox, this archive contains a few shaders, each in their own folder.

- The "Default" shader is the one most commonly used, it represents a simple lit material with 1 layer and a standard texture.
- "Cube_MultOverlay_Lightmap" combines a cubemap as first layer, a second standard texture multiplying the cubemap's values, and a lightmap. The cube+mult texture is often used on objects like Zandi's trailer to fake reflective surfaces. In this case it comes from the Nexus floor, which does that but is also lightmapped.
- "Relto_material_BahroPole" is the "Bahro Pole" material inside of Personal_District_psnlMystII.prp. It combines a cubemap, a standard texture and an animated texture.
- "WaveSet7" obviously contains the two shaders for water (the second one, "CompCosine" is used to generate the waveset's normal map).

Each folder contains:
- SL_xxx which is the original ShaderLab source (most of them are "surface shaders", not vert/frag shaders).
- GeneratedFromSurface-xxx is still a SL shader, but uses standard vert/frag methods instead.
- Compiled-xxx is a debug file which contains multiple variants of the shader compiled to GLSL, assembly, etc.

And you can download the Unity shader source here, click one of the "Download" buttons and select "Builtin shaders".

Like I said, the compiled files are massive. You'll probably have a hard time making head or tail out of them :/

And if you want more, you need only ask. Best of luck !

Re: Idea: Play Plasma from another engine

PostPosted: Sun Aug 05, 2018 1:43 pm
by Sirius
Smallish video of Gira.
This was to test dynamic lighting. Mimicking Plasma behavior 1:1 isn't easy since Unity only has a few "light groups", but I think I managed a close enough approximation. Unity's shadows usually don't work in Plasma Ages unless the whole Age uses dynamic lighting, which is the case here. And I increased the number of shadow caster meshes, so it looks pretty good.

I also got decent support for mods (both Plasma and Unity) in the engine. As an intentional side-effect, I can also specify multiple game folders, which will be treated as one (think playing MOUL and EOA at the same time). Rather useful.

As for the rest... I can finally load big Ages like the city or Gahreesen (which were previously buggy due to their size). Wavesets work, but are still glitchy, and interfaces are boring to do. Bah, add it to the very long todo list...

Oh, and speaking of wavesets, here is the code for them. Still a bit glitchy but it will take me a while to figure out the last bugs, so might as well release the first version.

Re: Idea: Play Plasma from another engine

PostPosted: Sun Aug 05, 2018 2:27 pm
by Tweek
Nice.. I know it's work in progress but will the sky eventually cycle through the same colours Gira does in Plasma?

Re: Idea: Play Plasma from another engine

PostPosted: Mon Aug 06, 2018 2:56 am
by Sirius
Sure. Layer animations don't quite work yet, but should at some point.

Re: Idea: Play Plasma from another engine

PostPosted: Tue Aug 07, 2018 12:13 pm
by Emor D'ni Lap
Gira's looking really good there, Sirius!
I noticed you got some of the animations working (BOID!), and the waveset - it's a good start.
And the basket physics look like they're behaving very much like in Plasma (is that a compliment?)!!!
Thanks for being persistent with this project; I'm fascinated by the ongoing progress.

Re: Idea: Play Plasma from another engine

PostPosted: Fri Aug 10, 2018 5:32 am
by Sirius
I'm glad that you enjoy it ! :D Baskets collide pretty well with the rest of the environment, however the avatar isn't a physical object itself - which means pushing the baskets is a bit jerky for now. Will probably change that at some point.

Sometime doing all the coding is fun and enjoyable, sometime it's a chore and makes me wonder why I even bother. Being persistent is really tough. But it's always cool to make progress, write about it here and see people interested in it :)
I'll continue doing a few videos like this when I'm making progress. I'm not an expert at shooting videos but it's fun regardless.

And speaking of persistent, the guys who wrote HSPlasma and all the related Plasma tools really deserve praise. These are really helpful to me, and I can't even begin to think about how annoying it must have been to reverse engineer the whole PRP format :shock:

Re: Idea: Play Plasma from another engine

PostPosted: Fri Aug 10, 2018 11:36 am
by Deledrius
Sirius wrote:which means pushing the baskets is a bit jerky for now.

Good. You have accurately recreated the authentic basket experience.

Re: Idea: Play Plasma from another engine

PostPosted: Sat Aug 11, 2018 4:39 am
by Sirius
Actually, you can safely walk on top of kickables without generating any force between the two colliders. It won't be authentic enough until there is a risk of having a forced bath IMHO ;)
I might switch the avatar type to a real rigidbody next, to see which behaves best with slopes, stairs, jumping and kicking Kadish leaves :)