• 10
• 10
• 12
• 12
• 14
• ### Similar Content

• By isu diss
How do I fill the gap between sky and terrain? Scaling the terrain or procedural terrain rendering?

• By Jiraya
For a 2D game, does using a float2 for position increases performance in any way?
I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?

• By ucfchuck
I am feeding in 16 bit unsigned integer data to process in a compute shader and i need to get a standard deviation.
So I read in a series of samples and push them into float arrays
float vals1[9], vals2[9], vals3[9], vals4[9]; int x = 0,y=0; for ( x = 0; x < 3; x++) { for (y = 0; y < 3; y++) { vals1[3 * x + y] = (float) (asuint(Input1[threadID.xy + int2(x - 1, y - 1)].x)); vals2[3 * x + y] = (float) (asuint(Input2[threadID.xy + int2(x - 1, y - 1)].x)); vals3[3 * x + y] = (float) (asuint(Input3[threadID.xy + int2(x - 1, y - 1)].x)); vals4[3 * x + y] = (float) (asuint(Input4[threadID.xy + int2(x - 1, y - 1)].x)); } } I can send these values out directly and the data is as expected

Output1[threadID.xy] = (uint) (vals1[4] ); Output2[threadID.xy] = (uint) (vals2[4] ); Output3[threadID.xy] = (uint) (vals3[4] ); Output4[threadID.xy] = (uint) (vals4[4] ); however if i do anything to that data it is destroyed.
vals1[4] = vals1[4]/2;
or a
vals1[4] = vals[1]-vals[4];
the data is gone and everything comes back 0.

How does one go about converting a uint to a float and performing operations on it and then converting back to a rounded uint?
• By fs1
I have been trying to see how the ID3DInclude, and how its methods Open and Close work.
I would like to add a custom path for the D3DCompile function to search for some of my includes.
I have not found any working example. Could someone point me on how to implement these functions? I would like D3DCompile to look at a custom C:\Folder path for some of the include files.
Thanks
• By stale
I'm continuing to learn more about terrain rendering, and so far I've managed to load in a heightmap and render it as a tessellated wireframe (following Frank Luna's DX11 book). However, I'm getting some really weird behavior where a large section of the wireframe is being rendered with a yellow color, even though my pixel shader is hard coded to output white.

The parts of the mesh that are discolored changes as well, as pictured below (mesh is being clipped by far plane).

Here is my pixel shader. As mentioned, I simply hard code it to output white:
float PS(DOUT pin) : SV_Target { return float4(1.0f, 1.0f, 1.0f, 1.0f); } I'm completely lost on what could be causing this, so any help in the right direction would be greatly appreciated. If I can help by providing more information please let me know.

# DX11 Bitmap font engine problem

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

## Recommended Posts

Hello.

I'm trying to create my own text-rendering engine based on Rastertek's tutorial. The steps I did to make it work:

1. Created my own .png file, containing common ASCII symbols divided by spaces. PNG file had not been compressed.

2. Successfully parsed PNG file so that each symbol has it's own texture coordinates and width/height in pixels. The height is the same for each letter and equals to texture height.

3. Created DDS file from PNG font file.

4. Loaded texture from DDS file.

5. Created squares for each letter according to their width/height in pixels and texture coordinates.

6. Created orthogonal projection matrix to project them on the screen within pixel shader without any changes.

Everything seems well, but the result looks bad:

[attachment=13749:game.png]

As you can see, the letters look dirty and unprecise. Thats how DDS file looks in DX texture tool for comparison:

[attachment=13750:font_dds.png]

Edited by GuardianX

##### Share on other sites

What kind of filtering are you using  for your sampler state when you draw it?

##### Share on other sites
Thank you for response. I use this sampler state:

    D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;

mpDevice->CreateSamplerState(&samplerDesc, &mpSamplerState);


##### Share on other sites

Out of curiosity, why don't you use the sprite fonts that are part of XNA.

Anyways, I took a look at more detail.  I thought it might have been a slightly reduced image, but the final image and the original font both show the Capital 'M' at 10 pixels tall.

However, this looks like compression artifacts.  I.e. when it was saved, it may have included a small decompression like PNG/JPG would use.  Or it could be from the loading process.  I haven't used DX font loading of any type, so I'm not sure exactly how it should work, but that really looks like compression artifacts.

##### Share on other sites

Are you sure of your texture coordinate and your vertex coordinates ? I had a similar issue with OpenGl, and I had to correct the texture coordinates. It was years ago though, so I cannot be more accurate.

##### Share on other sites

Thank you for response, guys.

Out of curiosity, why don't you use the sprite fonts that are part of XNA.

Anyways, I took a look at more detail.  I thought it might have been a slightly reduced image, but the final image and the original font both show the Capital 'M' at 10 pixels tall.

However, this looks like compression artifacts.  I.e. when it was saved, it may have included a small decompression like PNG/JPG would use.  Or it could be from the loading process.  I haven't used DX font loading of any type, so I'm not sure exactly how it should work, but that really looks like compression artifacts.

I'm creating my own C++ rendering engine for the sake of learning DX11. Not sure if XNA sprite fonts can be used in such application.

I don't think it is caused by image compressing in my case, since DDS file, generated from image (which I receive uncompressed) looks precise and has no artefacts. However, It is possible that this behavior is caused by loading mechanism. In my engine, I use DDS loader, provided by new Microsoft D3D11 tutorials. I'll create plane with size of the font texture and check if this behavior keeps bubbling up even for sole plane mesh, thanks for pointing that out.

Are you sure of your texture coordinate and your vertex coordinates ? I had a similar issue with OpenGl, and I had to correct the texture coordinates. It was years ago though, so I cannot be more accurate.

Well, I'm absolutely sure about generated vertex coordinates and that I load and set correct texture coordinates from font description file, generated by one of my tools. At first glance, texture coordinates and width of every character, obtained from this tool are legit. The whole mechanism of generating data from PNG file in this tool is just about getting start pixel and end pixel of each symbol and dividing those values by width of the file, so it's pretty clear and simple.

##### Share on other sites

So you have startPixel/width and endPixel/width OR startPixel/width and (endPixel + 1)/width ?

##### Share on other sites

If you paste your two images on top of each other and align the letters it's clearly visible that the rendered characters are wider than those in the texture. Perhaps you scale horizontally somewhere. Also, if you manually specify the back-buffer size, double-check that it matches the window client area.

##### Share on other sites

So you have startPixel/width and endPixel/width OR startPixel/width and (endPixel + 1)/width ?

If you paste your two images on top of each other and align the letters it's clearly visible that the rendered characters are wider than those in the texture. Perhaps you scale horizontally somewhere. Also, if you manually specify the back-buffer size, double-check that it matches the window client area.

Yeah, I just checked font description generation program and it seems that it was (endPixel+1)/width that caused result letters look wider. Anyway, I fixed it, and result text still looks bad:

[attachment=13758:update.png]

Back-buffer's size is okay. By the way, letters on this new screen are 32 pixels tall, so pay no attention to that.

Edited by GuardianX

##### Share on other sites

Out of curiosity, why don't you use the sprite fonts that are part of XNA.

OOPS, a title near this one when I posted had said something about XNA and I confused it slightly with this one, presuming XNA, which as I recall allows the use of DX components.

I'm creating my own C++ rendering engine for the sake of learning DX11. Not sure if XNA sprite fonts can be used in such application.

Yeah, same issue as prior, and I don't think XNA fonts would be usable in DX