Jump to content
  • Advertisement
Sign in to follow this  
pmangalvedkar

Matrix as texture: Help Needed!

This topic is 4079 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!