So second thought was to create module for every node, and have it output relevant data as string as well as render it, so cumbersome, bleh again...

Then last thought, oh I got dx11 source code (since I wrote it), so i should be able to traverse the graph and store data instead of render (and then serialize as any format like json, no xml please ;)

Issues:

I don't want to store vertices/indices, takes too much space. I already know what geometry I use, so it would be better to just tell how to generate it again.

Most 3d formats suck for batching, in my case I can have the same geometry sent 10 times to shader, most 3d software would replicate geometry (come on, please start to do proper format one day), Instead it would be much easier to tell geometry-> transform list.

So for the moment once geometry is created I got no way to know how it was built.

So I simply added this in geometry provider

Code Snippet

string PrimitiveType { get; set; }

object Tag { get; set; }

Then for each type of geometry I create a descriptor, here is the base;

Code Snippet

publicabstractclassAbstractPrimitiveDescriptor

{

publicabstractstring PrimitiveType { get; }

publicabstractvoid Initialize(Dictionary<string, object> properties);

publicabstractIDX11Geometry GetGeometry(DX11RenderContext context);

}

Then here is sphere:

Code Snippet

publicclassSphere : AbstractPrimitiveDescriptor

{

publicfloat Radius { get; set; }

publicint ResX { get; set; }

publicint ResY { get; set; }

publicfloat CyclesX { get; set; }

publicfloat CyclesY { get; set; }

publicoverridestring PrimitiveType { get { return"Sphere"; } }

publicoverridevoid Initialize(Dictionary<string, object> properties)

{

this.Radius = (float)properties["Radius"];

this.ResX = (int)properties["ResX"];

this.ResY = (int)properties["ResY"];

this.CyclesX = (float)properties["CyclesX"];

this.CyclesY = (float)properties["CyclesY"];

}

publicoverrideIDX11Geometry GetGeometry(DX11RenderContext context)

{

return context.Primitives.Sphere(this);

}

}

That's it, instead of storing 1000 vertices i can just store 5 parameters instead, how cool is that?

When I create geometry, I just assign the descriptor to the geometry, so I can know at any time how things were created.

Now that's cool, but I need to grab geometry, so here is how it works.
Layer have RenderSettings which carry some info on how to render, so I simply added collector as render hint.

Code Snippet

publicenumeRenderHint { Forward, MRT, Shadow, Overlay, Collector }

Then settings carry:

Code Snippet

publicclassDX11ObjectGroup

{

public DX11ObjectGroup()

{

this.RenderObjects = newList<DX11RenderObject>();

}

publicstring ShaderName { get; set; }

publicList<DX11RenderObject> RenderObjects { get; set; }

}

publicclassDX11RenderObject

{

publicstring ObjectType { get; set; }

publicobject Descriptor { get; set; }

publicMatrix[] Transforms { get; set; }

}

So renderer only has to set it's flag to collector (tells shader that we don't want to render but collect information).

Shader then can just retrieve descriptor, and push it with list of associated transforms (huhu, batch friendly ;)

Little snippet for shader node, if render hint is set to collect it just appends object/transform instead of render.

Code Snippet

IDX11Geometry g = this.FGeometry[0][context];

if (g.Tag != null)

{

DX11RenderObject o = newDX11RenderObject();

o.ObjectType = g.PrimitiveType;

o.Descriptor = g.Tag;

o.Transforms = newMatrix[spmax];

for (int i = 0; i < this.spmax; i++)

{

o.Transforms[i] = this.mworld[i % this.mworldcount];

}

group.RenderObjects.Add(o);

settings.ObjectCollector.Add(group);

}

Object list is then serialized as Json Object, here is one part of it:

So next was just doing a Loader node for testing, pretty simple, retrieve descriptor, create geom, associate with transform and render. Please note that could do an importer for anything, it's not only 4v related (technically I got a use case for it, top secret ;)

The obvious great thing is it's totally transparent, I only need to enable collect, and I can retrieve whole scene, no need for any fancy stuff, and works for any part I have already done as well, no mod needed.

Here are few example of it:

That's it, now of course will need improvements, but pretty excited about possibilities. Having source code for render system is quite invaluable, without it would have done the dirty module way, brrr....scary!!