It is currently Sat Aug 22, 2020 12:37 pm


All times are UTC




Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Author Message
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 5:31 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 6:25 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 6:47 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Ok, I give up! I am gonna do it your way for now.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 7:01 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Yeah, get it working first and then worry about optimising it later ;)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 7:09 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 7:26 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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:
Image

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:
Image

uff..

Now I tried to set one of the new triangles to be of material 1:
Image

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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 7:28 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
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();
      }


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 7:37 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 8:35 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Ok, improvement - I got many more vertices showing now:
Image

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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: MLE Tech Demo :)
PostPosted: Sat Mar 19, 2011 9:30 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Ok, good news!

Image

Now I am only left with the texture atlas issues. I hate you DX 9. Thanks for working method David!


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 73 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net