• Breaking News

    (SOLVED) - SharpDX 4.2 Vertex Shader Instanced Vertex Position Manipulation Hi, my original question which I again deleted by accident and cannot get it back was to find a way to Manipulate each individual vertex in instances with a vertex shader. I have now solved that problem and wanted to post it here. The project is in VR and requires you to have an Oculus Rift VR Headset. I will soon have the project without VR. Project => http://bit.ly/2KHjtWW I have yet to find a suitable License for the project though. I was thinking of MIT license. Original question on another forum => http://bit.ly/2UVRNl7 How it works: I am creating a single chunk and assign to each individual vertex an index to which cube they belong to. This chunk also creates the original vertex and original triangle index. Those vertex index and triangle index will be the same for each instance but their position will be modified. The data is accessible inside of the vertexBufferBinding. I am then creating all of the chunks that are needed but only ouput the byteMap out of them in the form of integers with 8-9 digits each. For this project, 8 integers of 8 digits (9 digits total) are used and stored to be sent as INSTANCED data. Why only 8 integers? Well the chunks are 4*4*4 (width/height/depth) which is 64 bytes. I am taking padding each integer with a 1 (starting them with the digit 1) and then I fill them up with 0's and 1's until they reach 9 digit long. I might use decimals later on to increase the length of the data I can pass to the vertexBufferBinding. An integer is 32bit long maximum so you need to make sacrifices and you have to PAD your integers starting with a number and if you decide to go in Decimals, you need to PAD at the end with a digit also other than zero. I could've reduced the number to maybe 4 integers instead but it worked well like this so I kept it at 8-9 digits per integers. I don't even need to create a constant buffer to send the data to the instances, because the vertexBufferBindings as InstancedVertexBufferBindings are taking the integers array and sending that to each instances of each objects created in the scene. It's a bit complicated to explain, so it's better that you see the code for yourself. The next goal of this type of terrain is to access the byteMaps from a Texture1D instead of the vertexBufferBindings because the vertexBufferBindings is limiting me to 32bit floats and creating a huge amount of VertexBufferBindings to cover all of the different sizes of chunks that I want to make would take a while. A Texture1D seems more suitable for the task and this will be part of my next question. Current Result: - practically instant creation of a huge chunk 4*4*4 x 4*4*4 x 4*4*4.... each tinyChunk is 4*4*4. Each tinyChunk is instanced 4*4*4 and there is 4*4*4 objects on the screen. So this is 64 draw calls instead of 4096 draw calls. The problem now, is that ALL vertex and ALL triangles are drawn but their positions only changed so that you won't notice that they are there. The next step in the project is to remove the extra triangles and extra vertex by using a Geometry shader... I think that we can nullify faces in a Geometry shader, which would make it suitable to do the job. https://ift.tt/eA8V8J

    Hi, my original question which I again deleted by accident and cannot get it back was to find a way to Manipulate each individual vertex in instances with a vertex shader. I have now solved that problem and wanted to post it here. The project is in VR and requires you to have an Oculus Rift VR Headset. I will soon have the project without VR. Project => http://bit.ly/2KHjtWW I have yet to find a suitable License for the project though. I was thinking of MIT license. Original question on another forum => http://bit.ly/2UVRNl7 How it works: I am creating a single chunk and assign to each individual vertex an index to which cube they belong to. This chunk also creates the original vertex and original triangle index. Those vertex index and triangle index will be the same for each instance but their position will be modified. The data is accessible inside of the vertexBufferBinding. I am then creating all of the chunks that are needed but only ouput the byteMap out of them in the form of integers with 8-9 digits each. For this project, 8 integers of 8 digits (9 digits total) are used and stored to be sent as INSTANCED data. Why only 8 integers? Well the chunks are 4*4*4 (width/height/depth) which is 64 bytes. I am taking padding each integer with a 1 (starting them with the digit 1) and then I fill them up with 0's and 1's until they reach 9 digit long. I might use decimals later on to increase the length of the data I can pass to the vertexBufferBinding. An integer is 32bit long maximum so you need to make sacrifices and you have to PAD your integers starting with a number and if you decide to go in Decimals, you need to PAD at the end with a digit also other than zero. I could've reduced the number to maybe 4 integers instead but it worked well like this so I kept it at 8-9 digits per integers. I don't even need to create a constant buffer to send the data to the instances, because the vertexBufferBindings as InstancedVertexBufferBindings are taking the integers array and sending that to each instances of each objects created in the scene. It's a bit complicated to explain, so it's better that you see the code for yourself. The next goal of this type of terrain is to access the byteMaps from a Texture1D instead of the vertexBufferBindings because the vertexBufferBindings is limiting me to 32bit floats and creating a huge amount of VertexBufferBindings to cover all of the different sizes of chunks that I want to make would take a while. A Texture1D seems more suitable for the task and this will be part of my next question. Current Result: - practically instant creation of a huge chunk 4*4*4 x 4*4*4 x 4*4*4.... each tinyChunk is 4*4*4. Each tinyChunk is instanced 4*4*4 and there is 4*4*4 objects on the screen. So this is 64 draw calls instead of 4096 draw calls. The problem now, is that ALL vertex and ALL triangles are drawn but their positions only changed so that you won't notice that they are there. The next step in the project is to remove the extra triangles and extra vertex by using a Geometry shader... I think that we can nullify faces in a Geometry shader, which would make it suitable to do the job.

    from GameDev.net http://bit.ly/2KIyI1L

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728