Forum

VL - Custom Dynamic Buffer

vl

#1

Hi. Is there a way to create a custom dynamic buffer directly in VL? I have the same thing as a Dynamic Plugin, but it would be most awesome if I could do this directly in VL.
I think Craftlie is already doing something like this? Would it be possible to import SlimDX, we already gave it a try but it didn’t work out yet.


#2

hey, yea i’ve been looking for that also, i’m thinking there is a good way to go:
compile some custom buffer as plugin, then import that, i’m not sure how that will deal with dependencies but at list it should work… I guess isolating feature you want is way to go in this case…

i’ve seen vux does some overrides on the workshop i guess you have to use full dynamic buffer code…


#3

Ah, cool idea to compile as plug-in. I will give this a try!


#4

maybe this is a good start to create buffers from an array/list/spread of things:


#5

this is a great idea and should be easy to implement. we talked about it in the last meeting and the simplest solution would be one VL node and one VVVV node for each buffer type.

the VL node creates a buffer description that holds all information to create the buffer and a reference to the data. the VVVV node takes this description and builds the actual buffer that you can connect to a shader…

i hope nobody started to work on it yet.


#6

nice thing you are putting this on your agenda.
would the suggested VL - VVVV node pair also allow for custom buffer types?
for example a struct consisting of different floats, matrices etc…


#7

the shader would need to know about this struct and its properties, so it would need to be declared in shader code yet again. Would be kinda cool to think of a single pin to a shader for some kind of PBR material configuration without the need to mess with every single parameter as pin individually …
But I guess this kind of structured buffers is only available when dealing with ressources on the gpu where they also have been assembled in the first place. But frankly I don’t really have an idea, just never saw it around anywhere.


#8

this would be possible if the data structures would match exactly byte by byte.

for now there is Int, UInt, Float, 2d, 3d, 4d, Color and Transform, please test:

download below


#9

custom datatypes can be defined as struct in c# and in the shader and used by VL. contact me when there are concrete ideas for specific types.


#10

textures coming up next…


#11

now with dynamic texture nodes, please test again with new alpha and this update:

download below


#12

hey, thanks for these nodes. I tested it a bit with @sebl and it works fine!
But my use case is a bit more for custom dynamic buffer types.
I’m working on an update for SuperPhysical, where all logic is done in VL. I already created some custom data types for material and light setup, which works fine and allows for a very slim and patching friendly setup.
Now I would like to send the data from VL directly to the shader, thats what I need the custom dynamic buffers for.
Since I don’t wand to have dozens of connections and buffers, I’m bundeling them in custom structs.
Now if I want to use the current craftLie contribution, a custom struct has to be compiled, if I am not mistaken.
I’m not sure if this is a feasible workflow, since it adds complexity to the development process and depenencies to my contribution. Do you see a possibillity to create the struct dynamically ? I would need some kind of “dynamic buffer cons” to bundle different types, What are your thoughts on this?


#13

gald you tested it already and it works so far. unfortunately this is currently the best way of dong it… VL cannot build native C# structs, but we can make a general byte buffer that only gets the size in bytes and uploads the data, similar to the dynamic texture nodes in VL. this would ‘only’ need a custom serializer for your VL data types that outputs your data as a byte array with correct order.


#14

A byte buffer seems to be a good alternative. would be great, if it you could add it.
Thanks!


#15

yes, this follows now the pattern of the dynamic texture, there is FromSpread, FromArray and FromIntPtr. all expect the data as bytes:

download below

not that you need Buffer to read from raw buffers instead of StructuredBuffer in the shader code.

also it is best for performance to have structs that have a data alignment of 32 byte (128-bit). if your struct does not fit exactly you can pad with unused data to fill up to the next 32 byte.

struct Foo
{
    float4 Position;
    float  Radius;
    float pad0;
    float pad1;
    float pad2;
};

Buffer <Foo> FooBuf;

from: https://developer.nvidia.com/content/understanding-structured-buffer-performance


Color[] Arrays in tfx?
#16

i get an error when testing your latest version:
Could not load type 'VL.Core.TypeAttribute' from assembly 'VL.Core

is there a thing missing in latest alphas?i used b6a92831a2


#18

here is a rebuild against VL.Core.dll of latest alpha, hope that works:

download below


#19

Now with UploadTexture for DX9 as well and all VL nodes have a “Set” pin:

download below


#20

this now has options to load pixel data from streams and from image data (jpg, png, dds, …) in memory or streams:

download below


#21

do you have some help- or test-patches for the new nodes? didn’t get the new rawbuffer thing to work…