Can I create a tile engine in a pixel shader?

I am trying to create a tile engine using a pixel shader and two textures. One texture will contain a timer and one map.

Is it possible to read texture data as actual (non-sampled) data so that I can pull indices from the map?

What is the best way to read pixel data?

I tried only text2D, but it leaves much to be desired (I'm a little new to pixel shaders, to be honest).

Basically, I need a way to read the actual data from a specific pixel in my map texture and use this as an integer index in a tile texture. Suppose I managed to create and pass the appropriate textures to the shader.

Any thoughts?

(using monogame for metro, so dx level 9_1)

+7
source share
1 answer

If you use tex2D and go to (x + 0.5) / width and (y + 0.5) / height , you should get the exact pixel value in (x, y) . Additional information here: Basics of texture memory-tex2D

0
source

All Articles