When using this effect file:

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);

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

all models using this are rendered black. Is it possible to render them correctly?

  • \$\begingroup\$ that TODO is a huge hint that you need to learn more about HLSL \$\endgroup\$ – indeed005 Apr 6 '13 at 15:11

Your models are being rendered black because of the line return float4(0, 0, 0, 0) in the pixel shader; the return value for this method is the colour (in RBGA) that is being displayed (in your case, black). You are returning the same value irrespective of the model, which is causing your problem.

You need to write some code for your pixel shader to calculate the right colour values for your models. I suggest taking a look at a few tutorials such as this one so that you get the hang of how to write shader code.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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