Texture coordinate displacement shader?

Hey, so I’ve been having some success understanding and writing fixed-function shaders and am considering doing something in Cg (which I have yet to learn, although I have the GLSL orange book so I get the basic principles).

I’d like to write a simple fake/fixed bumpmapping/texture-coordinate-displacement effect.

I guess it’d be kinda like normal mapping but with precalculated lookup coordinate offsets stored in the texture. The texture should hold 16-bit X,Y offsets ie Red-Green is X, Blue-Alpha is Y - maybe using a fixed-point number format for a typical screen resolution, maybe 12-bit integer, 4-bit decimal to support offsets up to 4096?

I’d like to read values from this texture according to standard texture mapping (using the uv channel from the mesh), get the X,Y data from the texture, and then add the X,Y coordinates to the texture coordinate. This resulting tex coord would then give the lookup into a second texture - an actual RGBA image texture - and the texel pulled from that coordinate would then be rendered on-screen.

So the final effect would be a simple displacement of texture coordinates on a per-pixel basis.

My question is, besides writing this shader, is - is it possible in Unity free version to read from textures inside a Cg program? I don’t need to write to them, just reading. Is that supported or can you only read textures on UnityPro?

Anyone?

I’m a shader noob, but I can’t think of anything that would stop you from doing it. As long as you aren’t trying to read from a texture in the vertex function (which I’m pretty sure isn’t supported in either Indy or Pro), then I can’t think of anything else that would stop you. Although you might have to convert the X,Y data you extract into UV coords to fetch the color from the second texture, not really sure.

Yah it’d be reading the texture in the fragment shader. The vertex shader wouldn’t be doing much.

I presume it has to be possible otherwise it would be impossible to ever write a fragment shader that textures an object. That seems pretty obvious now that I think about it.