Sasuke
Glad you got it working. I haven't seen your video yet, but from your description and code snippet it sounds like you wanted a reflective effect. Your references to "opacity" made me think you wanted the object to appear semi-transparent - hence my earlier comments. Did you mean "reflectiveness of the object" rather than "opacity of the cubemap"?
coolgames
Quote: "I'm trying to make a shadow system that renders a real time shadow by capturing an image of the object using a seperate camera"
Guess what I've been working on for the last few days.
Have you looked at the example that comes with the MS DX9 SDK?
Your code seems to set the object's alpha to zero for ALL pixels here:
float4 ps_shadow_11(float2 inTex : TEXCOORD0) : COLOR {
float4 col = tex2D(shadowtexSampler , inTex);
col.a=0;
return col;
}
This means the alphablending settings here:
technique ShadowPS11 {
pass p0 {
VertexShader = compile vs_1_1 vs_shadow_11();
PixelShader = compile ps_1_1 ps_shadow_11();
ZENABLE = TRUE;
ALPHABLENDENABLE = TRUE;
SRCBLEND = SRCALPHA;
DESTBLEND = INVSRCALPHA;
}
}
just give you whatever's already been rendered whatever that happens to be. If you set "col.a" to 1, for example, you will just be rendering the shadowmap.
What information is contained in your shadowTexture? Is it just black/white for shadow/noshadow or is the shadowing contained in the alpha component? I can only guess.
If it's just a black/white shadow map then you probably want to set "col.a" equal to something like the sum of the rgb components of shadowTexture like this:
float4 ps_shadow_11(float2 inTex : TEXCOORD0) : COLOR {
float4 col = tex2D(shadowtexSampler , inTex);
col.a=dot(1.0rrr, col.rgb);
return col;
}
This assumes that the main texture is already rendered. How are you rendering the main texture?
The snippet above just gives you a blend between the shadowTexture and the previosly rendered scene depending on the brightness of the shadowTexture pixel. Is that what you want?
Quote: "How can I get the alpha blending to work correctly?"
The first, vital, step is to explain clearly what textures/images you are trying to blend and say what contains the blending information (and in what form).
Quote: "I want to set the alpha of the backdrop to 0, while coloring the rest of the captured image black."
What do you mean? The backdrop is the whole image, there is no "rest".
mrHandy
Quote: "So, have you got any ideas about stencil shadows question?"
Sorry, no I haven't.