Direct3D Textures Not Appearing...

Started by
10 comments, last by BrianMJC 20 years, 9 months ago
Hi all -- In my current project, I want to use D3D alpha blending for some textures. These will be colored, glowing lights which highlight graphic buttons when the cursor is placed over them. I just can''t get them to appear. I''ve followed a few online articles, one of which specifically explains how to do this. What makes this even more perplexing (and annoying!) is that I''ve previously been able to do this before. I''ve compared my previous code to this project''s code, and they seem identical. I''ve checked the following: - setup primary surface with DDSCAPS_3DDEVICE flag - successfully setup Direct3D (interface, device, viewport, etc.) - set surface caps with DDSCAPS_TEXTURE and caps2 with DDSCAPS2_TEXTUREMANAGE - assocaited the texture with the surface via IUnknown->QueryInterface (). - ordered the trinagle strip (D3DTLVERTEX array) and set the screen coordinates correctly (if I blit the surface via DirectDraw''s surface->Blt (), it appears just fine, except no alpha blending of course) - set the correct rendering states and set texture (bank 0 with device->SetTexture ()) - call BeginScene and EndScene correctly Also, I''ve noticed if I set the render state to fill wireframe without alpha blending, I see a white triangle strip of four vertices in the correct position, minus the texture. And if I set it to fill solid, I see a white filled rectangle in the right position. Btw, I''m using version 6.1 of DirectX in Win98SE. I appreciate any help, thanks and peace!!
Advertisement
Wrong forum. Moved to DirectX.
Oops, sorry!

DirectX 6, that''s going back a bit - had to dig out my old DX6 SDK CD to jog my memory about the way that works.


1) What have you got for your IDirect3DDevice3::SetTextureStageState() calls?. Those will directly control where the hardware gets the colour values from and how textures are used.

2) What are the "color" and "specular" members of your D3DTLVERTEX set to ?

3) Try setting D3DRENDERSTATE_SPECULARENABLE to FALSE

4) What are the rhw values of your D3DTLVERTEX set to ?... try "1.0f"

5) Beware that mixing any DirectDraw Blt/BltFast calls with your 3D stuff, particularly to the same areas of the screen can cause "issues" (graphic corruption, slow downs etc) on some cards (especially PowerVRs and similar). Check for DDCAPS2_NO2DDURING3DSCENE for an indication of this.

6) Does it work with the software D3D devices or RefRast (if that was in DX6) ?. Often if your polygons come out all white or all black it means the hardware is unhappy with something you''ve asked it to do.

7) Do bear in mind that many 3D cards have restrictions about the dimensions and bit depths of surfaces you can use as textures. This is reported in the caps. The old 3Dfx Voodoo2s for example requires textures to be: Square, Power-of-2 with and height, 16bit, and no greater than 256x256.

IDirect3DDevice3::GetCaps()
Check the dwTextureCaps in D3DPRIMCAPS, in particular D3DPTEXTURECAPS_POW2, D3DPTEXTURECAPS_SQUAREONLY and the max texture size caps etc



--
Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Hi Simon,

Here''s what I''ve done:

1) Device3D->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);

2) I tried color values of RGBA (255, 255, 255, 0) and RGBA (255, 255, 255, 255) and speculars are all set to D3DRGB (1.0f, 1.0f, 1.0f)

3) I''ll get back to you on this one...

4) All rhw''s are set to 1.0f

5) Aha... I am in fact mixing DD Blt and D3D DrawPrimitive calls within the BeginScene and EndScene segment... I suspect this is the problem then, I''ll get back to you on this soon...

6) Didn''t try it as a software device, but I suspect this is not the issue for the same reason as #7 below. Will try it if #5 proves to not be the problem.

7) I was aware of this, and although I didn''t try it, this can''t be the problem because I''ve gotten them to work on this same machine and video card and OS version before without such mods. It''s a Voodoo3, btw.

Regarding DX6, I''m keeping it older for two reasons. I want my game to be compatible with most systems. And I lack the resources to do current fx and super graphics anyway! I''m aiming for the shareware market, it will be my first commercial release.

Thanks very much, I''ll get back to you later on today.
Update:

3) Tried it with no change.

5) Turns out not to be the problem: I still get white rectangles with with fill solid rendering and nothing with alpha blending enabled, even though I eliminated the DD Blt calls inside the BeginScene and EndScene segment.

6) Interesting, something different happens when I setup D3D to run as software emulation with MMX instead of hardware: I no longer see white rectangles, but I don''t see the textures correctly displayed either. It is obviously doing something with the textures, but they are garbled, colored rectangles instead of spherical lights. I recognize them only because they each have a unique color. There appears to be an ordered pattern to the garbledness (it''s not random noise, but an obvious pattern of the correct colors).

7) Didn''t get to this, I will, and I''ll be back later.

Peace,
Brian
7) I stand corrected, turns out my Voodoo3 needs powers of two and square textures after all. Right after I posted last time, it occurred to me: I got it working last time, but I used 64x64 textures!

I''m sure this is the problem, I''ll try altering my textures to work. Thanks tremendously for your help!

Peace,
Brian
This is getting ugly... I redrew my textures to fit in 64x64 or 128x128... still I get the same outcome.

Only there is more clarity in the texture when software rendered with the square pow2 textures. It appears warped, as if it were reading the image from file with a slight error in width, such that each horizontal line in the texture is offset by one or two pixels left, and neighboring textures are mixed in. Yet I know that it is reading them from file correctly because when I revert to DD blitting it appears perfect.

I''m very tempted to write my own software alpha blending routine!!!
Ok, that''s a few things eliminated, but not all.

I think the best thing to do is separate the tasks - first get the texture working on the polygons without alpha blending THEN once that''s working, add in the alpha blending code.


1) Try disabling alpha blending altogether (D3DRENDERSTATE_ALPHABLENDENABLE = FALSE). Do you get the RGB parts of the texture on the polygons you render (albeit not blended with what''s underneath) ?. Or do they come out all white with this ?


2a) What are the rest of your SetTextureStageState() calls doing? If you haven''t set them, try something explicit like:

Device3D->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
Device3D->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
Device3D->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
Device3D->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
Device3D->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
Device3D->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_TEXTURE);

2b) Then set the .color member of your vertices to 0xFFFFFFFF and the .specular member of your vertices to 0x00000000


3) Have you got fog enabled ?


4a) If the suggestions in #1 & #2 still show the polygons as all white rather than having any textures, then double check your texture loading code.

4b) If the suggestions in #1 & #2 work albeit without the alpha blending, re-enable alpha blending and:
- check that the alpha blending mode is set to something that''s actually using the alpha value (such as SRCALPHA:INVSRCALPHA).
- check that you''re remembering to clear any Z buffer and frame buffer
- try replacing the interface being passed to SetTexture() with another texture that you know is working 100%


5) Try removing all of the 2D rendering from the scene so that you only have 3D.


If the texture isn''t coming out totally white but is still wrong, then can you post a screenshot?

--
Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Here we go:

1) Nothing different.

2) Nothing different here either. Previously I just had wireframe or solid fill enabled, just one call to SetRenderState.

3) No, and I set it to FALSE just to make sure.

4) I''m no longer getting white rectangles in solid fill with hardware rendering. I''ve been getting a warped texture, described in my previous post. This was thanks to redoing my textures to have power of two and square dimensions.

I don''t yet have a website, and I don''t know how to post screenshots without one. I just formed my business entity yesterday, one thing at a time.

--------------------------------

Hold on, I don''t think it''s D3D that''s causing the problem anymore... I tried DD Blt and they show up the same exact way! I must have screwed up my graphics reader routine, I''ll get back to you when I figure it out.

Peace,
Brian

This topic is closed to new replies.

Advertisement