Jump to content
  • Advertisement
Sign in to follow this  

set a VertexShader and nothing is seen

This topic is 2862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey,

Im dealing with vertexshaders with DX 8.1 and Im seem to be beginner. First the vertex itself:

Microsoft (R) D3D10 Shader Compiler 9.19.949.0046
Copyright (C) Microsoft Corporation 2002-2006. All rights reserved.

//
// Generated by Microsoft (R) D3DX9 Shader Compiler
//
// fxc /Gpp /Tvs_1_1 prj2
//
//
// Parameters:
//
// float4x4 WorldViewProj;
//
//
// Registers:
//
// Name Reg Size
// ------------- ----- ----
// WorldViewProj c0 4
//

vs_1_1
def c4, 1, 0, 0, 0
dcl_position v0
mad r0, v0.xyzx, c4.xxxy, c4.yyyx
dp4 oPos.x, r0, c0
dp4 oPos.y, r0, c1
dp4 oPos.z, r0, c2
dp4 oPos.w, r0, c3




generated from this:

// Global variables
uniform extern float4x4 WorldViewProj;

struct VS_OUTPUT
{
float4 Position : POSITION0;
};

VS_OUTPUT main (float3 pos : POSITION0)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.Position = mul(float4(pos, 1.0f), WorldViewProj);
return Out;
}



So I wouldn't change anything, just return the vertex shader as it is. The vertex format: D3DFVF_BUMPVERTEX2 = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2; in structure:
D3DXVector3 p;
D3DCOLOR color;
float u1,v1,u2,v2;

so they are fit. The D3DXAssembleShader assembles the code with no error. After I set the declarations with "D3DXDeclaratorFromFVF (D3DFVF_BUMPVERTEX2, dwDecl);" function. I know, many places I seen manual filling this declaration - but I can't see no reason why not to automatize this.
Then I pass the world matrix every time: SetVertexShaderConstant (0, wm, 4);
and when I want to draw a texture which should be applied for this vertex shader to, I use SetVertexShader, then DrawPrimitive and SetVertexShader (0).

But then no texture gets drawn. As if I hadn't draw anything. Can a practiced vertex programmer explain this?

Of course, without activation that shader, this texture is shown well.

Share this post


Link to post
Share on other sites
Advertisement
I don't know about a beginner! I've been doing this for a bit now (not that long) and I couldn't follow what you wrote. I do have a working shader which produces a nice effect if you want to try it but to be honest I think you're already beyond my level!

Good luck with this I hope it works out for you.

Share this post


Link to post
Share on other sites
I'm not familiar with DX10. However, I'm sure the problem is that you're not passing in or out texture coordinates to the shader. Are there examples of texture shaders in the SDK you can learn from?

Share this post


Link to post
Share on other sites
[smile] I'm not familiar with using shaders in Dx8, either. However, the same comments apply. You need something like:

uniform extern float4x4 WorldViewProj;

struct VS_OUTPUT
{
float4 Position : POSITION0;
float2 TexCoord : TEXCOORD;
};

VS_OUTPUT main (float3 pos : POSITION0, float2 texCoord : TEXCOORD0 )
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.Position = mul(float4(pos, 1.0f), WorldViewProj);
Out.TexCoord = texCoord;
return Out;
}





You need to set the texture in the pipeline before rendering. If you're going to use multiple tex coords, you'll have to input and output multiple tex coords in the shader, and you'll have to set the pipeline stages properly, of course.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!