jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« on: June 17, 2007, 01:40:25 AM » |
|
I have the following program the takes any mesh and explodes it: http://rapidshare.com/files/37683651/jviper_ExplodeMesh.zipCurrently what it does is shatters the mesh into thousands of meshes and move them all seperate ways. It loops through all the parts to move them. What I wanted to do is do the same thing, or as close to it as possible using minimeshes. Any tips on how tot go about this?
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|
v3ry01
|
 |
« Reply #1 on: June 17, 2007, 08:52:54 AM » |
|
Hello,you sample is very good,certainly implented in my project,any update as coming?
|
|
|
|
|
Logged
|
|
|
|
jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« Reply #2 on: June 17, 2007, 11:29:51 AM » |
|
Update? What do you mean? You mean, optimization? Yeah, I was hoping I'd get some help on that. I considered trying to do the same thing with minimeshes somehow. I guess another way would be to do it with a shader, but I would need a routine to shatter the mesh so the shader could move the peices around. But, yeah, hopfully I'll be able to come up with an update.
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|
sybixsus
|
 |
« Reply #3 on: June 17, 2007, 11:46:28 AM » |
|
You know how you could cheat and get this done with a shader on the cheap? Bones. Give the mesh x bones, parent chunks around to different bones. Then just send the bones off in different differections and as long as the actor is set to shader mode, it's all done in a shader for you. I haven't looked into the bones commands too much, so I'm not sure how much of this could be done "on the fly" and how much would have to be precalculated, but it was just a thought that sprang to mind.
|
|
|
|
|
Logged
|
|
|
|
jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« Reply #4 on: June 17, 2007, 12:28:52 PM » |
|
Thinking about this, I ran into some possible issues: 1.) This code I intend to be able to implement at run-time. So would there be a way to add bones in run-time when I shatter the mesh? 2.) What happens if a mesh/actor has adjencencies over joints (skinning)? Would there be a way to seperate the bones? 3.) What about key-frames?
But the whole idea of using shaders seems like a good idea to me. I was thinking if I can break up the adjecnecies then the shader would work great because then it's just about moving the verticies in the vertex shader. What do you think?
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|
SylvainTV
|
 |
« Reply #5 on: June 17, 2007, 03:06:33 PM » |
|
If all created meshes are different, you can't really use minimeshes. However if you could "cheat" and use several times the same created mesh, it would be interesting to use minimeshes or of course duplicated meshes.
|
|
|
|
|
Logged
|
|
|
|
jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« Reply #6 on: June 17, 2007, 09:39:08 PM » |
|
That was another thought I had. Ofcourse that would decrease the realisim just a litltle because some parts would be flying that did not neccisarily come from the mesh, but I think if I use a couple of minimesh systems and some particle systems for an eye-candyed effect, I could problebly pull off a good effect. So, I think I will try that technique, then I will figure out how I can effectively "crease" the mesh.
Now, for the other technique (the one where I split the mesh geometrically and then use a shader), I think the challenge will be ofcource altering the geoemtry just so that not everything is attached so that when I move the verticies, it doen't just look like a blob. I have an idea on how to do this: A verticies. I know that a cube has 36 indicies (3 for each triangle), but only 8 verticies. If I change the number of verticies to 24 and re-reference the indicies (indicies still = 36) then I will have effectlivly seperated the cube into it's 6 sides. I just need to apply that on a much larger scale, and more abstract. But I think it should be doable. I'll let you know how that goes.
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« Reply #7 on: June 18, 2007, 01:00:31 PM » |
|
Ok, here's an update: I have begun coding for the shader-way of doign thie explosion thing. I have written and completed the routine that takes the mesh and splits it up into it's seperate parts by altering the vertex/index array only. So the mesh looks exactly the same after clicking ExplodeMesh button regarless of how many parts it will explode into. But internally, it is actually split. Now that that is done, all the shader has to do is move the verticies. Now, there are two things I have ran into, and I need alittle help for this to work. 1)textures. Is there some scematic that I could send to the shader so that it knows which group a vertex is in? This way, I can get textures working for all groups (if there are more than one textures). 2) Is there anyway I can send to the shader which part it is. This way, the shader knows which verticies I intended to be part of the same "flying peice" of the original mesh. Otherwaise, it will just be moving everything randomly. Here is the project that I have thus far: http://rapidshare.com/files/37970438/jviper_ShaderExplodeMesh_NoMove.zipHelp appricieated. Thankyou.
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|
zwiglm
|
 |
« Reply #8 on: June 19, 2007, 02:07:59 AM » |
|
Can any of you mirror this file please.
Cheers, Martin
|
|
|
|
|
Logged
|
Cheers, Martin
|
|
|
|
Eric
|
 |
« Reply #9 on: June 19, 2007, 05:11:56 PM » |
|
|
|
|
|
|
Logged
|
|
|
|
jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« Reply #10 on: June 19, 2007, 10:51:13 PM » |
|
Ofcourse not, but updates are coming fast so hope you can keep up :wink: . Another update today. I have written out the shader as it will hopefully be completely working, other than the fact that texture coordinates are not exactly right. Here is the project: http://rapidshare.com/files/38249179/jviper_ShaderExplodeMesh_MovementReady.zipI've been having problems trying to figure out how to pass information to the shader. I finnally figureed out how to pass the fragment id for each vertex, but it now will not pass the texture coordinates. There is somthing else: It appears that the shader does not take in vectors. When I pass a vector to the shader by using TVShader.SetEffectParamVector......, the value is being passed to the shader correctly because I get the same value back through the TVShader.GetEffectParamVector. The problem is, somehow, the shader sees it as garbage. In the shader file, there is a line of code: float4x4 Mov = mul(MatxRot(t*float4(0,0,0,0)),MatxPos(t*float4(0,0,0,0))); which is commented out. Below it is the line that is suppose to move that fragment: float4x4 Mov = mul(MatxRot(t*RotSpeed[IN.partIdx]),MatxPos(t*PosSpeed[IN.partIdx])); You will notice that when you run the program as is, everything will simply disappear. But when you comment out this line, and use the line above it, it seems to work. You can even change the values of that top line to verify that the shader the way it is written is correct. So the problem seems to be that the shader is not using its own variables correctly. Any hints on this?
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« Reply #11 on: June 21, 2007, 11:39:35 AM » |
|
Ok, this is crap. I've finnally found a way to get movemet BUT, it seems that there is a 100 item limit, so no more than 100 fragments on the exploding mesh flying around. That sucks! Here is the updated Shader File: http://rapidshare.com/files/38542983/jviper_ExplodeMesh.zipNot sure if this is a limitation of the shader, or TV3D. I'll double check in like RenderMonkey or somthing. Hopfully, it might just be a limitation/bug in TV3D.
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|
Eric
|
 |
« Reply #12 on: June 21, 2007, 02:58:57 PM » |
|
|
|
|
|
|
Logged
|
|
|
|
|
zwiglm
|
 |
« Reply #13 on: June 22, 2007, 03:14:58 AM » |
|
@Eric: Thanks for the support and mirroring the files.
Cheers, Martin
|
|
|
|
|
Logged
|
Cheers, Martin
|
|
|
|
SylvainTV
|
 |
« Reply #14 on: June 22, 2007, 03:36:52 AM » |
|
Remember that for VS2.0, there is a limit to the number of vertex shader constants that can be sent to the 3D card : 256 float4 registers. So it's probably the reason. You might have to divide in several meshes or render it in several passes.
|
|
|
|
|
Logged
|
|
|
|
|
GD
|
 |
« Reply #15 on: June 22, 2007, 05:03:00 AM » |
|
Maybe compute physics with CPU, and pass vertex position via COLORx or TEXCOORDx ?
|
|
|
|
|
Logged
|
|
|
|
jviper
Community Member

Posts: 2130
Discipline in training
|
 |
« Reply #16 on: June 22, 2007, 11:08:06 AM » |
|
Compute phyics by CPU? You mean, like do a for loop through all the verticies and add velocities and gravity, and then pass the final geometry to the shader? Or do you mean find a way to use TVPhysics?
|
|
|
|
|
Logged
|
JAbstract.....Don't just imagine, make it happen!
|
|
|
|