Sign in to follow this  

Matrix as texture: Help Needed!

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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.

Admiral

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this