Textures

Started by
30 comments, last by Yura 11 years, 3 months ago
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.
Advertisement
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??

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?

[quote name='Yura' timestamp='1358855043' post='5024261']
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)
[/quote]

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.

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;
            }
        }
}

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

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...
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.valueOnPoint[]' when you index it with 'j'.


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.valueOnPoint[]' when you index it with 'j'.

No, they matches well, becouse "list" is an "element".
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),                    
});                
}
}

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

This topic is closed to new replies.

Advertisement