Page 1 of 1

[EditorPlugin] VertexRenderer

Posted: 17 Feb 2018, 17:06
by zocka
[media]https://cdn.discordapp.com/attachments/ ... yramid.mp4[/media]

Inspired by OpenGL rendering you define an "ArrayBuffer" with vertex and optionally data values, set how the values are interpreted as vertex or data[1] and then it get's passed through the pipeline of being potentially transformed in the "VertexShader"[2], the values are interpreted as block-coordinates and lastly the block to be placed may be influenced in the "FragmentShader"[3].

Of course the whole "draw triangles" thing is not as useful as it is when drawing primitives, everything is a mess, might break unintendedly, is blocking and awfully slow (64³ maps of course render a nicer result, but are even slower) - especially when using the useless animation loop, but it was a fun project testing yet again what useless stuff can be done with the possibilities provided to us.

Would be cool if someone would actually load objects and post pictures :D

[1]

Code: Select all

G_ArrayBuffer = [
	// x, y, z, data[0]
	-.3,  0., 0.,  0.,
	 .2,  .3, 0.,  0.,
	 .2, -.3, 0.,  0.,
	
	 .2,  .3, 0.,  1.,
	 .2, -.3, 0.,  1.,
	 0.,  0., .6,  1.,

	-.3,  0., 0.,  2.,
	 .2, -.3, 0.,  2.,
	 0.,  0., .6,  2.,

	-.3,  0., 0.,  3.,
	 .2,  .3, 0.,  3.,
	 0.,  0., .6,  3.
];
G_VertexSize = 3;
G_DataSize = 1;
[2]

Code: Select all

Position = _V3Mul(Position, 1.5);
declare X = Position.X * MathLib::Cos(G_Angle) - Position.Y * MathLib::Sin(G_Angle);
declare Y = Position.X * MathLib::Sin(G_Angle) + Position.Y * MathLib::Cos(G_Angle);
Position.X = X;
Position.Y = Y;
[3]

Code: Select all

if (Data[0] >= 0.9) {
	BlockModel = GetBlockModelFromName("StadiumCircuitTurbo");
}
if (Data[0] >= 1.9) {
	BlockModel = GetBlockModelFromName("StadiumControlRoadGlass");
}
if (Data[0] >= 2.9) {
	BlockModel = GetBlockModelFromName("StadiumTubeRoadSoundSystem");
}
Source

Re: [EditorPlugin] VertexRenderer

Posted: 17 Feb 2018, 20:24
by Miss
This is incredible. Well done! :thumbsup:

:roflol:

Re: [EditorPlugin] VertexRenderer

Posted: 18 Feb 2018, 12:46
by zocka
With some stability adjustments it should now be possible to load objects like suzanne or the teapot with more than 6000 faces.

Image
The teddy has 3180 faces. Unfortunately for sitting it up you have to decrease the resolution too much to fit the whole object while stretching it along the z-axis to make up for the non-square blocks. Configuration for the teddy: gist. (Note that accessing Data in the FragmentShader block will break with this example).

(On a site-note: your gist-include should respect the hash so that you can include a single file and not get the whole dump of files in the gist)

Re: [EditorPlugin] VertexRenderer

Posted: 18 Feb 2018, 15:24
by TMarc
you're doing like voxels but with Maniaplanet blocks? "Bloxels"? :roflol:
Crazy, really crazy :3

Re: [EditorPlugin] VertexRenderer

Posted: 18 Feb 2018, 15:39
by Dommy
One of the prettier things I've seen in ManiaPlanet lately. :D