Jump to content
  • Advertisement
Sign in to follow this  
[deleted 87362]

Vertex Program Problem

This topic is 4831 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, Currentlly im trying to implement bump maping with lighting into my engine. Ive got bump mapping to work, and implementing the actuall code for the lighting isn't my problem. My problem is whenever I set the vertex program to be active, my world doesn't render. Im using DirectX 9, with assembler coding(im using FXC to compile the shader to the assembler shader langugage). Any Ideas?

Share this post

Link to post
Share on other sites
Hey there eviltwigflipper,
How are you doing buddy?

The Problem
Your scene does not render after you set the shaders

The Solution
There might be a few problems here.
I am going to try and list as many as I can think of..

1) Makes sure you are rendering your entities after you set your Shaders.
2) Have you computed the color of your pixels in the pixel shader?
3) Have you extract the color information from the texture?
4) Have you set the pixel shader aswell as the vertex shader?
such as:
5) Have you set your constants to use with your shader?
such as:

I hope this helps a bit buddy.
Take care.

Share this post

Link to post
Share on other sites
yeah it works when I have just have the pixel shader set. Then when I activate the vertex shader(they are both running at this point) then it stops drawing the world.

Yes in the pixel shader I compute the texture output correctlly. Ill post here for reference.

Vertex Delcarations:
[source lang=cpp]
sys_data.g_pd3dDevice->CreateVertexDeclaration(decl, &sys_data.m_VSDecl);

Heres the vertex shader im using.
[source lang=cpp]
float4x4 view_proj_matrix;
float3 view_position;

struct VS_OUTPUT
float4 Pos : POSITION;
float3 Normal : TEXCOORD0;
float3 view : TEXCOORD1;

VS_OUTPUT main( float4 inPos : POSITION, float3 inNorm : NORMAL)

Out.Pos = mul(view_proj_matrix, inPos);

Out.Normal = inNorm;

Out.view = normalize(view_position - inPos);

return Out;

Heres the compiled version:
[source lang=cpp]
dcl_position v0
dcl_normal v1
mul r0, v0.y, c1
mad r0, c0, v0.x, r0
add r1.xyz, -v0, c4
mad r0, c2, v0.z, r0
dp3 r2.x, r1, r1
mad oPos, c3, v0.w, r0
rsq r0.w, r2.x
mul oT1.xyz, r1, r0.w
mov oT0.xyz, v1

My Pixel Shader:
[source lang=cpp]

sampler NormalImage;
sampler DiffuseImage;

float4 main(float3 Normal: TEXCOORD1,
float2 Diffuse: TEXCOORD2) : COLOR
float4 NormalTex = tex2D(NormalImage, Normal);
float4 diffuseTex = tex2D(DiffuseImage, Diffuse);

float3 bias = clamp(NormalTex.rgb, -1, 1);

float3 bumpMap = dot(diffuseTex, bias);

return diffuseTex * float4(bumpMap,0.0);

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!