Jump to content

  • Log In with Google      Sign In   
  • Create Account


Textures


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
31 replies to this topic

#21 EWClay   Members   -  Reputation: 659

Like
1Likes
Like

Posted 22 January 2013 - 03:40 AM

Look at the bottom right of the first quad. There are four different colours around the vertex. If those four quads are sharing a vertex, how can they get different colours at the same point?

Also, the left and right edges of each quad are the same colour, when they ought to be different.

Sponsor:

#22 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 22 January 2013 - 05:44 AM

Look at the bottom right of the first quad. There are four different colours around the vertex. If those four quads are sharing a vertex, how can they get different colours at the same point?

Also, the left and right edges of each quad are the same colour, when they ought to be different.
There are mustn't be 4 different corors around 1 vertex. Oposite, there are must be one color on the 4 quads (near this vertex)

EDIT: Maybe there is other way to receive needed result? Maybe, textures are a bad idea??

Edited by Yura, 22 January 2013 - 05:44 AM.


#23 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 22 January 2013 - 06:18 AM

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),
}

 

Good idea, it works, but the same as a texture (look at picture "I receive this" at the begining of post).

Is it possible to modificate it to receive the result I want?



#24 eppo   Crossbones+   -  Reputation: 2406

Like
1Likes
Like

Posted 22 January 2013 - 07:59 AM

There are mustn't be 4 different corors around 1 vertex. Oposite, there are must be one color on the 4 quads (near this vertex)

 

Perhaps it's best if you post the code that shows how you set up the quads' vertex positions and their accompanying temperature-texcoords. Like said before, it's probably something in there that's causing these unwanted discontinuities.



#25 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 22 January 2013 - 08:23 AM

There are mustn't be 4 different corors around 1 vertex. Oposite, there are must be one color on the 4 quads (near this vertex)

 

 

Perhaps it's best if you post the code that shows how you set up the quads' vertex positions and their accompanying temperature-texcoords. Like said before, it's probably something in there that's causing these unwanted discontinuities.

 

Ofcourse, if it would help...

So, I initialize VertexBubber with data in "points":

for (int j = 0; j < list.Count; j++)
                {
                    
                    points.Add(new Vertex()
                    {
                        Coord = new Vector2(chooser.GetTexture1DCoordinate(elements[i].valueOnPoint[j]), 0),
                        Position = new Vector3(list[j].X, list[j].Y, list[j].Z),
                        
                    });
                }

 

And here is ColorChooser.GetTexture1DCoordinate method, which takes load on vertex as input information and returns tenture coordinate on each point:

 

public class ColorChooser
    {
public ColorChooser(float min, float max)
        {
            MaxValue = max;
            MinValue = min;

            float step = (Math.Abs(min) + Math.Abs(max)) / lvlCount;
            float nextStep = min;

            levels[0] = min;
            for (int i = 1; i < lvlCount - 1; i++)
            {
                nextStep += step;
                levels[i] = nextStep;
            }
            levels[lvlCount - 1] = max;
        }


public float GetTexture1DCoordinate(float val)
        {
            if ((val >= levels[0]) && (val < levels[1]))
            {
                return 0.06f;
            }
            if ((val >= levels[1]) && (val < levels[2]))
            {
                return 0.164f;
            }
            if ((val >= levels[2]) && (val < levels[3]))
            {
                return 0.244f;
            }
            if ((val >= levels[3]) && (val < levels[4]))
            {
                return 0.336f;
            }
            if ((val >= levels[4]) && (val < levels[5]))
            {
                return 0.425f;
            }
            if ((val >= levels[5]) && (val < levels[6]))
            {
                return 0.576f;
            }
            if ((val >= levels[6]) && (val < levels[7]))
            {
                return 0.66f;
            }
            if ((val >= levels[7]) && (val < levels[8]))
            {
                return 0.74f;
            }
            if ((val >= levels[8]) && (val < levels[9]))
            {
                return 0.832f;
            }
            if ((val >= levels[9]) && (val < levels[10]))
            {
                return 0.904f;
            }
            if ((val >= levels[10]) && (val < levels[11]))
            {
                return 0.986f;
            }
            if ((val >= levels[11]) && (val < levels[12]))
            {
                return 0.999f;
            }
            else
            {
                return 0.999f;
            }
        }
}


#26 eppo   Crossbones+   -  Reputation: 2406

Like
1Likes
Like

Posted 22 January 2013 - 08:35 AM

Are the positions in 'list[]' duplicated somehow?



#27 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 22 January 2013 - 09:18 AM

Yes, they are duplicated.
For example, 2 related quads have 2 common vertices, so, each of those vertices will be added in buffer 2 times, for each of quad.
Each quad has 4 vertices, even if it located inside the surface and surrounded with other quads. It is not very well, I know, becouse many points are duplicated up for 4 times. I'll try to fix it later (skip duplicating points), but right now my primary objective is to make such kind of color transition.
But is it important? Point will be added several times (for each rectangle) but with same texCoords...


#28 eppo   Crossbones+   -  Reputation: 2406

Like
1Likes
Like

Posted 22 January 2013 - 09:43 AM

But is it important? Point will be added several times (for each rectangle) but with same texCoords...
It may be. When you iterate over all the points (for (int j = 0; j < list.Count; j++)), including the duplicates, they may no longer match up with what you have stored in 'elements[i].valueOnPoint[]' when you index it with 'j'.

Edited by eppo, 22 January 2013 - 09:44 AM.


#29 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 23 January 2013 - 02:03 AM


But is it important? Point will be added several times (for each rectangle) but with same texCoords...

It may be. When you iterate over all the points (for (int j = 0; j < list.Count; j++)), including the duplicates, they may no longer match up with what you have stored in 'elements[i].valueOnPoint[]' when you index it with 'j'.

No, they matches well, becouse "list" is an "element[i]".
Sorry if I confused you.. Element class is representing quad (points and data) and Node class is representing point (coordinates).

for (int i = 0; i < elements.Length; i++)            
{                
List list = elements[i].Nodes;                
for (int j = 0; j < list.Count; j++)                
{                    
points.Add(new Vertex()                    
{                        
Coord = new Vector2(chooser.GetTexture1DCoordinate(elements[i].valueOnPoint[j]), 0),                        Position = new Vector3(list[j].X, list[j].Y, list[j].Z),                    
});                
}
}


#30 eppo   Crossbones+   -  Reputation: 2406

Like
1Likes
Like

Posted 23 January 2013 - 03:49 AM

Have you inspected the final contents of the Points[] list in a debugger?



#31 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 23 January 2013 - 06:32 AM

YES! Its it!

Edited by Yura, 23 January 2013 - 06:36 AM.


#32 Yura   Members   -  Reputation: 263

Like
1Likes
Like

Posted 23 January 2013 - 06:35 AM

You were damn right!! The problem was in TexCoords! 

Thank you EPPO,

Thank you all for helping!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS