#### Archived

This topic is now archived and is closed to further replies.

# using vertex shaders AND fixed function: flashing triangles

This topic is 5148 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i cannot solve this strange bug: i render the entities using a vertex shader, like this:
		pEntity=m_pEntityManager->GetEntity(i);
m_pTextureManager->SetCachedTexture(0,pEntity->GetTextureIndex());

D3DXMATRIX Transform;
Transform=pEntity->GetTransform()*View*Projection;
D3DXMatrixTranspose(&Transform,&Transform);

//draw the model
m_pModelManager->DrawModel(pEntity->GetModelIndex(),NULL,NULL);

it works perfectly. CShaderManager::SetVertexShader() just calls LPDIRECT3DDEVICE::SetVertexShader() passing an indexed handle. after i do this, if i try to draw other stuff with the fixed function pipeline, calling SetVertexShader(D3DFVF_MYVERTEX) for example, and then setting up the vertex buffer and stuff, the new geometry is ok, but all the geometry previously rendered with the vertex shader is "flashing". this is really strange because drawing new geometry anyway shouldnt modify previously rendered stuff! is there some known issue in drawing with both programmable pipeline and fixed function? should i stick to vertex shaders for everything i want to draw? another thing, this doesnt happens if i use transform and lit vertices the second time. i think its because T&L vertices do not pass into the geometry pipeline so the problem is avoided.. [edited by - Arcibald Wearlot on April 15, 2004 3:29:35 AM]

##### Share on other sites
Could you please provide more details? What are you rendering, exactly? What is the relation between the FFP-rendered objects and the VS-rendered objects? (i.e. Decals or something?)

- It sounds to me like some z-fighting issue. The FFP and VS paths have different precision, and that could cause some small z-difference between polygons with the same depth, which would cause z-fighting.

Optimize
Bitwise account: MHaggag -

##### Share on other sites
it isn''t a z-buffer issue, as im drawing completely different models. i always get flashing triangles no matter of what models i draw. for example the first time i render a rotating planet and the second time a "ground" model. the planet model start flashing. the more fps i get, the faster it flashes. it is as if there is another model that overlaps the original one, and some of its triangles get shown. this seems to be affected by the rotation of the camera: when i am in a certain angle the flashing triangles are almost white, while in another angle they are almost transparent. this makes me think of something related to lighting, but i disabled it..

##### Share on other sites
I''ve seen this on GeForce3 and XBox hardware. I never figured out what the problem was. On PC, in windowed mode, if you click on your titlebar the app should halt until you let go of the button. While clicked can you see any triangles missing? I know it sounds odd, but we''ve never been able to see any problem when halted, but it flashes quite a bit when left to run. The odds of us never seeing an incorrectly rendered image seem pretty low, which makes me think it''s actually a timing issue, where the backbuffer is presented before everything is drawn.

Once or twice I saw this same effect in NFSU on one or two polys, which made me feel better.

##### Share on other sites
got it. it was pixel fog.
the documentation says that "Pixel fog is not supported when using a vertex shader."
it was enabled so when i switched back to fixed function it was activated again and messed up with the shader.

• 10
• 15
• 14
• 18
• 15