| Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
| MLE Tech Demo :) http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=154 |
Page 5 of 8 |
| Author: | David Williams [ Sat Mar 19, 2011 5:31 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
So, in your code a material of 300 means it will be transparent? But this value is still being interpolated across the triangle, so it's only 300 exactly on the vertex? |
|
| Author: | Shanee [ Sat Mar 19, 2011 6:25 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
David Williams wrote: So, in your code a material of 300 means it will be transparent? But this value is still being interpolated across the triangle, so it's only 300 exactly on the vertex? Yes. Have an idea, z-problem maybe? |
|
| Author: | Shanee [ Sat Mar 19, 2011 6:47 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
Ok, I give up! I am gonna do it your way for now. |
|
| Author: | David Williams [ Sat Mar 19, 2011 7:01 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
Yeah, get it working first and then worry about optimising it later |
|
| Author: | Shanee [ Sat Mar 19, 2011 7:09 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
David Williams wrote: Yeah, get it working first and then worry about optimising it later off, still not working. what render states were you using to blend? |
|
| Author: | Shanee [ Sat Mar 19, 2011 7:26 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
I changed the line of code to instead of clip do the following: Code: if (input.Material > gNumMaterials) return float4(0.0, 0.0, 0.0, 1.0); And here is the result without additive: ![]() This is rendering black properly. Now when trying to render the other ones on top of it with the following render states: (D3DRS_ALPHABLENDENABLE, true); (D3DRS_BLENDOP, D3DBLENDOP_ADD); ( D3DRS_SRCBLEND, D3DBLEND_ONE ); ( D3DRS_DESTBLEND, D3DBLEND_ONE ); Here is the result: ![]() uff.. Now I tried to set one of the new triangles to be of material 1: ![]() Seems like it is rendering, but missing triangles. Also why wouldn't they blend if all it does is change 2 vertices out of 3 each time to return black? |
|
| Author: | Shanee [ Sat Mar 19, 2011 7:28 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
This is how I am generating the new buffer: Code: if (!problemVertices.empty())
{ vector<uint32_t> vecIndices; vecIndices.reserve(problemVertices.size() * 3); vector<PolyVox::PositionMaterialNormal> vecVertices; vecVertices.reserve(problemVertices.size() * 3); PolyVox::PositionMaterialNormal fixVert; for (vector<uint32_t>::iterator iter = problemVertices.begin(); iter != problemVertices.end();) { // First triangle vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*iter]; fixVert.setMaterial(300); vecVertices.push_back(fixVert); vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*(iter+1)]; fixVert.setMaterial(300); vecVertices.push_back(fixVert); vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*(iter+2)]; vecVertices.push_back(fixVert); // Second triangle vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*iter]; vecVertices.push_back(fixVert); vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*(iter+1)]; fixVert.setMaterial(300); vecVertices.push_back(fixVert); vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*(iter+2)]; fixVert.setMaterial(300); vecVertices.push_back(fixVert); // third triangle vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*iter]; fixVert.setMaterial(300); vecVertices.push_back(fixVert); vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*(iter+1)]; vecVertices.push_back(fixVert); vecIndices.push_back(vecVertices.size()); fixVert = vecVerticest[*(iter+2)]; fixVert.setMaterial(300); vecVertices.push_back(fixVert); iter+=3; } m_NumVerticesFix = vecVertices.size(); m_NumFacesFix = vecIndices.size() / 3 ; m_VertexBufferFix.Create(sizeof(PolyVox::PositionMaterialNormal) * (vecVertices.size())); m_IndexBufferFix.Create(vecIndices.size() * sizeof(DWORD), 8UL, D3DFMT_INDEX32); void* pVoid; m_IndexBufferFix.Lock(&pVoid); const void* pIndices = static_cast<const void*>(&(vecIndices[0])); uint32_t count = 0; memcpy((pVoid), pIndices, sizeof(uint32_t) * vecIndices.size()); m_IndexBufferFix.Unlock(); const void* pVertices = static_cast<const void*>(&(vecVertices[0])); m_VertexBufferFix.Lock(&pVoid); count = 0; memcpy((pVoid), pVertices, sizeof(PolyVox::PositionMaterialNormal) * vecVertices.size()); m_VertexBufferFix.Unlock(); } |
|
| Author: | David Williams [ Sat Mar 19, 2011 7:37 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
Shanee wrote: I changed the line of code to instead of clip do the following: Code: if (input.Material > gNumMaterials) return float4(0.0, 0.0, 0.0, 1.0); I think this is a little different to what I was describing. In your case it seems that each fragment will either be fully transparent or fully opaque (based on the gNumMaterials threshold). In my case, I'm making one corner of the triangle to be fully opaque, the other two to be fully transparent, but I then let the texture fade in across the triangle (so most of the pixel have partial transparency). I'm not using the material to determine the transparency in the shader. I'm using the material to determine what alpha value to assign the vertices on the CPU. This alpha value is always 0 or 1. Then the hardware interpolates this alpha value across the polygon and I use that value to determine how transparent each fragment should be. Unfortunatly I'm off for a bit now, so I can't help you more until tomorrow. It's complicated, but hopefully you can get it working... |
|
| Author: | Shanee [ Sat Mar 19, 2011 8:35 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
Ok, improvement - I got many more vertices showing now: ![]() They were gone due to me being silly and making the vertex material 300 forgetting it is also used in uniform triangles, therefore it broke them. Now I instead just remove the indices related to the broken triangles. Now for the middle part :/ I guess the question might be how you got the alpha value to interpolate in between the vertices maybe? |
|
| Author: | Shanee [ Sat Mar 19, 2011 9:30 pm ] |
| Post subject: | Re: MLE Tech Demo :) |
Ok, good news! ![]() Now I am only left with the texture atlas issues. I hate you DX 9. Thanks for working method David! |
|
| Page 5 of 8 | All times are UTC |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|