Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to draw a model partially (along the X, Y or Z axis) to make an extending barrier or something like that? (Scaling doesn't work because of the textures)

share|improve this question
up vote 2 down vote accepted

It is possible. There was a nice feature in XNA pre-4.0 called ClipPlanes. There are several good tutorials on how to use them, I'd recommend this one:

Riemers XNA Tutorial - Clip planes

Now the problem is, ClipPlanes have been removed from XNA 4.0. Developers are supposed to implement it using shaders. I've found the following piece of code to do exactly this:

float4x4 World; 
float4x4 View; 
float4x4 Projection; 

float4 ClipPlane0; 

void vs(inout float4 position : POSITION0, out float4 clipDistances : TEXCOORD0) 
    clipDistances.x = dot(position, ClipPlane0); 
    clipDistances.y = 0; 
    clipDistances.z = 0; 
    clipDistances.w = 0; 

    position = mul(mul(mul(position, World), View), Projection); 

float4 ps(float4 clipDistances : TEXCOORD0) : COLOR0 

    return float4(0, 0, 0, 0); // TODO: whatever other shading logic you want 

        VertexShader = compile vs_2_0 vs(); 
        PixelShader = compile ps_2_0 ps(); 

I didn't test it myself, but I hope it helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.