Can I create a tile engine in a pixel shader?
Asked Answered
U

1

7

I am attempting to create a tile engine using a pixel shader and two textures. One texture will hold the tileset and one the map.

Is it possible to read the texture data as actual (unsampled) data so I can pull indexes from the map?

What is the best way to read that pixel data?

I have tried just text2D but that leaves something to be desired (I am a bit 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 that as an integer index into the tile texture. Assume I have managed to create and pass the appropriate textures to the shader.

Any thoughts?

(using monogame for metro so dx level 9_1)

Ussery answered 29/10, 2012 at 23:55 Comment(0)
O
0

If you use tex2D and pass in (x + 0.5) / width and (y + 0.5) / height, you should get the exact pixel value at (x, y). More information here: Texture memory-tex2D basics

Orson answered 14/5, 2013 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.