Unity Geometry Shader: Dynamic Grass - unity3d

So, I have a functioning voxel engine that creates smoothed terrain in chunks of 1x1x1 meter in a 1024 radius around my player.
I wanted to create a geometry shader that not only continues to texture the ground appropriately, but also creates grass (preferably waving with the wind).
I have found some basic billboard geometry shaders to get me started, but they seem to cause the mesh to stop texturing. Is there anyway to do both from one shader?
Do I pass the mesh triangles and the new grass triangles on to the fragment shader with a flag? Thanks in advance!

You can do this by implementing two passes to the shader as it turns out. My first pass is a simple surface shader, but my second pass is the geometry shader. The multi-pass still results in 130 FPS, so it seems to be adequate.

Related

Any way to get a URP shader to tile at a constant size, regardless of face orientation?

I need a shader which I can apply to a surface, and have it tile a texture at a constant size. Think 'stretchable brick wall' I looked at this world shader hoping I could adapt. https://www.youtube.com/watch?v=vIh_6xtBwsI&ab_channel=JustinFoley
The problem with world UV's is they only project along the major axes. I need it to follow the rotation of the object, just not affected by scale.
This is what I was trying:
But as you can imagine, it is still affected by scale, and appears to align with the y plane:

Unity Point-cloud to mesh with texture/color

I have a point-cloud and a rgb texture that fit together from a depth camera. I procedurally created a mesh from a selected part of the point-cloud implementing the quickhull 3D algorithm for mesh creation.
Now, somehow I need to apply the texture that I have to that mesh. Note that there can be multiple selected parts of the point-cloud thus making multiple objects that need the texture. The texture is just a basic 720p file that should be applied to the mesh material.
Basically I have to do this: https://www.andreasjakl.com/capturing-3d-point-cloud-intel-realsense-converting-mesh-meshlab/ but inside Unity. (I'm also using a RealSense camera)
I tried with a decal shader but the result is not precise. The UV map is completely twisted from the creation process, and I'm not sure how to generate a correct one.
UV and the mesh
I only have two ideas but don't really know if they'll work/how to do them.
Try to create a correct UV and then wrap the texture around somehow
Somehow bake colors to vertices and then use vertex colors to create the desired effect.
What other things could I try?
I'm working on quite a similar problem. But in my case I just want to create a complete mesh from the point cloud. Not just a quickhull, because I don't want to lose any depth information.
I'm nearly done with the mesh algorithm (just need to do some optimizations). Quite challenging now is to match the RGB camera's texture with the depth camera sensor's point cloud, because they of course have a different viewport.
Intel RealSense provides an interesting whitepaper about this problem and as far as I know the SDK corrects these different perspectives with uv mapping and provides a red/green uv map stream for your shader.
Maybe the short report can help you out. Here's the link. I'm also very interested in what you are doing. Please keep us up to date.
Regards

How to texture mesh? Shader vs. generated texture

I managed to create a map divided in chunks. Each one holding a mesh generated by using perlin noise and so on. The basic procedural map method, shown in multiple tutorials.
At this point i took a look at surface shader and managed to write one which fades multiple textures depending on the vertex heights.
This gives me a map which is colored smoothly.
In tutorials i watched they seem to use different methods to texture a mesh. So in this one for example a texture is generated for each mesh. This texture will hold a different color depending on the noise value.This texture is applied to the mesh and after that the mesh vertices are displaced depending on the z-value.
This results in a map with sharper borders between the colors giving the whole thing a different look. I believe there is a way to create smoother transitions between the tile-colors by fading them like i do in my shader.
My question is simply what are the pro and cons of those methods. Let's call them "shader" and "texture map". I am lost right now, not knowing in which direction to go.

How to do texture mapping in openglES? ( Mapping 2D face into a 3D mesh )

I need to convert a 2D face image to a 3D image. For this I thought of using texture mapping with openglES. I tried a lot googling to find some samples I couldnt get any. Can some one guide me to do this?
Input: 2D image
Output : 3D image
Platform : ios
As you know, OpenGL is using 3D or 2D vertices that has a few attributes such as position, normal value, color, texture coordinate. So you should set these values first and you can render.
In ES 2.0 clearly you have to give these values to Vertice Shader
and then you have to transfer two values texture coordinate , normal value to Fragment Shader
and then in Fragment Shader, you can control these values with sampler texture for rendering your face object.
If you work In IOS, It's going to be very help .
Explanation :
http://ofps.oreilly.com/titles/9780596804824/chtextures.html
Source Code :
http://www.developers-life.com/iphone-3d-samples.html

draw texture on 4 vertices plane

i have a standard plane created with unity and replaced its mesh filter (that had 121 tri, 202 vertices) with a mesh filter made in blender that has 2 tri/4 vertices.
if i set the material up with a texture, i get only a very small portion of the texture drawn on the plane. How can i draw the full texture on the new plane?
You need to adjust your UV mapping so that the 4 vertices cover the whole image. Take a look at the this demo file especially at the UV scene layout.
If a texture shows that way it means either the UVs of the imported model are wrong or the texture tilling or offset in the material are wrong.
Instead of importing a mesh for such simple shape you can create one procedurally in code like this: https://github.com/doukasd/Unity-Components/blob/master/ProceduralPlane/Assets/Scripts/Procedural/ProceduralPlane.cs