- Home /
Shader for Global illumination via vertex array
Hello, dear Unity community
I'm new to shaders, but hope someone can help me. I think that solution for this theme can be found via shaders (If there is some other solution, please tell me).
What we have:
We have a static geometry mesh consisted of different objects.
We have an array of vertices that looks like:
.....
v -48.1629 81.8135 0.0000 126 126 126
v 6.3909 77.2903 0.0000 124 124 124
v -32.4754 -6.6671 23.8640 104 104 104
v -53.9047 81.9580 0.0000 126 126 126
v 8.2705 74.2350 0.0000 124 124 124
v -51.8147 79.4345 0.0000 126 126 126
v 10.5213 72.1797 0.0000 123 123 123
[v-vertex][xpos][ypoz][zpoz][rcolor][gcolor][bcolor]
......
This array describes light intensity and color in each point for the whole scene (For the simple scene more than 90 000 vertesies. The vertices of this array lay on or near the surface of the geometry that we have to light up.
I've written a parser for this array, that creates a Unity3D mesh from this array (now for 65K vertices, but soon I'll rewrite script that will create needed count of mesh objects for the whole array). Also I faced the problem to assigne vertex colors for the mesh.colors(mesh.colors[i].r = r;) But I think will solve these problems soon.
So we have the geometry that we should light and the information about the light in the meshFilter component.
What we need and what way to chose?:
Render the whole scene with a specific shader that uses that light info and then overlay the image rendered from camera?
How to transfer that light information to the shader? And how to use it? )
The solution has to be without unwrapping objects.
Or to write a shader and assign it to all objects in the scene?
Any ideas?