More 3D Improvements

-=-=-=-=-=-=-=-=-=-=

-Sprite3D and AnimatedSprite3D support.
-Opaque pre-pass works, is compatible with shadows
-Improved shadow map rendering (can differentiate between plain opaque and opaque with shaders/discard/etc)
-Added option to use alpha discard in FixedMaterial
-Improved Glow FX, many more options (three modes, Additive, Screen and SoftLight), strength and scale
-Ability for Background (image or cubemap) to send to glow buffer
-Dumb Deploy of clients now actually works in Android
-Many Many rendering fixes, 3D is much more usable now.
This commit is contained in:
Juan Linietsky
2014-05-29 10:56:39 -03:00
parent d9adf2627a
commit 6f0b4678e2
50 changed files with 2261 additions and 93 deletions

View File

@ -274,6 +274,55 @@ RID VisualServer::make_sphere_mesh(int p_lats,int p_lons,float p_radius) {
return mesh;
}
RID VisualServer::material_2d_get(bool p_shaded, bool p_transparent, bool p_cut_alpha, bool p_opaque_prepass) {
int version=0;
if (p_shaded)
version=1;
if (p_transparent)
version|=2;
if (p_cut_alpha)
version|=4;
if (p_opaque_prepass)
version|=8;
if (material_2d[version].is_valid())
return material_2d[version];
//not valid, make
material_2d[version]=fixed_material_create();
fixed_material_set_flag(material_2d[version],FIXED_MATERIAL_FLAG_USE_ALPHA,p_transparent);
fixed_material_set_flag(material_2d[version],FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);
fixed_material_set_flag(material_2d[version],FIXED_MATERIAL_FLAG_DISCARD_ALPHA,p_cut_alpha);
material_set_flag(material_2d[version],MATERIAL_FLAG_UNSHADED,!p_shaded);
material_set_flag(material_2d[version],MATERIAL_FLAG_DOUBLE_SIDED,true);
material_set_hint(material_2d[version],MATERIAL_HINT_OPAQUE_PRE_PASS,p_opaque_prepass);
fixed_material_set_texture(material_2d[version],FIXED_MATERIAL_PARAM_DIFFUSE,get_white_texture());
//material cut alpha?
return material_2d[version];
}
RID VisualServer::get_white_texture() {
if (white_texture.is_valid())
return white_texture;
DVector<uint8_t> wt;
wt.resize(16*3);
{
DVector<uint8_t>::Write w =wt.write();
for(int i=0;i<16*3;i++)
w[i]=255;
}
Image white(4,4,0,Image::FORMAT_RGB,wt);
white_texture=texture_create();
texture_allocate(white_texture,4,4,Image::FORMAT_RGB);
texture_set_data(white_texture,white);
return white_texture;
}
void VisualServer::_bind_methods() {