Skip to main content
GameDev.net gamedev.net
🔒 Locked

rendering different FVF simultaneously

Started by AlexanderCZ Oct 25, 2002 at 2:29 AM 16 replies 950+ views
Original Post
AlexanderCZ
AlexanderCZ
I tried render two graphic object with different FVF type.
    

typedef struct _FVF1{
float x,y,z;
DWORD col;
} FVF1;

typedef struct _FVF2{
float       x, y, z;     
float       nx, ny, nz;     
DWORD       col;         
float       tu, tv;
} FVF2;
//i am using template classes for graphic objects:

GrObj<FVF1> g_axes;
GrObj<FVF2> g_mesh;
.
.
//creating...

g_axes.Create("axes.vsh");
g_mesh.Create("mesh.vsh","tiger.x","tiger.bmp");
.
.
//rendering...

g_axes.Render(D3DPT_LINELIST);
g_mesh.Render();
    
When i enable rendering of axes first,then the axes are displayed right(lines are continuous and full). When I enable rendeering of mesh,the lines are interupted,strange fade-out.Mesh is displayed properly... Know anybody where is problem,please? [edited by - AlexanderCZ on October 25, 2002 3:31:11 AM]
Draigan
Draigan
Yeah, you have to tell Direct3D that you are changing FVF''s either in your DrawPrimitiveUP or with a call to SetVertexShader()

Read the docs.
AlexanderCZ
AlexanderCZ
But how can I tell to Direct3D that i am changing FVF type?There is no method of IDirect3DDevice8 called SetFVFtype...
After some experiments I know,that when i enable dithering then the interrupting disappear,but line weaking is still present.(but it look much better).So one important thing i have to say-problem occured only when texture is loaded.
Thank for reply and sorry for my bad english...
AlexanderCZ
AlexanderCZ
Shall I use SetVertexShader twice???

  
template<typename FVFTYPE>
bool Grobj<FVFTYPE>::Render()
{
.
.
.
m_dev->SetVertexShader(m_shader);
//and you say:

m_dev->SetVertexShader(FVFTYPE);
.
.
.
}

Or vice-versa(first i set the FVFTYPE and then m_shader)???
I think you don''t understand where my problem is...but I am going to create web about this problem
gerogerber
gerogerber
No, calling m_dev->SetVertexShader(...) with FVF when using vertex shaders is wrong!

Did you pass a correct vertex shader declaration for each FVF to m_dev->CreateVertexShader(...)?

Gero

[edited by - gerogerber on October 27, 2002 10:27:54 AM]
Draigan
Draigan
Who says he was using vertex shaders? Since he doesn''t know how to do this, I doubt he''s using vertex shaders.

So unless your using the DrawPrimitiveUP methods, then changing the FVF with the SetVertexShader is the way to go.
gerogerber
gerogerber
Mmh...

m_dev->SetVertexShader(m_shader);

m_shader ''looks'' like a handle to a vertex shader. Maybe I''m wrong....

Gero
masonium
masonium

  
// set the first FVF

device->SetVertexShader(FVF1);

// render the first object

RenderFirstObject();

// set the second FVF

device->SetVertexShader(FVF2);

// render the second object

RenderSecondObject();


if you''re trying to put this in a class, then it should be something like:

  
Object::Render()
{
...
device->SetVertexShader(m_FVF);

...
device->DrawPrimitive(...);

...
}


basically, you call SetVertexShader, passing the new FVF or vertex shader, whenever you''re going to render a vertex buffer with a different FVF than the previous one.
AlexanderCZ
AlexanderCZ
quote:

Did you pass a correct vertex shader declaration for each FVF to m_dev->CreateVertexShader(...)?


Yes,I am sure that the shader declaration is right.
m_shader is the (valid)handle to the vertex shader.I have no problem with creating and rendering of objects which use own shaders.

quote:

Who says he was using vertex shaders? Since he doesn''t know how to do this, I doubt he''s using vertex shaders.


I realy know how to use vertex shader...

I will try be more concrete:
GrObj use m_FVF to store information about used FVFTYPE
and m_shader to store handle of vertex shader.

Here is modified original story:

  
typedef struct _FVF1
{
float x,y,z;
DWORD col;
} FVF1;

typedef struct _FVF2
{
float x,y,z;
float nx, ny, nz;
DWORD col;
float tu, tv;} FVF2;

FVF1 g_points[]={six points for creating three lines(axes)}

//i am using template classes for graphic objects:

GrObj<FVF1> g_axes;
GrObj<FVF2> g_mesh;
.
.
//setting information about FVFTYPE:

g_axes.m_FVF=D3DFVF_XYZ | D3DFVF_DIFFUSE;
g_mesh.m_FVF=D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1;
.
.
//creating ...

g_axes.Create("axes.vsh",g_points);
g_mesh.Create("mesh.vsh","tiger.x","tiger.bmp");

//after creating g_axes.m_shader is valid handle to vertex

//shader which will be used when renderig g_axes.

//g_mesh.m_shader is valid handle to vertex

//shader which will be used when renderig g_mesh.

//

.
.

//rendering...


g_axes.Render(D3DPT_LINELIST);
//three lines(axes) are rendered using shader code from

//axes.vsh(when g_axes is visible)


g_mesh.Render();
//mesh(tiger) is rendered using shader code from mesh.vsh

//(when g_mesh is visible)




And problem is folowing:
When g_axes object is renderd alone(g_axes.m_bvisible=true),then the axes lines are displayed correctly.

When g_msh object is renderd together with g_axes(g_axes.m_bvisible=true and g_mesh.m_bvisible=true),then the axes lines are displayed incorrectly.Those three lines are interrupted and inferior.Mesh of tiger is displayed correctly.

When i enable dithering then those three lines(axes) are not interrupted,they are only inferior.


So I hope you understand now what am i talking about.
Sorry for my bad english and thanks for replies.
Wreakon
Wreakon
"strange fade-out."

Can you post a screenshot? (strange is a bad word to describe a problem) As far as I see thats how it should be, if you render the tiget _after the axes_ then the tiger will be _over_ the axis if the depth isn''t on, if depth buffer/Z-buffer is turned on then whichever is closer to the camera will come out on top.

-------
Homepage: http://students.washington.edu/andrey
-------Homepage: http://www.pclx.com
AlexanderCZ
AlexanderCZ
look at:

http://www.problem.mysteria.cz/
and now,could you tell me why the red line from the second image doesn't look like the red line from the first image?
thanks

[edited by - AlexanderCZ on October 29, 2002 4:17:49 AM]

[edited by - AlexanderCZ on October 29, 2002 4:19:51 AM]
AlexanderCZ
AlexanderCZ
I would like to know why the COLOR of axis in the second image is different.
I wrote ''the lines are interupted'' and it was mistake,i though on the color of each line which is sometimes darkness and sometimes lightness(it looks like interrupting-litle bit...). Axes are interrupted because of mesh, i know it.

Be patient with me,my english skills are bad...
BrianH
BrianH
My guess is that you are leaving the texture for the tiger set as an active texture stage... looks like it is being applied to the line. Be sure to disable the texture stage operation or set the texture to NULL before rendering the lines.

AlexanderCZ
AlexanderCZ
quote:

looks like it is being applied to the line


Yes it look,you are right,but in this case lines are rendered first,with no texture setting.The lines quality depend on position of mesh too,when i move with it away(when the mesh is outside of viewing frustrum)then lines looks right,like in first image.

thank for reply
BrianH
BrianH
It really looks like the texture is being applied to the line, perhaps try just turning the texture off for the tiger and see what happens. When you load the tiger.x file, just dont put a texture in it. Maybe when the tiger moves out of the viewing frustum the texture is not being set (not being rendered). And even if the tiger is being rendered after the lines, its a loop so the tiger texture could still be set for the line when the loop restarts.

Oh.. just to clarify some of the stuff in these posts.. even if you are not using a programmable vertex shader (which you are not) you call SetVertexShader() with your FVF flags... which tells Direct3D to use the fixed-function shader. Now, be sure you are not calling SetVertexShader() with "FVF1" or "FVF2" because you defined those as structs... you should call SetVertexShader with something like this...

FVF1_FLAGS = (D3DFVF_XYZ | D3DFVF_DIFFUSE);
SetVertexShader(FVF1_FLAGS);


-BH
AlexanderCZ
AlexanderCZ
quote:

its a loop ...


I am really an idiot!
Of course that every object must be independent on any others...

Thank you Brian,you opened my closed mind

P.S.
But why everybody think that i am not using programmable vertex shader?What do you think about "blabla.VSH" parameter in Create method???


BrianH
BrianH
Doh! I guess you are using programmable vertex shaders, hehe... I guess when my eyes scanned the code the .vsh didnt pop out. Well, I am glad you were able to fix the problem.

-BH

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.