• 12
• 12
• 9
• 10
• 13
• ### Similar Content

• By isu diss
I'm following rastertek tutorial 14 (http://rastertek.com/tertut14.html). The problem is, slope based texturing doesn't work in my application. There are plenty of slopes in my terrain. None of them get slope color.
float4 PSMAIN(DS_OUTPUT Input) : SV_Target { float4 grassColor; float4 slopeColor; float4 rockColor; float slope; float blendAmount; float4 textureColor; grassColor = txTerGrassy.Sample(SSTerrain, Input.TextureCoords); slopeColor = txTerMossRocky.Sample(SSTerrain, Input.TextureCoords); rockColor = txTerRocky.Sample(SSTerrain, Input.TextureCoords); // Calculate the slope of this point. slope = (1.0f - Input.LSNormal.y); if(slope < 0.2) { blendAmount = slope / 0.2f; textureColor = lerp(grassColor, slopeColor, blendAmount); } if((slope < 0.7) && (slope >= 0.2f)) { blendAmount = (slope - 0.2f) * (1.0f / (0.7f - 0.2f)); textureColor = lerp(slopeColor, rockColor, blendAmount); } if(slope >= 0.7) { textureColor = rockColor; } return float4(textureColor.rgb, 1); } Can anyone help me? Thanks.

• By dgi
Hey all ,
For a few days I'm trying to solve some problems with my engine's memory management.Basically what is have is a custom heap with pre allocated memory.Every block has a header and so on.I decided to leave it like that(not cache friendly) because my model is that every block will be large and I will have a pool allocators and stack allocators dealing with those blocks internally. So far so good I figure out how to place my per scene resources . There is one thing that I really don't know how to do and thats dealing with containers.What kind of allocation strategy to use here.
If I use vector for my scene objects(entities , cameras , particle emitters .. ) I will fragment my custom heap if I do it in a standard way , adding and removing objects will cause a lot of reallocations . If I use a linked list this will not fragment the memory but it's not cache friendly.I guess if a reserve large amount of memory for those vectors it will work but then I will waste a lot memory.I was thinking for some sort of mix between a vector and a linked list , where you have block of memory that can contain lets say 40 items and if you go over that number a new one will be created and re location of the data would not be needed.There would be some cache misses but it will reduce the fragmentation.

How you guys deal with that ? Do you just reserve a lot data ?

dgi
• By EddieK
Hello everyone, I want present my new game which I've been working on for a quite while now.
It's a 2D zombie shooter with lots of cool weapons to choose from. Kill zombies, level up, buy new weapons and go through different levels.

Any feedback is appreciated

• Hi everyone!

Let me represent my first game.

It's mix of arcade and logic (just a little).

Play Market:
Gameplay:

Spiteful UFOs seized the hedgehog commune. Four hedgehog fighting commandos will not give them any chance to destroy it.
Be the fifth member of the team.
Destroy alien’s bases!
Use the commandos’ features to seize and destroy aliens’ bases.
You won’t be able to clean the commune from hateful aliens without rationality, speed and agility.
- 40 fascinating levels in different parts of the world;
- 8 different locations.
I'll wait for yours feedback. It's very important for upcomming updates!
Thanks!!!

• By Hermetix
I am trying to setup the custom wizard for making a 3ds MAX 2018 plug-in (to export a character animation data), but I can't locate the wizard file folder to put the .vsz file in. In the 3ds MAX 2018 docs, it only mentions where the folder is in VS 2015 (VC/vcprojects). It's a VC++ project, but I don't see any folder in VC for the wizard files. I'm using VS 2017 update 15.5.6 Enterprise, and the folders in VC are: Auxiliary, Redist and Tools.

Thanks.

## Recommended Posts

How do i open an image to use it as Texture2D information without D3DX11CreateShaderResourceViewFromFile? And how it works for different formats like (JPG, PNG, BMP, DDS,  etc.)?

I have an (512 x 512) image with font letters, also i have the position and texcoord of every letter. The main idea is that i want to obtain the image pixel info, use the position and texcoords to create a new texture with one letter and render it. Or am I wrong in something?

##### Share on other sites

First you would load your image into an array of bytes, representing the pixels of the image, essentially a bitmap. Then you can manipulate this array any way you like, including extracting portions of it to form a new texture. A pixel at location {x, y} would be addressed as

data[y*imageWidth + x]

To load a bitmap you could write you own parser by looking at the specs of a specific file format (BMP is fairly straightforward to load, others more challenging), or you could save yourself some time and use a library that does it for you. I prefer stb_image, it's lightweight and easy to use.

After that it's simply a matter of using DirectX API to initialize a Texture2D with your data. IIRC, you can pass a pointer to your bitmap as pSysMem member of D3D11_SUBRESOURCE_DATA, when calling ID3D11Device::CreateTexture2D.

Another option would be to actually preprocess you font into a set of textures, one per character. Again, stb_truetype by the very same Sean Barrett could do that for you.

Yet another option is to actually use a single font texture and use appropriate UV coordinates to draw a protion of your texture, containing the desired character. Personally, I would go with this option (I have tried both recently, and having a single texture just meant that much less bookkeeping, although it may well be different with your project), and since you already know the texcoords of each character in you texture, it shouldn't be too hard to implement.

Edited by dietrich
Accidentally submitted by Ctrl+Enter