# Matrix as texture: Help Needed!

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

## Recommended Posts

Hello, I want to know if a matrix can be represented as a texture. I have a matrix which is 56x8 and I send it to my fragment shader as a sampler2D. To retrieve the contents of the matrix I use the function tex2D. Here is the code: void main (uniform sampler2D texture, in float4 color : COLOR0, in float2 texcoord : TEXCOORD0, out float4 point : COLOR0, out float4 normal : COLOR1) { float4 point1, point2; if (texcoord.x < 0.5) { point1 = tex2D (texture, texcoord); /* ------- calculations --------*/ point = result; normal = result; } else { point2 = tex2D (texture, texcoord); /* ------- calculations --------*/ point = result; normal = result; } } So now I assume that the xyzw values of the point1 (that is, the RGBA values the tex2D has returned) represents the first 4 values of the matrix and point2 represents the next 4 values. Am I right? Can somebody please help?

##### Share on other sites
It really depends on how you casted the matrix into bitmap data. By the time the shader executes, the data-layout has already been established. The code you should be looking at is that which creates the texture being bound to sampler 0 before rendering the geometry.

I imagine that you are creating a texture object, locking its buffer and copying the matrix data across. If not, this is what you should be doing. The exact manner in which the matrix data finds its way onto the frame-buffer is determined completely by the matrix's original layout, the texture's format when created and the copying algorithm used to fill the texture buffer.

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 103
• 11
• ### Forum Statistics

• Total Topics
632976
• Total Posts
3009672
• ### Who's Online (See full list)

There are no registered users currently online

×