Sign in to follow this  
programmer_tom

Shader Stride Question

Recommended Posts

We are thinking about trying to let the vertex shader figure the UV coords on a terrain based upon it's model vertex data (height). Wondering if anyone knows if there's a way to have the leave out the UV coords in the FVF to save memory, leave them in the shader declaration, and not have stride errors.

Share this post


Link to post
Share on other sites
Hi,
I you want to generate the UV inside the vertex shader, you can do so. Your APP_TO_VS declaration doesnt have to declare UV info.

But, inside the VS you can generate the UV info, but you have to send it appropiately to the PS. So your complete shader may look as (just pseudocode):

struct APP_2_VS
{ position
normal
}

struct VS_2_PS
{ position
normal
UV
}

VS_2_PS VS(APP_2_VS in)
{ VS_2_PS out = 0;
use the in data and generate the out uv info
out.uv = your_formula();
}

float4 PS(VS_2_PS in)
{ read texture with your uv info as usual and do as you wish
}

Luck!
Guimo




Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this