Textures

Started by
30 comments, last by Yura 11 years, 2 months ago

That's not how we mean for using a second texture. what you did was just rotate the texture.

no, what we are saying is this:

from my understanding, you want to create some unique result from a set of data inputs.

so, you have to have some function for figuring out what color should be at what pixel.

so, if you know the size of the texture when it's rendered, do something like this:

//psedo- c code: char *Texels = new char[TexWidth*TexHeight];. for(int x=0;x<TexWidth;x++){
for(int y=0;y<TexHeight;y++){
int ColorLookup = YourFormulaForLookingUpTheColorAtASepeceficPoint(x, y); Texel[x+y*TexWidth] = Pallete[ColorLookup]; //Pallete is assumed to be your 1D array texture } } //Upload this newly created texture, and draw a single quad with only that texture, and use just a pass-through shader(essentially a shader that emulates a fixed-function pipeline texturing)

essentially what your doing is creating the texture of your sample image on the cpu side, then just drawing that texture.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Advertisement
That's not how we mean for using a second texture. what you did was just rotate the texture.

no, what we are saying is this:

from my understanding, you want to create some unique result from a set of data inputs.

so, you have to have some function for figuring out what color should be at what pixel.

so, if you know the size of the texture when it's rendered, do something like this:


  //psedo- c code:
  char *Texels = new char[TexWidth*TexHeight];.
  for(int x=0;x<TexWidth;x++){
   for(int y=0;y<TexHeight;y++){
     int ColorLookup = YourFormulaForLookingUpTheColorAtASepeceficPoint(x, y);
    Texel[x+y*TexWidth] = Pallete[ColorLookup]; //Pallete is assumed to be your 1D array texture
   }
 }
 //Upload this newly created texture, and draw a single quad with only that texture, and use just a pass-through shader(essentially a shader that emulates a fixed-function pipeline texturing)

essentially what your doing is creating the texture of your sample image on the cpu side, then just drawing that texture.

More information about my task:

X Y Z value

-0.095 0.095 0.695 864
-0.095 0.0475 0.695 963
-0.095 0 0.695 963
-0.095 -0.0475 0.695 321
.... and so on,
can have unlimited count of such points.
I must draw surface from these points and make color transition respectively to value on each point (as in picture at the beginning of this topic above).
The surface may be changed, so I'm searching for a universal method to resolve this problem.
I wrote a little, which calculates texCoords respectively to the value on point. It returns me value [0,1] for each point which I'm using as texCoord.
Now I'm trying to implement your suggestion... Hope it will do the trick, but I need some time to do it...

i think i understand what your doing, the key point here is what is the function you use to map your data points to your pallete?

for example, if i said, give me the pallete to use at x = 0, y = 0(using your data set from your sample, and in your sample is red), then what is your code for figuring out to choose red?

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
i think i understand what your doing, the key point here is what is the function you use to map your data points to your pallete?

for example, if i said, give me the pallete to use at x = 0, y = 0(using your data set from your sample, and in your sample is red), then what is your code for figuring out to choose red?
I'm just finding min and max value (on points) and splitting the range on 12 levels (12 colors in palette)
float step = (Math.Abs(min) + Math.Abs(max)) / 12;
and then I just calculate in what period input value belongs to:
if ((val >= levels[0]) && (val < levels[1]))            {                return 0.082f;            }            if ((val >= levels[1]) && (val < levels[2]))            {                return 0.164f;            }
And return float value, which apply to the texture above. For example 0-0.083 in my texture is blue and 9.8-9.999 is red. I'm using this returned values as coordinated of my texture.

EDIT: Tryed to implement your function. Created new texture, BUT: have no idea how to calculate "YourFormulaForLookingUpTheColorAtASepeceficPoint(x, y);". I have 4 points on element, for example I'm creating 24x24 texture. How can I choose color for 576 inner texels, when I know only 4 of them?

[quote name='Yura' timestamp='1358322904' post='5022085']
EDIT: Tryed to implement your function. Created new texture, BUT: have no idea how to calculate "YourFormulaForLookingUpTheColorAtASepeceficPoint(x, y);". I have 4 points on element, for example I'm creating 24x24 texture. How can I choose color for 576 inner texels, when I know only 4 of them?
[/quote]

You interpolate between them, using some function you define. There is no "right answer". You need to figure out how you want to interpolate between them. It could be a weighted average of all the points, with a weight inversely proportional to the distance to the current point, for instance.

i think i understand what your doing, the key point here is what is the function you use to map your data points to your pallete?

for example, if i said, give me the pallete to use at x = 0, y = 0(using your data set from your sample, and in your sample is red), then what is your code for figuring out to choose red?
I'm just finding min and max value (on points) and splitting the range on 12 levels (12 colors in palette)

float step = (Math.Abs(min) + Math.Abs(max)) / 12;
and then I just calculate in what period input value belongs to:

if ((val >= levels[0]) && (val < levels[1]))            {                return 0.082f;            }            if ((val >= levels[1]) && (val < levels[2]))            {                return 0.164f;            }
And return float value, which apply to the texture above. For example 0-0.083 in my texture is blue and 9.8-9.999 is red. I'm using this returned values as coordinated of my texture.

EDIT: Tryed to implement your function. Created new texture, BUT: have no idea how to calculate "YourFormulaForLookingUpTheColorAtASepeceficPoint(x, y);". I have 4 points on element, for example I'm creating 24x24 texture. How can I choose color for 576 inner texels, when I know only 4 of them?

sorry for the late reply, but i have to ask, how did you create that sample image?, how did you choose what pixel was what color?, when you can answer that question, you can do this. otherwise i'm not really certain what your expected to be able to do from the beginning of this thread.

obviously you have some points of data that mean something to you, but you seem to be avoiding how those points are to be used to actually create the representation you want.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
i think i understand what your doing, the key point here is what is the function you use to map your data points to your pallete?

for example, if i said, give me the pallete to use at x = 0, y = 0(using your data set from your sample, and in your sample is red), then what is your code for figuring out to choose red?
I'm just finding min and max value (on points) and splitting the range on 12 levels (12 colors in palette)

float step = (Math.Abs(min) + Math.Abs(max)) / 12;
and then I just calculate in what period input value belongs to:

if ((val >= levels[0]) && (val < levels[1]))            {                return 0.082f;            }            if ((val >= levels[1]) && (val < levels[2]))            {                return 0.164f;            }
And return float value, which apply to the texture above. For example 0-0.083 in my texture is blue and 9.8-9.999 is red. I'm using this returned values as coordinated of my texture.

EDIT: Tryed to implement your function. Created new texture, BUT: have no idea how to calculate "YourFormulaForLookingUpTheColorAtASepeceficPoint(x, y);". I have 4 points on element, for example I'm creating 24x24 texture. How can I choose color for 576 inner texels, when I know only 4 of them?

sorry for the late reply, but i have to ask, how did you create that sample image?, how did you choose what pixel was what color?, when you can answer that question, you can do this. otherwise i'm not really certain what your expected to be able to do from the beginning of this thread.

obviously you have some points of data that mean something to you, but you seem to be avoiding how those points are to be used to actually create the representation you want.

The sample image wasn't created by me. It is a sample of work of readymade program. I don't know how does it works, I just made this sample for you to explain what I want to achieve. Those points of data are pressure: X, Y, Z coordinates and PRESSURE. The surface is subjected to pressure. Where the pressure is greater surface tends to red, lower - to blue.

As a couple of people have said already, it looks like the problem is with the vertices.

If you were sharing vertices between quads, the colours would match across the boundary.

Doesn't matter what shader or textures you use if the vertex data is wrong, so try to fix that first.
As a couple of people have said already, it looks like the problem is with the vertices.

If you were sharing vertices between quads, the colours would match across the boundary.

Doesn't matter what shader or textures you use if the vertex data is wrong, so try to fix that first.

Yes, I'm sharing vertices between quads, but what the problem? For example:

0.9 ______ 0.5 -- texCoords on each point

| |

| |

0.2 |_____| 0.3____ 0.1

| | |

| | |

0.4 |_____| 0.9____| 0.3

How about you recreate the entire texture as a lookup table in the pixel shader and then sample it like this: out.color = colors[round(texCoords.x * 11)]?

const float3 colors[] = {

   float3(0.f, 0.f, .5f),
   float3(0.f, .23f, .73f),
   float3(0.f, .45f, .95f),
   float3(0.f, .68f, 1.f),

   float3(0.f, .9f, 1.f),
   float3(0.f, 1.f, .73f),
   float3(0.f, 1.f, .27f),
   float3(.23f, 1.f, 0.f),

   float3(.63f, 1.f, 0.f),
   float3(1.f, .91f, 0.f),
   float3(1.f, .45f, 0.f),
   float3(.93f, .11f, .14f),
}

This topic is closed to new replies.

Advertisement