parent
53d8f2b1ec
commit
d6567010bf
|
@ -914,6 +914,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list,int p_z,const
|
|||
}
|
||||
|
||||
|
||||
|
||||
if (shader_ptr && shader_ptr!=shader_cache) {
|
||||
|
||||
state.canvas_shader.set_custom_shader(shader_ptr->custom_code_id);
|
||||
|
@ -925,6 +926,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list,int p_z,const
|
|||
|
||||
int tc = material_ptr->textures.size();
|
||||
RID* textures = material_ptr->textures.ptr();
|
||||
ShaderLanguage::ShaderNode::Uniform::Hint* texture_hints = shader_ptr->texture_hints.ptr();
|
||||
|
||||
for(int i=0;i<tc;i++) {
|
||||
|
||||
|
@ -932,11 +934,30 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list,int p_z,const
|
|||
|
||||
RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull( textures[i] );
|
||||
if (!t) {
|
||||
//check hints
|
||||
|
||||
switch(texture_hints[i]) {
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: {
|
||||
glBindTexture(GL_TEXTURE_2D,storage->resources.black_tex);
|
||||
} break;
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_NORMAL: {
|
||||
glBindTexture(GL_TEXTURE_2D,storage->resources.normal_tex);
|
||||
} break;
|
||||
default: {
|
||||
glBindTexture(GL_TEXTURE_2D,storage->resources.white_tex);
|
||||
} break;
|
||||
}
|
||||
|
||||
//check hints
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (storage->config.srgb_decode_supported && t->using_srgb) {
|
||||
//no srgb in 2D
|
||||
glTexParameteri(t->target,_TEXTURE_SRGB_DECODE_EXT,_SKIP_DECODE_EXT);
|
||||
t->using_srgb=false;
|
||||
}
|
||||
|
||||
glBindTexture(t->target,t->tex_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -253,10 +253,8 @@ void RasterizerGLES3::make_current() {
|
|||
|
||||
void RasterizerGLES3::register_config() {
|
||||
|
||||
GLOBAL_DEF("rendering/gles3/framebuffer_format",RasterizerStorageGLES3::FBO_FORMAT_FLOAT);
|
||||
Globals::get_singleton()->set_custom_property_info("rendering/gles3/framebuffer_format",PropertyInfo(Variant::INT,"",PROPERTY_HINT_ENUM,"16 Bits,32 Bits,Half Float"));
|
||||
GLOBAL_DEF("rendering/gles3/lighting_technique",1);
|
||||
Globals::get_singleton()->set_custom_property_info("rendering/gles3/lighting_technique",PropertyInfo(Variant::INT,"",PROPERTY_HINT_ENUM,"Forward,Deferred"));
|
||||
GLOBAL_DEF("rendering/gles3/render_architecture",0);
|
||||
Globals::get_singleton()->set_custom_property_info("rendering/gles3/render_architecture",PropertyInfo(Variant::INT,"",PROPERTY_HINT_ENUM,"Desktop,Mobile"));
|
||||
GLOBAL_DEF("rendering/gles3/use_nearest_mipmap_filter",false);
|
||||
GLOBAL_DEF("rendering/gles3/anisotropic_filter_level",4.0);
|
||||
|
||||
|
|
|
@ -150,27 +150,19 @@ void RasterizerSceneGLES3::environment_set_fog(RID p_env,bool p_enable,float p_b
|
|||
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::environment_set_tonemap(RID p_env,bool p_enable,float p_exposure,float p_white,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,VS::EnvironmentToneMapper p_tone_mapper){
|
||||
|
||||
}
|
||||
void RasterizerSceneGLES3::environment_set_brightness(RID p_env,bool p_enable,float p_brightness){
|
||||
|
||||
}
|
||||
void RasterizerSceneGLES3::environment_set_contrast(RID p_env,bool p_enable,float p_contrast){
|
||||
|
||||
}
|
||||
void RasterizerSceneGLES3::environment_set_saturation(RID p_env,bool p_enable,float p_saturation){
|
||||
|
||||
}
|
||||
void RasterizerSceneGLES3::environment_set_color_correction(RID p_env,bool p_enable,RID p_ramp){
|
||||
void RasterizerSceneGLES3::environment_set_tonemap(RID p_env, bool p_enable, float p_exposure, float p_white, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale, VS::EnvironmentToneMapper p_tone_mapper){
|
||||
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::environment_set_adjustment(RID p_env,bool p_enable,float p_brightness,float p_contrast,float p_saturation,RID p_ramp) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
RID RasterizerSceneGLES3::light_instance_create(RID p_light) {
|
||||
|
||||
print_line("hello light");
|
||||
LightInstance *light_instance = memnew( LightInstance );
|
||||
|
||||
light_instance->light=p_light;
|
||||
|
@ -204,6 +196,29 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
|
|||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
if (state.current_line_width!=p_material->line_width) {
|
||||
glLineWidth(p_material->line_width);
|
||||
state.current_line_width=p_material->line_width;
|
||||
}
|
||||
|
||||
if (state.current_depth_draw!=p_material->shader->spatial.depth_draw_mode) {
|
||||
switch(p_material->shader->spatial.depth_draw_mode) {
|
||||
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS:
|
||||
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_OPAQUE: {
|
||||
|
||||
glDepthMask(!p_alpha_pass);
|
||||
} break;
|
||||
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALWAYS: {
|
||||
glDepthMask(GL_TRUE);
|
||||
} break;
|
||||
case RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_NEVER: {
|
||||
glDepthMask(GL_FALSE);
|
||||
} break;
|
||||
}
|
||||
|
||||
state.current_depth_draw=p_material->shader->spatial.depth_draw_mode;
|
||||
}
|
||||
|
||||
//glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
||||
|
||||
/*
|
||||
|
@ -216,7 +231,7 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
|
|||
//if (p_material->line_width)
|
||||
// glLineWidth(p_material->line_width);
|
||||
|
||||
|
||||
#if 0
|
||||
//blend mode
|
||||
if (state.current_blend_mode!=p_material->shader->spatial.blend_mode) {
|
||||
|
||||
|
@ -256,7 +271,7 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
|
|||
state.current_blend_mode=p_material->shader->spatial.blend_mode;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
//material parameters
|
||||
|
||||
|
||||
|
@ -273,6 +288,7 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
|
|||
|
||||
int tc = p_material->textures.size();
|
||||
RID* textures = p_material->textures.ptr();
|
||||
ShaderLanguage::ShaderNode::Uniform::Hint* texture_hints = p_material->shader->texture_hints.ptr();
|
||||
|
||||
for(int i=0;i<tc;i++) {
|
||||
|
||||
|
@ -281,11 +297,48 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material* p_m
|
|||
RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull( textures[i] );
|
||||
if (!t) {
|
||||
//check hints
|
||||
switch(texture_hints[i]) {
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_BLACK: {
|
||||
glBindTexture(GL_TEXTURE_2D,storage->resources.black_tex);
|
||||
} break;
|
||||
case ShaderLanguage::ShaderNode::Uniform::HINT_NORMAL: {
|
||||
glBindTexture(GL_TEXTURE_2D,storage->resources.normal_tex);
|
||||
} break;
|
||||
default: {
|
||||
glBindTexture(GL_TEXTURE_2D,storage->resources.white_tex);
|
||||
} break;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,storage->resources.white_tex);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (storage->config.srgb_decode_supported) {
|
||||
//if SRGB decode extension is present, simply switch the texture to whathever is needed
|
||||
bool must_srgb=false;
|
||||
|
||||
if (t->srgb && texture_hints[i]==ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO) {
|
||||
must_srgb=true;
|
||||
}
|
||||
|
||||
if (t->using_srgb!=must_srgb) {
|
||||
if (must_srgb) {
|
||||
glTexParameteri(t->target,_TEXTURE_SRGB_DECODE_EXT,_DECODE_EXT);
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (!(t->flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) {
|
||||
t->flags|=VS::TEXTURE_FLAG_CONVERT_TO_LINEAR;
|
||||
//notify that texture must be set to linear beforehand, so it works in other platforms when exported
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
glTexParameteri(t->target,_TEXTURE_SRGB_DECODE_EXT,_SKIP_DECODE_EXT);
|
||||
}
|
||||
t->using_srgb=must_srgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glBindTexture(t->target,t->tex_id);
|
||||
}
|
||||
|
||||
|
@ -348,7 +401,60 @@ void RasterizerSceneGLES3::_setup_light(LightInstance *p_light) {
|
|||
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER,3,p_light->light_ubo); //bind light uniform
|
||||
}
|
||||
void RasterizerSceneGLES3::_setup_transform(InstanceBase *p_instance,const Transform& p_view_transform,const CameraMatrix& p_projection) {
|
||||
|
||||
if (p_instance->billboard || p_instance->billboard_y || p_instance->depth_scale) {
|
||||
|
||||
Transform xf=p_instance->transform;
|
||||
if (p_instance->depth_scale) {
|
||||
|
||||
if (p_projection.matrix[3][3]) {
|
||||
//orthogonal matrix, try to do about the same
|
||||
//with viewport size
|
||||
//real_t w = Math::abs( 1.0/(2.0*(p_projection.matrix[0][0])) );
|
||||
real_t h = Math::abs( 1.0/(2.0*p_projection.matrix[1][1]) );
|
||||
float sc = (h*2.0); //consistent with Y-fov
|
||||
xf.basis.scale( Vector3(sc,sc,sc));
|
||||
} else {
|
||||
//just scale by depth
|
||||
real_t sc = Plane(p_view_transform.origin,-p_view_transform.get_basis().get_axis(2)).distance_to(xf.origin);
|
||||
xf.basis.scale( Vector3(sc,sc,sc));
|
||||
}
|
||||
}
|
||||
|
||||
if (p_instance->billboard) {
|
||||
|
||||
Vector3 scale = xf.basis.get_scale();
|
||||
|
||||
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP]) {
|
||||
xf.set_look_at(xf.origin, xf.origin + p_view_transform.get_basis().get_axis(2), -p_view_transform.get_basis().get_axis(1));
|
||||
} else {
|
||||
xf.set_look_at(xf.origin, xf.origin + p_view_transform.get_basis().get_axis(2), p_view_transform.get_basis().get_axis(1));
|
||||
}
|
||||
|
||||
xf.basis.scale(scale);
|
||||
}
|
||||
|
||||
if (p_instance->billboard_y) {
|
||||
|
||||
Vector3 scale = xf.basis.get_scale();
|
||||
Vector3 look_at = p_view_transform.get_origin();
|
||||
look_at.y = 0.0;
|
||||
Vector3 look_at_norm = look_at.normalized();
|
||||
|
||||
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP]) {
|
||||
xf.set_look_at(xf.origin,xf.origin + look_at_norm, Vector3(0.0, -1.0, 0.0));
|
||||
} else {
|
||||
xf.set_look_at(xf.origin,xf.origin + look_at_norm, Vector3(0.0, 1.0, 0.0));
|
||||
}
|
||||
xf.basis.scale(scale);
|
||||
}
|
||||
state.scene_shader.set_uniform(SceneShaderGLES3::WORLD_TRANSFORM, xf);
|
||||
|
||||
} else {
|
||||
state.scene_shader.set_uniform(SceneShaderGLES3::WORLD_TRANSFORM, p_instance->transform);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_element_count,const Transform& p_view_transform,const CameraMatrix& p_projection,RasterizerStorageGLES3::Texture* p_base_env,bool p_reverse_cull,bool p_alpha_pass) {
|
||||
|
||||
|
@ -372,12 +478,18 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
|
|||
glActiveTexture(GL_TEXTURE0+storage->config.max_texture_image_units-2);
|
||||
glBindTexture(p_base_env->target,p_base_env->tex_id);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_CUBEMAP,true);
|
||||
} else {
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_CUBEMAP,false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_SKELETON,false);
|
||||
|
||||
state.current_blend_mode=-1;
|
||||
state.current_line_width=-1;
|
||||
state.current_depth_draw=-1;
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
@ -390,6 +502,8 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
|
|||
int prev_blend=-1;
|
||||
int current_blend_mode=-1;
|
||||
|
||||
bool prev_additive=false;
|
||||
|
||||
for (int i=0;i<p_element_count;i++) {
|
||||
|
||||
RenderList::Element *e = p_elements[i];
|
||||
|
@ -554,10 +668,16 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
|
|||
_setup_geometry(e);
|
||||
}
|
||||
|
||||
if (rebind || prev_additive!=additive) {
|
||||
state.scene_shader.set_uniform(SceneShaderGLES3::NO_AMBIENT_LIGHT, additive);
|
||||
|
||||
}
|
||||
|
||||
// _set_cull(e->mirror,p_reverse_cull);
|
||||
|
||||
state.scene_shader.set_uniform(SceneShaderGLES3::NORMAL_MULT, e->instance->mirror?-1.0:1.0);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES3::WORLD_TRANSFORM, e->instance->transform);
|
||||
|
||||
_setup_transform(e->instance,p_view_transform,p_projection);
|
||||
|
||||
|
||||
// _render(e->geometry, material, skeleton,e->owner,e->instance->transform);
|
||||
|
@ -567,6 +687,10 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements,int p_e
|
|||
prev_material=material;
|
||||
prev_base_type=e->instance->base_type;
|
||||
prev_geometry=e->geometry;
|
||||
prev_additive=additive;
|
||||
prev_light_type=light_type;
|
||||
prev_light_index=light_index;
|
||||
|
||||
}
|
||||
|
||||
//print_line("shaderchanges: "+itos(p_alpha_pass)+": "+itos(_rinfo.shader_change_count));
|
||||
|
@ -824,6 +948,19 @@ void RasterizerSceneGLES3::_draw_skybox(RID p_skybox,CameraMatrix& p_projection,
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(tex->target,tex->tex_id);
|
||||
|
||||
|
||||
if (storage->config.srgb_decode_supported && tex->srgb && !tex->using_srgb) {
|
||||
|
||||
glTexParameteri(tex->target,_TEXTURE_SRGB_DECODE_EXT,_DECODE_EXT);
|
||||
tex->using_srgb=true;
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (!(tex->flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) {
|
||||
tex->flags|=VS::TEXTURE_FLAG_CONVERT_TO_LINEAR;
|
||||
//notify that texture must be set to linear beforehand, so it works in other platforms when exported
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
@ -876,6 +1013,7 @@ void RasterizerSceneGLES3::_draw_skybox(RID p_skybox,CameraMatrix& p_projection,
|
|||
glDrawArrays(GL_TRIANGLE_FAN,0,4);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glColorMask(1,1,1,1);
|
||||
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_CUBEMAP,false);
|
||||
|
||||
|
@ -977,9 +1115,10 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
|
|||
ERR_FAIL_COND( directional_light_instance_count >= RenderList::MAX_LIGHTS);
|
||||
directional_light_instances[directional_light_instance_count++]=li;
|
||||
|
||||
li->light_ubo_data.light_color_energy[0]=li->light_ptr->color.r;
|
||||
li->light_ubo_data.light_color_energy[1]=li->light_ptr->color.g;
|
||||
li->light_ubo_data.light_color_energy[2]=li->light_ptr->color.b;
|
||||
Color linear_col = li->light_ptr->color.to_linear();
|
||||
li->light_ubo_data.light_color_energy[0]=linear_col.r;
|
||||
li->light_ubo_data.light_color_energy[1]=linear_col.g;
|
||||
li->light_ubo_data.light_color_energy[2]=linear_col.b;
|
||||
li->light_ubo_data.light_color_energy[3]=li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
|
||||
|
||||
//omni, keep at 0
|
||||
|
@ -1018,9 +1157,10 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
|
|||
} break;
|
||||
case VS::LIGHT_OMNI: {
|
||||
|
||||
li->light_ubo_data.light_color_energy[0]=li->light_ptr->color.r;
|
||||
li->light_ubo_data.light_color_energy[1]=li->light_ptr->color.g;
|
||||
li->light_ubo_data.light_color_energy[2]=li->light_ptr->color.b;
|
||||
Color linear_col = li->light_ptr->color.to_linear();
|
||||
li->light_ubo_data.light_color_energy[0]=linear_col.r;
|
||||
li->light_ubo_data.light_color_energy[1]=linear_col.g;
|
||||
li->light_ubo_data.light_color_energy[2]=linear_col.b;
|
||||
li->light_ubo_data.light_color_energy[3]=li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
|
||||
|
||||
Vector3 pos = p_camera_inverse_transform.xform(li->transform.origin);
|
||||
|
@ -1050,9 +1190,10 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
|
|||
} break;
|
||||
case VS::LIGHT_SPOT: {
|
||||
|
||||
li->light_ubo_data.light_color_energy[0]=li->light_ptr->color.r;
|
||||
li->light_ubo_data.light_color_energy[1]=li->light_ptr->color.g;
|
||||
li->light_ubo_data.light_color_energy[2]=li->light_ptr->color.b;
|
||||
Color linear_col = li->light_ptr->color.to_linear();
|
||||
li->light_ubo_data.light_color_energy[0]=linear_col.r;
|
||||
li->light_ubo_data.light_color_energy[1]=linear_col.g;
|
||||
li->light_ubo_data.light_color_energy[2]=linear_col.b;
|
||||
li->light_ubo_data.light_color_energy[3]=li->light_ptr->param[VS::LIGHT_PARAM_ENERGY];
|
||||
|
||||
Vector3 pos = p_camera_inverse_transform.xform(li->transform.origin);
|
||||
|
@ -1108,6 +1249,51 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result,int p_light_cu
|
|||
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::_copy_screen() {
|
||||
|
||||
glBindVertexArray(storage->resources.quadie_array);
|
||||
glDrawArrays(GL_TRIANGLE_FAN,0,4);
|
||||
glBindVertexArray(0);
|
||||
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::_copy_to_front_buffer(Environment *env) {
|
||||
|
||||
//copy to front buffer
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->front.fbo);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_BLEND);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glColorMask(1,1,1,1);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D,storage->frame.current_rt->buffers.diffuse);
|
||||
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA,true);
|
||||
|
||||
if (!env) {
|
||||
//no environment, simply convert from linear to srgb
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB,true);
|
||||
} else {
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB,true);
|
||||
|
||||
}
|
||||
|
||||
storage->shaders.copy.bind();
|
||||
|
||||
_copy_screen();
|
||||
|
||||
|
||||
//turn off everything used
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::LINEAR_TO_SRGB,false);
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA,false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,CameraMatrix& p_cam_projection,bool p_cam_ortogonal,InstanceBase** p_cull_result,int p_cull_count,RID* p_light_cull_result,int p_light_cull_count,RID* p_directional_lights,int p_directional_light_count,RID p_environment){
|
||||
|
||||
//first of all, make a new render pass
|
||||
|
@ -1125,6 +1311,8 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,CameraM
|
|||
|
||||
current_material_index=0;
|
||||
|
||||
bool use_mrt=false;
|
||||
|
||||
//fill list
|
||||
|
||||
for(int i=0;i<p_cull_count;i++) {
|
||||
|
@ -1166,43 +1354,58 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,CameraM
|
|||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glClearDepth(1.0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->front.fbo);
|
||||
|
||||
RasterizerStorageGLES3::Texture* env_radiance_tex;
|
||||
RasterizerStorageGLES3::Texture* env_radiance_tex=NULL;
|
||||
|
||||
if (use_mrt) {
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.fbo);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_MULTIPLE_RENDER_TARGETS,true);
|
||||
|
||||
Color black(0,0,0,0);
|
||||
glClearBufferfv(GL_COLOR,1,black.components); // specular
|
||||
glClearBufferfv(GL_COLOR,2,black.components); // normal metal rough
|
||||
|
||||
} else {
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.alpha_fbo);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_MULTIPLE_RENDER_TARGETS,false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
glClearDepth(1.0);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
Color clear_color(0,0,0,0);
|
||||
|
||||
if (!env || env->bg_mode==VS::ENV_BG_CLEAR_COLOR) {
|
||||
|
||||
if (storage->frame.clear_request) {
|
||||
|
||||
glClearColor( storage->frame.clear_request_color.r, storage->frame.clear_request_color.g, storage->frame.clear_request_color.b, storage->frame.clear_request_color.a );
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
clear_color = storage->frame.clear_request_color.to_linear();
|
||||
storage->frame.clear_request=false;
|
||||
|
||||
}
|
||||
|
||||
} else if (env->bg_mode==VS::ENV_BG_COLOR) {
|
||||
|
||||
|
||||
glClearColor( env->bg_color.r, env->bg_color.g, env->bg_color.b, env->bg_color.a );
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
clear_color = env->bg_color.to_linear();
|
||||
storage->frame.clear_request=false;
|
||||
} else if (env->bg_mode==VS::ENV_BG_SKYBOX) {
|
||||
|
||||
if (env->skybox_radiance.is_valid()) {
|
||||
env_radiance_tex = storage->texture_owner.getornull(env->skybox_radiance);
|
||||
}
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
storage->frame.clear_request=false;
|
||||
|
||||
} else {
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
storage->frame.clear_request=false;
|
||||
|
||||
}
|
||||
|
||||
state.current_depth_test=true;
|
||||
state.current_depth_mask=true;
|
||||
glClearBufferfv(GL_COLOR,0,clear_color.components); // specular
|
||||
|
||||
|
||||
state.texscreen_copied=false;
|
||||
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
@ -1214,43 +1417,33 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,CameraM
|
|||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
//current_blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
|
||||
|
||||
|
||||
render_list.sort_by_key(false);
|
||||
|
||||
//_render_list_forward(&opaque_render_list,camera_transform,camera_transform_inverse,camera_projection,false,fragment_lighting);
|
||||
/*
|
||||
if (draw_tex_background) {
|
||||
|
||||
//most 3D vendors recommend drawing a texture bg or skybox here,
|
||||
//after opaque geometry has been drawn
|
||||
//so the zbuffer can get rid of most pixels
|
||||
_draw_tex_bg();
|
||||
}
|
||||
*/
|
||||
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
} else {
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
// glDisable(GL_BLEND);
|
||||
// current_blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
|
||||
// state.scene_shader.set_conditional(SceneShaderGLES3::USE_GLOW,false);
|
||||
// if (current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]) {
|
||||
// glColorMask(1,1,1,0); //don't touch alpha
|
||||
// }
|
||||
|
||||
|
||||
_render_list(render_list.elements,render_list.element_count,p_cam_transform,p_cam_projection,env_radiance_tex,false,false);
|
||||
|
||||
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_MULTIPLE_RENDER_TARGETS,false);
|
||||
|
||||
if (env && env->bg_mode==VS::ENV_BG_SKYBOX) {
|
||||
|
||||
if (use_mrt) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.alpha_fbo); //switch to alpha fbo for skybox, only diffuse/ambient matters
|
||||
}
|
||||
|
||||
_draw_skybox(env->skybox_color,p_cam_projection,p_cam_transform,storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_VFLIP],env->skybox_scale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//_render_list_forward(&alpha_render_list,camera_transform,camera_transform_inverse,camera_projection,false,fragment_lighting,true);
|
||||
//glColorMask(1,1,1,1);
|
||||
|
||||
|
@ -1261,13 +1454,15 @@ void RasterizerSceneGLES3::render_scene(const Transform& p_cam_transform,CameraM
|
|||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->front.fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER,storage->frame.current_rt->buffers.alpha_fbo);
|
||||
|
||||
render_list.sort_by_depth(true);
|
||||
|
||||
_render_list(&render_list.elements[render_list.max_elements-render_list.alpha_element_count],render_list.alpha_element_count,p_cam_transform,p_cam_projection,env_radiance_tex,false,false);
|
||||
_render_list(&render_list.elements[render_list.max_elements-render_list.alpha_element_count],render_list.alpha_element_count,p_cam_transform,p_cam_projection,env_radiance_tex,false,true);
|
||||
|
||||
|
||||
_copy_to_front_buffer(env);
|
||||
|
||||
#if 0
|
||||
if (use_fb) {
|
||||
|
||||
|
@ -1418,6 +1613,7 @@ bool RasterizerSceneGLES3::free(RID p_rid) {
|
|||
|
||||
if (light_instance_owner.owns(p_rid)) {
|
||||
|
||||
print_line("bye light");
|
||||
LightInstance *light_instance = light_instance_owner.getptr(p_rid);
|
||||
glDeleteBuffers(1,&light_instance->light_ubo);
|
||||
light_instance_owner.free(p_rid);
|
||||
|
|
|
@ -18,10 +18,11 @@ public:
|
|||
|
||||
struct State {
|
||||
|
||||
bool current_depth_test;
|
||||
bool current_depth_mask;
|
||||
|
||||
bool texscreen_copied;
|
||||
int current_blend_mode;
|
||||
float current_line_width;
|
||||
int current_depth_draw;
|
||||
|
||||
SceneShaderGLES3 scene_shader;
|
||||
|
||||
|
@ -57,6 +58,8 @@ public:
|
|||
GLuint skybox_verts;
|
||||
GLuint skybox_array;
|
||||
|
||||
|
||||
|
||||
} state;
|
||||
|
||||
|
||||
|
@ -109,11 +112,8 @@ public:
|
|||
virtual void environment_set_glow(RID p_env,bool p_enable,int p_radius,float p_intensity,float p_strength,float p_bloom_treshold,VS::EnvironmentGlowBlendMode p_blend_mode);
|
||||
virtual void environment_set_fog(RID p_env,bool p_enable,float p_begin,float p_end,RID p_gradient_texture);
|
||||
|
||||
virtual void environment_set_tonemap(RID p_env,bool p_enable,float p_exposure,float p_white,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,VS::EnvironmentToneMapper p_tone_mapper);
|
||||
virtual void environment_set_brightness(RID p_env,bool p_enable,float p_brightness);
|
||||
virtual void environment_set_contrast(RID p_env,bool p_enable,float p_contrast);
|
||||
virtual void environment_set_saturation(RID p_env,bool p_enable,float p_saturation);
|
||||
virtual void environment_set_color_correction(RID p_env,bool p_enable,RID p_ramp);
|
||||
virtual void environment_set_tonemap(RID p_env,bool p_enable,float p_exposure,float p_white,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,float p_auto_exp_scale,VS::EnvironmentToneMapper p_tone_mapper);
|
||||
virtual void environment_set_adjustment(RID p_env,bool p_enable,float p_brightness,float p_contrast,float p_saturation,RID p_ramp);
|
||||
|
||||
|
||||
/* LIGHT INSTANCE */
|
||||
|
@ -314,6 +314,7 @@ public:
|
|||
RenderList render_list;
|
||||
|
||||
_FORCE_INLINE_ bool _setup_material(RasterizerStorageGLES3::Material* p_material,bool p_alpha_pass);
|
||||
_FORCE_INLINE_ void _setup_transform(InstanceBase *p_instance,const Transform& p_view_transform,const CameraMatrix& p_projection);
|
||||
_FORCE_INLINE_ void _setup_geometry(RenderList::Element *e);
|
||||
_FORCE_INLINE_ void _render_geometry(RenderList::Element *e);
|
||||
_FORCE_INLINE_ void _setup_light(LightInstance *p_light);
|
||||
|
@ -327,6 +328,8 @@ public:
|
|||
|
||||
void _setup_environment(Environment *env,CameraMatrix& p_cam_projection, const Transform& p_cam_transform);
|
||||
void _setup_lights(RID *p_light_cull_result, int p_light_cull_count, const Transform &p_camera_inverse_transform);
|
||||
void _copy_screen();
|
||||
void _copy_to_front_buffer(Environment *env);
|
||||
|
||||
virtual void render_scene(const Transform& p_cam_transform,CameraMatrix& p_cam_projection,bool p_cam_ortogonal,InstanceBase** p_cull_result,int p_cull_count,RID* p_light_cull_result,int p_light_cull_count,RID* p_directional_lights,int p_directional_light_count,RID p_environment);
|
||||
|
||||
|
|
|
@ -57,9 +57,6 @@
|
|||
#define _EXT_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
|
||||
|
||||
|
||||
#define _TEXTURE_SRGB_DECODE_EXT 0x8A48
|
||||
#define _DECODE_EXT 0x8A49
|
||||
#define _SKIP_DECODE_EXT 0x8A4A
|
||||
|
||||
|
||||
#define _GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
|
@ -679,8 +676,10 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture,const Image& p_image
|
|||
if (texture->flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) {
|
||||
|
||||
glTexParameteri(texture->target,_TEXTURE_SRGB_DECODE_EXT,_DECODE_EXT);
|
||||
texture->using_srgb=true;
|
||||
} else {
|
||||
glTexParameteri(texture->target,_TEXTURE_SRGB_DECODE_EXT,_SKIP_DECODE_EXT);
|
||||
texture->using_srgb=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -892,8 +891,10 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture,uint32_t p_flags) {
|
|||
if (texture->flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) {
|
||||
|
||||
glTexParameteri(texture->target,_TEXTURE_SRGB_DECODE_EXT,_DECODE_EXT);
|
||||
texture->using_srgb=true;
|
||||
} else {
|
||||
glTexParameteri(texture->target,_TEXTURE_SRGB_DECODE_EXT,_SKIP_DECODE_EXT);
|
||||
texture->using_srgb=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1024,6 +1025,19 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source,int p_r
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(texture->target, texture->tex_id);
|
||||
|
||||
if (config.srgb_decode_supported && texture->srgb && !texture->using_srgb) {
|
||||
|
||||
glTexParameteri(texture->target,_TEXTURE_SRGB_DECODE_EXT,_DECODE_EXT);
|
||||
texture->using_srgb=true;
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (!(texture->flags&VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) {
|
||||
texture->flags|=VS::TEXTURE_FLAG_CONVERT_TO_LINEAR;
|
||||
//notify that texture must be set to linear beforehand, so it works in other platforms when exported
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
GLuint new_cubemap;
|
||||
glGenTextures(1, &new_cubemap);
|
||||
|
@ -1302,6 +1316,7 @@ void RasterizerStorageGLES3::_update_shader(Shader* p_shader) const {
|
|||
p_shader->ubo_size=gen_code.uniform_total_size;
|
||||
p_shader->ubo_offsets=gen_code.uniform_offsets;
|
||||
p_shader->texture_count=gen_code.texture_uniforms.size();
|
||||
p_shader->texture_hints=gen_code.texture_hints;
|
||||
|
||||
//all materials using this shader will have to be invalidated, unfortunately
|
||||
|
||||
|
@ -1510,7 +1525,17 @@ Variant RasterizerStorageGLES3::material_get_param(RID p_material, const StringN
|
|||
return Variant();
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataType type, const Variant& value, uint8_t *data) {
|
||||
void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_width) {
|
||||
|
||||
Material *material = material_owner.get( p_material );
|
||||
ERR_FAIL_COND(!material);
|
||||
|
||||
material->line_width=p_width;
|
||||
|
||||
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataType type, const Variant& value, uint8_t *data,bool p_linear_color) {
|
||||
switch(type) {
|
||||
case ShaderLanguage::TYPE_BOOL: {
|
||||
|
||||
|
@ -1683,6 +1708,10 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
|
|||
if (value.get_type()==Variant::COLOR) {
|
||||
Color v=value;
|
||||
|
||||
if (p_linear_color) {
|
||||
v=v.to_linear();
|
||||
}
|
||||
|
||||
gui[0]=v.r;
|
||||
gui[1]=v.g;
|
||||
gui[2]=v.b;
|
||||
|
@ -2019,7 +2048,7 @@ void RasterizerStorageGLES3::_update_material(Material* material) {
|
|||
|
||||
if (V) {
|
||||
//user provided
|
||||
_fill_std140_variant_ubo_value(E->get().type,V->get(),data);
|
||||
_fill_std140_variant_ubo_value(E->get().type,V->get(),data,material->shader->mode==VS::SHADER_SPATIAL);
|
||||
} else if (E->get().default_value.size()){
|
||||
//default value
|
||||
_fill_std140_ubo_value(E->get().type,E->get().default_value,data);
|
||||
|
@ -2641,9 +2670,7 @@ void RasterizerStorageGLES3::mesh_remove_surface(RID p_mesh, int p_surface){
|
|||
|
||||
Surface *surface = mesh->surfaces[p_surface];
|
||||
|
||||
ERR_FAIL_COND(surface->index_array_len==0);
|
||||
|
||||
glDeleteBuffers(1,&surface->array_id);
|
||||
glDeleteBuffers(1,&surface->vertex_id);
|
||||
if (surface->index_id) {
|
||||
glDeleteBuffers(1,&surface->index_id);
|
||||
}
|
||||
|
@ -3211,14 +3238,14 @@ void RasterizerStorageGLES3::_render_target_clear(RenderTarget *rt) {
|
|||
rt->back.fbo=0;
|
||||
}
|
||||
|
||||
if (rt->deferred.fbo) {
|
||||
glDeleteFramebuffers(1,&rt->deferred.fbo);
|
||||
glDeleteFramebuffers(1,&rt->deferred.fbo_color);
|
||||
glDeleteTextures(1,&rt->deferred.albedo_ao);
|
||||
glDeleteTextures(1,&rt->deferred.normal_special);
|
||||
glDeleteTextures(1,&rt->deferred.metal_rough_motion);
|
||||
rt->deferred.fbo=0;
|
||||
rt->deferred.fbo_color=0;
|
||||
if (rt->buffers.fbo) {
|
||||
glDeleteFramebuffers(1,&rt->buffers.fbo);
|
||||
glDeleteFramebuffers(1,&rt->buffers.alpha_fbo);
|
||||
glDeleteTextures(1,&rt->buffers.diffuse);
|
||||
glDeleteTextures(1,&rt->buffers.specular);
|
||||
glDeleteTextures(1,&rt->buffers.normal_sr);
|
||||
rt->buffers.fbo=0;
|
||||
rt->buffers.alpha_fbo=0;
|
||||
}
|
||||
|
||||
if (rt->depth) {
|
||||
|
@ -3239,26 +3266,6 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
if (rt->width<=0 || rt->height<=0)
|
||||
return;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glGenFramebuffers(1, &rt->front.fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rt->front.fbo);
|
||||
|
||||
|
||||
glGenRenderbuffers(1, &rt->depth);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rt->depth );
|
||||
if (config.fbo_format==FBO_FORMAT_16_BITS) {
|
||||
glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH_COMPONENT16, rt->width, rt->height);
|
||||
} else {
|
||||
glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH24_STENCIL8, rt->width, rt->height);
|
||||
}
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0 );
|
||||
|
||||
|
||||
glGenTextures(1, &rt->front.color);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->front.color);
|
||||
|
||||
|
||||
GLuint color_internal_format;
|
||||
GLuint color_format;
|
||||
|
@ -3266,21 +3273,8 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
Image::Format image_format;
|
||||
|
||||
|
||||
if (config.fbo_format==FBO_FORMAT_16_BITS) {
|
||||
|
||||
if (rt->flags[RENDER_TARGET_TRANSPARENT]) {
|
||||
color_internal_format=GL_RGB5_A1;
|
||||
color_format=GL_RGBA;
|
||||
color_type=GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
image_format=Image::FORMAT_RGBA5551;
|
||||
} else {
|
||||
color_internal_format=GL_RGB565;
|
||||
color_format=GL_RGB;
|
||||
color_type=GL_UNSIGNED_SHORT_5_6_5;
|
||||
image_format=Image::FORMAT_RGB565;
|
||||
}
|
||||
|
||||
} else if (config.fbo_format==FBO_FORMAT_32_BITS || (config.fbo_format==FBO_FORMAT_FLOAT && rt->flags[RENDER_TARGET_NO_3D])) {
|
||||
if (config.render_arch==RENDER_ARCH_MOBILE || rt->flags[RENDER_TARGET_NO_3D]) {
|
||||
|
||||
if (rt->flags[RENDER_TARGET_TRANSPARENT]) {
|
||||
color_internal_format=GL_RGBA8;
|
||||
|
@ -3293,14 +3287,34 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
color_type=GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||
image_format=Image::FORMAT_RGBA8;//todo
|
||||
}
|
||||
} else if (config.fbo_format==FBO_FORMAT_FLOAT) {
|
||||
|
||||
} else {
|
||||
color_internal_format=GL_RGBA16F;
|
||||
color_format=GL_RGBA;
|
||||
color_type=GL_HALF_FLOAT;
|
||||
image_format=Image::FORMAT_RGBAH;
|
||||
}
|
||||
|
||||
{
|
||||
/* FRONT FBO */
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glGenFramebuffers(1, &rt->front.fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rt->front.fbo);
|
||||
|
||||
|
||||
glGenRenderbuffers(1, &rt->depth);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rt->depth );
|
||||
|
||||
|
||||
glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH24_STENCIL8, rt->width, rt->height);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0 );
|
||||
|
||||
|
||||
glGenTextures(1, &rt->front.color);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->front.color);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, NULL);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -3309,12 +3323,10 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->front.color, 0);
|
||||
|
||||
{
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
|
||||
|
||||
ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE );
|
||||
}
|
||||
|
||||
Texture *tex = texture_owner.get(rt->texture);
|
||||
tex->format=image_format;
|
||||
|
@ -3330,16 +3342,20 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
|
||||
texture_set_flags(rt->texture,tex->flags);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* BACK FBO */
|
||||
|
||||
if (!rt->flags[RENDER_TARGET_NO_SAMPLING]) {
|
||||
|
||||
glGenFramebuffers(1, &rt->back.fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rt->back.fbo);
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rt->depth );
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
|
||||
|
||||
glGenTextures(1, &rt->back.color);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->back.color);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, color_internal_format, rt->width, rt->height, 0, color_format, color_type, NULL);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
@ -3357,43 +3373,42 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
}
|
||||
}
|
||||
|
||||
if (config.render_arch==RENDER_ARCH_DESKTOP && !rt->flags[RENDER_TARGET_NO_3D]) {
|
||||
|
||||
|
||||
if (config.fbo_deferred && !rt->flags[RENDER_TARGET_NO_3D]) {
|
||||
|
||||
|
||||
//regular fbo
|
||||
glGenFramebuffers(1, &rt->deferred.fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rt->deferred.fbo);
|
||||
glGenFramebuffers(1, &rt->buffers.fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rt->buffers.fbo);
|
||||
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
|
||||
|
||||
glGenTextures(1, &rt->deferred.albedo_ao);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->deferred.albedo_ao);
|
||||
glGenTextures(1, &rt->buffers.diffuse);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->buffers.diffuse);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, rt->width, rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->deferred.albedo_ao, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->buffers.diffuse, 0);
|
||||
|
||||
glGenTextures(1, &rt->deferred.metal_rough_motion);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->deferred.metal_rough_motion);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, rt->width, rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glGenTextures(1, &rt->buffers.specular);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->buffers.specular);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, rt->width, rt->height, 0, GL_RGBA, GL_HALF_FLOAT, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, rt->deferred.metal_rough_motion, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, rt->buffers.specular, 0);
|
||||
|
||||
glGenTextures(1, &rt->deferred.normal_special);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->deferred.normal_special);
|
||||
glGenTextures(1, &rt->buffers.normal_sr);
|
||||
glBindTexture(GL_TEXTURE_2D, rt->buffers.normal_sr);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, rt->width, rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, rt->deferred.normal_special, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, rt->buffers.normal_sr, 0);
|
||||
|
||||
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
|
@ -3404,17 +3419,13 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE );
|
||||
}
|
||||
|
||||
//regular fbo with color attachment (needed for emission or objects rendered as forward)
|
||||
|
||||
glGenFramebuffers(1, &rt->deferred.fbo_color);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rt->deferred.fbo_color);
|
||||
//alpha fbo
|
||||
glGenFramebuffers(1, &rt->buffers.alpha_fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rt->buffers.alpha_fbo);
|
||||
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->deferred.albedo_ao, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, rt->deferred.metal_rough_motion, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, rt->deferred.normal_special, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, rt->front.color, 0);
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->buffers.diffuse, 0);
|
||||
|
||||
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, config.system_fbo);
|
||||
|
@ -3423,6 +3434,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt){
|
|||
_render_target_clear(rt);
|
||||
ERR_FAIL_COND( status != GL_FRAMEBUFFER_COMPLETE );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -3797,8 +3809,8 @@ bool RasterizerStorageGLES3::free(RID p_rid){
|
|||
|
||||
void RasterizerStorageGLES3::initialize() {
|
||||
|
||||
config.fbo_format=FBOFormat(int(Globals::get_singleton()->get("rendering/gles3/framebuffer_format")));
|
||||
config.fbo_deferred=int(Globals::get_singleton()->get("rendering/gles3/lighting_technique"));
|
||||
config.render_arch=RENDER_ARCH_DESKTOP;
|
||||
//config.fbo_deferred=int(Globals::get_singleton()->get("rendering/gles3/lighting_technique"));
|
||||
|
||||
config.system_fbo=0;
|
||||
|
||||
|
@ -3925,10 +3937,10 @@ void RasterizerStorageGLES3::initialize() {
|
|||
glGenVertexArrays(1,&resources.quadie_array);
|
||||
glBindVertexArray(resources.quadie_array);
|
||||
glBindBuffer(GL_ARRAY_BUFFER,resources.quadie);
|
||||
glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,sizeof(float)*4,0);
|
||||
glVertexAttribPointer(VS::ARRAY_VERTEX,2,GL_FLOAT,GL_FALSE,sizeof(float)*4,0);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(1,2,GL_FLOAT,GL_FALSE,sizeof(float)*4,((uint8_t*)NULL)+8);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(VS::ARRAY_TEX_UV,2,GL_FLOAT,GL_FALSE,sizeof(float)*4,((uint8_t*)NULL)+8);
|
||||
glEnableVertexAttribArray(4);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER,0); //unbind
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
class RasterizerCanvasGLES3;
|
||||
class RasterizerSceneGLES3;
|
||||
|
||||
#define _TEXTURE_SRGB_DECODE_EXT 0x8A48
|
||||
#define _DECODE_EXT 0x8A49
|
||||
#define _SKIP_DECODE_EXT 0x8A4A
|
||||
|
||||
class RasterizerStorageGLES3 : public RasterizerStorage {
|
||||
public:
|
||||
|
@ -20,16 +23,15 @@ public:
|
|||
RasterizerCanvasGLES3 *canvas;
|
||||
RasterizerSceneGLES3 *scene;
|
||||
|
||||
enum FBOFormat {
|
||||
FBO_FORMAT_16_BITS,
|
||||
FBO_FORMAT_32_BITS,
|
||||
FBO_FORMAT_FLOAT,
|
||||
enum RenderArchitecture {
|
||||
RENDER_ARCH_MOBILE,
|
||||
RENDER_ARCH_DESKTOP,
|
||||
};
|
||||
|
||||
struct Config {
|
||||
|
||||
FBOFormat fbo_format;
|
||||
bool fbo_deferred;
|
||||
RenderArchitecture render_arch;
|
||||
|
||||
GLuint system_fbo; //on some devices, such as apple, screen is rendered to yet another fbo.
|
||||
|
||||
bool shrink_textures_x2;
|
||||
|
@ -135,12 +137,15 @@ public:
|
|||
bool active;
|
||||
GLuint tex_id;
|
||||
|
||||
bool using_srgb;
|
||||
|
||||
uint16_t stored_cube_sides;
|
||||
|
||||
RenderTarget *render_target;
|
||||
|
||||
Texture() {
|
||||
|
||||
using_srgb=false;
|
||||
stored_cube_sides=0;
|
||||
ignore_mipmaps=false;
|
||||
render_target=NULL;
|
||||
|
@ -218,6 +223,8 @@ public:
|
|||
|
||||
Map<StringName,RID> default_textures;
|
||||
|
||||
Vector<ShaderLanguage::ShaderNode::Uniform::Hint> texture_hints;
|
||||
|
||||
bool valid;
|
||||
|
||||
String path;
|
||||
|
@ -319,12 +326,14 @@ public:
|
|||
SelfList<Material> list;
|
||||
SelfList<Material> dirty_list;
|
||||
Vector<RID> textures;
|
||||
float line_width;
|
||||
|
||||
uint32_t index;
|
||||
uint64_t last_pass;
|
||||
|
||||
Material() : list(this), dirty_list(this) {
|
||||
shader=NULL;
|
||||
line_width=1.0;
|
||||
ubo_id=0;
|
||||
ubo_size=0;
|
||||
last_pass=0;
|
||||
|
@ -346,6 +355,8 @@ public:
|
|||
virtual void material_set_param(RID p_material, const StringName& p_param, const Variant& p_value);
|
||||
virtual Variant material_get_param(RID p_material, const StringName& p_param) const;
|
||||
|
||||
virtual void material_set_line_width(RID p_material, float p_width);
|
||||
|
||||
void _update_material(Material* material);
|
||||
|
||||
void update_dirty_materials();
|
||||
|
@ -655,14 +666,13 @@ public:
|
|||
|
||||
GLuint depth;
|
||||
|
||||
struct Deferred {
|
||||
struct Buffers {
|
||||
GLuint fbo;
|
||||
GLuint fbo_color;
|
||||
|
||||
GLuint albedo_ao;
|
||||
GLuint metal_rough_motion;
|
||||
GLuint normal_special;
|
||||
} deferred;
|
||||
GLuint alpha_fbo; //single buffer, just diffuse (for alpha pass)
|
||||
GLuint specular;
|
||||
GLuint diffuse;
|
||||
GLuint normal_sr;
|
||||
} buffers;
|
||||
|
||||
int width,height;
|
||||
|
||||
|
@ -679,8 +689,8 @@ public:
|
|||
depth=0;
|
||||
front.fbo=0;
|
||||
back.fbo=0;
|
||||
deferred.fbo=0;
|
||||
deferred.fbo_color=0;
|
||||
buffers.fbo=0;
|
||||
buffers.alpha_fbo=0;
|
||||
used_in_frame=false;
|
||||
|
||||
flags[RENDER_TARGET_VFLIP]=false;
|
||||
|
|
|
@ -75,25 +75,81 @@ static String _mkid(const String& p_id) {
|
|||
return "m_"+p_id;
|
||||
}
|
||||
|
||||
static String f2sp0(float p_float) {
|
||||
|
||||
if (int(p_float)==p_float)
|
||||
return itos(p_float)+".0";
|
||||
else
|
||||
return rtoss(p_float);
|
||||
}
|
||||
|
||||
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value>& p_values) {
|
||||
|
||||
switch(p_type) {
|
||||
case SL::TYPE_BOOL: return p_values[0].boolean?"true":"false";
|
||||
case SL::TYPE_BVEC2: return String()+"bvec2("+(p_values[0].boolean?"true":"false")+(p_values[1].boolean?"true":"false")+")";
|
||||
case SL::TYPE_BVEC3: return String()+"bvec3("+(p_values[0].boolean?"true":"false")+","+(p_values[1].boolean?"true":"false")+","+(p_values[2].boolean?"true":"false")+")";
|
||||
case SL::TYPE_BVEC4: return String()+"bvec4("+(p_values[0].boolean?"true":"false")+","+(p_values[1].boolean?"true":"false")+","+(p_values[2].boolean?"true":"false")+","+(p_values[3].boolean?"true":"false")+")";
|
||||
case SL::TYPE_INT: return rtos(p_values[0].sint);
|
||||
case SL::TYPE_IVEC2: return String()+"ivec2("+rtos(p_values[0].sint)+","+rtos(p_values[1].sint)+")";
|
||||
case SL::TYPE_IVEC3: return String()+"ivec3("+rtos(p_values[0].sint)+","+rtos(p_values[1].sint)+","+rtos(p_values[2].sint)+")";
|
||||
case SL::TYPE_IVEC4: return String()+"ivec4("+rtos(p_values[0].sint)+","+rtos(p_values[1].sint)+","+rtos(p_values[2].sint)+","+rtos(p_values[3].sint)+")";
|
||||
case SL::TYPE_UINT: return rtos(p_values[0].real);
|
||||
case SL::TYPE_UVEC2: return String()+"uvec2("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+")";
|
||||
case SL::TYPE_UVEC3: return String()+"uvec3("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+")";
|
||||
case SL::TYPE_UVEC4: return String()+"uvec4("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+","+rtos(p_values[3].real)+")";
|
||||
case SL::TYPE_FLOAT: return rtos(p_values[0].real);
|
||||
case SL::TYPE_VEC2: return String()+"vec2("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+")";
|
||||
case SL::TYPE_VEC3: return String()+"vec3("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+")";
|
||||
case SL::TYPE_VEC4: return String()+"vec4("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+","+rtos(p_values[3].real)+")";
|
||||
case SL::TYPE_BVEC2:
|
||||
case SL::TYPE_BVEC3:
|
||||
case SL::TYPE_BVEC4: {
|
||||
|
||||
|
||||
String text="bvec"+itos(p_type-SL::TYPE_BOOL+1)+"(";
|
||||
for(int i=0;i<p_values.size();i++) {
|
||||
if (i>0)
|
||||
text+=",";
|
||||
|
||||
text+=p_values[i].boolean?"true":"false";
|
||||
}
|
||||
text+=")";
|
||||
return text;
|
||||
}
|
||||
|
||||
case SL::TYPE_INT: return itos(p_values[0].sint);
|
||||
case SL::TYPE_IVEC2:
|
||||
case SL::TYPE_IVEC3:
|
||||
case SL::TYPE_IVEC4: {
|
||||
|
||||
String text="ivec"+itos(p_type-SL::TYPE_INT+1)+"(";
|
||||
for(int i=0;i<p_values.size();i++) {
|
||||
if (i>0)
|
||||
text+=",";
|
||||
|
||||
text+=itos(p_values[i].sint);
|
||||
}
|
||||
text+=")";
|
||||
return text;
|
||||
|
||||
} break;
|
||||
case SL::TYPE_UINT: return itos(p_values[0].uint)+"u";
|
||||
case SL::TYPE_UVEC2:
|
||||
case SL::TYPE_UVEC3:
|
||||
case SL::TYPE_UVEC4: {
|
||||
|
||||
String text="uvec"+itos(p_type-SL::TYPE_UINT+1)+"(";
|
||||
for(int i=0;i<p_values.size();i++) {
|
||||
if (i>0)
|
||||
text+=",";
|
||||
|
||||
text+=itos(p_values[i].uint)+"u";
|
||||
}
|
||||
text+=")";
|
||||
return text;
|
||||
} break;
|
||||
case SL::TYPE_FLOAT: return f2sp0(p_values[0].real)+"f";
|
||||
case SL::TYPE_VEC2:
|
||||
case SL::TYPE_VEC3:
|
||||
case SL::TYPE_VEC4: {
|
||||
|
||||
String text="vec"+itos(p_type-SL::TYPE_FLOAT+1)+"(";
|
||||
for(int i=0;i<p_values.size();i++) {
|
||||
if (i>0)
|
||||
text+=",";
|
||||
|
||||
text+=f2sp0(p_values[i].real);
|
||||
}
|
||||
text+=")";
|
||||
return text;
|
||||
|
||||
} break;
|
||||
default: ERR_FAIL_V(String());
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +245,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
|
|||
}
|
||||
|
||||
r_gen_code.texture_uniforms.resize(max_texture_uniforms);
|
||||
r_gen_code.texture_hints.resize(max_texture_uniforms);
|
||||
|
||||
Vector<int> uniform_sizes;
|
||||
uniform_sizes.resize(max_uniforms);
|
||||
|
@ -209,6 +266,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
|
|||
r_gen_code.vertex_global+=ucode;
|
||||
r_gen_code.fragment_global+=ucode;
|
||||
r_gen_code.texture_uniforms[E->get().texture_order]=_mkid(E->key());
|
||||
r_gen_code.texture_hints[E->get().texture_order]=E->get().hint;
|
||||
} else {
|
||||
if (r_gen_code.uniforms.empty()) {
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
|
||||
Vector<CharString> defines;
|
||||
Vector<StringName> texture_uniforms;
|
||||
Vector<ShaderLanguage::ShaderNode::Uniform::Hint> texture_hints;
|
||||
|
||||
Vector<uint32_t> uniform_offsets;
|
||||
uint32_t uniform_total_size;
|
||||
String uniforms;
|
||||
|
|
|
@ -5,9 +5,9 @@ layout(location=0) in highp vec4 vertex_attrib;
|
|||
#ifdef USE_CUBEMAP
|
||||
layout(location=4) in vec3 cube_in;
|
||||
#else
|
||||
layout(location=4) in vec2 uv_in; // attrib:4
|
||||
layout(location=4) in vec2 uv_in;
|
||||
#endif
|
||||
layout(location=5) in vec2 uv2_in; // attrib:5
|
||||
layout(location=5) in vec2 uv2_in;
|
||||
|
||||
#ifdef USE_CUBEMAP
|
||||
out vec3 cube_interp;
|
||||
|
@ -40,6 +40,15 @@ uniform sampler2D source; //texunit:0
|
|||
#endif
|
||||
|
||||
|
||||
float sRGB_gamma_correct(float c){
|
||||
float a = 0.055;
|
||||
if(c < 0.0031308)
|
||||
return 12.92*c;
|
||||
else
|
||||
return (1.0+a)*pow(c, 1.0/2.4) - a;
|
||||
}
|
||||
|
||||
|
||||
uniform float stuff;
|
||||
|
||||
in vec2 uv2_interp;
|
||||
|
@ -57,6 +66,20 @@ void main() {
|
|||
vec4 color = texture( source, uv_interp );
|
||||
#endif
|
||||
|
||||
#ifdef LINEAR_TO_SRGB
|
||||
//regular Linear -> SRGB conversion
|
||||
vec3 a = vec3(0.055);
|
||||
color.rgb = mix( (vec3(1.0)+a)*pow(color.rgb,vec3(1.0/2.4))-a , 12.92*color.rgb , lessThan(color.rgb,vec3(0.0031308)));
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_GRADIENT
|
||||
color.rg=uv_interp;
|
||||
color.b=0.0;
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_ALPHA
|
||||
color.a=1.0;
|
||||
#endif
|
||||
|
||||
frag_color = color;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
layout(location=0) in highp vec2 vertex;
|
||||
|
||||
layout(location=1) in highp vec2 uv;
|
||||
layout(location=4) in highp vec2 uv;
|
||||
|
||||
out highp vec2 uv_interp;
|
||||
|
||||
|
|
|
@ -269,11 +269,16 @@ in vec3 normal_interp;
|
|||
|
||||
/* PBR CHANNELS */
|
||||
|
||||
//used on forward mainly
|
||||
uniform bool no_ambient_light;
|
||||
|
||||
|
||||
#ifdef USE_RADIANCE_CUBEMAP
|
||||
|
||||
uniform sampler2D brdf_texture; //texunit:-1
|
||||
uniform samplerCube radiance_cube; //texunit:-2
|
||||
|
||||
|
||||
layout(std140) uniform Radiance { //ubo:2
|
||||
|
||||
mat4 radiance_inverse_xform;
|
||||
|
@ -346,8 +351,18 @@ in mediump vec4 forward_shadow_pos4;
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef USE_MULTIPLE_RENDER_TARGETS
|
||||
|
||||
layout(location=0) out vec4 diffuse_buffer;
|
||||
layout(location=1) out vec4 specular_buffer;
|
||||
layout(location=2) out vec4 normal_mr_buffer;
|
||||
|
||||
#else
|
||||
|
||||
layout(location=0) out vec4 frag_color;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// GGX Specular
|
||||
// Source: http://www.filmicworlds.com/images/ggx-opt/optimized-ggx.hlsl
|
||||
|
@ -470,13 +485,16 @@ FRAGMENT_SHADER_CODE
|
|||
/////////////////////// LIGHTING //////////////////////////////
|
||||
|
||||
vec3 specular_light = vec3(0.0,0.0,0.0);
|
||||
vec3 ambient_light = ambient_light_color.rgb;
|
||||
vec3 ambient_light;
|
||||
vec3 diffuse_light = vec3(0.0,0.0,0.0);
|
||||
|
||||
vec3 eye_vec = -normalize( vertex_interp );
|
||||
|
||||
#ifdef USE_RADIANCE_CUBEMAP
|
||||
|
||||
if (no_ambient_light) {
|
||||
ambient_light=vec3(0.0,0.0,0.0);
|
||||
} else {
|
||||
{
|
||||
|
||||
float ndotv = clamp(dot(normal,eye_vec),0.0,1.0);
|
||||
|
@ -496,13 +514,17 @@ FRAGMENT_SHADER_CODE
|
|||
vec3 ambient_dir=normalize((radiance_inverse_xform * vec4(normal,0.0)).xyz);
|
||||
vec3 env_ambient=textureLod(radiance_cube, ambient_dir, 5.0).xyz;
|
||||
|
||||
ambient_light=mix(ambient_light,env_ambient,radiance_ambient_contribution);
|
||||
ambient_light=mix(ambient_light_color.rgb,env_ambient,radiance_ambient_contribution);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
ambient_light=albedo;
|
||||
if (no_ambient_light){
|
||||
ambient_light=vec3(0.0,0.0,0.0);
|
||||
} else {
|
||||
ambient_light=ambient_light_color.rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -538,11 +560,25 @@ LIGHT_SHADER_CODE
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef SHADELESS
|
||||
#ifdef USE_MULTIPLE_RENDER_TARGETS
|
||||
|
||||
//approximate ambient scale for SSAO, since we will lack full ambient
|
||||
float max_ambient=max(ambient_light.r,max(ambient_light.g,ambient_light.b));
|
||||
float max_diffuse=max(diffuse_light.r,max(diffuse_light.g,diffuse_light.b));
|
||||
float total_ambient = max_ambient+max_diffuse;
|
||||
float ambient_scale = (total_ambient>0.0) ? max_ambient/total_ambient : 0.0;
|
||||
|
||||
diffuse_buffer=vec4(diffuse_light+ambient_light,ambient_scale);
|
||||
specular_buffer=vec4(specular_light,0.0);
|
||||
normal_mr_buffer=vec4(normal.x,normal.y,max(specular.r,max(specular.g,specular.b)),roughness);
|
||||
|
||||
#else
|
||||
|
||||
#ifdef SHADELESS
|
||||
frag_color=vec4(albedo,alpha);
|
||||
#else
|
||||
frag_color=vec4(ambient_light+diffuse_light+specular_light,alpha);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@ def build_glsl_header( filename ):
|
|||
|
||||
fd.write("\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n");
|
||||
fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; ERR_FAIL_COND( get_active()!=this );\n\n ");
|
||||
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, bool p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value?1:0); }\n\n");
|
||||
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n");
|
||||
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n");
|
||||
fd.write("\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n");
|
||||
|
|
|
@ -97,6 +97,7 @@ public:
|
|||
FLAG_MAX=VS::INSTANCE_FLAG_MAX,
|
||||
};
|
||||
|
||||
|
||||
enum ShadowCastingSetting {
|
||||
SHADOW_CASTING_SETTING_OFF=VS::SHADOW_CASTING_SETTING_OFF,
|
||||
SHADOW_CASTING_SETTING_ON = VS::SHADOW_CASTING_SETTING_ON,
|
||||
|
|
|
@ -134,6 +134,151 @@ float Environment::get_ambient_light_skybox_contribution() const{
|
|||
|
||||
|
||||
|
||||
void Environment::set_tonemapper(ToneMapper p_tone_mapper) {
|
||||
|
||||
tone_mapper=p_tone_mapper;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
}
|
||||
|
||||
Environment::ToneMapper Environment::get_tonemapper() const{
|
||||
|
||||
return tone_mapper;
|
||||
}
|
||||
|
||||
void Environment::set_tonemap_exposure(float p_exposure){
|
||||
|
||||
tonemap_exposure=p_exposure;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
}
|
||||
|
||||
float Environment::get_tonemap_exposure() const{
|
||||
|
||||
return get_tonemap_auto_exposure();
|
||||
}
|
||||
|
||||
void Environment::set_tonemap_white(float p_white){
|
||||
|
||||
tonemap_white=p_white;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
|
||||
}
|
||||
float Environment::get_tonemap_white() const {
|
||||
|
||||
return tonemap_white;
|
||||
}
|
||||
|
||||
void Environment::set_tonemap_auto_exposure(bool p_enabled) {
|
||||
|
||||
tonemap_auto_exposure=p_enabled;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
|
||||
}
|
||||
bool Environment::get_tonemap_auto_exposure() const {
|
||||
|
||||
return tonemap_auto_exposure;
|
||||
}
|
||||
|
||||
void Environment::set_tonemap_auto_exposure_max(float p_auto_exposure_max) {
|
||||
|
||||
tonemap_auto_exposure_max=p_auto_exposure_max;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
|
||||
}
|
||||
float Environment::get_tonemap_auto_exposure_max() const {
|
||||
|
||||
return tonemap_auto_exposure_max;
|
||||
}
|
||||
|
||||
void Environment::set_tonemap_auto_exposure_min(float p_auto_exposure_min) {
|
||||
|
||||
tonemap_auto_exposure_min=p_auto_exposure_min;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
|
||||
}
|
||||
float Environment::get_tonemap_auto_exposure_min() const {
|
||||
|
||||
return tonemap_auto_exposure_min;
|
||||
}
|
||||
|
||||
void Environment::set_tonemap_auto_exposure_speed(float p_auto_exposure_speed) {
|
||||
|
||||
tonemap_auto_exposure_speed=p_auto_exposure_speed;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
|
||||
}
|
||||
float Environment::get_tonemap_auto_exposure_speed() const {
|
||||
|
||||
return tonemap_auto_exposure_speed;
|
||||
}
|
||||
|
||||
void Environment::set_tonemap_auto_exposure_scale(float p_auto_exposure_scale) {
|
||||
|
||||
tonemap_auto_exposure_scale=p_auto_exposure_scale;
|
||||
VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper));
|
||||
|
||||
}
|
||||
float Environment::get_tonemap_auto_exposure_scale() const {
|
||||
|
||||
return tonemap_auto_exposure_scale;
|
||||
}
|
||||
|
||||
void Environment::set_adjustment_enable(bool p_enable) {
|
||||
|
||||
adjustment_enabled=p_enable;
|
||||
VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
|
||||
}
|
||||
|
||||
bool Environment::is_adjustment_enabled() const {
|
||||
|
||||
return adjustment_enabled;
|
||||
}
|
||||
|
||||
|
||||
void Environment::set_adjustment_brightness(float p_brightness) {
|
||||
|
||||
adjustment_brightness=p_brightness;
|
||||
VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
|
||||
|
||||
}
|
||||
float Environment::get_adjustment_brightness() const {
|
||||
|
||||
return adjustment_brightness;
|
||||
}
|
||||
|
||||
void Environment::set_adjustment_contrast(float p_contrast) {
|
||||
|
||||
adjustment_contrast=p_contrast;
|
||||
VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
|
||||
|
||||
}
|
||||
float Environment::get_adjustment_contrast() const {
|
||||
|
||||
return adjustment_contrast;
|
||||
}
|
||||
|
||||
void Environment::set_adjustment_saturation(float p_saturation) {
|
||||
|
||||
adjustment_saturation=p_saturation;
|
||||
VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
|
||||
|
||||
}
|
||||
float Environment::get_adjustment_saturation() const {
|
||||
|
||||
return adjustment_saturation;
|
||||
}
|
||||
|
||||
void Environment::set_adjustment_color_correction(const Ref<Texture>& p_ramp) {
|
||||
|
||||
adjustment_color_correction=p_ramp;
|
||||
VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
|
||||
|
||||
}
|
||||
Ref<Texture> Environment::get_adjustment_color_correction() const {
|
||||
|
||||
return adjustment_color_correction;
|
||||
}
|
||||
|
||||
|
||||
void Environment::_validate_property(PropertyInfo& property) const {
|
||||
|
||||
if (property.name=="background/skybox" || property.name=="background/skybox_scale" || property.name=="ambient_light/skybox_contribution") {
|
||||
|
@ -190,6 +335,61 @@ void Environment::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light/energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_ambient_light_energy"),_SCS("get_ambient_light_energy") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light/skybox_contribution",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_ambient_light_skybox_contribution"),_SCS("get_ambient_light_skybox_contribution") );
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemapper","mode"),&Environment::set_tonemapper);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemapper"),&Environment::get_tonemapper);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemap_exposure","exposure"),&Environment::set_tonemap_exposure);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemap_exposure"),&Environment::get_tonemap_exposure);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemap_white","white"),&Environment::set_tonemap_white);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemap_white"),&Environment::get_tonemap_white);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure","auto_exposure"),&Environment::set_tonemap_auto_exposure);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure"),&Environment::get_tonemap_auto_exposure);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_max","exposure_max"),&Environment::set_tonemap_auto_exposure_max);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_max"),&Environment::get_tonemap_auto_exposure_max);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_min","exposure_min"),&Environment::set_tonemap_auto_exposure_min);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_min"),&Environment::get_tonemap_auto_exposure_min);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_speed","exposure_speed"),&Environment::set_tonemap_auto_exposure_speed);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_speed"),&Environment::get_tonemap_auto_exposure_speed);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_scale","exposure_scale"),&Environment::set_tonemap_auto_exposure_scale);
|
||||
ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_scale"),&Environment::get_tonemap_auto_exposure_scale);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"tonemap/mode",PROPERTY_HINT_ENUM,"Linear,Log,Reindhart,Filmic,Aces"),_SCS("set_tonemapper"),_SCS("get_tonemapper") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap/exposure",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_exposure"),_SCS("get_tonemap_exposure") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap/white",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_white"),_SCS("get_tonemap_white") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"auto_exposure/enable"),_SCS("set_tonemap_auto_exposure"),_SCS("get_tonemap_auto_exposure") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_scale"),_SCS("get_tonemap_auto_exposure_scale") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/min_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_min"),_SCS("get_tonemap_auto_exposure_min") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/max_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_max"),_SCS("get_tonemap_auto_exposure_max") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/speed",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_speed"),_SCS("get_tonemap_auto_exposure_speed") );
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_adjustment_enable","enabled"),&Environment::set_adjustment_enable);
|
||||
ObjectTypeDB::bind_method(_MD("is_adjustment_enabled"),&Environment::is_adjustment_enabled);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_adjustment_brightness","brightness"),&Environment::set_adjustment_brightness);
|
||||
ObjectTypeDB::bind_method(_MD("get_adjustment_brightness"),&Environment::get_adjustment_brightness);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_adjustment_contrast","contrast"),&Environment::set_adjustment_contrast);
|
||||
ObjectTypeDB::bind_method(_MD("get_adjustment_contrast"),&Environment::get_adjustment_contrast);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_adjustment_saturation","saturation"),&Environment::set_adjustment_saturation);
|
||||
ObjectTypeDB::bind_method(_MD("get_adjustment_saturation"),&Environment::get_adjustment_saturation);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_adjustment_color_correction","color_correction"),&Environment::set_adjustment_color_correction);
|
||||
ObjectTypeDB::bind_method(_MD("get_adjustment_color_correction"),&Environment::get_adjustment_color_correction);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"adjustment/enabled"),_SCS("set_adjustment_enable"),_SCS("is_adjustment_enabled") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment/brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_brightness"),_SCS("get_adjustment_brightness") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment/contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_contrast"),_SCS("get_adjustment_contrast") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment/saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_saturation"),_SCS("get_adjustment_saturation") );
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"adjustment/color_correction",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_adjustment_color_correction"),_SCS("get_adjustment_color_correction") );
|
||||
|
||||
|
||||
GLOBAL_DEF("rendering/skybox/irradiance_cube_resolution",256);
|
||||
GLOBAL_DEF("rendering/skybox/radiance_cube_resolution",64);
|
||||
|
||||
|
@ -203,6 +403,12 @@ void Environment::_bind_methods() {
|
|||
BIND_CONSTANT(GLOW_BLEND_MODE_SCREEN);
|
||||
BIND_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
|
||||
BIND_CONSTANT(GLOW_BLEND_MODE_DISABLED);
|
||||
BIND_CONSTANT(TONE_MAPPER_LINEAR);
|
||||
BIND_CONSTANT(TONE_MAPPER_LOG);
|
||||
BIND_CONSTANT(TONE_MAPPER_REINHARDT);
|
||||
BIND_CONSTANT(TONE_MAPPER_FILMIC);
|
||||
BIND_CONSTANT(TONE_MAPPER_ACES_FILMIC);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -216,6 +422,24 @@ Environment::Environment() {
|
|||
ambient_skybox_contribution=0;
|
||||
|
||||
|
||||
tone_mapper=TONE_MAPPER_LINEAR;
|
||||
tonemap_exposure=1.0;
|
||||
tonemap_white=1.0;
|
||||
tonemap_auto_exposure=false;
|
||||
tonemap_auto_exposure_max=8;
|
||||
tonemap_auto_exposure_min=0.4;
|
||||
tonemap_auto_exposure_speed=0.5;
|
||||
tonemap_auto_exposure_scale=0.4;
|
||||
|
||||
set_tonemapper(tone_mapper); //update
|
||||
|
||||
adjustment_enabled=false;
|
||||
adjustment_contrast=1.0;
|
||||
adjustment_saturation=1.0;
|
||||
adjustment_brightness=1.0;
|
||||
|
||||
set_adjustment_enable(adjustment_enabled); //update
|
||||
|
||||
environment = VS::get_singleton()->environment_create();
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,16 @@ public:
|
|||
GLOW_BLEND_MODE_DISABLED,
|
||||
};
|
||||
|
||||
enum ToneMapper {
|
||||
TONE_MAPPER_LINEAR,
|
||||
TONE_MAPPER_LOG,
|
||||
TONE_MAPPER_REINHARDT,
|
||||
TONE_MAPPER_FILMIC,
|
||||
TONE_MAPPER_ACES_FILMIC
|
||||
};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
RID environment;
|
||||
|
||||
|
@ -68,6 +78,21 @@ private:
|
|||
float ambient_energy;
|
||||
float ambient_skybox_contribution;
|
||||
|
||||
ToneMapper tone_mapper;
|
||||
float tonemap_exposure;
|
||||
float tonemap_white;
|
||||
bool tonemap_auto_exposure;
|
||||
float tonemap_auto_exposure_max;
|
||||
float tonemap_auto_exposure_min;
|
||||
float tonemap_auto_exposure_speed;
|
||||
float tonemap_auto_exposure_scale;
|
||||
|
||||
bool adjustment_enabled;
|
||||
float adjustment_contrast;
|
||||
float adjustment_saturation;
|
||||
float adjustment_brightness;
|
||||
Ref<Texture> adjustment_color_correction;
|
||||
|
||||
protected:
|
||||
|
||||
static void _bind_methods();
|
||||
|
@ -97,14 +122,58 @@ public:
|
|||
float get_ambient_light_skybox_contribution() const;
|
||||
|
||||
|
||||
void set_tonemapper(ToneMapper p_tone_mapper);
|
||||
ToneMapper get_tonemapper() const;
|
||||
|
||||
void set_tonemap_exposure(float p_exposure);
|
||||
float get_tonemap_exposure() const;
|
||||
|
||||
void set_tonemap_white(float p_white);
|
||||
float get_tonemap_white() const;
|
||||
|
||||
void set_tonemap_auto_exposure(bool p_enabled);
|
||||
bool get_tonemap_auto_exposure() const;
|
||||
|
||||
void set_tonemap_auto_exposure_max(float p_auto_exposure_max);
|
||||
float get_tonemap_auto_exposure_max() const;
|
||||
|
||||
void set_tonemap_auto_exposure_min(float p_auto_exposure_min);
|
||||
float get_tonemap_auto_exposure_min() const;
|
||||
|
||||
void set_tonemap_auto_exposure_speed(float p_auto_exposure_speed);
|
||||
float get_tonemap_auto_exposure_speed() const;
|
||||
|
||||
void set_tonemap_auto_exposure_scale(float p_auto_exposure_scale);
|
||||
float get_tonemap_auto_exposure_scale() const;
|
||||
|
||||
void set_adjustment_enable(bool p_enable);
|
||||
bool is_adjustment_enabled() const;
|
||||
|
||||
void set_adjustment_brightness(float p_brightness);
|
||||
float get_adjustment_brightness() const;
|
||||
|
||||
void set_adjustment_contrast(float p_contrast);
|
||||
float get_adjustment_contrast() const;
|
||||
|
||||
void set_adjustment_saturation(float p_saturation);
|
||||
float get_adjustment_saturation() const;
|
||||
|
||||
void set_adjustment_color_correction(const Ref<Texture>& p_ramp);
|
||||
Ref<Texture> get_adjustment_color_correction() const;
|
||||
|
||||
|
||||
virtual RID get_rid() const;
|
||||
|
||||
Environment();
|
||||
~Environment();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
VARIANT_ENUM_CAST(Environment::BGMode)
|
||||
VARIANT_ENUM_CAST(Environment::GlowBlendMode)
|
||||
VARIANT_ENUM_CAST(Environment::ToneMapper)
|
||||
|
||||
|
||||
#endif // ENVIRONMENT_H
|
||||
|
|
|
@ -74,6 +74,7 @@ void FixedSpatialMaterial::init_shaders() {
|
|||
shader_names->subsurface_scattering="subsurface_scattering";
|
||||
shader_names->refraction="refraction";
|
||||
shader_names->refraction_roughness="refraction_roughness";
|
||||
shader_names->point_size="point_size";
|
||||
|
||||
shader_names->texture_names[TEXTURE_ALBEDO]="texture_albedo";
|
||||
shader_names->texture_names[TEXTURE_SPECULAR]="texture_specular";
|
||||
|
@ -166,15 +167,33 @@ void FixedSpatialMaterial::_update_shader() {
|
|||
|
||||
|
||||
code+="uniform vec4 albedo : hint_color;\n";
|
||||
code+="uniform sampler2D albedo_texture : hint_albedo;\n";
|
||||
code+="uniform sampler2D texture_albedo : hint_albedo;\n";
|
||||
code+="uniform vec4 specular : hint_color;\n";
|
||||
code+="uniform float roughness : hint_range(0,1);\n";
|
||||
code+="uniform sampler2D specular_texture : hint_white;\n";
|
||||
code+="uniform float point_size : hint_range(0,128);\n";
|
||||
code+="uniform sampler2D texture_specular : hint_white;\n";
|
||||
code+="\n\n";
|
||||
|
||||
code+="void vertex() {\n";
|
||||
|
||||
if (flags[FLAG_SRGB_VERTEX_COLOR]) {
|
||||
|
||||
code+="\tCOLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) );\n";
|
||||
}
|
||||
if (flags[FLAG_USE_POINT_SIZE]) {
|
||||
|
||||
code+="\tPOINT_SIZE=point_size;\n";
|
||||
}
|
||||
|
||||
code+="}\n";
|
||||
code+="\n\n";
|
||||
code+="void fragment() {\n";
|
||||
code+="\tvec4 albedo_tex = texture(albedo_texture,UV);\n";
|
||||
|
||||
if (flags[FLAG_USE_POINT_SIZE]) {
|
||||
code+="\tvec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n";
|
||||
} else {
|
||||
code+="\tvec4 albedo_tex = texture(texture_albedo,UV);\n";
|
||||
}
|
||||
|
||||
if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) {
|
||||
code+="\talbedo_tex *= COLOR;\n";
|
||||
|
@ -184,7 +203,7 @@ void FixedSpatialMaterial::_update_shader() {
|
|||
if (features[FEATURE_TRANSPARENT]) {
|
||||
code+="\tALPHA = albedo.a * albedo_tex.a;\n";
|
||||
}
|
||||
code+="\tvec4 specular_tex = texture(specular_texture,UV);\n";
|
||||
code+="\tvec4 specular_tex = texture(texture_specular,UV);\n";
|
||||
code+="\tSPECULAR = specular.rgb * specular_tex.rgb;\n";
|
||||
code+="\tROUGHNESS = specular.a * roughness;\n";
|
||||
code+="}\n";
|
||||
|
@ -526,7 +545,8 @@ void FixedSpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture>
|
|||
|
||||
ERR_FAIL_INDEX(p_param,TEXTURE_MAX);
|
||||
textures[p_param]=p_texture;
|
||||
VS::get_singleton()->material_set_param(_get_material(),shader_names->texture_names[p_param],p_texture);
|
||||
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
|
||||
VS::get_singleton()->material_set_param(_get_material(),shader_names->texture_names[p_param],rid);
|
||||
}
|
||||
|
||||
Ref<Texture> FixedSpatialMaterial::get_texture(TextureParam p_param) const {
|
||||
|
@ -540,6 +560,7 @@ void FixedSpatialMaterial::_validate_feature(const String& text, Feature feature
|
|||
if (property.name.begins_with(text) && property.name!=text+"/enabled" && !features[feature]) {
|
||||
property.usage=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FixedSpatialMaterial::_validate_property(PropertyInfo& property) const {
|
||||
|
@ -555,6 +576,28 @@ void FixedSpatialMaterial::_validate_property(PropertyInfo& property) const {
|
|||
|
||||
}
|
||||
|
||||
void FixedSpatialMaterial::set_line_width(float p_line_width) {
|
||||
|
||||
line_width=p_line_width;
|
||||
VS::get_singleton()->material_set_line_width(_get_material(),line_width);
|
||||
}
|
||||
|
||||
float FixedSpatialMaterial::get_line_width() const {
|
||||
|
||||
return line_width;
|
||||
}
|
||||
|
||||
void FixedSpatialMaterial::set_point_size(float p_point_size) {
|
||||
|
||||
point_size=p_point_size;
|
||||
VS::get_singleton()->material_set_param(_get_material(),shader_names->point_size,p_point_size);
|
||||
}
|
||||
|
||||
float FixedSpatialMaterial::get_point_size() const {
|
||||
|
||||
return point_size;
|
||||
}
|
||||
|
||||
void FixedSpatialMaterial::_bind_methods() {
|
||||
|
||||
|
||||
|
@ -600,6 +643,12 @@ void FixedSpatialMaterial::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("set_refraction_roughness","refraction_roughness"),&FixedSpatialMaterial::set_refraction_roughness);
|
||||
ObjectTypeDB::bind_method(_MD("get_refraction_roughness"),&FixedSpatialMaterial::get_refraction_roughness);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_line_width","line_width"),&FixedSpatialMaterial::set_line_width);
|
||||
ObjectTypeDB::bind_method(_MD("get_line_width"),&FixedSpatialMaterial::get_line_width);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_point_size","point_size"),&FixedSpatialMaterial::set_point_size);
|
||||
ObjectTypeDB::bind_method(_MD("get_point_size"),&FixedSpatialMaterial::get_point_size);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_detail_uv","detail_uv"),&FixedSpatialMaterial::set_detail_uv);
|
||||
ObjectTypeDB::bind_method(_MD("get_detail_uv"),&FixedSpatialMaterial::get_detail_uv);
|
||||
|
||||
|
@ -630,12 +679,16 @@ void FixedSpatialMaterial::_bind_methods() {
|
|||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/transparent"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_TRANSPARENT);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/unshaded"),_SCS("set_flag"),_SCS("get_flag"),FLAG_UNSHADED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/on_top"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ONTOP);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/vcol_albedo"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ALBEDO_FROM_VERTEX_COLOR);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/use_point_size"),_SCS("set_flag"),_SCS("get_flag"),FLAG_USE_POINT_SIZE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color/use_as_albedo"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ALBEDO_FROM_VERTEX_COLOR);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color/is_srgb"),_SCS("set_flag"),_SCS("get_flag"),FLAG_SRGB_VERTEX_COLOR);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"params/diffuse_mode",PROPERTY_HINT_ENUM,"Labert,Lambert Wrap,Oren Nayar,Burley"),_SCS("set_diffuse_mode"),_SCS("get_diffuse_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),_SCS("set_blend_mode"),_SCS("get_blend_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"params/cull_mode",PROPERTY_HINT_ENUM,"Back,Front,Disabled"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"params/depth_draw_mode",PROPERTY_HINT_ENUM,"Opaque Only,Always,Never,Opaque Pre-Pass"),_SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"params/line_width",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_line_width"),_SCS("get_line_width"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL,"params/point_size",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_point_size"),_SCS("get_point_size"));
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR,"albedo/color"),_SCS("set_albedo"),_SCS("get_albedo"));
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"albedo/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_ALBEDO);
|
||||
|
@ -737,6 +790,8 @@ void FixedSpatialMaterial::_bind_methods() {
|
|||
BIND_CONSTANT( FLAG_UNSHADED );
|
||||
BIND_CONSTANT( FLAG_ONTOP );
|
||||
BIND_CONSTANT( FLAG_ALBEDO_FROM_VERTEX_COLOR );
|
||||
BIND_CONSTANT( FLAG_SRGB_VERTEX_COLOR )
|
||||
BIND_CONSTANT( FLAG_USE_POINT_SIZE )
|
||||
BIND_CONSTANT( FLAG_MAX );
|
||||
|
||||
BIND_CONSTANT( DIFFUSE_LAMBERT );
|
||||
|
@ -763,6 +818,8 @@ FixedSpatialMaterial::FixedSpatialMaterial() : element(this) {
|
|||
set_subsurface_scattering(0);
|
||||
set_refraction(0);
|
||||
set_refraction_roughness(0);
|
||||
set_line_width(1);
|
||||
set_point_size(1);
|
||||
|
||||
detail_uv=DETAIL_UV_1;
|
||||
blend_mode=BLEND_MODE_MIX;
|
||||
|
|
|
@ -132,6 +132,8 @@ public:
|
|||
FLAG_UNSHADED,
|
||||
FLAG_ONTOP,
|
||||
FLAG_ALBEDO_FROM_VERTEX_COLOR,
|
||||
FLAG_SRGB_VERTEX_COLOR,
|
||||
FLAG_USE_POINT_SIZE,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
|
@ -146,12 +148,12 @@ private:
|
|||
union MaterialKey {
|
||||
|
||||
struct {
|
||||
uint32_t feature_mask : 16;
|
||||
uint32_t feature_mask : 15;
|
||||
uint32_t detail_uv : 1;
|
||||
uint32_t blend_mode : 2;
|
||||
uint32_t depth_draw_mode : 2;
|
||||
uint32_t cull_mode : 2;
|
||||
uint32_t flags : 3;
|
||||
uint32_t flags : 5;
|
||||
uint32_t detail_blend_mode : 2;
|
||||
uint32_t diffuse_mode : 2;
|
||||
uint32_t invalid_key : 1;
|
||||
|
@ -213,7 +215,9 @@ private:
|
|||
StringName subsurface_scattering;
|
||||
StringName refraction;
|
||||
StringName refraction_roughness;
|
||||
StringName point_size;
|
||||
StringName texture_names[TEXTURE_MAX];
|
||||
|
||||
};
|
||||
|
||||
static Mutex *material_mutex;
|
||||
|
@ -240,6 +244,8 @@ private:
|
|||
float subsurface_scattering;
|
||||
float refraction;
|
||||
float refraction_roughness;
|
||||
float line_width;
|
||||
float point_size;
|
||||
|
||||
DetailUV detail_uv;
|
||||
|
||||
|
@ -306,6 +312,12 @@ public:
|
|||
void set_refraction_roughness(float p_refraction_roughness);
|
||||
float get_refraction_roughness() const;
|
||||
|
||||
void set_line_width(float p_line_width);
|
||||
float get_line_width() const;
|
||||
|
||||
void set_point_size(float p_point_size);
|
||||
float get_point_size() const;
|
||||
|
||||
void set_detail_uv(DetailUV p_detail_uv);
|
||||
DetailUV get_detail_uv() const;
|
||||
|
||||
|
|
|
@ -54,11 +54,8 @@ public:
|
|||
virtual void environment_set_glow(RID p_env,bool p_enable,int p_radius,float p_intensity,float p_strength,float p_bloom_treshold,VS::EnvironmentGlowBlendMode p_blend_mode)=0;
|
||||
virtual void environment_set_fog(RID p_env,bool p_enable,float p_begin,float p_end,RID p_gradient_texture)=0;
|
||||
|
||||
virtual void environment_set_tonemap(RID p_env,bool p_enable,float p_exposure,float p_white,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,VS::EnvironmentToneMapper p_tone_mapper)=0;
|
||||
virtual void environment_set_brightness(RID p_env,bool p_enable,float p_brightness)=0;
|
||||
virtual void environment_set_contrast(RID p_env,bool p_enable,float p_contrast)=0;
|
||||
virtual void environment_set_saturation(RID p_env,bool p_enable,float p_saturation)=0;
|
||||
virtual void environment_set_color_correction(RID p_env,bool p_enable,RID p_ramp)=0;
|
||||
virtual void environment_set_tonemap(RID p_env,bool p_enable,float p_exposure,float p_white,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,float p_auto_exp_scale,VS::EnvironmentToneMapper p_tone_mapper)=0;
|
||||
virtual void environment_set_adjustment(RID p_env,bool p_enable,float p_brightness,float p_contrast,float p_saturation,RID p_ramp)=0;
|
||||
|
||||
struct InstanceBase : RID_Data {
|
||||
|
||||
|
@ -176,6 +173,8 @@ public:
|
|||
virtual void material_set_param(RID p_material, const StringName& p_param, const Variant& p_value)=0;
|
||||
virtual Variant material_get_param(RID p_material, const StringName& p_param) const=0;
|
||||
|
||||
virtual void material_set_line_width(RID p_material, float p_width)=0;
|
||||
|
||||
/* MESH API */
|
||||
|
||||
virtual RID mesh_create()=0;
|
||||
|
|
|
@ -658,6 +658,10 @@ public:
|
|||
BIND3(material_set_param,RID, const StringName&, const Variant& )
|
||||
BIND2RC(Variant,material_get_param,RID, const StringName& )
|
||||
|
||||
BIND2(material_set_line_width,RID, float )
|
||||
|
||||
|
||||
|
||||
/* MESH API */
|
||||
|
||||
BIND0R(RID,mesh_create)
|
||||
|
@ -864,11 +868,8 @@ public:
|
|||
BIND7(environment_set_glow,RID,bool ,int ,float ,float ,float ,EnvironmentGlowBlendMode )
|
||||
BIND5(environment_set_fog,RID,bool ,float ,float ,RID )
|
||||
|
||||
BIND8(environment_set_tonemap,RID,bool ,float ,float ,float ,float ,float ,EnvironmentToneMapper )
|
||||
BIND3(environment_set_brightness,RID,bool ,float )
|
||||
BIND3(environment_set_contrast,RID,bool ,float )
|
||||
BIND3(environment_set_saturation,RID,bool ,float )
|
||||
BIND3(environment_set_color_correction,RID,bool ,RID )
|
||||
BIND9(environment_set_tonemap,RID,bool ,float ,float ,float ,float ,float,float ,EnvironmentToneMapper )
|
||||
BIND6(environment_set_adjustment,RID,bool ,float ,float ,float ,RID )
|
||||
|
||||
|
||||
/* SCENARIO API */
|
||||
|
|
|
@ -692,22 +692,82 @@ void VisualServerScene::instance_set_extra_visibility_margin( RID p_instance, re
|
|||
|
||||
}
|
||||
|
||||
// don't use these in a game!
|
||||
Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB& p_aabb, RID p_scenario) const{
|
||||
Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB& p_aabb, RID p_scenario) const {
|
||||
|
||||
return Vector<ObjectID>();
|
||||
|
||||
Vector<ObjectID> instances;
|
||||
Scenario *scenario=scenario_owner.get(p_scenario);
|
||||
ERR_FAIL_COND_V(!scenario,instances);
|
||||
|
||||
const_cast<VisualServerScene*>(this)->update_dirty_instances(); // check dirty instances before culling
|
||||
|
||||
int culled=0;
|
||||
Instance *cull[1024];
|
||||
culled=scenario->octree.cull_AABB(p_aabb,cull,1024);
|
||||
|
||||
for (int i=0;i<culled;i++) {
|
||||
|
||||
Instance *instance=cull[i];
|
||||
ERR_CONTINUE(!instance);
|
||||
if (instance->object_ID==0)
|
||||
continue;
|
||||
|
||||
instances.push_back(instance->object_ID);
|
||||
}
|
||||
|
||||
return instances;
|
||||
}
|
||||
|
||||
Vector<ObjectID> VisualServerScene::instances_cull_ray(const Vector3& p_from, const Vector3& p_to, RID p_scenario) const{
|
||||
|
||||
return Vector<ObjectID>();
|
||||
}
|
||||
Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane>& p_convex, RID p_scenario) const {
|
||||
Vector<ObjectID> instances;
|
||||
Scenario *scenario=scenario_owner.get(p_scenario);
|
||||
ERR_FAIL_COND_V(!scenario,instances);
|
||||
const_cast<VisualServerScene*>(this)->update_dirty_instances(); // check dirty instances before culling
|
||||
|
||||
return Vector<ObjectID>();
|
||||
}
|
||||
int culled=0;
|
||||
Instance *cull[1024];
|
||||
culled=scenario->octree.cull_segment(p_from,p_to*10000,cull,1024);
|
||||
|
||||
|
||||
for (int i=0;i<culled;i++) {
|
||||
Instance *instance=cull[i];
|
||||
ERR_CONTINUE(!instance);
|
||||
if (instance->object_ID==0)
|
||||
continue;
|
||||
|
||||
instances.push_back(instance->object_ID);
|
||||
}
|
||||
|
||||
return instances;
|
||||
|
||||
}
|
||||
Vector<ObjectID> VisualServerScene::instances_cull_convex(const Vector<Plane>& p_convex, RID p_scenario) const{
|
||||
|
||||
Vector<ObjectID> instances;
|
||||
Scenario *scenario=scenario_owner.get(p_scenario);
|
||||
ERR_FAIL_COND_V(!scenario,instances);
|
||||
const_cast<VisualServerScene*>(this)->update_dirty_instances(); // check dirty instances before culling
|
||||
|
||||
int culled=0;
|
||||
Instance *cull[1024];
|
||||
|
||||
|
||||
culled=scenario->octree.cull_convex(p_convex,cull,1024);
|
||||
|
||||
for (int i=0;i<culled;i++) {
|
||||
|
||||
Instance *instance=cull[i];
|
||||
ERR_CONTINUE(!instance);
|
||||
if (instance->object_ID==0)
|
||||
continue;
|
||||
|
||||
instances.push_back(instance->object_ID);
|
||||
}
|
||||
|
||||
return instances;
|
||||
|
||||
}
|
||||
|
||||
void VisualServerScene::instance_geometry_set_flag(RID p_instance,VS::InstanceFlags p_flags,bool p_enabled){
|
||||
|
||||
Instance *instance = instance_owner.get( p_instance );
|
||||
|
|
|
@ -162,7 +162,7 @@ public:
|
|||
Scenario() { debug=VS::SCENARIO_DEBUG_DISABLED; }
|
||||
};
|
||||
|
||||
RID_Owner<Scenario> scenario_owner;
|
||||
mutable RID_Owner<Scenario> scenario_owner;
|
||||
|
||||
static void* _instance_pair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int);
|
||||
static void _instance_unpair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int,void*);
|
||||
|
|
|
@ -172,6 +172,8 @@ public:
|
|||
virtual void material_set_param(RID p_material, const StringName& p_param, const Variant& p_value)=0;
|
||||
virtual Variant material_get_param(RID p_material, const StringName& p_param) const=0;
|
||||
|
||||
virtual void material_set_line_width(RID p_material, float p_width)=0;
|
||||
|
||||
/* MESH API */
|
||||
|
||||
enum ArrayType {
|
||||
|
@ -512,15 +514,14 @@ public:
|
|||
|
||||
enum EnvironmentToneMapper {
|
||||
ENV_TONE_MAPPER_LINEAR,
|
||||
ENV_TONE_MAPPER_LOG,
|
||||
ENV_TONE_MAPPER_REINHARDT,
|
||||
ENV_TONE_MAPPER_FILMIC
|
||||
ENV_TONE_MAPPER_FILMIC,
|
||||
ENV_TONE_MAPPER_ACES_FILMIC
|
||||
};
|
||||
|
||||
virtual void environment_set_tonemap(RID p_env,bool p_enable,float p_exposure,float p_white,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,EnvironmentToneMapper p_tone_mapper)=0;
|
||||
virtual void environment_set_brightness(RID p_env,bool p_enable,float p_brightness)=0;
|
||||
virtual void environment_set_contrast(RID p_env,bool p_enable,float p_contrast)=0;
|
||||
virtual void environment_set_saturation(RID p_env,bool p_enable,float p_saturation)=0;
|
||||
virtual void environment_set_color_correction(RID p_env,bool p_enable,RID p_ramp)=0;
|
||||
virtual void environment_set_tonemap(RID p_env,bool p_enable,float p_exposure,float p_white,float p_min_luminance,float p_max_luminance,float p_auto_exp_speed,float p_auto_exp_scale,EnvironmentToneMapper p_tone_mapper)=0;
|
||||
virtual void environment_set_adjustment(RID p_env,bool p_enable,float p_brightness,float p_contrast,float p_saturation,RID p_ramp)=0;
|
||||
|
||||
|
||||
/* SCENARIO API */
|
||||
|
|
|
@ -4144,7 +4144,7 @@ void EditorNode::register_editor_types() {
|
|||
ObjectTypeDB::register_type<EditorFileDialog>();
|
||||
//ObjectTypeDB::register_type<EditorImportExport>();
|
||||
ObjectTypeDB::register_type<EditorSettings>();
|
||||
// ObjectTypeDB::register_type<EditorSpatialGizmo>();
|
||||
ObjectTypeDB::register_type<EditorSpatialGizmo>();
|
||||
ObjectTypeDB::register_type<EditorResourcePreview>();
|
||||
ObjectTypeDB::register_type<EditorResourcePreviewGenerator>();
|
||||
ObjectTypeDB::register_type<EditorFileSystem>();
|
||||
|
|
|
@ -2553,6 +2553,7 @@ void SpatialEditor::_generate_selection_box() {
|
|||
mat->set_albedo(Color(1,1,1));
|
||||
mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
|
||||
st->set_material(mat);
|
||||
selection_box = st->commit();
|
||||
}
|
||||
|
@ -3143,6 +3144,8 @@ void SpatialEditor::_init_indicators() {
|
|||
indicator_mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
|
||||
indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
|
||||
indicator_mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
|
||||
indicator_mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
|
||||
|
||||
indicator_mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
|
||||
|
||||
DVector<Color> grid_colors[3];
|
||||
|
@ -3543,7 +3546,7 @@ void SpatialEditor::_notification(int p_what) {
|
|||
|
||||
if (p_what==NOTIFICATION_ENTER_TREE) {
|
||||
|
||||
//gizmos = memnew( SpatialEditorGizmos );
|
||||
gizmos = memnew( SpatialEditorGizmos );
|
||||
_init_indicators();
|
||||
_update_default_light_angle();
|
||||
}
|
||||
|
@ -3551,7 +3554,7 @@ void SpatialEditor::_notification(int p_what) {
|
|||
if (p_what==NOTIFICATION_EXIT_TREE) {
|
||||
|
||||
_finish_indicators();
|
||||
// memdelete( gizmos );
|
||||
memdelete( gizmos );
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3597,7 +3600,7 @@ void SpatialEditor::_request_gizmo(Object* p_obj) {
|
|||
}
|
||||
|
||||
if (!seg.is_valid()) {
|
||||
// seg = gizmos->get_gizmo(sp);
|
||||
seg = gizmos->get_gizmo(sp);
|
||||
}
|
||||
|
||||
if (seg.is_valid()) {
|
||||
|
|
|
@ -467,7 +467,7 @@ private:
|
|||
static SpatialEditor *singleton;
|
||||
|
||||
void _node_removed(Node* p_node);
|
||||
//SpatialEditorGizmos *gizmos;
|
||||
SpatialEditorGizmos *gizmos;
|
||||
SpatialEditor();
|
||||
|
||||
void _update_ambient_light_color(const Color& p_color);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
// Keep small children away from this file.
|
||||
// It's so ugly it will eat them alive
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
#define HANDLE_HALF_SIZE 0.05
|
||||
|
||||
|
@ -84,7 +84,6 @@ void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base) {
|
|||
if (extra_margin)
|
||||
VS::get_singleton()->instance_set_extra_visibility_margin(instance,1);
|
||||
VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance,VS::SHADOW_CASTING_SETTING_OFF);
|
||||
VS::get_singleton()->instance_geometry_set_flag(instance,VS::INSTANCE_FLAG_RECEIVE_SHADOWS,false);
|
||||
VS::get_singleton()->instance_set_layer_mask(instance,1<<SpatialEditorViewport::GIZMO_EDIT_LAYER); //gizmos are 26
|
||||
}
|
||||
|
||||
|
@ -669,9 +668,9 @@ String LightSpatialGizmo::get_handle_name(int p_idx) const {
|
|||
Variant LightSpatialGizmo::get_handle_value(int p_idx) const{
|
||||
|
||||
if (p_idx==0)
|
||||
return light->get_parameter(Light::PARAM_RADIUS);
|
||||
return light->get_param(Light::PARAM_RANGE);
|
||||
if (p_idx==1)
|
||||
return light->get_parameter(Light::PARAM_SPOT_ANGLE);
|
||||
return light->get_param(Light::PARAM_SPOT_ANGLE);
|
||||
|
||||
return Variant();
|
||||
}
|
||||
|
@ -729,7 +728,7 @@ void LightSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_p
|
|||
if (d<0)
|
||||
d=0;
|
||||
|
||||
light->set_parameter(Light::PARAM_RADIUS,d);
|
||||
light->set_param(Light::PARAM_RANGE,d);
|
||||
} else if (light->cast_to<OmniLight>()) {
|
||||
|
||||
Plane cp=Plane( gt.origin, p_camera->get_transform().basis.get_axis(2));
|
||||
|
@ -738,15 +737,15 @@ void LightSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_p
|
|||
if (cp.intersects_ray(ray_from,ray_dir,&inters)) {
|
||||
|
||||
float r = inters.distance_to(gt.origin);
|
||||
light->set_parameter(Light::PARAM_RADIUS,r);
|
||||
light->set_param(Light::PARAM_RANGE,r);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (p_idx==1) {
|
||||
|
||||
float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],light->get_parameter(Light::PARAM_RADIUS),gt);
|
||||
light->set_parameter(Light::PARAM_SPOT_ANGLE,CLAMP(a,0.01,89.99));
|
||||
float a = _find_closest_angle_to_half_pi_arc(s[0],s[1],light->get_param(Light::PARAM_RANGE),gt);
|
||||
light->set_param(Light::PARAM_SPOT_ANGLE,CLAMP(a,0.01,89.99));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -754,21 +753,21 @@ void LightSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_
|
|||
|
||||
if (p_cancel) {
|
||||
|
||||
light->set_parameter(p_idx==0?Light::PARAM_RADIUS:Light::PARAM_SPOT_ANGLE,p_restore);
|
||||
light->set_param(p_idx==0?Light::PARAM_RANGE:Light::PARAM_SPOT_ANGLE,p_restore);
|
||||
|
||||
} else if (p_idx==0) {
|
||||
|
||||
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
|
||||
ur->create_action(TTR("Change Light Radius"));
|
||||
ur->add_do_method(light,"set_parameter",Light::PARAM_RADIUS,light->get_parameter(Light::PARAM_RADIUS));
|
||||
ur->add_undo_method(light,"set_parameter",Light::PARAM_RADIUS,p_restore);
|
||||
ur->add_do_method(light,"set_param",Light::PARAM_RANGE,light->get_param(Light::PARAM_RANGE));
|
||||
ur->add_undo_method(light,"set_param",Light::PARAM_RANGE,p_restore);
|
||||
ur->commit_action();
|
||||
} else if (p_idx==1) {
|
||||
|
||||
UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo();
|
||||
ur->create_action(TTR("Change Light Radius"));
|
||||
ur->add_do_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,light->get_parameter(Light::PARAM_SPOT_ANGLE));
|
||||
ur->add_undo_method(light,"set_parameter",Light::PARAM_SPOT_ANGLE,p_restore);
|
||||
ur->add_do_method(light,"set_param",Light::PARAM_SPOT_ANGLE,light->get_param(Light::PARAM_SPOT_ANGLE));
|
||||
ur->add_undo_method(light,"set_param",Light::PARAM_SPOT_ANGLE,p_restore);
|
||||
ur->commit_action();
|
||||
|
||||
}
|
||||
|
@ -831,7 +830,7 @@ void LightSpatialGizmo::redraw() {
|
|||
|
||||
OmniLight *on = light->cast_to<OmniLight>();
|
||||
|
||||
float r = on->get_parameter(Light::PARAM_RADIUS);
|
||||
float r = on->get_param(Light::PARAM_RANGE);
|
||||
|
||||
Vector<Vector3> points;
|
||||
|
||||
|
@ -871,9 +870,9 @@ void LightSpatialGizmo::redraw() {
|
|||
Vector<Vector3> points;
|
||||
SpotLight *on = light->cast_to<SpotLight>();
|
||||
|
||||
float r = on->get_parameter(Light::PARAM_RADIUS);
|
||||
float w = r*Math::sin(Math::deg2rad(on->get_parameter(Light::PARAM_SPOT_ANGLE)));
|
||||
float d = r*Math::cos(Math::deg2rad(on->get_parameter(Light::PARAM_SPOT_ANGLE)));
|
||||
float r = on->get_param(Light::PARAM_RANGE);
|
||||
float w = r*Math::sin(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE)));
|
||||
float d = r*Math::cos(Math::deg2rad(on->get_param(Light::PARAM_SPOT_ANGLE)));
|
||||
|
||||
|
||||
|
||||
|
@ -1543,7 +1542,7 @@ void RayCastSpatialGizmo::redraw() {
|
|||
|
||||
}
|
||||
|
||||
RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast* p_raycast){
|
||||
RayCastSpatialGizmo::RayCastSpatialGizmo(RayCast* p_raycast) {
|
||||
|
||||
set_spatial_node(p_raycast);
|
||||
raycast=p_raycast;
|
||||
|
@ -2979,11 +2978,12 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
|
|||
Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_line_material(const Color& p_base_color) {
|
||||
|
||||
Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
line_material->set_flag(Material::FLAG_UNSHADED, true);
|
||||
line_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
line_material->set_line_width(3.0);
|
||||
line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
|
||||
line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,p_base_color);
|
||||
line_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
line_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
|
||||
line_material->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
|
||||
line_material->set_albedo(p_base_color);
|
||||
|
||||
return line_material;
|
||||
|
||||
|
@ -2992,9 +2992,9 @@ Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_line_material(const Color&
|
|||
Ref<FixedSpatialMaterial> SpatialEditorGizmos::create_solid_material(const Color& p_base_color) {
|
||||
|
||||
Ref<FixedSpatialMaterial> line_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
line_material->set_flag(Material::FLAG_UNSHADED, true);
|
||||
line_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
line_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,p_base_color);
|
||||
line_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
line_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
line_material->set_albedo(p_base_color);
|
||||
|
||||
return line_material;
|
||||
|
||||
|
@ -3005,56 +3005,59 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
singleton=this;
|
||||
|
||||
handle_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
handle_material->set_flag(Material::FLAG_UNSHADED, true);
|
||||
handle_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(0.8,0.8,0.8));
|
||||
handle_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
handle_material->set_albedo(Color(0.8,0.8,0.8));
|
||||
|
||||
handle2_material = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
handle2_material->set_flag(Material::FLAG_UNSHADED, true);
|
||||
handle2_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_POINT_SIZE, true);
|
||||
handle2_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
handle2_material->set_flag(FixedSpatialMaterial::FLAG_USE_POINT_SIZE, true);
|
||||
handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle","EditorIcons");
|
||||
handle2_material->set_point_size(handle_t->get_width());
|
||||
handle2_material->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,handle_t);
|
||||
handle2_material->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1));
|
||||
handle2_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
handle2_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
|
||||
handle2_material->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,handle_t);
|
||||
handle2_material->set_albedo(Color(1,1,1));
|
||||
handle2_material->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
handle2_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
|
||||
handle2_material->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
|
||||
|
||||
light_material = create_line_material(Color(1,1,0.2));
|
||||
|
||||
light_material_omni_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
light_material_omni_icon->set_flag(Material::FLAG_UNSHADED, true);
|
||||
light_material_omni_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
|
||||
light_material_omni_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
|
||||
light_material_omni_icon->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
light_material_omni_icon->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
|
||||
light_material_omni_icon->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoLight","EditorIcons"));
|
||||
light_material_omni_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
light_material_omni_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
light_material_omni_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
light_material_omni_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
light_material_omni_icon->set_albedo(Color(1,1,1,0.9));
|
||||
light_material_omni_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoLight","EditorIcons"));
|
||||
|
||||
|
||||
light_material_directional_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
light_material_directional_icon->set_flag(Material::FLAG_UNSHADED, true);
|
||||
light_material_directional_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
|
||||
light_material_directional_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
|
||||
light_material_directional_icon->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
light_material_directional_icon->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
|
||||
light_material_directional_icon->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight","EditorIcons"));
|
||||
light_material_directional_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
light_material_directional_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
light_material_directional_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
light_material_directional_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
light_material_directional_icon->set_albedo(Color(1,1,1,0.9));
|
||||
light_material_directional_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight","EditorIcons"));
|
||||
|
||||
camera_material = create_line_material(Color(1.0,0.5,1.0));
|
||||
|
||||
|
||||
navmesh_edge_material = create_line_material(Color(0.1,0.8,1.0));
|
||||
navmesh_solid_material = create_solid_material(Color(0.1,0.8,1.0,0.4));
|
||||
navmesh_edge_material->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, false);
|
||||
navmesh_solid_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
|
||||
navmesh_edge_material->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, false);
|
||||
navmesh_edge_material->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, false);
|
||||
navmesh_solid_material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
|
||||
navmesh_edge_material_disabled = create_line_material(Color(1.0,0.8,0.1));
|
||||
navmesh_solid_material_disabled = create_solid_material(Color(1.0,0.8,0.1,0.4));
|
||||
navmesh_edge_material_disabled->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, false);
|
||||
navmesh_solid_material_disabled->set_flag(Material::FLAG_DOUBLE_SIDED,true);
|
||||
navmesh_edge_material_disabled->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, false);
|
||||
navmesh_edge_material_disabled->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, false);
|
||||
navmesh_solid_material_disabled->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
|
||||
skeleton_material = create_line_material(Color(0.6,1.0,0.3));
|
||||
skeleton_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
|
||||
skeleton_material->set_flag(Material::FLAG_UNSHADED,true);
|
||||
skeleton_material->set_flag(Material::FLAG_ONTOP,true);
|
||||
skeleton_material->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
|
||||
skeleton_material->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
skeleton_material->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
|
||||
skeleton_material->set_flag(FixedSpatialMaterial::FLAG_ONTOP,true);
|
||||
skeleton_material->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
|
||||
//position 3D Shared mesh
|
||||
|
||||
|
@ -3078,9 +3081,10 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
cursor_colors.push_back(Color(0.5,0.5,1,0.7));
|
||||
|
||||
Ref<FixedSpatialMaterial> mat = memnew( FixedSpatialMaterial );
|
||||
mat->set_flag(Material::FLAG_UNSHADED,true);
|
||||
mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true);
|
||||
mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA,true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED,true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR,true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR,true);
|
||||
mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT,true);
|
||||
mat->set_line_width(3);
|
||||
Array d;
|
||||
d.resize(VS::ARRAY_MAX);
|
||||
|
@ -3101,9 +3105,10 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
cursor_colors.push_back(Color(0.5, 0.5, 0.5, 0.7));
|
||||
|
||||
Ref<FixedSpatialMaterial> mat = memnew(FixedSpatialMaterial);
|
||||
mat->set_flag(Material::FLAG_UNSHADED, true);
|
||||
mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY, true);
|
||||
mat->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
|
||||
mat->set_flag(FixedSpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
|
||||
mat->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
mat->set_line_width(3);
|
||||
Array d;
|
||||
d.resize(VS::ARRAY_MAX);
|
||||
|
@ -3115,12 +3120,12 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
|
||||
|
||||
sample_player_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
sample_player_icon->set_flag(Material::FLAG_UNSHADED, true);
|
||||
sample_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
|
||||
sample_player_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
|
||||
sample_player_icon->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
sample_player_icon->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
|
||||
sample_player_icon->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer","EditorIcons"));
|
||||
sample_player_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
sample_player_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
sample_player_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
sample_player_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
sample_player_icon->set_albedo(Color(1,1,1,0.9));
|
||||
sample_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer","EditorIcons"));
|
||||
|
||||
room_material = create_line_material(Color(1.0,0.6,0.9));
|
||||
portal_material = create_line_material(Color(1.0,0.8,0.6));
|
||||
|
@ -3130,28 +3135,28 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
joint_material = create_line_material(Color(0.6,0.8,1.0));
|
||||
|
||||
stream_player_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
stream_player_icon->set_flag(Material::FLAG_UNSHADED, true);
|
||||
stream_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
|
||||
stream_player_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
|
||||
stream_player_icon->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
stream_player_icon->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
|
||||
stream_player_icon->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer","EditorIcons"));
|
||||
stream_player_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
stream_player_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
stream_player_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
stream_player_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
stream_player_icon->set_albedo(Color(1,1,1,0.9));
|
||||
stream_player_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer","EditorIcons"));
|
||||
|
||||
visibility_notifier_icon = Ref<FixedSpatialMaterial>( memnew( FixedSpatialMaterial ));
|
||||
visibility_notifier_icon->set_flag(Material::FLAG_UNSHADED, true);
|
||||
visibility_notifier_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
|
||||
visibility_notifier_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
|
||||
visibility_notifier_icon->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
visibility_notifier_icon->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
|
||||
visibility_notifier_icon->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("Visible","EditorIcons"));
|
||||
visibility_notifier_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
visibility_notifier_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
visibility_notifier_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
visibility_notifier_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
visibility_notifier_icon->set_albedo(Color(1,1,1,0.9));
|
||||
visibility_notifier_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO,SpatialEditor::get_singleton()->get_icon("Visible","EditorIcons"));
|
||||
|
||||
listener_icon = Ref<FixedSpatialMaterial>(memnew(FixedSpatialMaterial));
|
||||
listener_icon->set_flag(Material::FLAG_UNSHADED, true);
|
||||
listener_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
|
||||
listener_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
|
||||
listener_icon->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_ALPHA, true);
|
||||
listener_icon->set_parameter(FixedSpatialMaterial::PARAM_DIFFUSE, Color(1, 1, 1, 0.9));
|
||||
listener_icon->set_texture(FixedSpatialMaterial::PARAM_DIFFUSE, SpatialEditor::get_singleton()->get_icon("GizmoListener", "EditorIcons"));
|
||||
listener_icon->set_flag(FixedSpatialMaterial::FLAG_UNSHADED, true);
|
||||
listener_icon->set_cull_mode(FixedSpatialMaterial::CULL_DISABLED);
|
||||
listener_icon->set_depth_draw_mode(FixedSpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
listener_icon->set_feature(FixedSpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
listener_icon->set_albedo( Color(1, 1, 1, 0.9));
|
||||
listener_icon->set_texture(FixedSpatialMaterial::TEXTURE_ALBEDO, SpatialEditor::get_singleton()->get_icon("GizmoListener", "EditorIcons"));
|
||||
|
||||
{
|
||||
|
||||
|
@ -3200,4 +3205,4 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
|
||||
class Camera;
|
||||
#if 0
|
||||
|
||||
class EditorSpatialGizmo : public SpatialEditorGizmo {
|
||||
|
||||
OBJ_TYPE(EditorSpatialGizmo,SpatialGizmo);
|
||||
|
@ -505,5 +505,4 @@ public:
|
|||
|
||||
SpatialEditorGizmos();
|
||||
};
|
||||
#endif
|
||||
#endif // SPATIAL_EDITOR_GIZMOS_H
|
||||
|
|
Loading…
Reference in New Issue