Cycles: shadow pass support. Note that this only takes into account lamps,
emitting objects or world lighting do not contribute to the shadow pass. Consider this more as a pass useful for some compositing tricks, unlike other lighting passes this pass can't be used to exactly reconstruct the combined pass.
This commit is contained in:
@@ -186,15 +186,28 @@ bool RenderBuffers::get_pass(PassType type, float exposure, int sample, int comp
|
||||
assert(pass.components == components);
|
||||
|
||||
/* RGBA */
|
||||
for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
|
||||
float4 f = make_float4(in[0], in[1], in[2], in[3]);
|
||||
if(type == PASS_SHADOW) {
|
||||
for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
|
||||
float4 f = make_float4(in[0], in[1], in[2], in[3]);
|
||||
float invw = (f.w > 0.0f)? 1.0f/f.w: 1.0f;
|
||||
|
||||
pixels[0] = f.x*scale_exposure;
|
||||
pixels[1] = f.y*scale_exposure;
|
||||
pixels[2] = f.z*scale_exposure;
|
||||
pixels[0] = f.x*invw;
|
||||
pixels[1] = f.y*invw;
|
||||
pixels[2] = f.z*invw;
|
||||
pixels[3] = 1.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) {
|
||||
float4 f = make_float4(in[0], in[1], in[2], in[3]);
|
||||
|
||||
/* clamp since alpha might be > 1.0 due to russian roulette */
|
||||
pixels[3] = clamp(f.w*scale, 0.0f, 1.0f);
|
||||
pixels[0] = f.x*scale_exposure;
|
||||
pixels[1] = f.y*scale_exposure;
|
||||
pixels[2] = f.z*scale_exposure;
|
||||
|
||||
/* clamp since alpha might be > 1.0 due to russian roulette */
|
||||
pixels[3] = clamp(f.w*scale, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user