🔒 Locked
vertexBuffer
Advertisement
Original Post
Hi there ZMax,
How are you doing?
The Problem
Setting a texture to each vertex.
The Solution
If you are talking about textures then you will have to render each individual vertex out of the buffer...
1) SetTexture(1)
2) Render(vertex1 out of the vertex buffer)
3) SetTexture(2)
4) Render(vertex2 out of the vertex buffer)
I fail to see why you would want to do something like this :P (Maybe i'm missing something)
Normally what I do is have.
Entity
- Texture
- Mesh
- Material
- Effect
I hope this helps buddy.
How are you doing?
The Problem
Setting a texture to each vertex.
The Solution
If you are talking about textures then you will have to render each individual vertex out of the buffer...
1) SetTexture(1)
2) Render(vertex1 out of the vertex buffer)
3) SetTexture(2)
4) Render(vertex2 out of the vertex buffer)
I fail to see why you would want to do something like this :P (Maybe i'm missing something)
Normally what I do is have.
Entity
- Texture
- Mesh
- Material
- Effect
I hope this helps buddy.
I red the tutorial about terain rendering you gave me and i thought i could somehow draw the terain only one time. There is said to draw let's say first the grass texture with alpha=0 where grass does not exist and 1 where it is,..and after to draw the next texture in the same way. So if I have 10 textures this process will become nasty,...to manny times rendering the same triangles.I thought it is possible with the newest dx9 to set both the texture coordonates on vertices and the texture that will be rendered on.And te rendering will be only once from the vertexbuffer.
Also how could i set the alpha value on a vertice?Should i have buffer or something created by me where i retain the alpha values or does the vertex have such an option,...a temporary value somewhere?
Also how could i set the alpha value on a vertice?Should i have buffer or something created by me where i retain the alpha values or does the vertex have such an option,...a temporary value somewhere?
Just to add to what the others said, vertex buffers only have texture coordinates (generally ranging from 0..1). They don't care about the actual texture that's assigned. So you just set the vertex texture coordinates, and then when you come to render you set the texture then render a group of vertices, and repeat as many times as needed.
Hi there Zmax,
How are you doing (again...)?
The Problem
Vertex Alpha
The Solution
A vertex can contain a number of elements,
Normal
Color
Texture coordinate
etc....
So what you can do is add a alpha value to each vertex... and use Alpha Blending to give the vertex some transparency and have something like grass show through the ground :)
You can lock you vertex buffer and add some alpha values to your vertices.
This might interest you.
Alpha blending
I hope this helps buddy.
Take care.
How are you doing (again...)?
The Problem
Vertex Alpha
The Solution
A vertex can contain a number of elements,
Normal
Color
Texture coordinate
etc....
So what you can do is add a alpha value to each vertex... and use Alpha Blending to give the vertex some transparency and have something like grass show through the ground :)
You can lock you vertex buffer and add some alpha values to your vertices.
This might interest you.
Alpha blending
I hope this helps buddy.
Take care.
I'm fine thanx(again) :)
Here appears a little problem if i use a vertex of this type PoitionNormalTextured...i can't use the alpha color to blend with the texture. if i use PositionColoredTextured I can't use ligths(not so sure) because i don't have normals for my vertices...I had to comine this types or hmm.
Here appears a little problem if i use a vertex of this type PoitionNormalTextured...i can't use the alpha color to blend with the texture. if i use PositionColoredTextured I can't use ligths(not so sure) because i don't have normals for my vertices...I had to comine this types or hmm.
It should be bossible to combine the two types. I know that a vetex can contain a normal and a diffuse colour. I'm not sure what the name for the type would be though.
Alternamtively, you can set your colour using the D3DRS_TEXTUREFACTOR renderstate, and set up your texture stage state to use D3DTA_TFACTOR instead of D3DTA_DIFFUSE.
Alternamtively, you can set your colour using the D3DRS_TEXTUREFACTOR renderstate, and set up your texture stage state to use D3DTA_TFACTOR instead of D3DTA_DIFFUSE.
Hi there ZMax,
The Problem
Blending
The Solution
If you want to blend textures you can follow a simple solution
You could just save your texture with some sort of transparency information and then just set your blending.
eg:
renderer.Device.RenderState.AlphaBlendEnable = true;
renderer.Device.RenderState.SourceBlend = Blend.SourceAlpha;
renderer.Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
This will enable you to use the transparency information in your texture so other textures behind it is visible.. Note... solid objects (100% alpha) must be rendered first and so forth.
So rendering will then be done with the following pattern
1) SetTexture(for solid object)
2) Render solid object
3) SetTexture(With transparency information)
4) Render object (the parts that are transparent will be faded out and the solid object will be visible through this object where the transparency is applied
I hope this helps buddy.
And not too confusing.
The Problem
Blending
The Solution
If you want to blend textures you can follow a simple solution
You could just save your texture with some sort of transparency information and then just set your blending.
eg:
renderer.Device.RenderState.AlphaBlendEnable = true;
renderer.Device.RenderState.SourceBlend = Blend.SourceAlpha;
renderer.Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
This will enable you to use the transparency information in your texture so other textures behind it is visible.. Note... solid objects (100% alpha) must be rendered first and so forth.
So rendering will then be done with the following pattern
1) SetTexture(for solid object)
2) Render solid object
3) SetTexture(With transparency information)
4) Render object (the parts that are transparent will be faded out and the solid object will be visible through this object where the transparency is applied
I hope this helps buddy.
And not too confusing.
The alternative choise you give me is imposible to use like i want...i want that all the vertices to have different alpha ..it is not the same everywhere...
ex: v1-> alpha 0.2
v2-> alpha 1
v3-> alpha 0
...Because i want to combine this with the textures
Sorry this is the response for Steves's post.
ex: v1-> alpha 0.2
v2-> alpha 1
v3-> alpha 0
...Because i want to combine this with the textures
Sorry this is the response for Steves's post.
Look this is exactly what i want to do:
I have 2 textures which i want to place only in some specific positions. So i thought that i could use a trick like setting the verices color with alpha needed.If i apply the second texture over the first one blending with vertices apha each time i'll get the effect i need.The problem is when i want to use ligths because they need a normal...and if i use vertexes of the type positionColoredTextured i can't set the normal....
ex:Let's assume this is a vertex point that i'm trying to render tis time
step 1: set alpha 0
texture1+vertex alpha color 0
step 2: set alpha 1
texture2+vertex alpha color 1 ------> texture2
so i 'll have a vertex only with texture 2 visible
or:
texture1+vertex alpha color 1
texture2+vertex alpha color 0 -------> texture1 ...
So I'll have the texture i want visible only depending on the alpha of the vertex. Thant's the trick...and so I don't have to use textures with alpha incorporated,...I't too hard to make a texture with alpha than getting a normal one and setting it's alpha only where needed.
[Edited by - Zmax on September 15, 2005 7:26:22 AM]
I have 2 textures which i want to place only in some specific positions. So i thought that i could use a trick like setting the verices color with alpha needed.If i apply the second texture over the first one blending with vertices apha each time i'll get the effect i need.The problem is when i want to use ligths because they need a normal...and if i use vertexes of the type positionColoredTextured i can't set the normal....
ex:Let's assume this is a vertex point that i'm trying to render tis time
step 1: set alpha 0
texture1+vertex alpha color 0
step 2: set alpha 1
texture2+vertex alpha color 1 ------> texture2
so i 'll have a vertex only with texture 2 visible
or:
texture1+vertex alpha color 1
texture2+vertex alpha color 0 -------> texture1 ...
So I'll have the texture i want visible only depending on the alpha of the vertex. Thant's the trick...and so I don't have to use textures with alpha incorporated,...I't too hard to make a texture with alpha than getting a normal one and setting it's alpha only where needed.
[Edited by - Zmax on September 15, 2005 7:26:22 AM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement