Okay basically the intention is to have a second map that shows bits of the car which aren't being shown on the regular UV map.
First of all.
Blender exports cubemaps in a different order.
http://imgur.com/i3DUn
So I produced this reference for how to translate to the 6 cubemap bits. (right face will have to wait til I generate one that's non-empty - I'd guess it's 180 too though)
Second. There's still a major issue - Racer cubemaps import 3 channels only, no transparency. Alpha is always 1.0. So what I'm going ahead with is not going to be a permanent solution - just working around this problem.
Anyway, ingame, using only the above map (except the _bw texture, which is black) the single reflection map looks like this:
Obviously this method can't do multiple internal reflections, so the window and frame are reflecting as plain grey.
You can also see another issue - the cubemap, or maybe its mipmaps, aren't being clamped right.
So. Next step: swizzle up the channels.
alpha->red, greyscale texture->green
edit the shader to use a second reflection map - this is a snippet from an edited dyn_standard_reflect_f.cg:
1) reflColor = (...).gggr is swizzling the 2 channels back into the expected 4, to make it easier to update later.
2) envColor is updated to use reflColor's alpha channel.
So, after also adding a TEXUNIT that loads reflMap, the car.shd is also updated:
And, finally, the static reflection map works!
Since the mirror's just using a regular reflection shader, not the mirror texture, the side of the car shows up there, too.
Okay so I'm cheating a little (which is why the car's parked diagonally - and also why I've probably got the cubemap rotated 90 degrees). The reflection vector's operating in the wrong coordinate space, so when you turn everything goes wrong. But this is a start. To fix that, I'm gonna have to hack up the vertex shader too, so it passes an object-space reflection vector.
First of all.
Blender exports cubemaps in a different order.
http://imgur.com/i3DUn
So I produced this reference for how to translate to the 6 cubemap bits. (right face will have to wait til I generate one that's non-empty - I'd guess it's 180 too though)
Second. There's still a major issue - Racer cubemaps import 3 channels only, no transparency. Alpha is always 1.0. So what I'm going ahead with is not going to be a permanent solution - just working around this problem.
Anyway, ingame, using only the above map (except the _bw texture, which is black) the single reflection map looks like this:
Obviously this method can't do multiple internal reflections, so the window and frame are reflecting as plain grey.
You can also see another issue - the cubemap, or maybe its mipmaps, aren't being clamped right.
So. Next step: swizzle up the channels.
alpha->red, greyscale texture->green
edit the shader to use a second reflection map - this is a snippet from an edited dyn_standard_reflect_f.cg:
Code:
// Reflection
#ifdef USE_CUBEMAP_MIPMAPS
float3 envColor=texCUBElod(envMap,float4(IN.R,mipmap));
#else
float3 envColor=texCUBE(envMap,IN.R);
#endif
float reflectiveNess=baseCol.a;
float4 reflColor=texCUBE(reflMap,IN.R).gggr;
// Lighting
float3 ambient,diffuse,specular;
LightingSun(Ke,Ka,Kd,Ks,shininess,lightDirection,lightColor,lightAmbient,IN.Position,N,eyePosW,
ambient,diffuse,specular);
float3 litColor=baseCol*diffuse+specular*reflectiveNess;
float3 shadowColor=baseCol*(ambient+Ke);
envColor.rgb=envColor.rgb*(1.0-reflColor.a)+reflColor.a*reflColor.rgb*(diffuse+ambient);
2) envColor is updated to use reflColor's alpha channel.
So, after also adding a TEXUNIT that loads reflMap, the car.shd is also updated:
Code:
shader_chromemirror~shader_chrome
{
;reflect=0.0
;ambient=1.0 0.0 0.0
layer1
{
map=cubemaps/mirror_rg*.tga
}
layer2
{
map=$trackenvmap
}
fragment_shader
{
file=dyn_stereo_reflect_f.cg
}
}
Since the mirror's just using a regular reflection shader, not the mirror texture, the side of the car shows up there, too.
Okay so I'm cheating a little (which is why the car's parked diagonally - and also why I've probably got the cubemap rotated 90 degrees). The reflection vector's operating in the wrong coordinate space, so when you turn everything goes wrong. But this is a start. To fix that, I'm gonna have to hack up the vertex shader too, so it passes an object-space reflection vector.