vf_glass
{
fresnel
{
bias=0.15 ; Fresnel = bias + scale*exp(incident angle, power)
scale=1.0; eg. chrome would be more like bias=1, scale=0 as it always reflects
power=2.0 ; power just changes the curve
}
cast_shadow=1
vertex_shader
{
file=dyn_standard_reflect_window_v.cg
}
fragment_shader
{
file=dyn_standard_reflect_window_f.cg
}
}
;----------------------- shaders -----------------------
shader_glasstail~vf_glass
{
sort_offset=1
reflect=0.2
layer0
{
map=lights.tga
blendfunc=blend
depthwrite=1
shininess=13500
ambient=.1 .1 .1
diffuse=1 1 1
specular=3 3 3
}
layer1
{
map=$trackenvmap
}
}
Alex Forbin
Sorry to nit pick, but didn't we decide that glass fresnel values were something more like 0.04 0.96 4.5? Using glass IOR to calculate the proper values? Very close to lacquer on car paint, as they are kinda the same material really. Just glass seems to have a stronger power/falloff amount!?
For any smooth glass surface, reflect needs to be almost 1 to get the mirror appearance at steep viewing angles? (not exactly 1 probably because of tiny roughness or dirt/dust on the surface?)
It'd probably look better and not need the extra specular to look 'right' if the base values for glass were used, and then the opacity channel to tint it can be used to bring the transparency down. Hmmmmm.
It is these settings that perpetually catch me out though.
Ruud hasn't really offered an example of 'best practice' way to use the glass shader or the settings.
Ie, depthwrite is always 1, but we can toggle it off, but then we need to make sure we set a sort_offset to make sure it is rendered appropriately (from what I read on racer.nl)
I suppose this is an opportunity to make a car that has lots of modern 'features' that all work but also using good values, then Ruud can help us make sure it's optimised and using shaders efficiently and logically so we can use it as reference material for best practice!
I've made a few nice cars but have hit issues with glass/blending but got over most of them simply by toggling switches and sort-orders and splitting models so they were done in a different batch... not ideal at all, and not so useful for new content creators who will fight with things for hours!
I guess what I mean is, we could do with hard and fast rules for transparent materials so we can just make them and they just work
Ie, somehow, the Murcielago headlight models use a blendfunc=blend, they appear under glass fine (not the new glass though, hmmm, maybe it's the new glass shader not perfect?), the bloom appears fine under the glass too, and they don't use any special settings bar sort_offset=-1
Yet when I try do the same on some other cars all hell breaks loose haha...
It does frazzle my brain and it's one of those areas that should just work, rather than having you spending hours fudging things and fighting.
Dave