Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

1260 Excellent

About Namethatnobodyelsetook

  • Rank
  1. Namethatnobodyelsetook


    One thing I've considered, but never tried... If you lock your static VB you'll stall the CPU until the GPU is done with the buffer. If the changes are infrequent (ie: blowing up a chunk of landscape with a rocket), you could... Have a flag to indicate if static or dynamic VB should be used. Normally you're using the static buffer. If the data changes, you'll switch to a dynamic VB for 3-4 frames. After 3-4 frames, the static buffer should not be referenced by the GPU, and you can lock and copy data into the static buffer without stalling. You could also use 2 static buffers and ping-pong between them, but if two buffer changing events happen in rapid succession you'd stall.
  2. Namethatnobodyelsetook

    [c++ directx 9] rendering alpha problem

    Instead of alpha blending, perhaps alpha testing is what you're after. With alphatest a pixel is drawn or not, based on alpha. This eliminates the need to sort for depth, but there is no partial blend. Set the following render states: D3DRS_ALPHATESTENABLE, true D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL D3DRS_ALPHAREF, 128 This will tell D3D to draw any pixels who's alpha is greater than 128. You can enable both alphablend and alphatest at the same time. If a pixel passes the test, it will then blend, but you still have all your usual front-back issues. As for render order, draw all solids first, then all alphatests (as soon as you use an alphatest you destroy many z cull optimizations GPUs use, so you want to put these off until after proper solids), then alpha-blended objects sorted.
  3. Namethatnobodyelsetook

    [D3D9/C++] - deliberately stalling the pipeline

    Create a render target surface that's not your backbuffer. It can be small, like 1x1. When you need to stall, render a triangle to it (or maybe even just clear it), and lock it. You need to do *something* to it, or the surface won't get marked as in use. I don't remember if you need to make a render target texture to get a lockable surface. It shouldn't take too long for you to verify what works. If you want to test that some operation is complete, but still allow buffering of even more work, create several such surfaces. Render to one, perform more work, Render to the second, perform more work, lock the first. You can use lock w/ donotwait to test if the previous work is completed or not, and if not, use a third surface and do more work.
  4. Namethatnobodyelsetook

    Little Clarification on Shaders

    I can answer that last part. 1 Float will become float,0,0,1 as a float4 in the shader 2 floats will become float1,float2,0,1 as a float4 in the shader. 3 floats will become float1,float2,float3,1 as a float4 in the shader. This applies to ALL shader inputs, not just position. I'm not sure if this changed in shader model 4 or 5, as I've yet to try them. Booleans in shaders are tricky. The card may actually branch, or it may calculate both sets of code, and then discard one. As long as the final answer is correct, it can do whatever it wants. The problem comes in the code path you didn't intend to run. Perhaps you'll cause floating point exceptions with you uninitialized values, slowing down your shader (that is, slowing it down even more than the fact that it's running both sets of code). You can probably get away with it in a vertex shader, however I'd advise against it in the pixel shader.
  5. Namethatnobodyelsetook

    Perspective - Orthographic projections

    Pass both projections into your shader, and a blend float. Multiply your worldview coords by each projection and blend between them, output the result.
  6. Namethatnobodyelsetook

    D3D Lighting only specific textures

    Yes, as starman said, you can disable lighting (D3DRS_LIGHTING, FALSE) if the two textures you're drawing are in separate draw calls. Basing it on the presence of vertex color isn't ideal as you can get some nice effects by using the vertex colors with lighting (D3DRS_COLORVERTEXENABLE, D3DRS_*MATERIALSOURCE). If you want to mix lit and unlit in one draw call, that's possible too. In the fixed pipeline, you'd modulate the first texture with diffuse, then blend in the remaining textures in later stages. The multiply with diffuse is what give you the lighting. If you don't multiply at the end, not everything is affected.
  7. Namethatnobodyelsetook

    Little Clarification on Shaders

    I'm not sure if the inputs are guaranteed to be 0. You wouldn't make a single shader or a single input to replicate the fixed pipeline, nor would you attempt to recreate each possible version of the shader. Also, each of those texcoords can be float1, float2, float3, or float4, even in the fixed pipe. There is a second vertex color too, and they are float4s. Using just 1 texcoord, it can be float1-4, and come from any of the 8 texcoord inputs, or be generated as either positon, normal, reflection, spheremap. It may or may not have a texture coord transform, and it might use projected lookup. So just handling a single texcoord, and nothing else gives 4*(8+4)*2*2, or 192 possible permutations. Using 2 texcoords, you'll have 192 possible permuations of each, or 36,864 combinations. For 8 texcoords, you'll have 1.84675732 * pow(10,18) combinations. Even if you could store each shader in a byte, you'd run out of RAM, and we've haven't touched fixed pipe skinning, material options, lights, and the texture stage blending options. What I'm saying is DON'T MAKE A SHADER THAT DOES EVERYTHING. MAKE THE SHADERS THAT YOU NEED. Typically a full game will use a dozen shaders, maybe two dozen, each with a few techniques in each (normal, boned, batched, etc.)
  8. Namethatnobodyelsetook

    Orthographic projection and resizing

    Quote:Original post by jyk You can use an orthographic projection of, say, 800x600 with *any* resolution for which the aspect ratio is 4:3 (assuming you don't want the image to be distorted), and it'll work fine. To make this even clearer. The projection width and height are WORLD SPACE units, not on screen pixels. You choose how much of your world you want visible, and use that. Typically you'll pick the length of one axis, width or height (depending on which is most critical to your game), and calculate the other axis based on the aspect ratio of the window or screen resolution. If widescreen users shouldn't see extra to the sides, then made the width the fixed size, and calculate the height based on the aspect. If seeing the expected top and bottom is more critical, you'll pick the height, and calculate the width.
  9. First the texture stages run. After the last stage, the result is either written to the framebuffer, or blended with the framebuffer, depending on if you have ALPHABLENDENABLE set. SrcBlend, DestBlend, and BlendOp control how the blending operates. NewColor is the result of the texture stages or pixel shader. PreviousColor is what's already in the frame buffer. FinalColor is the new value that gets written in the frame buffer. The blending takes the form of: FinalColor = SrcBlend * NewColor (BLENDOP) DestBlend * PreviousColor Your example stages would then be: FinalColor = 1 * NewColor + 0 * PreviousColor This result is exactly what you would get with blending disabled (ie: it will write the NewColor to the frame buffer). This particular blend state setup accomplishes nothing, aside from potentially slowing down rendering.
  10. Namethatnobodyelsetook

    How'd you come up with your profile name?

    Gaiiden's plan failed, as I've never replied to any of the other threads, it keeps this one relevant. I used to go by Redbeard, as I have a reddish-brown beard. As the web got older, it became exceedingly common name, and harder to use. In the 2001, my PC killed itself. I signed up for Yahoo to get to my mail (pop from ISP mail server) while the PC was dead. By 2001 a lot of names were taken, including Redbeard. While Yahoo helpfully offered to make me redbeard2352, I declined their kind offer. I tried something like 20 names before I gave up, typing 'namethatnobodyelsetook' in defeat, and half expecting it to be taken too. It was only meant to be a temporary account, while waiting for my PC to be revived, then discarded. Shortly after getting a new PC, I learned that Win98SE didn't like large drives. Instead of not using the space beyond what it knew how to comprehend, would just wrap around and overwrite the critical beginning sectors of the drive. Awesome. After that, I decided to switch to web mail completely, instead of risking losing it all again. I figured Yahoo probably had a better backup plan than I did, plus I could use it anywhere. That moved the name from being an occasional use thing to being my main online name. Continuing on my story, despite the name being explained, it's a good thing I switched to web mail. I installed Win2K to replace Win98SE (nobody trusted XP yet) to support my larger drive, as Win2K supported LBA mode. Once again, shortly thereafter, I discovered my mistake. While Win2K does indeed support LBA mode, instead of detecting it, Windows just decides to turn it off in the registry by default. Again Windows was braindead, and again just wrapped around to the beginning critical sectors of the drive. I think every edition of Windows I've ever used has self-destructed on me eventually... Vista hasn't yet, but give it time. XP did, Win2K did, 98SE did, 98 did, I'm fairly sure 95 did too. It's a fairly impressive track record.
  11. Namethatnobodyelsetook

    Games that don't allow diagonal movement

    Quote:Original post by pithlit ... are there any games that use 4 direction movement? Oh, the horrible memories. Ultima 3. You could only move and attack in 4 directions, but the enemies could attack (and probably move, but I'd don't truly remember) in 8. I felt no guilt when I discovered I could herd the enemies into single file, as they refused to step on treasure chests.
  12. Namethatnobodyelsetook

    Cockroaches in Canada

    If you treat your place like a slum you may get roaches in Ottawa. They do live here. If you move into a largely student filled apartment complex (such as the Prince Of Wales apartments, close to Carleton University), someone in the building is going to get a roach problem, and it will affect neighboring units. POW tends to spray at least every few years from what I hear, and I'm sure it's not just because feel like it. I'm not sure I've seen a roach in Ottawa aside from the POW apartments, but I'm betting all large student filled complexes have roach issues. You can move into a house in the suburbs, like Kanata, then all you have to deal with is skunks (stinky), raccoons(tip your garbage, wash their prey in your kids pool), chipmunks(shred things in your shed for bedding), bunnies(eat your flowers), endangered turtles(blocking development in Kanata north), and squirrels(also eat your flowers, and any seed you leave for birds). Though we have an occasional bear wander into town, and we have had deer on our lawn, that's not normal... they tend to stick to the fields in the greenbelt, which for Kanata, is fairly close by.
  13. Namethatnobodyelsetook

    [DX9] A problem with vertex buffer..

    Looks like m_v0, m_v1, and m_v2 are pointers, as new would return a pointer. Change these to be vertices, not pointers to them, and get rid of the 'new's when you copy. When copying into the VB, don't copy 'this'. Copy from &m_v0 (address of first vertex), and sizeof(CVertex)*3. 'this' may have all sorts of extra data inside it that isn't related to the vertex data. When your lock fails, you'll crash, as you immediately memcpy into address 0... you might want to return an error value.
  14. Namethatnobodyelsetook

    Texture Coordinate Generation

    Yeah, you should be able to do that with a matrix, no problem. Good luck.
  15. Namethatnobodyelsetook

    Texture Coordinate Generation

    You could set the D3DTSS_TEXCOORDINDEX to D3DTSS_TCI_CAMERASPACEPOSITION, set up a texture transform matrix, (D3DTSS_TEXTURETRANSFORMFLAGS = D3DTTFF_COUNT3, and SetTransform(D3DTS_TEXTURE0, &mat) ). The matrix can transform the points into a plane, if you figure out the correct matrix. I've used it to scale Y to 0, and shear X and Z towards an arbitrary angle, creating a shadow on a flat plane. Since you mention DX10, DX11, and PS3, I should point out that they're shader only (as is the omitted X360). As you mentioned the Wii, I should point out that the fixed pipeline isn't dead, as the Wii doesn't support shaders, only fixed pipeline.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!