allow omnilights and spotlights to use negative in GLES2
(cherry picked from commit 96c3004855
)
This commit is contained in:
parent
ac09460cd1
commit
bd9cff1b20
|
@ -1847,14 +1847,14 @@ void RasterizerSceneGLES2::_setup_light_type(LightInstance *p_light, ShadowAtlas
|
|||
}
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform) {
|
||||
void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform, bool accum_pass) {
|
||||
|
||||
RasterizerStorageGLES2::Light *light_ptr = light->light_ptr;
|
||||
|
||||
//common parameters
|
||||
float energy = light_ptr->param[VS::LIGHT_PARAM_ENERGY];
|
||||
float specular = light_ptr->param[VS::LIGHT_PARAM_SPECULAR];
|
||||
float sign = light_ptr->negative ? -1 : 1;
|
||||
float sign = (light_ptr->negative && !accum_pass) ? -1 : 1; //inverse color for base pass lights only
|
||||
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::LIGHT_SPECULAR, specular);
|
||||
Color color = light_ptr->color * sign * energy * Math_PI;
|
||||
|
@ -2258,6 +2258,11 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
|||
|
||||
if (accum_pass) { //accum pass force pass
|
||||
blend_mode = RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_ADD;
|
||||
if (rebind_light && light && light->light_ptr->negative) {
|
||||
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
blend_mode = RasterizerStorageGLES2::Shader::Spatial::BLEND_MODE_SUB;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev_blend_mode != blend_mode) {
|
||||
|
@ -2484,7 +2489,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
|||
}
|
||||
|
||||
if (rebind_light && light) {
|
||||
_setup_light(light, shadow_atlas, p_view_transform);
|
||||
_setup_light(light, shadow_atlas, p_view_transform, accum_pass);
|
||||
}
|
||||
|
||||
if (rebind_reflection && (refprobe_1 || refprobe_2)) {
|
||||
|
|
|
@ -686,7 +686,7 @@ public:
|
|||
_FORCE_INLINE_ bool _setup_material(RasterizerStorageGLES2::Material *p_material, bool p_reverse_cull, bool p_alpha_pass, Size2i p_skeleton_tex_size = Size2i(0, 0));
|
||||
_FORCE_INLINE_ void _setup_geometry(RenderList::Element *p_element, RasterizerStorageGLES2::Skeleton *p_skeleton);
|
||||
_FORCE_INLINE_ void _setup_light_type(LightInstance *p_light, ShadowAtlas *shadow_atlas);
|
||||
_FORCE_INLINE_ void _setup_light(LightInstance *p_light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform);
|
||||
_FORCE_INLINE_ void _setup_light(LightInstance *p_light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform, bool accum_pass);
|
||||
_FORCE_INLINE_ void _setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform &p_view_transform, Environment *p_env);
|
||||
_FORCE_INLINE_ void _render_geometry(RenderList::Element *p_element);
|
||||
|
||||
|
|
Loading…
Reference in New Issue