mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 13:12:42 +00:00
Rename GLES2 driver to OpenGL to prepare for the upgrade to GLES3
- Use lowercase driver names for the `--rendering-driver` command line argument.
This commit is contained in:
parent
e3491a3744
commit
ce97ddbcb1
17
SConstruct
17
SConstruct
@ -15,7 +15,7 @@ from collections import OrderedDict
|
||||
# Local
|
||||
import methods
|
||||
import glsl_builders
|
||||
import gles_builders
|
||||
import opengl_builders
|
||||
from platform_methods import run_in_subprocess
|
||||
|
||||
# Scan possible build platforms
|
||||
@ -708,20 +708,11 @@ if selected_platform in platform_list:
|
||||
}
|
||||
env.Append(BUILDERS=GLSL_BUILDERS)
|
||||
|
||||
if not env["platform"] == "server": # FIXME: detect GLES3
|
||||
if not env["platform"] == "server":
|
||||
env.Append(
|
||||
BUILDERS={
|
||||
"GLES3_GLSL": env.Builder(
|
||||
action=run_in_subprocess(gles_builders.build_gles3_headers),
|
||||
suffix="glsl.gen.h",
|
||||
src_suffix=".glsl",
|
||||
)
|
||||
}
|
||||
)
|
||||
env.Append(
|
||||
BUILDERS={
|
||||
"GLES2_GLSL": env.Builder(
|
||||
action=run_in_subprocess(gles_builders.build_gles2_headers),
|
||||
"OpenGL_GLSL": env.Builder(
|
||||
action=run_in_subprocess(opengl_builders.build_opengl_headers),
|
||||
suffix="glsl.gen.h",
|
||||
src_suffix=".glsl",
|
||||
)
|
||||
|
@ -603,8 +603,8 @@ void OS::_bind_methods() {
|
||||
ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
|
||||
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
|
||||
|
||||
BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES2);
|
||||
BIND_ENUM_CONSTANT(VIDEO_DRIVER_VULKAN);
|
||||
BIND_ENUM_CONSTANT(VIDEO_DRIVER_OPENGL);
|
||||
|
||||
BIND_ENUM_CONSTANT(DAY_SUNDAY);
|
||||
BIND_ENUM_CONSTANT(DAY_MONDAY);
|
||||
|
@ -119,8 +119,8 @@ protected:
|
||||
|
||||
public:
|
||||
enum VideoDriver {
|
||||
VIDEO_DRIVER_GLES2,
|
||||
VIDEO_DRIVER_VULKAN,
|
||||
VIDEO_DRIVER_OPENGL,
|
||||
};
|
||||
|
||||
enum Weekday {
|
||||
|
@ -128,10 +128,10 @@
|
||||
The bleed scale of the HDR glow.
|
||||
</member>
|
||||
<member name="glow_hdr_threshold" type="float" setter="set_glow_hdr_bleed_threshold" getter="get_glow_hdr_bleed_threshold" default="1.0">
|
||||
The lower threshold of the HDR glow. When using the GLES2 renderer (which doesn't support HDR), this needs to be below [code]1.0[/code] for glow to be visible. A value of [code]0.9[/code] works well in this case.
|
||||
The lower threshold of the HDR glow. When using the OpenGL renderer (which doesn't support HDR), this needs to be below [code]1.0[/code] for glow to be visible. A value of [code]0.9[/code] works well in this case.
|
||||
</member>
|
||||
<member name="glow_intensity" type="float" setter="set_glow_intensity" getter="get_glow_intensity" default="0.8">
|
||||
The overall brightness multiplier of the glow effect. When using the GLES2 renderer, this should be increased to 1.5 to compensate for the lack of HDR rendering.
|
||||
The overall brightness multiplier of the glow effect. When using the OpenGL renderer, this should be increased to 1.5 to compensate for the lack of HDR rendering.
|
||||
</member>
|
||||
<member name="glow_levels/1" type="float" setter="set_glow_level" getter="get_glow_level" default="0.0">
|
||||
The intensity of the 1st level of glow. This is the most "local" level (least blurry).
|
||||
@ -160,7 +160,7 @@
|
||||
If [code]true[/code], glow levels will be normalized so that summed together their intensities equal [code]1.0[/code].
|
||||
</member>
|
||||
<member name="glow_strength" type="float" setter="set_glow_strength" getter="get_glow_strength" default="1.0">
|
||||
The strength of the glow effect. This applies as the glow is blurred across the screen and increases the distance and intensity of the blur. When using the GLES2 renderer, this should be increased to 1.3 to compensate for the lack of HDR rendering.
|
||||
The strength of the glow effect. This applies as the glow is blurred across the screen and increases the distance and intensity of the blur. When using the OpenGL renderer, this should be increased to 1.3 to compensate for the lack of HDR rendering.
|
||||
</member>
|
||||
<member name="reflected_light_source" type="int" setter="set_reflection_source" getter="get_reflection_source" enum="Environment.ReflectionSource" default="0">
|
||||
</member>
|
||||
|
@ -68,11 +68,11 @@
|
||||
</constant>
|
||||
<constant name="AXIS_STRETCH_MODE_TILE" value="1" enum="AxisStretchMode">
|
||||
Repeats the center texture across the NinePatchRect. This won't cause any visible distortion. The texture must be seamless for this to work without displaying artifacts between edges.
|
||||
[b]Note:[/b] Only supported when using the GLES3 renderer. When using the GLES2 renderer, this will behave like [constant AXIS_STRETCH_MODE_STRETCH].
|
||||
[b]Note:[/b] Only supported when using the Vulkan renderer. When using the OpenGL renderer, this will behave like [constant AXIS_STRETCH_MODE_STRETCH].
|
||||
</constant>
|
||||
<constant name="AXIS_STRETCH_MODE_TILE_FIT" value="2" enum="AxisStretchMode">
|
||||
Repeats the center texture across the NinePatchRect, but will also stretch the texture to make sure each tile is visible in full. This may cause the texture to be distorted, but less than [constant AXIS_STRETCH_MODE_STRETCH]. The texture must be seamless for this to work without displaying artifacts between edges.
|
||||
[b]Note:[/b] Only supported when using the GLES3 renderer. When using the GLES2 renderer, this will behave like [constant AXIS_STRETCH_MODE_STRETCH].
|
||||
[b]Note:[/b] Only supported when using the Vulkan renderer. When using the OpenGL renderer, this will behave like [constant AXIS_STRETCH_MODE_STRETCH].
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
||||
|
@ -455,12 +455,12 @@
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="VIDEO_DRIVER_GLES2" value="0" enum="VideoDriver">
|
||||
The GLES2 rendering backend. It uses OpenGL ES 2.0 on mobile devices, OpenGL 2.1 on desktop platforms and WebGL 1.0 on the web.
|
||||
</constant>
|
||||
<constant name="VIDEO_DRIVER_VULKAN" value="1" enum="VideoDriver">
|
||||
<constant name="VIDEO_DRIVER_VULKAN" value="0" enum="VideoDriver">
|
||||
The Vulkan rendering backend.
|
||||
</constant>
|
||||
<constant name="VIDEO_DRIVER_OPENGL" value="1" enum="VideoDriver">
|
||||
The OpenGL rendering backend. It uses OpenGL ES 3.0 on mobile devices, OpenGL 3.3 on desktop platforms and WebGL 2.0 on the web.
|
||||
</constant>
|
||||
<constant name="DAY_SUNDAY" value="0" enum="Weekday">
|
||||
Sunday.
|
||||
</constant>
|
||||
|
@ -25,8 +25,7 @@ SConscript("winmidi/SCsub")
|
||||
# Graphics drivers
|
||||
if env["vulkan"]:
|
||||
SConscript("vulkan/SCsub")
|
||||
SConscript("gles2/SCsub")
|
||||
SConscript("gles_common/SCsub")
|
||||
SConscript("opengl/SCsub")
|
||||
SConscript("gl_context/SCsub")
|
||||
else:
|
||||
SConscript("dummy/SCsub")
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,793 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_scene_gles2.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
// dummy
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
|
||||
#include "core/math/camera_matrix.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
#include "core/templates/self_list.h"
|
||||
#include "drivers/gles_common/rasterizer_common_stubs.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
#include "servers/rendering_server.h"
|
||||
#include "shaders/scene.glsl.gen.h"
|
||||
|
||||
class RasterizerSceneGLES2 : public StubsScene {
|
||||
public:
|
||||
struct State {
|
||||
SceneShaderGLES2 scene_shader;
|
||||
|
||||
} state;
|
||||
|
||||
public:
|
||||
RasterizerSceneGLES2() {}
|
||||
~RasterizerSceneGLES2() {}
|
||||
};
|
||||
|
||||
#ifdef GODOT_3
|
||||
|
||||
/* Must come before shaders or the Windows build fails... */
|
||||
#include "drivers/gles_common/rasterizer_version.h"
|
||||
#include "rasterizer_storage_gles2.h"
|
||||
|
||||
#include "shaders/cube_to_dp.glsl.gen.h"
|
||||
#include "shaders/effect_blur.glsl.gen.h"
|
||||
#include "shaders/scene.glsl.gen.h"
|
||||
#include "shaders/tonemap.glsl.gen.h"
|
||||
/*
|
||||
|
||||
#include "drivers/gles3/shaders/exposure.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/resolve.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/scene.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/screen_space_reflection.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/ssao.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/ssao_blur.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/ssao_minify.glsl.gen.h"
|
||||
#include "drivers/gles3/shaders/subsurf_scattering.glsl.gen.h"
|
||||
|
||||
*/
|
||||
|
||||
class RasterizerSceneGLES2 : public RasterizerScene {
|
||||
public:
|
||||
enum ShadowFilterMode {
|
||||
SHADOW_FILTER_NEAREST,
|
||||
SHADOW_FILTER_PCF5,
|
||||
SHADOW_FILTER_PCF13,
|
||||
};
|
||||
|
||||
enum {
|
||||
INSTANCE_ATTRIB_BASE = 8,
|
||||
INSTANCE_BONE_BASE = 13,
|
||||
};
|
||||
|
||||
ShadowFilterMode shadow_filter_mode;
|
||||
|
||||
RID default_material;
|
||||
RID default_material_twosided;
|
||||
RID default_shader;
|
||||
RID default_shader_twosided;
|
||||
|
||||
RID default_worldcoord_material;
|
||||
RID default_worldcoord_material_twosided;
|
||||
RID default_worldcoord_shader;
|
||||
RID default_worldcoord_shader_twosided;
|
||||
|
||||
RID default_overdraw_material;
|
||||
RID default_overdraw_shader;
|
||||
|
||||
uint64_t render_pass;
|
||||
uint64_t scene_pass;
|
||||
uint32_t current_material_index;
|
||||
uint32_t current_geometry_index;
|
||||
uint32_t current_light_index;
|
||||
uint32_t current_refprobe_index;
|
||||
uint32_t current_shader_index;
|
||||
|
||||
RasterizerStorageGLES2 *storage;
|
||||
struct State {
|
||||
bool texscreen_copied;
|
||||
int current_blend_mode;
|
||||
float current_line_width;
|
||||
int current_depth_draw;
|
||||
bool current_depth_test;
|
||||
GLuint current_main_tex;
|
||||
|
||||
SceneShaderGLES2 scene_shader;
|
||||
CubeToDpShaderGLES2 cube_to_dp_shader;
|
||||
TonemapShaderGLES2 tonemap_shader;
|
||||
EffectBlurShaderGLES2 effect_blur_shader;
|
||||
|
||||
GLuint sky_verts;
|
||||
|
||||
GLuint immediate_buffer;
|
||||
Color default_ambient;
|
||||
Color default_bg;
|
||||
|
||||
// ResolveShaderGLES3 resolve_shader;
|
||||
// ScreenSpaceReflectionShaderGLES3 ssr_shader;
|
||||
// EffectBlurShaderGLES3 effect_blur_shader;
|
||||
// SubsurfScatteringShaderGLES3 sss_shader;
|
||||
// SsaoMinifyShaderGLES3 ssao_minify_shader;
|
||||
// SsaoShaderGLES3 ssao_shader;
|
||||
// SsaoBlurShaderGLES3 ssao_blur_shader;
|
||||
// ExposureShaderGLES3 exposure_shader;
|
||||
|
||||
/*
|
||||
struct SceneDataUBO {
|
||||
//this is a std140 compatible struct. Please read the OpenGL 3.3 Specificaiton spec before doing any changes
|
||||
float projection_matrix[16];
|
||||
float inv_projection_matrix[16];
|
||||
float camera_inverse_matrix[16];
|
||||
float camera_matrix[16];
|
||||
float ambient_light_color[4];
|
||||
float bg_color[4];
|
||||
float fog_color_enabled[4];
|
||||
float fog_sun_color_amount[4];
|
||||
|
||||
float ambient_energy;
|
||||
float bg_energy;
|
||||
float z_offset;
|
||||
float z_slope_scale;
|
||||
float shadow_dual_paraboloid_render_zfar;
|
||||
float shadow_dual_paraboloid_render_side;
|
||||
float viewport_size[2];
|
||||
float screen_pixel_size[2];
|
||||
float shadow_atlas_pixel_size[2];
|
||||
float shadow_directional_pixel_size[2];
|
||||
|
||||
float time;
|
||||
float z_far;
|
||||
float reflection_multiplier;
|
||||
float subsurface_scatter_width;
|
||||
float ambient_occlusion_affect_light;
|
||||
|
||||
uint32_t fog_depth_enabled;
|
||||
float fog_depth_begin;
|
||||
float fog_depth_curve;
|
||||
uint32_t fog_transmit_enabled;
|
||||
float fog_transmit_curve;
|
||||
uint32_t fog_height_enabled;
|
||||
float fog_height_min;
|
||||
float fog_height_max;
|
||||
float fog_height_curve;
|
||||
// make sure this struct is padded to be a multiple of 16 bytes for webgl
|
||||
|
||||
} ubo_data;
|
||||
|
||||
GLuint scene_ubo;
|
||||
|
||||
struct EnvironmentRadianceUBO {
|
||||
float transform[16];
|
||||
float ambient_contribution;
|
||||
uint8_t padding[12];
|
||||
|
||||
} env_radiance_data;
|
||||
|
||||
GLuint env_radiance_ubo;
|
||||
|
||||
GLuint sky_array;
|
||||
|
||||
GLuint directional_ubo;
|
||||
|
||||
GLuint spot_array_ubo;
|
||||
GLuint omni_array_ubo;
|
||||
GLuint reflection_array_ubo;
|
||||
|
||||
GLuint immediate_buffer;
|
||||
GLuint immediate_array;
|
||||
|
||||
uint32_t ubo_light_size;
|
||||
uint8_t *spot_array_tmp;
|
||||
uint8_t *omni_array_tmp;
|
||||
uint8_t *reflection_array_tmp;
|
||||
|
||||
int max_ubo_lights;
|
||||
int max_forward_lights_per_object;
|
||||
int max_ubo_reflections;
|
||||
int max_skeleton_bones;
|
||||
|
||||
bool used_contact_shadows;
|
||||
|
||||
int spot_light_count;
|
||||
int omni_light_count;
|
||||
int directional_light_count;
|
||||
int reflection_probe_count;
|
||||
|
||||
bool used_sss;
|
||||
bool using_contact_shadows;
|
||||
|
||||
VS::ViewportDebugDraw debug_draw;
|
||||
*/
|
||||
|
||||
bool cull_front;
|
||||
bool cull_disabled;
|
||||
|
||||
bool used_screen_texture;
|
||||
bool shadow_is_dual_parabolloid;
|
||||
float dual_parbolloid_direction;
|
||||
float dual_parbolloid_zfar;
|
||||
|
||||
bool render_no_shadows;
|
||||
|
||||
Vector2 viewport_size;
|
||||
|
||||
Vector2 screen_pixel_size;
|
||||
} state;
|
||||
|
||||
/* SHADOW ATLAS API */
|
||||
|
||||
uint64_t shadow_atlas_realloc_tolerance_msec;
|
||||
|
||||
struct ShadowAtlas : public RID_Data {
|
||||
enum {
|
||||
QUADRANT_SHIFT = 27,
|
||||
SHADOW_INDEX_MASK = (1 << QUADRANT_SHIFT) - 1,
|
||||
SHADOW_INVALID = 0xFFFFFFFF,
|
||||
};
|
||||
|
||||
struct Quadrant {
|
||||
uint32_t subdivision;
|
||||
|
||||
struct Shadow {
|
||||
RID owner;
|
||||
uint64_t version;
|
||||
uint64_t alloc_tick;
|
||||
|
||||
Shadow() {
|
||||
version = 0;
|
||||
alloc_tick = 0;
|
||||
}
|
||||
};
|
||||
|
||||
Vector<Shadow> shadows;
|
||||
|
||||
Quadrant() {
|
||||
subdivision = 0;
|
||||
}
|
||||
} quadrants[4];
|
||||
|
||||
int size_order[4];
|
||||
uint32_t smallest_subdiv;
|
||||
|
||||
int size;
|
||||
|
||||
GLuint fbo;
|
||||
GLuint depth;
|
||||
GLuint color;
|
||||
|
||||
Map<RID, uint32_t> shadow_owners;
|
||||
};
|
||||
|
||||
struct ShadowCubeMap {
|
||||
GLuint fbo[6];
|
||||
GLuint cubemap;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
Vector<ShadowCubeMap> shadow_cubemaps;
|
||||
|
||||
RID_Owner<ShadowAtlas> shadow_atlas_owner;
|
||||
|
||||
RID shadow_atlas_create();
|
||||
void shadow_atlas_set_size(RID p_atlas, int p_size);
|
||||
void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision);
|
||||
bool _shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas, int *p_in_quadrants, int p_quadrant_count, int p_current_subdiv, uint64_t p_tick, int &r_quadrant, int &r_shadow);
|
||||
bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version);
|
||||
|
||||
struct DirectionalShadow {
|
||||
GLuint fbo;
|
||||
GLuint depth;
|
||||
GLuint color;
|
||||
|
||||
int light_count;
|
||||
int size;
|
||||
int current_light;
|
||||
} directional_shadow;
|
||||
|
||||
virtual int get_directional_light_shadow_size(RID p_light_intance);
|
||||
virtual void set_directional_shadow_count(int p_count);
|
||||
|
||||
/* REFLECTION PROBE ATLAS API */
|
||||
|
||||
virtual RID reflection_atlas_create();
|
||||
virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size);
|
||||
virtual void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv);
|
||||
|
||||
/* REFLECTION CUBEMAPS */
|
||||
|
||||
/* REFLECTION PROBE INSTANCE */
|
||||
|
||||
struct ReflectionProbeInstance : public RID_Data {
|
||||
RasterizerStorageGLES2::ReflectionProbe *probe_ptr;
|
||||
RID probe;
|
||||
RID self;
|
||||
RID atlas;
|
||||
|
||||
int reflection_atlas_index;
|
||||
|
||||
int render_step;
|
||||
int reflection_index;
|
||||
|
||||
GLuint fbo[6];
|
||||
GLuint color[6];
|
||||
GLuint depth;
|
||||
GLuint cubemap;
|
||||
|
||||
int current_resolution;
|
||||
mutable bool dirty;
|
||||
|
||||
uint64_t last_pass;
|
||||
uint32_t index;
|
||||
|
||||
Transform3D transform;
|
||||
};
|
||||
|
||||
mutable RID_Owner<ReflectionProbeInstance> reflection_probe_instance_owner;
|
||||
|
||||
ReflectionProbeInstance **reflection_probe_instances;
|
||||
int reflection_probe_count;
|
||||
|
||||
virtual RID reflection_probe_instance_create(RID p_probe);
|
||||
virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform);
|
||||
virtual void reflection_probe_release_atlas_index(RID p_instance);
|
||||
virtual bool reflection_probe_instance_needs_redraw(RID p_instance);
|
||||
virtual bool reflection_probe_instance_has_reflection(RID p_instance);
|
||||
virtual bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas);
|
||||
virtual bool reflection_probe_instance_postprocess_step(RID p_instance);
|
||||
|
||||
/* ENVIRONMENT API */
|
||||
|
||||
struct Environment : public RID_Data {
|
||||
VS::EnvironmentBG bg_mode;
|
||||
|
||||
RID sky;
|
||||
float sky_custom_fov;
|
||||
Basis sky_orientation;
|
||||
|
||||
Color bg_color;
|
||||
float bg_energy;
|
||||
float sky_ambient;
|
||||
|
||||
int camera_feed_id;
|
||||
|
||||
Color ambient_color;
|
||||
float ambient_energy;
|
||||
float ambient_sky_contribution;
|
||||
|
||||
int canvas_max_layer;
|
||||
|
||||
bool glow_enabled;
|
||||
int glow_levels;
|
||||
float glow_intensity;
|
||||
float glow_strength;
|
||||
float glow_bloom;
|
||||
VS::EnvironmentGlowBlendMode glow_blend_mode;
|
||||
float glow_hdr_bleed_threshold;
|
||||
float glow_hdr_bleed_scale;
|
||||
float glow_hdr_luminance_cap;
|
||||
bool glow_bicubic_upscale;
|
||||
|
||||
bool dof_blur_far_enabled;
|
||||
float dof_blur_far_distance;
|
||||
float dof_blur_far_transition;
|
||||
float dof_blur_far_amount;
|
||||
VS::EnvironmentDOFBlurQuality dof_blur_far_quality;
|
||||
|
||||
bool dof_blur_near_enabled;
|
||||
float dof_blur_near_distance;
|
||||
float dof_blur_near_transition;
|
||||
float dof_blur_near_amount;
|
||||
VS::EnvironmentDOFBlurQuality dof_blur_near_quality;
|
||||
|
||||
bool adjustments_enabled;
|
||||
float adjustments_brightness;
|
||||
float adjustments_contrast;
|
||||
float adjustments_saturation;
|
||||
RID color_correction;
|
||||
|
||||
bool fog_enabled;
|
||||
Color fog_color;
|
||||
Color fog_sun_color;
|
||||
float fog_sun_amount;
|
||||
|
||||
bool fog_depth_enabled;
|
||||
float fog_depth_begin;
|
||||
float fog_depth_end;
|
||||
float fog_depth_curve;
|
||||
bool fog_transmit_enabled;
|
||||
float fog_transmit_curve;
|
||||
bool fog_height_enabled;
|
||||
float fog_height_min;
|
||||
float fog_height_max;
|
||||
float fog_height_curve;
|
||||
|
||||
Environment() :
|
||||
bg_mode(GD_VS::ENV_BG_CLEAR_COLOR),
|
||||
sky_custom_fov(0.0),
|
||||
bg_energy(1.0),
|
||||
sky_ambient(0),
|
||||
camera_feed_id(0),
|
||||
ambient_energy(1.0),
|
||||
ambient_sky_contribution(0.0),
|
||||
canvas_max_layer(0),
|
||||
glow_enabled(false),
|
||||
glow_levels((1 << 2) | (1 << 4)),
|
||||
glow_intensity(0.8),
|
||||
glow_strength(1.0),
|
||||
glow_bloom(0.0),
|
||||
glow_blend_mode(GD_VS::GLOW_BLEND_MODE_SOFTLIGHT),
|
||||
glow_hdr_bleed_threshold(1.0),
|
||||
glow_hdr_bleed_scale(2.0),
|
||||
glow_hdr_luminance_cap(12.0),
|
||||
glow_bicubic_upscale(false),
|
||||
dof_blur_far_enabled(false),
|
||||
dof_blur_far_distance(10),
|
||||
dof_blur_far_transition(5),
|
||||
dof_blur_far_amount(0.1),
|
||||
dof_blur_far_quality(GD_VS::ENV_DOF_BLUR_QUALITY_MEDIUM),
|
||||
dof_blur_near_enabled(false),
|
||||
dof_blur_near_distance(2),
|
||||
dof_blur_near_transition(1),
|
||||
dof_blur_near_amount(0.1),
|
||||
dof_blur_near_quality(GD_VS::ENV_DOF_BLUR_QUALITY_MEDIUM),
|
||||
adjustments_enabled(false),
|
||||
adjustments_brightness(1.0),
|
||||
adjustments_contrast(1.0),
|
||||
adjustments_saturation(1.0),
|
||||
fog_enabled(false),
|
||||
fog_color(Color(0.5, 0.5, 0.5)),
|
||||
fog_sun_color(Color(0.8, 0.8, 0.0)),
|
||||
fog_sun_amount(0),
|
||||
fog_depth_enabled(true),
|
||||
fog_depth_begin(10),
|
||||
fog_depth_end(0),
|
||||
fog_depth_curve(1),
|
||||
fog_transmit_enabled(true),
|
||||
fog_transmit_curve(1),
|
||||
fog_height_enabled(false),
|
||||
fog_height_min(10),
|
||||
fog_height_max(0),
|
||||
fog_height_curve(1) {
|
||||
}
|
||||
};
|
||||
|
||||
mutable RID_Owner<Environment> environment_owner;
|
||||
|
||||
virtual RID environment_create();
|
||||
|
||||
virtual void environment_set_background(RID p_env, GD_VS::EnvironmentBG p_bg);
|
||||
virtual void environment_set_sky(RID p_env, RID p_sky);
|
||||
virtual void environment_set_sky_custom_fov(RID p_env, float p_scale);
|
||||
virtual void environment_set_sky_orientation(RID p_env, const Basis &p_orientation);
|
||||
virtual void environment_set_bg_color(RID p_env, const Color &p_color);
|
||||
virtual void environment_set_bg_energy(RID p_env, float p_energy);
|
||||
virtual void environment_set_canvas_max_layer(RID p_env, int p_max_layer);
|
||||
virtual void environment_set_ambient_light(RID p_env, const Color &p_color, float p_energy = 1.0, float p_sky_contribution = 0.0);
|
||||
virtual void environment_set_camera_feed_id(RID p_env, int p_camera_feed_id);
|
||||
|
||||
virtual void environment_set_dof_blur_near(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, GD_VS::EnvironmentDOFBlurQuality p_quality);
|
||||
virtual void environment_set_dof_blur_far(RID p_env, bool p_enable, float p_distance, float p_transition, float p_amount, GD_VS::EnvironmentDOFBlurQuality p_quality);
|
||||
|
||||
virtual void environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_bloom_threshold, GD_VS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap, bool p_bicubic_upscale);
|
||||
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_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_in, float p_fade_out, float p_depth_tolerance, bool p_roughness);
|
||||
virtual void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_radius2, float p_intensity2, float p_bias, float p_light_affect, float p_ao_channel_affect, const Color &p_color, GD_VS::EnvironmentSSAOQuality p_quality, GD_VS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness);
|
||||
|
||||
virtual void environment_set_tonemap(RID p_env, GD_VS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale);
|
||||
|
||||
virtual void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, RID p_ramp);
|
||||
|
||||
virtual void environment_set_fog(RID p_env, bool p_enable, const Color &p_color, const Color &p_sun_color, float p_sun_amount);
|
||||
virtual void environment_set_fog_depth(RID p_env, bool p_enable, float p_depth_begin, float p_depth_end, float p_depth_curve, bool p_transmit, float p_transmit_curve);
|
||||
virtual void environment_set_fog_height(RID p_env, bool p_enable, float p_min_height, float p_max_height, float p_height_curve);
|
||||
|
||||
virtual bool is_environment(RID p_env);
|
||||
|
||||
virtual GD_VS::EnvironmentBG environment_get_background(RID p_env);
|
||||
virtual int environment_get_canvas_max_layer(RID p_env);
|
||||
|
||||
/* LIGHT INSTANCE */
|
||||
|
||||
struct LightInstance : public RID_Data {
|
||||
struct ShadowTransform {
|
||||
CameraMatrix camera;
|
||||
Transform3D transform;
|
||||
float farplane;
|
||||
float split;
|
||||
float bias_scale;
|
||||
};
|
||||
|
||||
ShadowTransform shadow_transform[4];
|
||||
|
||||
RID self;
|
||||
RID light;
|
||||
|
||||
RasterizerStorageGLES2::Light *light_ptr;
|
||||
Transform3D transform;
|
||||
|
||||
Vector3 light_vector;
|
||||
Vector3 spot_vector;
|
||||
float linear_att;
|
||||
|
||||
// TODO passes and all that stuff ?
|
||||
uint64_t last_scene_pass;
|
||||
uint64_t last_scene_shadow_pass;
|
||||
|
||||
uint16_t light_index;
|
||||
uint16_t light_directional_index;
|
||||
|
||||
Rect2 directional_rect;
|
||||
|
||||
Set<RID> shadow_atlases; // atlases where this light is registered
|
||||
};
|
||||
|
||||
mutable RID_Owner<LightInstance> light_instance_owner;
|
||||
|
||||
virtual RID light_instance_create(RID p_light);
|
||||
virtual void light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform);
|
||||
virtual void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0);
|
||||
virtual void light_instance_mark_visible(RID p_light_instance);
|
||||
virtual bool light_instances_can_render_shadow_cube() const { return storage->config.support_shadow_cubemaps; }
|
||||
|
||||
LightInstance **render_light_instances;
|
||||
int render_directional_lights;
|
||||
int render_light_instance_count;
|
||||
|
||||
/* REFLECTION INSTANCE */
|
||||
|
||||
virtual RID gi_probe_instance_create();
|
||||
virtual void gi_probe_instance_set_light_data(RID p_probe, RID p_base, RID p_data);
|
||||
virtual void gi_probe_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform);
|
||||
virtual void gi_probe_instance_set_bounds(RID p_probe, const Vector3 &p_bounds);
|
||||
|
||||
/* RENDER LIST */
|
||||
|
||||
enum LightMode {
|
||||
LIGHTMODE_NORMAL,
|
||||
LIGHTMODE_UNSHADED,
|
||||
LIGHTMODE_LIGHTMAP,
|
||||
LIGHTMODE_LIGHTMAP_CAPTURE,
|
||||
};
|
||||
|
||||
struct RenderList {
|
||||
enum {
|
||||
MAX_LIGHTS = 255,
|
||||
MAX_REFLECTION_PROBES = 255,
|
||||
DEFAULT_MAX_ELEMENTS = 65536
|
||||
};
|
||||
|
||||
int max_elements;
|
||||
|
||||
struct Element {
|
||||
InstanceBaseDependency *instance;
|
||||
|
||||
RasterizerStorageGLES2::Geometry *geometry;
|
||||
RasterizerStorageGLES2::Material *material;
|
||||
RasterizerStorageGLES2::GeometryOwner *owner;
|
||||
|
||||
bool use_accum; //is this an add pass for multipass
|
||||
bool *use_accum_ptr;
|
||||
bool front_facing;
|
||||
|
||||
union {
|
||||
//TODO: should be endian swapped on big endian
|
||||
struct {
|
||||
int32_t depth_layer : 16;
|
||||
int32_t priority : 16;
|
||||
};
|
||||
|
||||
uint32_t depth_key;
|
||||
};
|
||||
|
||||
union {
|
||||
struct {
|
||||
//from least significant to most significant in sort, TODO: should be endian swapped on big endian
|
||||
|
||||
uint64_t geometry_index : 14;
|
||||
uint64_t instancing : 1;
|
||||
uint64_t skeleton : 1;
|
||||
uint64_t shader_index : 10;
|
||||
uint64_t material_index : 10;
|
||||
uint64_t light_index : 8;
|
||||
uint64_t light_type2 : 1; // if 1==0 : nolight/directional, else omni/spot
|
||||
uint64_t refprobe_1_index : 8;
|
||||
uint64_t refprobe_0_index : 8;
|
||||
uint64_t light_type1 : 1; //no light, directional is 0, omni spot is 1
|
||||
uint64_t light_mode : 2; // LightMode enum
|
||||
};
|
||||
|
||||
uint64_t sort_key;
|
||||
};
|
||||
};
|
||||
|
||||
Element *base_elements;
|
||||
Element **elements;
|
||||
|
||||
int element_count;
|
||||
int alpha_element_count;
|
||||
|
||||
void clear() {
|
||||
element_count = 0;
|
||||
alpha_element_count = 0;
|
||||
}
|
||||
|
||||
// sorts
|
||||
|
||||
struct SortByKey {
|
||||
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
|
||||
if (A->depth_key == B->depth_key) {
|
||||
return A->sort_key < B->sort_key;
|
||||
} else {
|
||||
return A->depth_key < B->depth_key;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void sort_by_key(bool p_alpha) {
|
||||
SortArray<Element *, SortByKey> sorter;
|
||||
|
||||
if (p_alpha) {
|
||||
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
|
||||
} else {
|
||||
sorter.sort(elements, element_count);
|
||||
}
|
||||
}
|
||||
|
||||
struct SortByDepth {
|
||||
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
|
||||
return A->instance->depth < B->instance->depth;
|
||||
}
|
||||
};
|
||||
|
||||
void sort_by_depth(bool p_alpha) { //used for shadows
|
||||
|
||||
SortArray<Element *, SortByDepth> sorter;
|
||||
if (p_alpha) {
|
||||
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
|
||||
} else {
|
||||
sorter.sort(elements, element_count);
|
||||
}
|
||||
}
|
||||
|
||||
struct SortByReverseDepthAndPriority {
|
||||
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
|
||||
if (A->priority == B->priority) {
|
||||
return A->instance->depth > B->instance->depth;
|
||||
} else {
|
||||
return A->priority < B->priority;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void sort_by_reverse_depth_and_priority(bool p_alpha) { //used for alpha
|
||||
|
||||
SortArray<Element *, SortByReverseDepthAndPriority> sorter;
|
||||
if (p_alpha) {
|
||||
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
|
||||
} else {
|
||||
sorter.sort(elements, element_count);
|
||||
}
|
||||
}
|
||||
|
||||
// element adding and stuff
|
||||
|
||||
_FORCE_INLINE_ Element *add_element() {
|
||||
if (element_count + alpha_element_count >= max_elements)
|
||||
return NULL;
|
||||
|
||||
elements[element_count] = &base_elements[element_count];
|
||||
return elements[element_count++];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Element *add_alpha_element() {
|
||||
if (element_count + alpha_element_count >= max_elements) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int idx = max_elements - alpha_element_count - 1;
|
||||
elements[idx] = &base_elements[idx];
|
||||
alpha_element_count++;
|
||||
return elements[idx];
|
||||
}
|
||||
|
||||
void init() {
|
||||
element_count = 0;
|
||||
alpha_element_count = 0;
|
||||
|
||||
elements = memnew_arr(Element *, max_elements);
|
||||
base_elements = memnew_arr(Element, max_elements);
|
||||
|
||||
for (int i = 0; i < max_elements; i++) {
|
||||
elements[i] = &base_elements[i];
|
||||
}
|
||||
}
|
||||
|
||||
RenderList() {
|
||||
max_elements = DEFAULT_MAX_ELEMENTS;
|
||||
}
|
||||
|
||||
~RenderList() {
|
||||
memdelete_arr(elements);
|
||||
memdelete_arr(base_elements);
|
||||
}
|
||||
};
|
||||
|
||||
RenderList render_list;
|
||||
|
||||
void _add_geometry(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass);
|
||||
void _add_geometry_with_material(RasterizerStorageGLES2::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES2::GeometryOwner *p_owner, RasterizerStorageGLES2::Material *p_material, bool p_depth_pass, bool p_shadow_pass);
|
||||
|
||||
void _copy_texture_to_buffer(GLuint p_texture, GLuint p_buffer);
|
||||
void _fill_render_list(InstanceBase **p_cull_result, int p_cull_count, bool p_depth_pass, bool p_shadow_pass);
|
||||
void _render_render_list(RenderList::Element **p_elements, int p_element_count,
|
||||
const Transform3D &p_view_transform,
|
||||
const CameraMatrix &p_projection,
|
||||
RID p_shadow_atlas,
|
||||
Environment *p_env,
|
||||
GLuint p_base_env,
|
||||
float p_shadow_bias,
|
||||
float p_shadow_normal_bias,
|
||||
bool p_reverse_cull,
|
||||
bool p_alpha_pass,
|
||||
bool p_shadow);
|
||||
|
||||
void _draw_sky(RasterizerStorageGLES2::Sky *p_sky, const CameraMatrix &p_projection, const Transform3D &p_transform, bool p_vflip, float p_custom_fov, float p_energy, const Basis &p_sky_orientation);
|
||||
|
||||
_FORCE_INLINE_ void _set_cull(bool p_front, bool p_disabled, bool p_reverse_cull);
|
||||
_FORCE_INLINE_ bool _setup_material(RasterizerStorageGLES2::Material *p_material, 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 Transform3D &p_view_transform, bool accum_pass);
|
||||
_FORCE_INLINE_ void _setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform3D &p_view_transform, Environment *p_env);
|
||||
_FORCE_INLINE_ void _render_geometry(RenderList::Element *p_element);
|
||||
|
||||
void _post_process(Environment *env, const CameraMatrix &p_cam_projection);
|
||||
|
||||
virtual void render_scene(const Transform3D &p_cam_transform, const 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_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
|
||||
virtual void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count);
|
||||
virtual bool free(RID p_rid);
|
||||
|
||||
virtual void set_scene_pass(uint64_t p_pass);
|
||||
virtual void set_debug_draw_mode(GD_VS::ViewportDebugDraw p_debug_draw);
|
||||
|
||||
void iteration();
|
||||
void initialize();
|
||||
void finalize();
|
||||
RasterizerSceneGLES2();
|
||||
};
|
||||
|
||||
#endif // godot 3
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
File diff suppressed because it is too large
Load Diff
@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
|
||||
if "GLES2_GLSL" in env["BUILDERS"]:
|
||||
env.GLES2_GLSL("copy.glsl")
|
||||
# env.GLES2_GLSL('resolve.glsl');
|
||||
env.GLES2_GLSL("canvas.glsl")
|
||||
env.GLES2_GLSL("canvas_shadow.glsl")
|
||||
env.GLES2_GLSL("scene.glsl")
|
||||
env.GLES2_GLSL("cubemap_filter.glsl")
|
||||
env.GLES2_GLSL("cube_to_dp.glsl")
|
||||
# env.GLES2_GLSL('blend_shape.glsl');
|
||||
# env.GLES2_GLSL('screen_space_reflection.glsl');
|
||||
env.GLES2_GLSL("effect_blur.glsl")
|
||||
# env.GLES2_GLSL('subsurf_scattering.glsl');
|
||||
# env.GLES2_GLSL('ssao.glsl');
|
||||
# env.GLES2_GLSL('ssao_minify.glsl');
|
||||
# env.GLES2_GLSL('ssao_blur.glsl');
|
||||
# env.GLES2_GLSL('exposure.glsl');
|
||||
env.GLES2_GLSL("tonemap.glsl")
|
||||
# env.GLES2_GLSL('particles.glsl');
|
||||
env.GLES2_GLSL("lens_distorted.glsl")
|
@ -1,192 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
/*
|
||||
from VisualServer:
|
||||
|
||||
ARRAY_VERTEX=0,
|
||||
ARRAY_NORMAL=1,
|
||||
ARRAY_TANGENT=2,
|
||||
ARRAY_COLOR=3,
|
||||
ARRAY_TEX_UV=4,
|
||||
ARRAY_TEX_UV2=5,
|
||||
ARRAY_BONES=6,
|
||||
ARRAY_WEIGHTS=7,
|
||||
ARRAY_INDEX=8,
|
||||
*/
|
||||
|
||||
#ifdef USE_2D_VERTEX
|
||||
#define VFORMAT vec2
|
||||
#else
|
||||
#define VFORMAT vec3
|
||||
#endif
|
||||
|
||||
/* INPUT ATTRIBS */
|
||||
|
||||
layout(location = 0) in highp VFORMAT vertex_attrib;
|
||||
/* clang-format on */
|
||||
layout(location = 1) in vec3 normal_attrib;
|
||||
|
||||
#ifdef ENABLE_TANGENT
|
||||
layout(location = 2) in vec4 tangent_attrib;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
layout(location = 3) in vec4 color_attrib;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV
|
||||
layout(location = 4) in vec2 uv_attrib;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV2
|
||||
layout(location = 5) in vec2 uv2_attrib;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SKELETON
|
||||
layout(location = 6) in ivec4 bone_attrib;
|
||||
layout(location = 7) in vec4 weight_attrib;
|
||||
#endif
|
||||
|
||||
/* BLEND ATTRIBS */
|
||||
|
||||
#ifdef ENABLE_BLEND
|
||||
|
||||
layout(location = 8) in highp VFORMAT vertex_attrib_blend;
|
||||
layout(location = 9) in vec3 normal_attrib_blend;
|
||||
|
||||
#ifdef ENABLE_TANGENT
|
||||
layout(location = 10) in vec4 tangent_attrib_blend;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
layout(location = 11) in vec4 color_attrib_blend;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV
|
||||
layout(location = 12) in vec2 uv_attrib_blend;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV2
|
||||
layout(location = 13) in vec2 uv2_attrib_blend;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SKELETON
|
||||
layout(location = 14) in ivec4 bone_attrib_blend;
|
||||
layout(location = 15) in vec4 weight_attrib_blend;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* OUTPUTS */
|
||||
|
||||
out VFORMAT vertex_out; //tfb:
|
||||
|
||||
#ifdef ENABLE_NORMAL
|
||||
out vec3 normal_out; //tfb:ENABLE_NORMAL
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_TANGENT
|
||||
out vec4 tangent_out; //tfb:ENABLE_TANGENT
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
out vec4 color_out; //tfb:ENABLE_COLOR
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV
|
||||
out vec2 uv_out; //tfb:ENABLE_UV
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV2
|
||||
out vec2 uv2_out; //tfb:ENABLE_UV2
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SKELETON
|
||||
out ivec4 bone_out; //tfb:ENABLE_SKELETON
|
||||
out vec4 weight_out; //tfb:ENABLE_SKELETON
|
||||
#endif
|
||||
|
||||
uniform float blend_amount;
|
||||
|
||||
void main() {
|
||||
#ifdef ENABLE_BLEND
|
||||
|
||||
vertex_out = vertex_attrib_blend + vertex_attrib * blend_amount;
|
||||
|
||||
#ifdef ENABLE_NORMAL
|
||||
normal_out = normal_attrib_blend + normal_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_TANGENT
|
||||
|
||||
tangent_out.xyz = tangent_attrib_blend.xyz + tangent_attrib.xyz * blend_amount;
|
||||
tangent_out.w = tangent_attrib_blend.w; //just copy, no point in blending his
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
|
||||
color_out = color_attrib_blend + color_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV
|
||||
|
||||
uv_out = uv_attrib_blend + uv_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV2
|
||||
|
||||
uv2_out = uv2_attrib_blend + uv2_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SKELETON
|
||||
|
||||
bone_out = bone_attrib_blend;
|
||||
weight_out = weight_attrib_blend + weight_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#else //ENABLE_BLEND
|
||||
|
||||
vertex_out = vertex_attrib * blend_amount;
|
||||
|
||||
#ifdef ENABLE_NORMAL
|
||||
normal_out = normal_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_TANGENT
|
||||
|
||||
tangent_out.xyz = tangent_attrib.xyz * blend_amount;
|
||||
tangent_out.w = tangent_attrib.w; //just copy, no point in blending his
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
|
||||
color_out = color_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV
|
||||
|
||||
uv_out = uv_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UV2
|
||||
|
||||
uv2_out = uv2_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SKELETON
|
||||
|
||||
bone_out = bone_attrib;
|
||||
weight_out = weight_attrib * blend_amount;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
gl_Position = vec4(0.0);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
void main() {
|
||||
}
|
||||
/* clang-format on */
|
@ -1,86 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 vertex_attrib;
|
||||
/* clang-format on */
|
||||
|
||||
void main() {
|
||||
gl_Position = vertex_attrib;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
uniform highp sampler2D source_exposure; //texunit:0
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef EXPOSURE_BEGIN
|
||||
|
||||
uniform highp ivec2 source_render_size;
|
||||
uniform highp ivec2 target_size;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef EXPOSURE_END
|
||||
|
||||
uniform highp sampler2D prev_exposure; //texunit:1
|
||||
uniform highp float exposure_adjust;
|
||||
uniform highp float min_luminance;
|
||||
uniform highp float max_luminance;
|
||||
|
||||
#endif
|
||||
|
||||
layout(location = 0) out highp float exposure;
|
||||
|
||||
void main() {
|
||||
#ifdef EXPOSURE_BEGIN
|
||||
|
||||
ivec2 src_pos = ivec2(gl_FragCoord.xy) * source_render_size / target_size;
|
||||
|
||||
#if 1
|
||||
//more precise and expensive, but less jittery
|
||||
ivec2 next_pos = ivec2(gl_FragCoord.xy + ivec2(1)) * source_render_size / target_size;
|
||||
next_pos = max(next_pos, src_pos + ivec2(1)); //so it at least reads one pixel
|
||||
highp vec3 source_color = vec3(0.0);
|
||||
for (int i = src_pos.x; i < next_pos.x; i++) {
|
||||
for (int j = src_pos.y; j < next_pos.y; j++) {
|
||||
source_color += texelFetch(source_exposure, ivec2(i, j), 0).rgb;
|
||||
}
|
||||
}
|
||||
|
||||
source_color /= float((next_pos.x - src_pos.x) * (next_pos.y - src_pos.y));
|
||||
#else
|
||||
highp vec3 source_color = texelFetch(source_exposure, src_pos, 0).rgb;
|
||||
|
||||
#endif
|
||||
|
||||
exposure = max(source_color.r, max(source_color.g, source_color.b));
|
||||
|
||||
#else
|
||||
|
||||
ivec2 coord = ivec2(gl_FragCoord.xy);
|
||||
exposure = texelFetch(source_exposure, coord * 3 + ivec2(0, 0), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(1, 0), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(2, 0), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(0, 1), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(1, 1), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(2, 1), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(0, 2), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(1, 2), 0).r;
|
||||
exposure += texelFetch(source_exposure, coord * 3 + ivec2(2, 2), 0).r;
|
||||
exposure *= (1.0 / 9.0);
|
||||
|
||||
#ifdef EXPOSURE_END
|
||||
|
||||
#ifdef EXPOSURE_FORCE_SET
|
||||
//will stay as is
|
||||
#else
|
||||
highp float prev_lum = texelFetch(prev_exposure, ivec2(0, 0), 0).r; //1 pixel previous exposure
|
||||
exposure = clamp(prev_lum + (exposure - prev_lum) * exposure_adjust, min_luminance, max_luminance);
|
||||
|
||||
#endif //EXPOSURE_FORCE_SET
|
||||
|
||||
#endif //EXPOSURE_END
|
||||
|
||||
#endif //EXPOSURE_BEGIN
|
||||
}
|
@ -1,258 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 color;
|
||||
/* clang-format on */
|
||||
layout(location = 1) in highp vec4 velocity_active;
|
||||
layout(location = 2) in highp vec4 custom;
|
||||
layout(location = 3) in highp vec4 xform_1;
|
||||
layout(location = 4) in highp vec4 xform_2;
|
||||
layout(location = 5) in highp vec4 xform_3;
|
||||
|
||||
struct Attractor {
|
||||
vec3 pos;
|
||||
vec3 dir;
|
||||
float radius;
|
||||
float eat_radius;
|
||||
float strength;
|
||||
float attenuation;
|
||||
};
|
||||
|
||||
#define MAX_ATTRACTORS 64
|
||||
|
||||
uniform bool emitting;
|
||||
uniform float system_phase;
|
||||
uniform float prev_system_phase;
|
||||
uniform int total_particles;
|
||||
uniform float explosiveness;
|
||||
uniform float randomness;
|
||||
uniform float time;
|
||||
uniform float delta;
|
||||
|
||||
uniform int attractor_count;
|
||||
uniform Attractor attractors[MAX_ATTRACTORS];
|
||||
uniform bool clear;
|
||||
uniform uint cycle;
|
||||
uniform float lifetime;
|
||||
uniform mat4 emission_transform;
|
||||
uniform uint random_seed;
|
||||
|
||||
out highp vec4 out_color; //tfb:
|
||||
out highp vec4 out_velocity_active; //tfb:
|
||||
out highp vec4 out_custom; //tfb:
|
||||
out highp vec4 out_xform_1; //tfb:
|
||||
out highp vec4 out_xform_2; //tfb:
|
||||
out highp vec4 out_xform_3; //tfb:
|
||||
|
||||
#if defined(USE_MATERIAL)
|
||||
|
||||
/* clang-format off */
|
||||
layout(std140) uniform UniformData { //ubo:0
|
||||
|
||||
MATERIAL_UNIFORMS
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
VERTEX_SHADER_GLOBALS
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
uint hash(uint x) {
|
||||
x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b);
|
||||
x = ((x >> uint(16)) ^ x) * uint(0x45d9f3b);
|
||||
x = (x >> uint(16)) ^ x;
|
||||
return x;
|
||||
}
|
||||
|
||||
void main() {
|
||||
#ifdef PARTICLES_COPY
|
||||
|
||||
out_color = color;
|
||||
out_velocity_active = velocity_active;
|
||||
out_custom = custom;
|
||||
out_xform_1 = xform_1;
|
||||
out_xform_2 = xform_2;
|
||||
out_xform_3 = xform_3;
|
||||
|
||||
#else
|
||||
|
||||
bool apply_forces = true;
|
||||
bool apply_velocity = true;
|
||||
float local_delta = delta;
|
||||
|
||||
float mass = 1.0;
|
||||
|
||||
float restart_phase = float(gl_VertexID) / float(total_particles);
|
||||
|
||||
if (randomness > 0.0) {
|
||||
uint seed = cycle;
|
||||
if (restart_phase >= system_phase) {
|
||||
seed -= uint(1);
|
||||
}
|
||||
seed *= uint(total_particles);
|
||||
seed += uint(gl_VertexID);
|
||||
float random = float(hash(seed) % uint(65536)) / 65536.0;
|
||||
restart_phase += randomness * random * 1.0 / float(total_particles);
|
||||
}
|
||||
|
||||
restart_phase *= (1.0 - explosiveness);
|
||||
bool restart = false;
|
||||
bool shader_active = velocity_active.a > 0.5;
|
||||
|
||||
if (system_phase > prev_system_phase) {
|
||||
// restart_phase >= prev_system_phase is used so particles emit in the first frame they are processed
|
||||
|
||||
if (restart_phase >= prev_system_phase && restart_phase < system_phase) {
|
||||
restart = true;
|
||||
#ifdef USE_FRACTIONAL_DELTA
|
||||
local_delta = (system_phase - restart_phase) * lifetime;
|
||||
#endif
|
||||
}
|
||||
|
||||
} else {
|
||||
if (restart_phase >= prev_system_phase) {
|
||||
restart = true;
|
||||
#ifdef USE_FRACTIONAL_DELTA
|
||||
local_delta = (1.0 - restart_phase + system_phase) * lifetime;
|
||||
#endif
|
||||
} else if (restart_phase < system_phase) {
|
||||
restart = true;
|
||||
#ifdef USE_FRACTIONAL_DELTA
|
||||
local_delta = (system_phase - restart_phase) * lifetime;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
uint current_cycle = cycle;
|
||||
|
||||
if (system_phase < restart_phase) {
|
||||
current_cycle -= uint(1);
|
||||
}
|
||||
|
||||
uint particle_number = current_cycle * uint(total_particles) + uint(gl_VertexID);
|
||||
int index = int(gl_VertexID);
|
||||
|
||||
if (restart) {
|
||||
shader_active = emitting;
|
||||
}
|
||||
|
||||
mat4 xform;
|
||||
|
||||
#if defined(ENABLE_KEEP_DATA)
|
||||
if (clear) {
|
||||
#else
|
||||
if (clear || restart) {
|
||||
#endif
|
||||
out_color = vec4(1.0);
|
||||
out_velocity_active = vec4(0.0);
|
||||
out_custom = vec4(0.0);
|
||||
if (!restart)
|
||||
shader_active = false;
|
||||
|
||||
xform = mat4(
|
||||
vec4(1.0, 0.0, 0.0, 0.0),
|
||||
vec4(0.0, 1.0, 0.0, 0.0),
|
||||
vec4(0.0, 0.0, 1.0, 0.0),
|
||||
vec4(0.0, 0.0, 0.0, 1.0));
|
||||
} else {
|
||||
out_color = color;
|
||||
out_velocity_active = velocity_active;
|
||||
out_custom = custom;
|
||||
xform = transpose(mat4(xform_1, xform_2, xform_3, vec4(vec3(0.0), 1.0)));
|
||||
}
|
||||
|
||||
if (shader_active) {
|
||||
//execute shader
|
||||
|
||||
{
|
||||
/* clang-format off */
|
||||
|
||||
VERTEX_SHADER_CODE
|
||||
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_FORCE)
|
||||
|
||||
if (false) {
|
||||
vec3 force = vec3(0.0);
|
||||
for (int i = 0; i < attractor_count; i++) {
|
||||
vec3 rel_vec = xform[3].xyz - attractors[i].pos;
|
||||
float dist = length(rel_vec);
|
||||
if (attractors[i].radius < dist)
|
||||
continue;
|
||||
if (attractors[i].eat_radius > 0.0 && attractors[i].eat_radius > dist) {
|
||||
out_velocity_active.a = 0.0;
|
||||
}
|
||||
|
||||
rel_vec = normalize(rel_vec);
|
||||
|
||||
float attenuation = pow(dist / attractors[i].radius, attractors[i].attenuation);
|
||||
|
||||
if (attractors[i].dir == vec3(0.0)) {
|
||||
//towards center
|
||||
force += attractors[i].strength * rel_vec * attenuation * mass;
|
||||
} else {
|
||||
force += attractors[i].strength * attractors[i].dir * attenuation * mass;
|
||||
}
|
||||
}
|
||||
|
||||
out_velocity_active.xyz += force * local_delta;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_VELOCITY)
|
||||
|
||||
if (true) {
|
||||
xform[3].xyz += out_velocity_active.xyz * local_delta;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
xform = mat4(0.0);
|
||||
}
|
||||
|
||||
xform = transpose(xform);
|
||||
|
||||
out_velocity_active.a = mix(0.0, 1.0, shader_active);
|
||||
|
||||
out_xform_1 = xform[0];
|
||||
out_xform_2 = xform[1];
|
||||
out_xform_3 = xform[2];
|
||||
|
||||
#endif //PARTICLES_COPY
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
//any code here is never executed, stuff is filled just so it works
|
||||
|
||||
#if defined(USE_MATERIAL)
|
||||
|
||||
layout(std140) uniform UniformData {
|
||||
|
||||
MATERIAL_UNIFORMS
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
|
||||
void main() {
|
||||
{
|
||||
|
||||
LIGHT_SHADER_CODE
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
FRAGMENT_SHADER_CODE
|
||||
|
||||
}
|
||||
}
|
||||
/* clang-format on */
|
@ -1,42 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 vertex_attrib;
|
||||
/* clang-format on */
|
||||
layout(location = 4) in vec2 uv_in;
|
||||
|
||||
out vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = uv_in;
|
||||
gl_Position = vertex_attrib;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
#if !defined(GLES_OVER_GL)
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
in vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
uniform sampler2D source_specular; //texunit:0
|
||||
uniform sampler2D source_ssr; //texunit:1
|
||||
|
||||
uniform vec2 pixel_size;
|
||||
|
||||
in vec2 uv2_interp;
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
vec4 specular = texture(source_specular, uv_interp);
|
||||
|
||||
#ifdef USE_SSR
|
||||
vec4 ssr = textureLod(source_ssr, uv_interp, 0.0);
|
||||
specular.rgb = mix(specular.rgb, ssr.rgb * specular.a, ssr.a);
|
||||
#endif
|
||||
|
||||
frag_color = vec4(specular.rgb, 1.0);
|
||||
}
|
@ -1,284 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 vertex_attrib;
|
||||
/* clang-format on */
|
||||
layout(location = 4) in vec2 uv_in;
|
||||
|
||||
out vec2 uv_interp;
|
||||
out vec2 pos_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = uv_in;
|
||||
gl_Position = vertex_attrib;
|
||||
pos_interp.xy = gl_Position.xy;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
in vec2 uv_interp;
|
||||
/* clang-format on */
|
||||
in vec2 pos_interp;
|
||||
|
||||
uniform sampler2D source_diffuse; //texunit:0
|
||||
uniform sampler2D source_normal_roughness; //texunit:1
|
||||
uniform sampler2D source_depth; //texunit:2
|
||||
|
||||
uniform float camera_z_near;
|
||||
uniform float camera_z_far;
|
||||
|
||||
uniform vec2 viewport_size;
|
||||
uniform vec2 pixel_size;
|
||||
|
||||
uniform float filter_mipmap_levels;
|
||||
|
||||
uniform mat4 inverse_projection;
|
||||
uniform mat4 projection;
|
||||
|
||||
uniform int num_steps;
|
||||
uniform float depth_tolerance;
|
||||
uniform float distance_fade;
|
||||
uniform float curve_fade_in;
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
vec2 view_to_screen(vec3 view_pos, out float w) {
|
||||
vec4 projected = projection * vec4(view_pos, 1.0);
|
||||
projected.xyz /= projected.w;
|
||||
projected.xy = projected.xy * 0.5 + 0.5;
|
||||
w = projected.w;
|
||||
return projected.xy;
|
||||
}
|
||||
|
||||
#define M_PI 3.14159265359
|
||||
|
||||
void main() {
|
||||
vec4 diffuse = texture(source_diffuse, uv_interp);
|
||||
vec4 normal_roughness = texture(source_normal_roughness, uv_interp);
|
||||
|
||||
vec3 normal;
|
||||
|
||||
normal = normal_roughness.xyz * 2.0 - 1.0;
|
||||
|
||||
float roughness = normal_roughness.w;
|
||||
|
||||
float depth_tex = texture(source_depth, uv_interp).r;
|
||||
|
||||
vec4 world_pos = inverse_projection * vec4(uv_interp * 2.0 - 1.0, depth_tex * 2.0 - 1.0, 1.0);
|
||||
vec3 vertex = world_pos.xyz / world_pos.w;
|
||||
|
||||
vec3 view_dir = normalize(vertex);
|
||||
vec3 ray_dir = normalize(reflect(view_dir, normal));
|
||||
|
||||
if (dot(ray_dir, normal) < 0.001) {
|
||||
frag_color = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
//ray_dir = normalize(view_dir - normal * dot(normal,view_dir) * 2.0);
|
||||
|
||||
//ray_dir = normalize(vec3(1,1,-1));
|
||||
|
||||
////////////////
|
||||
|
||||
//make ray length and clip it against the near plane (don't want to trace beyond visible)
|
||||
float ray_len = (vertex.z + ray_dir.z * camera_z_far) > -camera_z_near ? (-camera_z_near - vertex.z) / ray_dir.z : camera_z_far;
|
||||
vec3 ray_end = vertex + ray_dir * ray_len;
|
||||
|
||||
float w_begin;
|
||||
vec2 vp_line_begin = view_to_screen(vertex, w_begin);
|
||||
float w_end;
|
||||
vec2 vp_line_end = view_to_screen(ray_end, w_end);
|
||||
vec2 vp_line_dir = vp_line_end - vp_line_begin;
|
||||
|
||||
//we need to interpolate w along the ray, to generate perspective correct reflections
|
||||
|
||||
w_begin = 1.0 / w_begin;
|
||||
w_end = 1.0 / w_end;
|
||||
|
||||
float z_begin = vertex.z * w_begin;
|
||||
float z_end = ray_end.z * w_end;
|
||||
|
||||
vec2 line_begin = vp_line_begin / pixel_size;
|
||||
vec2 line_dir = vp_line_dir / pixel_size;
|
||||
float z_dir = z_end - z_begin;
|
||||
float w_dir = w_end - w_begin;
|
||||
|
||||
// clip the line to the viewport edges
|
||||
|
||||
float scale_max_x = min(1.0, 0.99 * (1.0 - vp_line_begin.x) / max(1e-5, vp_line_dir.x));
|
||||
float scale_max_y = min(1.0, 0.99 * (1.0 - vp_line_begin.y) / max(1e-5, vp_line_dir.y));
|
||||
float scale_min_x = min(1.0, 0.99 * vp_line_begin.x / max(1e-5, -vp_line_dir.x));
|
||||
float scale_min_y = min(1.0, 0.99 * vp_line_begin.y / max(1e-5, -vp_line_dir.y));
|
||||
float line_clip = min(scale_max_x, scale_max_y) * min(scale_min_x, scale_min_y);
|
||||
line_dir *= line_clip;
|
||||
z_dir *= line_clip;
|
||||
w_dir *= line_clip;
|
||||
|
||||
//clip z and w advance to line advance
|
||||
vec2 line_advance = normalize(line_dir); //down to pixel
|
||||
float step_size = length(line_advance) / length(line_dir);
|
||||
float z_advance = z_dir * step_size; // adapt z advance to line advance
|
||||
float w_advance = w_dir * step_size; // adapt w advance to line advance
|
||||
|
||||
//make line advance faster if direction is closer to pixel edges (this avoids sampling the same pixel twice)
|
||||
float advance_angle_adj = 1.0 / max(abs(line_advance.x), abs(line_advance.y));
|
||||
line_advance *= advance_angle_adj; // adapt z advance to line advance
|
||||
z_advance *= advance_angle_adj;
|
||||
w_advance *= advance_angle_adj;
|
||||
|
||||
vec2 pos = line_begin;
|
||||
float z = z_begin;
|
||||
float w = w_begin;
|
||||
float z_from = z / w;
|
||||
float z_to = z_from;
|
||||
float depth;
|
||||
vec2 prev_pos = pos;
|
||||
|
||||
bool found = false;
|
||||
|
||||
float steps_taken = 0.0;
|
||||
|
||||
for (int i = 0; i < num_steps; i++) {
|
||||
pos += line_advance;
|
||||
z += z_advance;
|
||||
w += w_advance;
|
||||
|
||||
//convert to linear depth
|
||||
|
||||
depth = texture(source_depth, pos * pixel_size).r * 2.0 - 1.0;
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
depth = ((depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
|
||||
#else
|
||||
depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near));
|
||||
#endif
|
||||
depth = -depth;
|
||||
|
||||
z_from = z_to;
|
||||
z_to = z / w;
|
||||
|
||||
if (depth > z_to) {
|
||||
//if depth was surpassed
|
||||
if (depth <= max(z_to, z_from) + depth_tolerance) {
|
||||
//check the depth tolerance
|
||||
found = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
steps_taken += 1.0;
|
||||
prev_pos = pos;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
float margin_blend = 1.0;
|
||||
|
||||
vec2 margin = vec2((viewport_size.x + viewport_size.y) * 0.5 * 0.05); //make a uniform margin
|
||||
if (any(bvec4(lessThan(pos, -margin), greaterThan(pos, viewport_size + margin)))) {
|
||||
//clip outside screen + margin
|
||||
frag_color = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
//blend fading out towards external margin
|
||||
vec2 margin_grad = mix(pos - viewport_size, -pos, lessThan(pos, vec2(0.0)));
|
||||
margin_blend = 1.0 - smoothstep(0.0, margin.x, max(margin_grad.x, margin_grad.y));
|
||||
//margin_blend=1.0;
|
||||
}
|
||||
|
||||
vec2 final_pos;
|
||||
float grad;
|
||||
grad = steps_taken / float(num_steps);
|
||||
float initial_fade = curve_fade_in == 0.0 ? 1.0 : pow(clamp(grad, 0.0, 1.0), curve_fade_in);
|
||||
float fade = pow(clamp(1.0 - grad, 0.0, 1.0), distance_fade) * initial_fade;
|
||||
final_pos = pos;
|
||||
|
||||
#ifdef REFLECT_ROUGHNESS
|
||||
|
||||
vec4 final_color;
|
||||
//if roughness is enabled, do screen space cone tracing
|
||||
if (roughness > 0.001) {
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//use a blurred version (in consecutive mipmaps) of the screen to simulate roughness
|
||||
|
||||
float gloss = 1.0 - roughness;
|
||||
float cone_angle = roughness * M_PI * 0.5;
|
||||
vec2 cone_dir = final_pos - line_begin;
|
||||
float cone_len = length(cone_dir);
|
||||
cone_dir = normalize(cone_dir); //will be used normalized from now on
|
||||
float max_mipmap = filter_mipmap_levels - 1.0;
|
||||
float gloss_mult = gloss;
|
||||
|
||||
float rem_alpha = 1.0;
|
||||
final_color = vec4(0.0);
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
float op_len = 2.0 * tan(cone_angle) * cone_len; //opposite side of iso triangle
|
||||
float radius;
|
||||
{
|
||||
//fit to sphere inside cone (sphere ends at end of cone), something like this:
|
||||
// ___
|
||||
// \O/
|
||||
// V
|
||||
//
|
||||
// as it avoids bleeding from beyond the reflection as much as possible. As a plus
|
||||
// it also makes the rough reflection more elongated.
|
||||
float a = op_len;
|
||||
float h = cone_len;
|
||||
float a2 = a * a;
|
||||
float fh2 = 4.0f * h * h;
|
||||
radius = (a * (sqrt(a2 + fh2) - a)) / (4.0f * h);
|
||||
}
|
||||
|
||||
//find the place where screen must be sampled
|
||||
vec2 sample_pos = (line_begin + cone_dir * (cone_len - radius)) * pixel_size;
|
||||
//radius is in pixels, so it's natural that log2(radius) maps to the right mipmap for the amount of pixels
|
||||
float mipmap = clamp(log2(radius), 0.0, max_mipmap);
|
||||
|
||||
//mipmap = max(mipmap-1.0,0.0);
|
||||
//do sampling
|
||||
|
||||
vec4 sample_color;
|
||||
{
|
||||
sample_color = textureLod(source_diffuse, sample_pos, mipmap);
|
||||
}
|
||||
|
||||
//multiply by gloss
|
||||
sample_color.rgb *= gloss_mult;
|
||||
sample_color.a = gloss_mult;
|
||||
|
||||
rem_alpha -= sample_color.a;
|
||||
if (rem_alpha < 0.0) {
|
||||
sample_color.rgb *= (1.0 - abs(rem_alpha));
|
||||
}
|
||||
|
||||
final_color += sample_color;
|
||||
|
||||
if (final_color.a >= 0.95) {
|
||||
// This code of accumulating gloss and aborting on near one
|
||||
// makes sense when you think of cone tracing.
|
||||
// Think of it as if roughness was 0, then we could abort on the first
|
||||
// iteration. For lesser roughness values, we need more iterations, but
|
||||
// each needs to have less influence given the sphere is smaller
|
||||
break;
|
||||
}
|
||||
|
||||
cone_len -= radius * 2.0; //go to next (smaller) circle.
|
||||
|
||||
gloss_mult *= gloss;
|
||||
}
|
||||
} else {
|
||||
final_color = textureLod(source_diffuse, final_pos * pixel_size, 0.0);
|
||||
}
|
||||
|
||||
frag_color = vec4(final_color.rgb, fade * margin_blend);
|
||||
|
||||
#else
|
||||
frag_color = vec4(textureLod(source_diffuse, final_pos * pixel_size, 0.0).rgb, fade * margin_blend);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
frag_color = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
@ -1,283 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 vertex_attrib;
|
||||
/* clang-format on */
|
||||
|
||||
void main() {
|
||||
gl_Position = vertex_attrib;
|
||||
gl_Position.z = 1.0;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
#define TWO_PI 6.283185307179586476925286766559
|
||||
|
||||
#ifdef SSAO_QUALITY_HIGH
|
||||
|
||||
#define NUM_SAMPLES (80)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SSAO_QUALITY_LOW
|
||||
|
||||
#define NUM_SAMPLES (15)
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(SSAO_QUALITY_LOW) && !defined(SSAO_QUALITY_HIGH)
|
||||
|
||||
#define NUM_SAMPLES (40)
|
||||
|
||||
#endif
|
||||
|
||||
// If using depth mip levels, the log of the maximum pixel offset before we need to switch to a lower
|
||||
// miplevel to maintain reasonable spatial locality in the cache
|
||||
// If this number is too small (< 3), too many taps will land in the same pixel, and we'll get bad variance that manifests as flashing.
|
||||
// If it is too high (> 5), we'll get bad performance because we're not using the MIP levels effectively
|
||||
#define LOG_MAX_OFFSET (3)
|
||||
|
||||
// This must be less than or equal to the MAX_MIP_LEVEL defined in SSAO.cpp
|
||||
#define MAX_MIP_LEVEL (4)
|
||||
|
||||
// This is the number of turns around the circle that the spiral pattern makes. This should be prime to prevent
|
||||
// taps from lining up. This particular choice was tuned for NUM_SAMPLES == 9
|
||||
|
||||
const int ROTATIONS[] = int[](
|
||||
1, 1, 2, 3, 2, 5, 2, 3, 2,
|
||||
3, 3, 5, 5, 3, 4, 7, 5, 5, 7,
|
||||
9, 8, 5, 5, 7, 7, 7, 8, 5, 8,
|
||||
11, 12, 7, 10, 13, 8, 11, 8, 7, 14,
|
||||
11, 11, 13, 12, 13, 19, 17, 13, 11, 18,
|
||||
19, 11, 11, 14, 17, 21, 15, 16, 17, 18,
|
||||
13, 17, 11, 17, 19, 18, 25, 18, 19, 19,
|
||||
29, 21, 19, 27, 31, 29, 21, 18, 17, 29,
|
||||
31, 31, 23, 18, 25, 26, 25, 23, 19, 34,
|
||||
19, 27, 21, 25, 39, 29, 17, 21, 27);
|
||||
/* clang-format on */
|
||||
|
||||
//#define NUM_SPIRAL_TURNS (7)
|
||||
const int NUM_SPIRAL_TURNS = ROTATIONS[NUM_SAMPLES - 1];
|
||||
|
||||
uniform sampler2D source_depth; //texunit:0
|
||||
uniform highp usampler2D source_depth_mipmaps; //texunit:1
|
||||
uniform sampler2D source_normal; //texunit:2
|
||||
|
||||
uniform ivec2 screen_size;
|
||||
uniform float camera_z_far;
|
||||
uniform float camera_z_near;
|
||||
|
||||
uniform float intensity_div_r6;
|
||||
uniform float radius;
|
||||
|
||||
#ifdef ENABLE_RADIUS2
|
||||
uniform float intensity_div_r62;
|
||||
uniform float radius2;
|
||||
#endif
|
||||
|
||||
uniform float bias;
|
||||
uniform float proj_scale;
|
||||
|
||||
layout(location = 0) out float visibility;
|
||||
|
||||
uniform vec4 proj_info;
|
||||
|
||||
vec3 reconstructCSPosition(vec2 S, float z) {
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
return vec3((S.xy * proj_info.xy + proj_info.zw), z);
|
||||
#else
|
||||
return vec3((S.xy * proj_info.xy + proj_info.zw) * z, z);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
vec3 getPosition(ivec2 ssP) {
|
||||
vec3 P;
|
||||
P.z = texelFetch(source_depth, ssP, 0).r;
|
||||
|
||||
P.z = P.z * 2.0 - 1.0;
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
P.z = ((P.z + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
|
||||
#else
|
||||
P.z = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - P.z * (camera_z_far - camera_z_near));
|
||||
#endif
|
||||
P.z = -P.z;
|
||||
|
||||
// Offset to pixel center
|
||||
P = reconstructCSPosition(vec2(ssP) + vec2(0.5), P.z);
|
||||
return P;
|
||||
}
|
||||
|
||||
/** Reconstructs screen-space unit normal from screen-space position */
|
||||
vec3 reconstructCSFaceNormal(vec3 C) {
|
||||
return normalize(cross(dFdy(C), dFdx(C)));
|
||||
}
|
||||
|
||||
/** Returns a unit vector and a screen-space radius for the tap on a unit disk (the caller should scale by the actual disk radius) */
|
||||
vec2 tapLocation(int sampleNumber, float spinAngle, out float ssR) {
|
||||
// Radius relative to ssR
|
||||
float alpha = (float(sampleNumber) + 0.5) * (1.0 / float(NUM_SAMPLES));
|
||||
float angle = alpha * (float(NUM_SPIRAL_TURNS) * 6.28) + spinAngle;
|
||||
|
||||
ssR = alpha;
|
||||
return vec2(cos(angle), sin(angle));
|
||||
}
|
||||
|
||||
/** Read the camera-space position of the point at screen-space pixel ssP + unitOffset * ssR. Assumes length(unitOffset) == 1 */
|
||||
vec3 getOffsetPosition(ivec2 ssC, vec2 unitOffset, float ssR) {
|
||||
// Derivation:
|
||||
// mipLevel = floor(log(ssR / MAX_OFFSET));
|
||||
int mipLevel = clamp(int(floor(log2(ssR))) - LOG_MAX_OFFSET, 0, MAX_MIP_LEVEL);
|
||||
|
||||
ivec2 ssP = ivec2(ssR * unitOffset) + ssC;
|
||||
|
||||
vec3 P;
|
||||
|
||||
// We need to divide by 2^mipLevel to read the appropriately scaled coordinate from a MIP-map.
|
||||
// Manually clamp to the texture size because texelFetch bypasses the texture unit
|
||||
ivec2 mipP = clamp(ssP >> mipLevel, ivec2(0), (screen_size >> mipLevel) - ivec2(1));
|
||||
|
||||
if (mipLevel < 1) {
|
||||
//read from depth buffer
|
||||
P.z = texelFetch(source_depth, mipP, 0).r;
|
||||
P.z = P.z * 2.0 - 1.0;
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
P.z = ((P.z + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
|
||||
#else
|
||||
P.z = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - P.z * (camera_z_far - camera_z_near));
|
||||
|
||||
#endif
|
||||
P.z = -P.z;
|
||||
|
||||
} else {
|
||||
//read from mipmaps
|
||||
uint d = texelFetch(source_depth_mipmaps, mipP, mipLevel - 1).r;
|
||||
P.z = -(float(d) / 65535.0) * camera_z_far;
|
||||
}
|
||||
|
||||
// Offset to pixel center
|
||||
P = reconstructCSPosition(vec2(ssP) + vec2(0.5), P.z);
|
||||
|
||||
return P;
|
||||
}
|
||||
|
||||
/** Compute the occlusion due to sample with index \a i about the pixel at \a ssC that corresponds
|
||||
to camera-space point \a C with unit normal \a n_C, using maximum screen-space sampling radius \a ssDiskRadius
|
||||
|
||||
Note that units of H() in the HPG12 paper are meters, not
|
||||
unitless. The whole falloff/sampling function is therefore
|
||||
unitless. In this implementation, we factor out (9 / radius).
|
||||
|
||||
Four versions of the falloff function are implemented below
|
||||
*/
|
||||
float sampleAO(in ivec2 ssC, in vec3 C, in vec3 n_C, in float ssDiskRadius, in float p_radius, in int tapIndex, in float randomPatternRotationAngle) {
|
||||
// Offset on the unit disk, spun for this pixel
|
||||
float ssR;
|
||||
vec2 unitOffset = tapLocation(tapIndex, randomPatternRotationAngle, ssR);
|
||||
ssR *= ssDiskRadius;
|
||||
|
||||
// The occluding point in camera space
|
||||
vec3 Q = getOffsetPosition(ssC, unitOffset, ssR);
|
||||
|
||||
vec3 v = Q - C;
|
||||
|
||||
float vv = dot(v, v);
|
||||
float vn = dot(v, n_C);
|
||||
|
||||
const float epsilon = 0.01;
|
||||
float radius2 = p_radius * p_radius;
|
||||
|
||||
// A: From the HPG12 paper
|
||||
// Note large epsilon to avoid overdarkening within cracks
|
||||
//return float(vv < radius2) * max((vn - bias) / (epsilon + vv), 0.0) * radius2 * 0.6;
|
||||
|
||||
// B: Smoother transition to zero (lowers contrast, smoothing out corners). [Recommended]
|
||||
float f = max(radius2 - vv, 0.0);
|
||||
return f * f * f * max((vn - bias) / (epsilon + vv), 0.0);
|
||||
|
||||
// C: Medium contrast (which looks better at high radii), no division. Note that the
|
||||
// contribution still falls off with radius^2, but we've adjusted the rate in a way that is
|
||||
// more computationally efficient and happens to be aesthetically pleasing.
|
||||
// return 4.0 * max(1.0 - vv * invRadius2, 0.0) * max(vn - bias, 0.0);
|
||||
|
||||
// D: Low contrast, no division operation
|
||||
// return 2.0 * float(vv < radius * radius) * max(vn - bias, 0.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Pixel being shaded
|
||||
ivec2 ssC = ivec2(gl_FragCoord.xy);
|
||||
|
||||
// World space point being shaded
|
||||
vec3 C = getPosition(ssC);
|
||||
|
||||
/*
|
||||
if (C.z <= -camera_z_far*0.999) {
|
||||
// We're on the skybox
|
||||
visibility=1.0;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
//visibility=-C.z/camera_z_far;
|
||||
//return;
|
||||
#if 0
|
||||
vec3 n_C = texelFetch(source_normal,ssC,0).rgb * 2.0 - 1.0;
|
||||
#else
|
||||
vec3 n_C = reconstructCSFaceNormal(C);
|
||||
n_C = -n_C;
|
||||
#endif
|
||||
|
||||
// Hash function used in the HPG12 AlchemyAO paper
|
||||
float randomPatternRotationAngle = mod(float((3 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 10), TWO_PI);
|
||||
|
||||
// Reconstruct normals from positions. These will lead to 1-pixel black lines
|
||||
// at depth discontinuities, however the blur will wipe those out so they are not visible
|
||||
// in the final image.
|
||||
|
||||
// Choose the screen-space sample radius
|
||||
// proportional to the projected area of the sphere
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
float ssDiskRadius = -proj_scale * radius;
|
||||
#else
|
||||
float ssDiskRadius = -proj_scale * radius / C.z;
|
||||
#endif
|
||||
float sum = 0.0;
|
||||
for (int i = 0; i < NUM_SAMPLES; ++i) {
|
||||
sum += sampleAO(ssC, C, n_C, ssDiskRadius, radius, i, randomPatternRotationAngle);
|
||||
}
|
||||
|
||||
float A = max(0.0, 1.0 - sum * intensity_div_r6 * (5.0 / float(NUM_SAMPLES)));
|
||||
|
||||
#ifdef ENABLE_RADIUS2
|
||||
|
||||
//go again for radius2
|
||||
randomPatternRotationAngle = mod(float((5 * ssC.x ^ ssC.y + ssC.x * ssC.y) * 11), TWO_PI);
|
||||
|
||||
// Reconstruct normals from positions. These will lead to 1-pixel black lines
|
||||
// at depth discontinuities, however the blur will wipe those out so they are not visible
|
||||
// in the final image.
|
||||
|
||||
// Choose the screen-space sample radius
|
||||
// proportional to the projected area of the sphere
|
||||
ssDiskRadius = -proj_scale * radius2 / C.z;
|
||||
|
||||
sum = 0.0;
|
||||
for (int i = 0; i < NUM_SAMPLES; ++i) {
|
||||
sum += sampleAO(ssC, C, n_C, ssDiskRadius, radius2, i, randomPatternRotationAngle);
|
||||
}
|
||||
|
||||
A = min(A, max(0.0, 1.0 - sum * intensity_div_r62 * (5.0 / float(NUM_SAMPLES))));
|
||||
#endif
|
||||
// Bilateral box-filter over a quad for free, respecting depth edges
|
||||
// (the difference that this makes is subtle)
|
||||
if (abs(dFdx(C.z)) < 0.02) {
|
||||
A -= dFdx(A) * (float(ssC.x & 1) - 0.5);
|
||||
}
|
||||
if (abs(dFdy(C.z)) < 0.02) {
|
||||
A -= dFdy(A) * (float(ssC.y & 1) - 0.5);
|
||||
}
|
||||
|
||||
visibility = A;
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 vertex_attrib;
|
||||
/* clang-format on */
|
||||
|
||||
void main() {
|
||||
gl_Position = vertex_attrib;
|
||||
gl_Position.z = 1.0;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
uniform sampler2D source_ssao; //texunit:0
|
||||
/* clang-format on */
|
||||
uniform sampler2D source_depth; //texunit:1
|
||||
uniform sampler2D source_normal; //texunit:3
|
||||
|
||||
layout(location = 0) out float visibility;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Tunable Parameters:
|
||||
|
||||
/** Increase to make depth edges crisper. Decrease to reduce flicker. */
|
||||
uniform float edge_sharpness;
|
||||
|
||||
/** Step in 2-pixel intervals since we already blurred against neighbors in the
|
||||
first AO pass. This constant can be increased while R decreases to improve
|
||||
performance at the expense of some dithering artifacts.
|
||||
|
||||
Morgan found that a scale of 3 left a 1-pixel checkerboard grid that was
|
||||
unobjectionable after shading was applied but eliminated most temporal incoherence
|
||||
from using small numbers of sample taps.
|
||||
*/
|
||||
|
||||
uniform int filter_scale;
|
||||
|
||||
/** Filter radius in pixels. This will be multiplied by SCALE. */
|
||||
#define R (4)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Gaussian coefficients
|
||||
const float gaussian[R + 1] =
|
||||
//float[](0.356642, 0.239400, 0.072410, 0.009869);
|
||||
//float[](0.398943, 0.241971, 0.053991, 0.004432, 0.000134); // stddev = 1.0
|
||||
float[](0.153170, 0.144893, 0.122649, 0.092902, 0.062970); // stddev = 2.0
|
||||
//float[](0.111220, 0.107798, 0.098151, 0.083953, 0.067458, 0.050920, 0.036108); // stddev = 3.0
|
||||
|
||||
/** (1, 0) or (0, 1)*/
|
||||
uniform ivec2 axis;
|
||||
|
||||
uniform float camera_z_far;
|
||||
uniform float camera_z_near;
|
||||
|
||||
uniform ivec2 screen_size;
|
||||
|
||||
void main() {
|
||||
ivec2 ssC = ivec2(gl_FragCoord.xy);
|
||||
|
||||
float depth = texelFetch(source_depth, ssC, 0).r;
|
||||
//vec3 normal = texelFetch(source_normal,ssC,0).rgb * 2.0 - 1.0;
|
||||
|
||||
depth = depth * 2.0 - 1.0;
|
||||
depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near));
|
||||
|
||||
float depth_divide = 1.0 / camera_z_far;
|
||||
|
||||
//depth *= depth_divide;
|
||||
|
||||
/*
|
||||
if (depth > camera_z_far * 0.999) {
|
||||
discard; //skybox
|
||||
}
|
||||
*/
|
||||
|
||||
float sum = texelFetch(source_ssao, ssC, 0).r;
|
||||
|
||||
// Base weight for depth falloff. Increase this for more blurriness,
|
||||
// decrease it for better edge discrimination
|
||||
float BASE = gaussian[0];
|
||||
float totalWeight = BASE;
|
||||
sum *= totalWeight;
|
||||
|
||||
ivec2 clamp_limit = screen_size - ivec2(1);
|
||||
|
||||
for (int r = -R; r <= R; ++r) {
|
||||
// We already handled the zero case above. This loop should be unrolled and the static branch optimized out,
|
||||
// so the IF statement has no runtime cost
|
||||
if (r != 0) {
|
||||
ivec2 ppos = ssC + axis * (r * filter_scale);
|
||||
float value = texelFetch(source_ssao, clamp(ppos, ivec2(0), clamp_limit), 0).r;
|
||||
ivec2 rpos = clamp(ppos, ivec2(0), clamp_limit);
|
||||
float temp_depth = texelFetch(source_depth, rpos, 0).r;
|
||||
//vec3 temp_normal = texelFetch(source_normal, rpos, 0).rgb * 2.0 - 1.0;
|
||||
|
||||
temp_depth = temp_depth * 2.0 - 1.0;
|
||||
temp_depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - temp_depth * (camera_z_far - camera_z_near));
|
||||
// temp_depth *= depth_divide;
|
||||
|
||||
// spatial domain: offset gaussian tap
|
||||
float weight = 0.3 + gaussian[abs(r)];
|
||||
//weight *= max(0.0,dot(temp_normal,normal));
|
||||
|
||||
// range domain (the "bilateral" weight). As depth difference increases, decrease weight.
|
||||
weight *= max(0.0, 1.0 - edge_sharpness * abs(temp_depth - depth));
|
||||
|
||||
sum += value * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
}
|
||||
|
||||
const float epsilon = 0.0001;
|
||||
visibility = sum / (totalWeight + epsilon);
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 vertex_attrib;
|
||||
/* clang-format on */
|
||||
|
||||
void main() {
|
||||
gl_Position = vertex_attrib;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
#ifdef MINIFY_START
|
||||
|
||||
#define SDEPTH_TYPE highp sampler2D
|
||||
uniform float camera_z_far;
|
||||
uniform float camera_z_near;
|
||||
/* clang-format on */
|
||||
|
||||
#else
|
||||
|
||||
#define SDEPTH_TYPE mediump usampler2D
|
||||
|
||||
#endif
|
||||
|
||||
uniform SDEPTH_TYPE source_depth; //texunit:0
|
||||
|
||||
uniform ivec2 from_size;
|
||||
uniform int source_mipmap;
|
||||
|
||||
layout(location = 0) out mediump uint depth;
|
||||
|
||||
void main() {
|
||||
ivec2 ssP = ivec2(gl_FragCoord.xy);
|
||||
|
||||
// Rotated grid subsampling to avoid XY directional bias or Z precision bias while downsampling.
|
||||
// On DX9, the bit-and can be implemented with floating-point modulo
|
||||
|
||||
#ifdef MINIFY_START
|
||||
float fdepth = texelFetch(source_depth, clamp(ssP * 2 + ivec2(ssP.y & 1, ssP.x & 1), ivec2(0), from_size - ivec2(1)), source_mipmap).r;
|
||||
fdepth = fdepth * 2.0 - 1.0;
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
fdepth = ((fdepth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
|
||||
#else
|
||||
fdepth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - fdepth * (camera_z_far - camera_z_near));
|
||||
#endif
|
||||
fdepth /= camera_z_far;
|
||||
depth = uint(clamp(fdepth * 65535.0, 0.0, 65535.0));
|
||||
|
||||
#else
|
||||
depth = texelFetch(source_depth, clamp(ssP * 2 + ivec2(ssP.y & 1, ssP.x & 1), ivec2(0), from_size - ivec2(1)), source_mipmap).r;
|
||||
#endif
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
/* clang-format off */
|
||||
[vertex]
|
||||
|
||||
layout(location = 0) in highp vec4 vertex_attrib;
|
||||
/* clang-format on */
|
||||
layout(location = 4) in vec2 uv_in;
|
||||
|
||||
out vec2 uv_interp;
|
||||
|
||||
void main() {
|
||||
uv_interp = uv_in;
|
||||
gl_Position = vertex_attrib;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
//#define QUALIFIER uniform // some guy on the interweb says it may be faster with this
|
||||
#define QUALIFIER const
|
||||
|
||||
#ifdef USE_25_SAMPLES
|
||||
const int kernel_size = 25;
|
||||
/* clang-format on */
|
||||
QUALIFIER vec2 kernel[25] = vec2[](
|
||||
vec2(0.530605, 0.0),
|
||||
vec2(0.000973794, -3.0),
|
||||
vec2(0.00333804, -2.52083),
|
||||
vec2(0.00500364, -2.08333),
|
||||
vec2(0.00700976, -1.6875),
|
||||
vec2(0.0094389, -1.33333),
|
||||
vec2(0.0128496, -1.02083),
|
||||
vec2(0.017924, -0.75),
|
||||
vec2(0.0263642, -0.520833),
|
||||
vec2(0.0410172, -0.333333),
|
||||
vec2(0.0493588, -0.1875),
|
||||
vec2(0.0402784, -0.0833333),
|
||||
vec2(0.0211412, -0.0208333),
|
||||
vec2(0.0211412, 0.0208333),
|
||||
vec2(0.0402784, 0.0833333),
|
||||
vec2(0.0493588, 0.1875),
|
||||
vec2(0.0410172, 0.333333),
|
||||
vec2(0.0263642, 0.520833),
|
||||
vec2(0.017924, 0.75),
|
||||
vec2(0.0128496, 1.02083),
|
||||
vec2(0.0094389, 1.33333),
|
||||
vec2(0.00700976, 1.6875),
|
||||
vec2(0.00500364, 2.08333),
|
||||
vec2(0.00333804, 2.52083),
|
||||
vec2(0.000973794, 3.0));
|
||||
#endif //USE_25_SAMPLES
|
||||
|
||||
#ifdef USE_17_SAMPLES
|
||||
const int kernel_size = 17;
|
||||
QUALIFIER vec2 kernel[17] = vec2[](
|
||||
vec2(0.536343, 0.0),
|
||||
vec2(0.00317394, -2.0),
|
||||
vec2(0.0100386, -1.53125),
|
||||
vec2(0.0144609, -1.125),
|
||||
vec2(0.0216301, -0.78125),
|
||||
vec2(0.0347317, -0.5),
|
||||
vec2(0.0571056, -0.28125),
|
||||
vec2(0.0582416, -0.125),
|
||||
vec2(0.0324462, -0.03125),
|
||||
vec2(0.0324462, 0.03125),
|
||||
vec2(0.0582416, 0.125),
|
||||
vec2(0.0571056, 0.28125),
|
||||
vec2(0.0347317, 0.5),
|
||||
vec2(0.0216301, 0.78125),
|
||||
vec2(0.0144609, 1.125),
|
||||
vec2(0.0100386, 1.53125),
|
||||
vec2(0.00317394, 2.0));
|
||||
#endif //USE_17_SAMPLES
|
||||
|
||||
#ifdef USE_11_SAMPLES
|
||||
const int kernel_size = 11;
|
||||
QUALIFIER vec2 kernel[11] = vec2[](
|
||||
vec2(0.560479, 0.0),
|
||||
vec2(0.00471691, -2.0),
|
||||
vec2(0.0192831, -1.28),
|
||||
vec2(0.03639, -0.72),
|
||||
vec2(0.0821904, -0.32),
|
||||
vec2(0.0771802, -0.08),
|
||||
vec2(0.0771802, 0.08),
|
||||
vec2(0.0821904, 0.32),
|
||||
vec2(0.03639, 0.72),
|
||||
vec2(0.0192831, 1.28),
|
||||
vec2(0.00471691, 2.0));
|
||||
#endif //USE_11_SAMPLES
|
||||
|
||||
uniform float max_radius;
|
||||
uniform float camera_z_far;
|
||||
uniform float camera_z_near;
|
||||
uniform float unit_size;
|
||||
uniform vec2 dir;
|
||||
in vec2 uv_interp;
|
||||
|
||||
uniform sampler2D source_diffuse; //texunit:0
|
||||
uniform sampler2D source_sss; //texunit:1
|
||||
uniform sampler2D source_depth; //texunit:2
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
float strength = texture(source_sss, uv_interp).r;
|
||||
strength *= strength; //stored as sqrt
|
||||
|
||||
// Fetch color of current pixel:
|
||||
vec4 base_color = texture(source_diffuse, uv_interp);
|
||||
|
||||
if (strength > 0.0) {
|
||||
// Fetch linear depth of current pixel:
|
||||
float depth = texture(source_depth, uv_interp).r * 2.0 - 1.0;
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
depth = ((depth + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
|
||||
float scale = unit_size; //remember depth is negative by default in OpenGL
|
||||
#else
|
||||
depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth * (camera_z_far - camera_z_near));
|
||||
float scale = unit_size / depth; //remember depth is negative by default in OpenGL
|
||||
#endif
|
||||
|
||||
// Calculate the final step to fetch the surrounding pixels:
|
||||
vec2 step = max_radius * scale * dir;
|
||||
step *= strength; // Modulate it using the alpha channel.
|
||||
step *= 1.0 / 3.0; // Divide by 3 as the kernels range from -3 to 3.
|
||||
|
||||
// Accumulate the center sample:
|
||||
vec3 color_accum = base_color.rgb;
|
||||
color_accum *= kernel[0].x;
|
||||
#ifdef ENABLE_STRENGTH_WEIGHTING
|
||||
float color_weight = kernel[0].x;
|
||||
#endif
|
||||
|
||||
// Accumulate the other samples:
|
||||
for (int i = 1; i < kernel_size; i++) {
|
||||
// Fetch color and depth for current sample:
|
||||
vec2 offset = uv_interp + kernel[i].y * step;
|
||||
vec3 color = texture(source_diffuse, offset).rgb;
|
||||
|
||||
#ifdef ENABLE_FOLLOW_SURFACE
|
||||
// If the difference in depth is huge, we lerp color back to "colorM":
|
||||
float depth_cmp = texture(source_depth, offset).r * 2.0 - 1.0;
|
||||
|
||||
#ifdef USE_ORTHOGONAL_PROJECTION
|
||||
depth_cmp = ((depth_cmp + (camera_z_far + camera_z_near) / (camera_z_far - camera_z_near)) * (camera_z_far - camera_z_near)) / 2.0;
|
||||
#else
|
||||
depth_cmp = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - depth_cmp * (camera_z_far - camera_z_near));
|
||||
#endif
|
||||
|
||||
float s = clamp(300.0f * scale * max_radius * abs(depth - depth_cmp), 0.0, 1.0);
|
||||
color = mix(color, base_color.rgb, s);
|
||||
#endif
|
||||
|
||||
// Accumulate:
|
||||
color *= kernel[i].x;
|
||||
|
||||
#ifdef ENABLE_STRENGTH_WEIGHTING
|
||||
float color_s = texture(source_sss, offset).r;
|
||||
color_weight += color_s * kernel[i].x;
|
||||
color *= color_s;
|
||||
#endif
|
||||
color_accum += color;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STRENGTH_WEIGHTING
|
||||
color_accum /= color_weight;
|
||||
#endif
|
||||
frag_color = vec4(color_accum, base_color.a); //keep alpha (used for SSAO)
|
||||
} else {
|
||||
frag_color = base_color;
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
|
||||
env.add_source_files(env.drivers_sources, "*.cpp")
|
@ -1,192 +0,0 @@
|
||||
void _debug_write_garbage() {
|
||||
// extremely slow, writes garbage over arrays to detect using
|
||||
// uninitialized in graphical output. Do not enable in normal use!!
|
||||
#ifdef RASTERIZER_EXTRA_CHECKS
|
||||
int num_verts = MIN(bdata.vertices.max_size(), 32);
|
||||
for (int n = 0; n < num_verts; n++) {
|
||||
bdata.vertices[n].pos.set(Math::random(-200.0f, 200.0f), Math::random(-200.0f, 200.0f));
|
||||
bdata.vertices[n].uv.set(Math::random(0.0f, 1.0f), Math::random(0.0f, 1.0f));
|
||||
}
|
||||
|
||||
int num_colors = MIN(bdata.vertex_colors.max_size(), 32);
|
||||
for (int n = 0; n < num_colors; n++) {
|
||||
bdata.vertex_colors[n].set(Math::randf(), Math::randf(), Math::randf(), 1.0f);
|
||||
}
|
||||
|
||||
int num_modulates = MIN(bdata.vertex_modulates.max_size(), 32);
|
||||
for (int n = 0; n < num_modulates; n++) {
|
||||
bdata.vertex_modulates[n].set(Math::randf(), Math::randf(), Math::randf(), 1.0f);
|
||||
}
|
||||
|
||||
int num_light_angles = MIN(bdata.light_angles.max_size(), 32);
|
||||
for (int n = 0; n < num_light_angles; n++) {
|
||||
bdata.light_angles[n] = Math::random(-3.0f, +3.0f);
|
||||
}
|
||||
|
||||
int num_transforms = MIN(bdata.vertex_transforms.max_size(), 32);
|
||||
for (int n = 0; n < num_transforms; n++) {
|
||||
bdata.vertex_transforms[n].translate.set(Math::random(-200.0f, 200.0f), Math::random(-200.0f, 200.0f));
|
||||
bdata.vertex_transforms[n].basis[0].set(Math::random(-2.0f, 2.0f), Math::random(-2.0f, 2.0f));
|
||||
bdata.vertex_transforms[n].basis[1].set(Math::random(-2.0f, 2.0f), Math::random(-2.0f, 2.0f));
|
||||
}
|
||||
|
||||
int num_unit_verts = MIN(bdata.unit_vertices.max_size(), 32);
|
||||
for (int n = 0; n < num_unit_verts; n++) {
|
||||
uint8_t *data = bdata.unit_vertices.get_unit(n);
|
||||
for (int b = 0; b > bdata.unit_vertices.get_unit_size_bytes(); b++) {
|
||||
data[b] = Math::random(0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
String get_command_type_string(const RendererCanvasRender::Item::Command &p_command) const {
|
||||
String sz = "";
|
||||
|
||||
switch (p_command.type) {
|
||||
default:
|
||||
break;
|
||||
#ifdef GODOT_3
|
||||
case RendererCanvasRender::Item::Command::GD_TYPE_LINE: {
|
||||
sz = "l";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::GD_TYPE_POLYLINE: {
|
||||
sz = "PL";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::GD_TYPE_CIRCLE: {
|
||||
sz = "c";
|
||||
} break;
|
||||
#endif
|
||||
case RendererCanvasRender::Item::Command::TYPE_RECT: {
|
||||
sz = "r";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_NINEPATCH: {
|
||||
sz = "n";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_PRIMITIVE: {
|
||||
sz = "PR";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_POLYGON: {
|
||||
sz = "p";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_MESH: {
|
||||
sz = "m";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_MULTIMESH: {
|
||||
sz = "MM";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_PARTICLES: {
|
||||
sz = "PA";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_TRANSFORM: {
|
||||
sz = "t";
|
||||
|
||||
// add a bit more info in debug build
|
||||
const RendererCanvasRender::Item::CommandTransform *transform = static_cast<const RendererCanvasRender::Item::CommandTransform *>(&p_command);
|
||||
const Transform2D &mat = transform->xform;
|
||||
|
||||
sz += " ";
|
||||
sz += String(Variant(mat.elements[2]));
|
||||
sz += " ";
|
||||
} break;
|
||||
case RendererCanvasRender::Item::Command::TYPE_CLIP_IGNORE: {
|
||||
sz = "CI";
|
||||
} break;
|
||||
} // switch
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
void diagnose_batches(RendererCanvasRender::Item::Command *const *p_commands) {
|
||||
int num_batches = bdata.batches.size();
|
||||
|
||||
BatchColor curr_color;
|
||||
curr_color.set(Color(-1, -1, -1, -1));
|
||||
bool first_color_change = true;
|
||||
|
||||
for (int batch_num = 0; batch_num < num_batches; batch_num++) {
|
||||
const Batch &batch = bdata.batches[batch_num];
|
||||
bdata.frame_string += "\t\t\tbatch ";
|
||||
|
||||
switch (batch.type) {
|
||||
case RasterizerStorageCommon::BT_POLY: {
|
||||
bdata.frame_string += "P ";
|
||||
bdata.frame_string += itos(batch.first_command) + "-";
|
||||
bdata.frame_string += itos(batch.num_commands);
|
||||
|
||||
bdata.frame_string += " " + batch.color.to_string();
|
||||
|
||||
if (batch.num_commands > 1) {
|
||||
bdata.frame_string += " MULTI";
|
||||
}
|
||||
if (curr_color != batch.color) {
|
||||
curr_color = batch.color;
|
||||
if (!first_color_change) {
|
||||
bdata.frame_string += " color";
|
||||
} else {
|
||||
first_color_change = false;
|
||||
}
|
||||
}
|
||||
bdata.frame_string += "\n";
|
||||
} break;
|
||||
case RasterizerStorageCommon::BT_LINE:
|
||||
case RasterizerStorageCommon::BT_LINE_AA: {
|
||||
bdata.frame_string += "L ";
|
||||
bdata.frame_string += itos(batch.first_command) + "-";
|
||||
bdata.frame_string += itos(batch.num_commands);
|
||||
|
||||
bdata.frame_string += " " + batch.color.to_string();
|
||||
|
||||
if (batch.num_commands > 1) {
|
||||
bdata.frame_string += " MULTI";
|
||||
}
|
||||
if (curr_color != batch.color) {
|
||||
curr_color = batch.color;
|
||||
if (!first_color_change) {
|
||||
bdata.frame_string += " color";
|
||||
} else {
|
||||
first_color_change = false;
|
||||
}
|
||||
}
|
||||
bdata.frame_string += "\n";
|
||||
} break;
|
||||
case RasterizerStorageCommon::BT_RECT: {
|
||||
bdata.frame_string += "R ";
|
||||
bdata.frame_string += itos(batch.first_command) + "-";
|
||||
bdata.frame_string += itos(batch.num_commands);
|
||||
|
||||
int tex_id = (int)bdata.batch_textures[batch.batch_texture_id].RID_texture.get_id();
|
||||
bdata.frame_string += " [" + itos(batch.batch_texture_id) + " - " + itos(tex_id) + "]";
|
||||
|
||||
bdata.frame_string += " " + batch.color.to_string();
|
||||
|
||||
if (batch.num_commands > 1) {
|
||||
bdata.frame_string += " MULTI";
|
||||
}
|
||||
if (curr_color != batch.color) {
|
||||
curr_color = batch.color;
|
||||
if (!first_color_change) {
|
||||
bdata.frame_string += " color";
|
||||
} else {
|
||||
first_color_change = false;
|
||||
}
|
||||
}
|
||||
bdata.frame_string += "\n";
|
||||
} break;
|
||||
default: {
|
||||
bdata.frame_string += "D ";
|
||||
bdata.frame_string += itos(batch.first_command) + "-";
|
||||
bdata.frame_string += itos(batch.num_commands) + " ";
|
||||
|
||||
int num_show = MIN(batch.num_commands, 16);
|
||||
for (int n = 0; n < num_show; n++) {
|
||||
const RendererCanvasRender::Item::Command &comm = *p_commands[batch.first_command + n];
|
||||
bdata.frame_string += get_command_type_string(comm) + " ";
|
||||
}
|
||||
|
||||
bdata.frame_string += "\n";
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,84 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_version.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
//#define GLES_OVER_GL
|
||||
|
||||
//#define GODOT_3
|
||||
#define GODOT_4
|
||||
|
||||
#ifdef GODOT_4
|
||||
// visual server becomes rendering server
|
||||
#define GD_VS RS
|
||||
|
||||
#define GD_RD RenderingDevice
|
||||
|
||||
//#define GD_COMMAND_LINE CommandPrimitive
|
||||
#else
|
||||
|
||||
//class ContextGL_Windows {
|
||||
// HDC hDC;
|
||||
// HGLRC hRC;
|
||||
// unsigned int pixel_format;
|
||||
// HWND hWnd;
|
||||
// bool opengl_3_context;
|
||||
// bool use_vsync;
|
||||
#define GD_VS VS
|
||||
|
||||
// no rendering device in 3.2?
|
||||
#define GD_RD VS
|
||||
|
||||
//public:
|
||||
// void release_current();
|
||||
|
||||
// void make_current();
|
||||
|
||||
// int get_window_width();
|
||||
// int get_window_height();
|
||||
// void swap_buffers();
|
||||
|
||||
// Error initialize();
|
||||
|
||||
// void set_use_vsync(bool p_use);
|
||||
// bool is_using_vsync() const;
|
||||
|
||||
// ContextGL_Windows(HWND hwnd, bool p_opengl_3_context);
|
||||
// ~ContextGL_Windows();
|
||||
//};
|
||||
|
||||
//#endif
|
||||
//#define GD_COMMAND_LINE CommandLine
|
||||
|
||||
#define GD_TYPE_LINE TYPE_LINE
|
||||
#define GD_TYPE_POLYLINE TYPE_POLYLINE
|
||||
#define GD_TYPE_POLYGON TYPE_POLYGON
|
||||
#define GD_TYPE_CIRCLE TYPE_CIRCLE
|
||||
#endif
|
@ -36,29 +36,24 @@
|
||||
* For use in render drivers, not for general use.
|
||||
* TO BE REPLACED by local_vector.
|
||||
*/
|
||||
#include "rasterizer_version.h"
|
||||
|
||||
#include "core/os/memory.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef GODOT_4
|
||||
#include "core/templates/local_vector.h"
|
||||
#include "core/templates/vector.h"
|
||||
#else
|
||||
#include "core/vector.h"
|
||||
#endif
|
||||
|
||||
// very simple non-growable array, that keeps track of the size of a 'unit'
|
||||
// which can be cast to whatever vertex format FVF required, and is initially
|
||||
// created with enough memory to hold the biggest FVF.
|
||||
// This allows multiple FVFs to use the same array.
|
||||
class RasterizerUnitArrayGLES2 {
|
||||
class RasterizerUnitArrayOpenGL {
|
||||
public:
|
||||
RasterizerUnitArrayGLES2() {
|
||||
RasterizerUnitArrayOpenGL() {
|
||||
_list = nullptr;
|
||||
free();
|
||||
}
|
||||
~RasterizerUnitArrayGLES2() { free(); }
|
||||
~RasterizerUnitArrayOpenGL() { free(); }
|
||||
|
||||
uint8_t *get_unit(unsigned int ui) { return &_list[ui * _unit_size_bytes]; }
|
||||
const uint8_t *get_unit(unsigned int ui) const { return &_list[ui * _unit_size_bytes]; }
|
@ -1,12 +1,12 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_canvas_base_gles2.cpp */
|
||||
/* rasterizer_canvas_base_opengl.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -28,36 +28,70 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_canvas_base_gles2.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "rasterizer_canvas_base_opengl.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "drivers/gles_common/rasterizer_asserts.h"
|
||||
#include "rasterizer_scene_gles2.h"
|
||||
#include "drivers/opengl/rasterizer_asserts.h"
|
||||
#include "rasterizer_scene_opengl.h"
|
||||
|
||||
#ifdef GODOT_3
|
||||
#include "core/project_settings.h"
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
#else
|
||||
#include "core/config/project_settings.h"
|
||||
#include "servers/rendering/rendering_server_default.h"
|
||||
#endif
|
||||
|
||||
#ifndef GLES_OVER_GL
|
||||
#define glClearDepth glClearDepthf
|
||||
#endif
|
||||
|
||||
RID RasterizerCanvasBaseGLES2::light_internal_create() {
|
||||
RID RasterizerCanvasBaseOpenGL::light_internal_create() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::light_internal_update(RID p_rid, Light *p_light) {
|
||||
void RasterizerCanvasBaseOpenGL::light_internal_update(RID p_rid, Light *p_light) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::light_internal_free(RID p_rid) {
|
||||
void RasterizerCanvasBaseOpenGL::light_internal_free(RID p_rid) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::canvas_begin() {
|
||||
RID RasterizerCanvasBaseOpenGL::light_create() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::light_set_texture(RID p_rid, RID p_texture) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::light_set_use_shadow(RID p_rid, bool p_enable) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) {
|
||||
}
|
||||
|
||||
RID RasterizerCanvasBaseOpenGL::occluder_polygon_create() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::set_shadow_texture_size(int p_size) {
|
||||
}
|
||||
|
||||
bool RasterizerCanvasBaseOpenGL::free(RID p_rid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::update() {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseOpenGL::canvas_begin() {
|
||||
state.using_transparent_rt = false;
|
||||
|
||||
// always start with light_angle unset
|
||||
@ -65,9 +99,9 @@ void RasterizerCanvasBaseGLES2::canvas_begin() {
|
||||
state.using_large_vertex = false;
|
||||
state.using_modulate = false;
|
||||
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_ATTRIB_LIGHT_ANGLE, false);
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_ATTRIB_MODULATE, false);
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_ATTRIB_LARGE_VERTEX, false);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LIGHT_ANGLE, false);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_MODULATE, false);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LARGE_VERTEX, false);
|
||||
state.canvas_shader.bind();
|
||||
|
||||
int viewport_x, viewport_y, viewport_width, viewport_height;
|
||||
@ -135,8 +169,8 @@ void RasterizerCanvasBaseGLES2::canvas_begin() {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
|
||||
|
||||
glVertexAttrib4f(GD_VS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
|
||||
// set up default uniforms
|
||||
|
||||
@ -172,10 +206,10 @@ void RasterizerCanvasBaseGLES2::canvas_begin() {
|
||||
_bind_quad_buffer();
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::canvas_end() {
|
||||
void RasterizerCanvasBaseOpenGL::canvas_end() {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
for (int i = 0; i < GD_VS::ARRAY_MAX; i++) {
|
||||
for (int i = 0; i < RS::ARRAY_MAX; i++) {
|
||||
glDisableVertexAttribArray(i);
|
||||
}
|
||||
|
||||
@ -195,38 +229,38 @@ void RasterizerCanvasBaseGLES2::canvas_end() {
|
||||
state.using_transparent_rt = false;
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y));
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y));
|
||||
void RasterizerCanvasBaseOpenGL::draw_generic_textured_rect(const Rect2 &p_rect, const Rect2 &p_src) {
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::DST_RECT, Color(p_rect.position.x, p_rect.position.y, p_rect.size.x, p_rect.size.y));
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SRC_RECT, Color(p_src.position.x, p_src.position.y, p_src.size.x, p_src.size.y));
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_set_texture_rect_mode(bool p_texture_rect, bool p_light_angle, bool p_modulate, bool p_large_vertex) {
|
||||
void RasterizerCanvasBaseOpenGL::_set_texture_rect_mode(bool p_texture_rect, bool p_light_angle, bool p_modulate, bool p_large_vertex) {
|
||||
// always set this directly (this could be state checked)
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_TEXTURE_RECT, p_texture_rect);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_TEXTURE_RECT, p_texture_rect);
|
||||
|
||||
if (state.using_light_angle != p_light_angle) {
|
||||
state.using_light_angle = p_light_angle;
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_ATTRIB_LIGHT_ANGLE, p_light_angle);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LIGHT_ANGLE, p_light_angle);
|
||||
}
|
||||
|
||||
if (state.using_modulate != p_modulate) {
|
||||
state.using_modulate = p_modulate;
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_ATTRIB_MODULATE, p_modulate);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_MODULATE, p_modulate);
|
||||
}
|
||||
|
||||
if (state.using_large_vertex != p_large_vertex) {
|
||||
state.using_large_vertex = p_large_vertex;
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_ATTRIB_LARGE_VERTEX, p_large_vertex);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_ATTRIB_LARGE_VERTEX, p_large_vertex);
|
||||
}
|
||||
}
|
||||
|
||||
RasterizerStorageGLES2::Texture *RasterizerCanvasBaseGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
|
||||
RasterizerStorageGLES2::Texture *tex_return = NULL;
|
||||
RasterizerStorageOpenGL::Texture *RasterizerCanvasBaseOpenGL::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
|
||||
RasterizerStorageOpenGL::Texture *tex_return = NULL;
|
||||
|
||||
if (p_texture.is_valid()) {
|
||||
RasterizerStorageGLES2::Texture *texture = storage->texture_owner.getornull(p_texture);
|
||||
RasterizerStorageOpenGL::Texture *texture = storage->texture_owner.get_or_null(p_texture);
|
||||
|
||||
if (!texture) {
|
||||
state.current_tex = RID();
|
||||
@ -268,16 +302,16 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasBaseGLES2::_bind_canvas_texture
|
||||
|
||||
if (p_normal_map == state.current_normal) {
|
||||
//do none
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, state.current_normal.is_valid());
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, state.current_normal.is_valid());
|
||||
|
||||
} else if (p_normal_map.is_valid()) {
|
||||
RasterizerStorageGLES2::Texture *normal_map = storage->texture_owner.getornull(p_normal_map);
|
||||
RasterizerStorageOpenGL::Texture *normal_map = storage->texture_owner.get_or_null(p_normal_map);
|
||||
|
||||
if (!normal_map) {
|
||||
state.current_normal = RID();
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, false);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, false);
|
||||
|
||||
} else {
|
||||
if (normal_map->redraw_if_visible) { //check before proxy, because this is usually used with proxies
|
||||
@ -289,21 +323,21 @@ RasterizerStorageGLES2::Texture *RasterizerCanvasBaseGLES2::_bind_canvas_texture
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
|
||||
glBindTexture(GL_TEXTURE_2D, normal_map->tex_id);
|
||||
state.current_normal = p_normal_map;
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, true);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, true);
|
||||
}
|
||||
|
||||
} else {
|
||||
state.current_normal = RID();
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 2);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::USE_DEFAULT_NORMAL, false);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::USE_DEFAULT_NORMAL, false);
|
||||
}
|
||||
|
||||
return tex_return;
|
||||
}
|
||||
|
||||
/*
|
||||
void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *black_image) {
|
||||
void RasterizerCanvasBaseOpenGL::draw_window_margins(int *black_margin, RID *black_image) {
|
||||
return;
|
||||
|
||||
// FTODO
|
||||
@ -375,74 +409,74 @@ void RasterizerCanvasBaseGLES2::draw_window_margins(int *black_margin, RID *blac
|
||||
}
|
||||
*/
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_bind_quad_buffer() {
|
||||
void RasterizerCanvasBaseOpenGL::_bind_quad_buffer() {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, data.canvas_quad_vertices);
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_set_uniforms() {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX, state.uniforms.projection_matrix);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, state.uniforms.extra_matrix);
|
||||
void RasterizerCanvasBaseOpenGL::_set_uniforms() {
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::PROJECTION_MATRIX, state.uniforms.projection_matrix);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::EXTRA_MATRIX, state.uniforms.extra_matrix);
|
||||
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::FINAL_MODULATE, state.uniforms.final_modulate);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::FINAL_MODULATE, state.uniforms.final_modulate);
|
||||
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::TIME, storage->frame.time[0]);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::TIME, storage->frame.time[0]);
|
||||
|
||||
if (storage->frame.current_rt) {
|
||||
Vector2 screen_pixel_size;
|
||||
screen_pixel_size.x = 1.0 / storage->frame.current_rt->width;
|
||||
screen_pixel_size.y = 1.0 / storage->frame.current_rt->height;
|
||||
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SCREEN_PIXEL_SIZE, screen_pixel_size);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SCREEN_PIXEL_SIZE, screen_pixel_size);
|
||||
}
|
||||
|
||||
if (state.using_skeleton) {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SKELETON_TRANSFORM, state.skeleton_transform);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SKELETON_TEXTURE_SIZE, state.skeleton_texture_size);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TRANSFORM, state.skeleton_transform);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TRANSFORM_INVERSE, state.skeleton_transform_inverse);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SKELETON_TEXTURE_SIZE, state.skeleton_texture_size);
|
||||
}
|
||||
|
||||
if (state.using_light) {
|
||||
Light *light = state.using_light;
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_MATRIX, light->light_shader_xform);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_MATRIX, light->light_shader_xform);
|
||||
Transform2D basis_inverse = light->light_shader_xform.affine_inverse().orthonormalized();
|
||||
basis_inverse.elements[2] = Vector2();
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_MATRIX_INVERSE, basis_inverse);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_LOCAL_MATRIX, light->xform_cache.affine_inverse());
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_COLOR, light->color * light->energy);
|
||||
// state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_POS, light->light_shader_pos);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_MATRIX_INVERSE, basis_inverse);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_LOCAL_MATRIX, light->xform_cache.affine_inverse());
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_COLOR, light->color * light->energy);
|
||||
// state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_POS, light->light_shader_pos);
|
||||
// FTODO
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_POS, light->light_shader_xform.elements[2]);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_HEIGHT, light->height);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_POS, light->light_shader_xform.elements[2]);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_HEIGHT, light->height);
|
||||
|
||||
// FTODO
|
||||
//state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == GD_VS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, 0.0f);
|
||||
//state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_OUTSIDE_ALPHA, light->mode == RS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_OUTSIDE_ALPHA, 0.0f);
|
||||
|
||||
if (state.using_shadow) {
|
||||
// FTODO
|
||||
#if 0
|
||||
RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
|
||||
RasterizerStorageOpenGL::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(light->shadow_buffer);
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5);
|
||||
glBindTexture(GL_TEXTURE_2D, cls->distance);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_MATRIX, light->shadow_matrix_cache);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_SHADOW_COLOR, light->shadow_color);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_MATRIX, light->shadow_matrix_cache);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::LIGHT_SHADOW_COLOR, light->shadow_color);
|
||||
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SHADOWPIXEL_SIZE, (1.0 / light->shadow_buffer_size) * (1.0 + light->shadow_smooth));
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOWPIXEL_SIZE, (1.0 / light->shadow_buffer_size) * (1.0 + light->shadow_smooth));
|
||||
if (light->radius_cache == 0) {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_GRADIENT, 0.0);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_GRADIENT, 0.0);
|
||||
} else {
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_GRADIENT, light->shadow_gradient_length / (light->radius_cache * 1.1));
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_GRADIENT, light->shadow_gradient_length / (light->radius_cache * 1.1));
|
||||
}
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_DISTANCE_MULT, light->radius_cache * 1.1);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::SHADOW_DISTANCE_MULT, light->radius_cache * 1.1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::reset_canvas() {
|
||||
void RasterizerCanvasBaseOpenGL::reset_canvas() {
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
@ -456,7 +490,7 @@ void RasterizerCanvasBaseGLES2::reset_canvas() {
|
||||
}
|
||||
|
||||
// bind the back buffer to a texture so shaders can use it.
|
||||
// It should probably use texture unit -3 (as GLES2 does as well) but currently that's buggy.
|
||||
// It should probably use texture unit -3 (as OpenGL does as well) but currently that's buggy.
|
||||
// keeping this for now as there's nothing else that uses texture unit 2
|
||||
// TODO ^
|
||||
if (storage->frame.current_rt) {
|
||||
@ -468,10 +502,10 @@ void RasterizerCanvasBaseGLES2::reset_canvas() {
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::canvas_debug_viewport_shadows(Light *p_lights_with_shadow) {
|
||||
void RasterizerCanvasBaseOpenGL::canvas_debug_viewport_shadows(Light *p_lights_with_shadow) {
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_copy_texscreen(const Rect2 &p_rect) {
|
||||
void RasterizerCanvasBaseOpenGL::_copy_texscreen(const Rect2 &p_rect) {
|
||||
state.canvas_texscreen_used = true;
|
||||
|
||||
_copy_screen(p_rect);
|
||||
@ -483,7 +517,7 @@ void RasterizerCanvasBaseGLES2::_copy_texscreen(const Rect2 &p_rect) {
|
||||
_set_uniforms();
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
|
||||
void RasterizerCanvasBaseOpenGL::_draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor, const float *p_weights, const int *p_bones) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
||||
|
||||
uint32_t buffer_ofs = 0;
|
||||
@ -494,47 +528,47 @@ void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_
|
||||
|
||||
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, sizeof(Vector2) * p_vertex_count, p_vertices, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true);
|
||||
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
||||
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
|
||||
if (p_singlecolor) {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
Color m = *p_colors;
|
||||
glVertexAttrib4f(GD_VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||
glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||
} else if (!p_colors) {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttrib4f(GD_VS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
} else {
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
}
|
||||
|
||||
if (p_uvs) {
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_TEX_UV);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
|
||||
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
} else {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_TEX_UV);
|
||||
glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
|
||||
}
|
||||
|
||||
if (p_weights && p_bones) {
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(float) * 4 * p_vertex_count, p_weights, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_WEIGHTS);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_WEIGHTS);
|
||||
glVertexAttribPointer(RS::ARRAY_WEIGHTS, 4, GL_FLOAT, GL_FALSE, sizeof(float) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(int) * 4 * p_vertex_count, p_bones, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_BONES);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, sizeof(int) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_BONES);
|
||||
glVertexAttribPointer(RS::ARRAY_BONES, 4, GL_UNSIGNED_INT, GL_FALSE, sizeof(int) * 4, CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
|
||||
} else {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_WEIGHTS);
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_BONES);
|
||||
glDisableVertexAttribArray(RS::ARRAY_WEIGHTS);
|
||||
glDisableVertexAttribArray(RS::ARRAY_BONES);
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer);
|
||||
@ -564,7 +598,7 @@ void RasterizerCanvasBaseGLES2::_draw_polygon(const int *p_indices, int p_index_
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
||||
void RasterizerCanvasBaseOpenGL::_draw_generic(GLuint p_primitive, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
||||
|
||||
uint32_t buffer_ofs = 0;
|
||||
@ -574,31 +608,31 @@ void RasterizerCanvasBaseGLES2::_draw_generic(GLuint p_primitive, int p_vertex_c
|
||||
#endif
|
||||
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, sizeof(Vector2) * p_vertex_count, p_vertices, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true);
|
||||
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
||||
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
|
||||
if (p_singlecolor) {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
Color m = *p_colors;
|
||||
glVertexAttrib4f(GD_VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||
glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||
} else if (!p_colors) {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttrib4f(GD_VS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
} else {
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
}
|
||||
|
||||
if (p_uvs) {
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_TEX_UV);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
|
||||
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
} else {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_TEX_UV);
|
||||
glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
|
||||
}
|
||||
|
||||
glDrawArrays(p_primitive, 0, p_vertex_count);
|
||||
@ -607,7 +641,7 @@ void RasterizerCanvasBaseGLES2::_draw_generic(GLuint p_primitive, int p_vertex_c
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
||||
void RasterizerCanvasBaseOpenGL::_draw_generic_indices(GLuint p_primitive, const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
||||
|
||||
uint32_t buffer_ofs = 0;
|
||||
@ -617,31 +651,31 @@ void RasterizerCanvasBaseGLES2::_draw_generic_indices(GLuint p_primitive, const
|
||||
#endif
|
||||
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, sizeof(Vector2) * p_vertex_count, p_vertices, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true);
|
||||
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
||||
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), NULL);
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
|
||||
if (p_singlecolor) {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
Color m = *p_colors;
|
||||
glVertexAttrib4f(GD_VS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||
glVertexAttrib4f(RS::ARRAY_COLOR, m.r, m.g, m.b, m.a);
|
||||
} else if (!p_colors) {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttrib4f(GD_VS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttrib4f(RS::ARRAY_COLOR, 1, 1, 1, 1);
|
||||
} else {
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(Color) * p_vertex_count, p_colors, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(Color), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
}
|
||||
|
||||
if (p_uvs) {
|
||||
RAST_FAIL_COND(!storage->safe_buffer_sub_data(data.polygon_buffer_size, GL_ARRAY_BUFFER, buffer_ofs, sizeof(Vector2) * p_vertex_count, p_uvs, buffer_ofs_after));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_TEX_UV);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
|
||||
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, sizeof(Vector2), CAST_INT_TO_UCHAR_PTR(buffer_ofs));
|
||||
buffer_ofs = buffer_ofs_after;
|
||||
} else {
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_TEX_UV);
|
||||
glDisableVertexAttribArray(RS::ARRAY_TEX_UV);
|
||||
}
|
||||
|
||||
#ifdef RASTERIZER_EXTRA_CHECKS
|
||||
@ -677,7 +711,7 @@ void RasterizerCanvasBaseGLES2::_draw_generic_indices(GLuint p_primitive, const
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageGLES2::Material *p_material) {
|
||||
void RasterizerCanvasBaseOpenGL::_legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageOpenGL::Material *p_material) {
|
||||
// return;
|
||||
|
||||
const PolyData &pd = _polydata[p_poly->polygon.polygon_id];
|
||||
@ -690,12 +724,12 @@ void RasterizerCanvasBaseGLES2::_legacy_draw_poly_triangles(Item::CommandPolygon
|
||||
}
|
||||
|
||||
// FTODO
|
||||
//RasterizerStorageGLES2::Texture *texture = _bind_canvas_texture(polygon->texture, polygon->normal_map);
|
||||
RasterizerStorageGLES2::Texture *texture = _bind_canvas_texture(p_poly->texture, RID());
|
||||
//RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(polygon->texture, polygon->normal_map);
|
||||
RasterizerStorageOpenGL::Texture *texture = _bind_canvas_texture(p_poly->texture, RID());
|
||||
|
||||
if (texture) {
|
||||
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::COLOR_TEXPIXEL_SIZE, texpixel_size);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::COLOR_TEXPIXEL_SIZE, texpixel_size);
|
||||
}
|
||||
|
||||
_draw_polygon(pd.indices.ptr(), pd.indices.size(), pd.points.size(), pd.points.ptr(), pd.uvs.ptr(), pd.colors.ptr(), pd.colors.size() == 1, nullptr, nullptr);
|
||||
@ -716,7 +750,7 @@ void RasterizerCanvasBaseGLES2::_legacy_draw_poly_triangles(Item::CommandPolygon
|
||||
#endif
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageGLES2::Material *p_material) {
|
||||
void RasterizerCanvasBaseOpenGL::_legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material) {
|
||||
// return;
|
||||
|
||||
if (p_pr->point_count != 4)
|
||||
@ -731,15 +765,15 @@ void RasterizerCanvasBaseGLES2::_legacy_draw_primitive(Item::CommandPrimitive *p
|
||||
|
||||
_bind_canvas_texture(RID(), RID());
|
||||
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttrib4fv(GD_VS::ARRAY_COLOR, p_pr->colors[0].components);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttrib4fv(RS::ARRAY_COLOR, p_pr->colors[0].components);
|
||||
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
|
||||
|
||||
_draw_gui_primitive(p_pr->point_count, p_pr->points, NULL, NULL);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageGLES2::Material *p_material) {
|
||||
void RasterizerCanvasBaseOpenGL::_legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material) {
|
||||
_set_texture_rect_mode(false);
|
||||
|
||||
if (state.canvas_shader.bind()) {
|
||||
@ -749,10 +783,10 @@ void RasterizerCanvasBaseGLES2::_legacy_draw_line(Item::CommandPrimitive *p_pr,
|
||||
|
||||
_bind_canvas_texture(RID(), RID());
|
||||
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttrib4fv(GD_VS::ARRAY_COLOR, p_pr->colors[0].components);
|
||||
glDisableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
glVertexAttrib4fv(RS::ARRAY_COLOR, p_pr->colors[0].components);
|
||||
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
|
||||
state.canvas_shader.set_uniform(CanvasShaderOpenGL::MODELVIEW_MATRIX, state.uniforms.modelview_matrix);
|
||||
|
||||
#ifdef GLES_OVER_GL
|
||||
// if (line->antialiased)
|
||||
@ -766,7 +800,7 @@ void RasterizerCanvasBaseGLES2::_legacy_draw_line(Item::CommandPrimitive *p_pr,
|
||||
#endif
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles) {
|
||||
void RasterizerCanvasBaseOpenGL::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles) {
|
||||
static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN };
|
||||
|
||||
int color_offset = 0;
|
||||
@ -822,21 +856,21 @@ void RasterizerCanvasBaseGLES2::_draw_gui_primitive(int p_points, const Vector2
|
||||
glBindBuffer(GL_ARRAY_BUFFER, data.polygon_buffer);
|
||||
storage->buffer_orphan_and_upload(data.polygon_buffer_size, 0, p_points * stride * 4 * sizeof(float), buffer_data, GL_ARRAY_BUFFER, _buffer_upload_usage_flag, true);
|
||||
|
||||
glVertexAttribPointer(GD_VS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
|
||||
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
|
||||
|
||||
if (p_colors) {
|
||||
glVertexAttribPointer(GD_VS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float)));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_COLOR);
|
||||
glVertexAttribPointer(RS::ARRAY_COLOR, 4, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_offset * sizeof(float)));
|
||||
glEnableVertexAttribArray(RS::ARRAY_COLOR);
|
||||
}
|
||||
|
||||
if (p_uvs) {
|
||||
glVertexAttribPointer(GD_VS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float)));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_TEX_UV);
|
||||
glVertexAttribPointer(RS::ARRAY_TEX_UV, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(uv_offset * sizeof(float)));
|
||||
glEnableVertexAttribArray(RS::ARRAY_TEX_UV);
|
||||
}
|
||||
|
||||
if (p_light_angles) {
|
||||
glVertexAttribPointer(GD_VS::ARRAY_TANGENT, 1, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(light_angle_offset * sizeof(float)));
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_TANGENT);
|
||||
glVertexAttribPointer(RS::ARRAY_TANGENT, 1, GL_FLOAT, GL_FALSE, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(light_angle_offset * sizeof(float)));
|
||||
glEnableVertexAttribArray(RS::ARRAY_TANGENT);
|
||||
}
|
||||
|
||||
glDrawArrays(prim[p_points], 0, p_points);
|
||||
@ -844,13 +878,13 @@ void RasterizerCanvasBaseGLES2::_draw_gui_primitive(int p_points, const Vector2
|
||||
|
||||
if (p_light_angles) {
|
||||
// may not be needed
|
||||
glDisableVertexAttribArray(GD_VS::ARRAY_TANGENT);
|
||||
glDisableVertexAttribArray(RS::ARRAY_TANGENT);
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::_copy_screen(const Rect2 &p_rect) {
|
||||
void RasterizerCanvasBaseOpenGL::_copy_screen(const Rect2 &p_rect) {
|
||||
if (storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
|
||||
ERR_PRINT_ONCE("Cannot use screen texture copying in render target set to render direct to screen.");
|
||||
return;
|
||||
@ -865,17 +899,17 @@ void RasterizerCanvasBaseGLES2::_copy_screen(const Rect2 &p_rect) {
|
||||
Color copy_section(p_rect.position.x / wh.x, p_rect.position.y / wh.y, p_rect.size.x / wh.x, p_rect.size.y / wh.y);
|
||||
|
||||
if (p_rect != Rect2()) {
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_COPY_SECTION, true);
|
||||
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_COPY_SECTION, true);
|
||||
}
|
||||
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_NO_ALPHA, !state.using_transparent_rt);
|
||||
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_NO_ALPHA, !state.using_transparent_rt);
|
||||
|
||||
storage->bind_framebuffer(storage->frame.current_rt->copy_screen_effect.fbo);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
|
||||
|
||||
storage->shaders.copy.bind();
|
||||
storage->shaders.copy.set_uniform(CopyShaderGLES2::COPY_SECTION, copy_section);
|
||||
storage->shaders.copy.set_uniform(CopyShaderOpenGL::COPY_SECTION, copy_section);
|
||||
|
||||
const Vector2 vertpos[4] = {
|
||||
Vector2(-1, -1),
|
||||
@ -898,16 +932,16 @@ void RasterizerCanvasBaseGLES2::_copy_screen(const Rect2 &p_rect) {
|
||||
|
||||
_draw_polygon(indexpos, 6, 4, vertpos, uvpos, NULL, false);
|
||||
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_COPY_SECTION, false);
|
||||
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_NO_ALPHA, false);
|
||||
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_COPY_SECTION, false);
|
||||
storage->shaders.copy.set_conditional(CopyShaderOpenGL::USE_NO_ALPHA, false);
|
||||
|
||||
storage->bind_framebuffer(storage->frame.current_rt->fbo);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
|
||||
void RasterizerCanvasBaseOpenGL::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {
|
||||
#if 0
|
||||
RasterizerStorageGLES2::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer);
|
||||
RasterizerStorageOpenGL::CanvasLightShadow *cls = storage->canvas_light_shadow_owner.get(p_buffer);
|
||||
ERR_FAIL_COND(!cls);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@ -920,7 +954,7 @@ void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer,
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, cls->fbo);
|
||||
|
||||
state.canvas_shadow_shader.set_conditional(CanvasShadowShaderGLES2::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
|
||||
state.canvas_shadow_shader.set_conditional(CanvasShadowShaderOpenGL::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
|
||||
state.canvas_shadow_shader.bind();
|
||||
|
||||
glViewport(0, 0, cls->size, cls->height);
|
||||
@ -928,7 +962,7 @@ void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer,
|
||||
glClearColor(1, 1, 1, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
GD_VS::CanvasOccluderPolygonCullMode cull = GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
|
||||
RS::CanvasOccluderPolygonCullMode cull = RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
//make sure it remains orthogonal, makes easy to read angle later
|
||||
@ -962,9 +996,9 @@ void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer,
|
||||
Vector3 cam_target = Basis(Vector3(0, 0, Math_PI * 2 * (i / 4.0))).xform(Vector3(0, 1, 0));
|
||||
projection = projection * CameraMatrix(Transform3D().looking_at(cam_target, Vector3(0, 0, -1)).affine_inverse());
|
||||
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::PROJECTION_MATRIX, projection);
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::LIGHT_MATRIX, light);
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::DISTANCE_NORM, 1.0 / p_far);
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::PROJECTION_MATRIX, projection);
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::LIGHT_MATRIX, light);
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::DISTANCE_NORM, 1.0 / p_far);
|
||||
|
||||
if (i == 0)
|
||||
*p_xform_cache = projection;
|
||||
@ -974,36 +1008,36 @@ void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer,
|
||||
LightOccluderInstance *instance = p_occluders;
|
||||
|
||||
while (instance) {
|
||||
RasterizerStorageGLES2::CanvasOccluder *cc = storage->canvas_occluder_owner.getornull(instance->polygon_buffer);
|
||||
RasterizerStorageOpenGL::CanvasOccluder *cc = storage->canvas_occluder_owner.get_or_null(instance->polygon_buffer);
|
||||
if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) {
|
||||
instance = instance->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::WORLD_MATRIX, instance->xform_cache);
|
||||
state.canvas_shadow_shader.set_uniform(CanvasShadowShaderOpenGL::WORLD_MATRIX, instance->xform_cache);
|
||||
|
||||
GD_VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
|
||||
RS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache;
|
||||
|
||||
if (transformed_cull_cache != GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
|
||||
if (transformed_cull_cache != RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
|
||||
(p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) {
|
||||
transformed_cull_cache =
|
||||
transformed_cull_cache == GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
|
||||
GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
|
||||
GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
|
||||
transformed_cull_cache == RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
|
||||
RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
|
||||
RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
|
||||
}
|
||||
|
||||
if (cull != transformed_cull_cache) {
|
||||
cull = transformed_cull_cache;
|
||||
switch (cull) {
|
||||
case GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
|
||||
case RS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: {
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
} break;
|
||||
case GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: {
|
||||
case RS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: {
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_FRONT);
|
||||
} break;
|
||||
case GD_VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: {
|
||||
case RS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: {
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
@ -1012,8 +1046,8 @@ void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer,
|
||||
}
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, cc->vertex_id);
|
||||
glEnableVertexAttribArray(GD_VS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(GD_VS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, 0);
|
||||
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
|
||||
glVertexAttribPointer(RS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cc->index_id);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, cc->len * 3, GL_UNSIGNED_SHORT, 0);
|
||||
@ -1027,7 +1061,7 @@ void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer,
|
||||
#endif
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {
|
||||
void RasterizerCanvasBaseOpenGL::draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {
|
||||
Vector2 half_size;
|
||||
if (storage->frame.current_rt) {
|
||||
half_size = Vector2(storage->frame.current_rt->width, storage->frame.current_rt->height);
|
||||
@ -1043,13 +1077,13 @@ void RasterizerCanvasBaseGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, f
|
||||
|
||||
// setup our lens shader
|
||||
state.lens_shader.bind();
|
||||
state.lens_shader.set_uniform(LensDistortedShaderGLES2::OFFSET, offset);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderGLES2::SCALE, scale);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderGLES2::K1, p_k1);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderGLES2::K2, p_k2);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderGLES2::EYE_CENTER, p_eye_center);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderGLES2::UPSCALE, p_oversample);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderGLES2::ASPECT_RATIO, aspect_ratio);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::OFFSET, offset);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::SCALE, scale);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::K1, p_k1);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::K2, p_k2);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::EYE_CENTER, p_eye_center);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::UPSCALE, p_oversample);
|
||||
state.lens_shader.set_uniform(LensDistortedShaderOpenGL::ASPECT_RATIO, aspect_ratio);
|
||||
|
||||
// bind our quad buffer
|
||||
_bind_quad_buffer();
|
||||
@ -1060,12 +1094,12 @@ void RasterizerCanvasBaseGLES2::draw_lens_distortion_rect(const Rect2 &p_rect, f
|
||||
// and cleanup
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
for (int i = 0; i < GD_VS::ARRAY_MAX; i++) {
|
||||
for (int i = 0; i < RS::ARRAY_MAX; i++) {
|
||||
glDisableVertexAttribArray(i);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::initialize() {
|
||||
void RasterizerCanvasBaseOpenGL::initialize() {
|
||||
bool flag_stream = false;
|
||||
//flag_stream = GLOBAL_GET("rendering/options/api_usage_legacy/flag_stream");
|
||||
if (flag_stream)
|
||||
@ -1183,20 +1217,20 @@ void RasterizerCanvasBaseGLES2::initialize() {
|
||||
state.canvas_shader.init();
|
||||
|
||||
_set_texture_rect_mode(true);
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows);
|
||||
|
||||
state.canvas_shader.bind();
|
||||
|
||||
state.lens_shader.init();
|
||||
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false));
|
||||
state.canvas_shader.set_conditional(CanvasShaderOpenGL::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false));
|
||||
|
||||
state.using_light = NULL;
|
||||
state.using_transparent_rt = false;
|
||||
state.using_skeleton = false;
|
||||
}
|
||||
|
||||
RendererCanvasRender::PolygonID RasterizerCanvasBaseGLES2::request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights) {
|
||||
RendererCanvasRender::PolygonID RasterizerCanvasBaseOpenGL::request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights) {
|
||||
uint32_t id = _polydata.alloc();
|
||||
PolyData &pd = _polydata[id];
|
||||
pd.indices = p_indices;
|
||||
@ -1205,14 +1239,14 @@ RendererCanvasRender::PolygonID RasterizerCanvasBaseGLES2::request_polygon(const
|
||||
pd.uvs = p_uvs;
|
||||
return id;
|
||||
}
|
||||
void RasterizerCanvasBaseGLES2::free_polygon(PolygonID p_polygon) {
|
||||
void RasterizerCanvasBaseOpenGL::free_polygon(PolygonID p_polygon) {
|
||||
_polydata.free(p_polygon);
|
||||
}
|
||||
|
||||
void RasterizerCanvasBaseGLES2::finalize() {
|
||||
void RasterizerCanvasBaseOpenGL::finalize() {
|
||||
}
|
||||
|
||||
RasterizerCanvasBaseGLES2::RasterizerCanvasBaseGLES2() {
|
||||
RasterizerCanvasBaseOpenGL::RasterizerCanvasBaseOpenGL() {
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
@ -1,12 +1,12 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_canvas_base_gles2.h */
|
||||
/* rasterizer_canvas_base_opengl.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -28,24 +28,24 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef RASTERIZER_CANVAS_BASE_OPENGL_H
|
||||
#define RASTERIZER_CANVAS_BASE_OPENGL_H
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "drivers/gles_common/rasterizer_array.h"
|
||||
#include "drivers/gles_common/rasterizer_common_stubs.h"
|
||||
#include "drivers/gles_common/rasterizer_storage_common.h"
|
||||
#include "drivers/gles_common/rasterizer_version.h"
|
||||
#include "rasterizer_scene_gles2.h"
|
||||
#include "rasterizer_storage_gles2.h"
|
||||
#include "drivers/opengl/rasterizer_array.h"
|
||||
#include "drivers/opengl/rasterizer_storage_common.h"
|
||||
#include "rasterizer_scene_opengl.h"
|
||||
#include "rasterizer_storage_opengl.h"
|
||||
#include "servers/rendering/renderer_canvas_render.h"
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
|
||||
#include "shaders/canvas.glsl.gen.h"
|
||||
#include "shaders/canvas_shadow.glsl.gen.h"
|
||||
#include "shaders/lens_distorted.glsl.gen.h"
|
||||
|
||||
class RasterizerCanvasBaseGLES2 : public StubsCanvas {
|
||||
class RasterizerCanvasBaseOpenGL : public RendererCanvasRender {
|
||||
public:
|
||||
enum {
|
||||
INSTANCE_ATTRIB_BASE = 8,
|
||||
@ -77,9 +77,9 @@ public:
|
||||
struct State {
|
||||
Uniforms uniforms;
|
||||
bool canvas_texscreen_used;
|
||||
CanvasShaderGLES2 canvas_shader;
|
||||
CanvasShadowShaderGLES2 canvas_shadow_shader;
|
||||
LensDistortedShaderGLES2 lens_shader;
|
||||
CanvasShaderOpenGL canvas_shader;
|
||||
CanvasShadowShaderOpenGL canvas_shadow_shader;
|
||||
LensDistortedShaderOpenGL lens_shader;
|
||||
|
||||
bool using_texture_rect;
|
||||
|
||||
@ -96,7 +96,7 @@ public:
|
||||
|
||||
RID current_tex;
|
||||
RID current_normal;
|
||||
RasterizerStorageGLES2::Texture *current_tex_ptr;
|
||||
RasterizerStorageOpenGL::Texture *current_tex_ptr;
|
||||
|
||||
Transform3D vp;
|
||||
Light *using_light;
|
||||
@ -111,9 +111,9 @@ public:
|
||||
|
||||
typedef void Texture;
|
||||
|
||||
RasterizerSceneGLES2 *scene_render;
|
||||
RasterizerSceneOpenGL *scene_render;
|
||||
|
||||
RasterizerStorageGLES2 *storage;
|
||||
RasterizerStorageOpenGL *storage;
|
||||
|
||||
// allow user to choose api usage
|
||||
GLenum _buffer_upload_usage_flag;
|
||||
@ -128,9 +128,9 @@ public:
|
||||
virtual void canvas_end();
|
||||
|
||||
protected:
|
||||
void _legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageGLES2::Material *p_material);
|
||||
void _legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageGLES2::Material *p_material);
|
||||
void _legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageGLES2::Material *p_material);
|
||||
void _legacy_draw_primitive(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material);
|
||||
void _legacy_draw_line(Item::CommandPrimitive *p_pr, RasterizerStorageOpenGL::Material *p_material);
|
||||
void _legacy_draw_poly_triangles(Item::CommandPolygon *p_poly, RasterizerStorageOpenGL::Material *p_material);
|
||||
|
||||
public:
|
||||
void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const float *p_light_angles = nullptr);
|
||||
@ -148,9 +148,27 @@ public:
|
||||
|
||||
virtual void reset_canvas();
|
||||
virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache);
|
||||
|
||||
// Copied from RasterizerCanvasDummy:
|
||||
virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) override;
|
||||
|
||||
RasterizerStorageGLES2::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map);
|
||||
RID light_create() override;
|
||||
void light_set_texture(RID p_rid, RID p_texture) override;
|
||||
void light_set_use_shadow(RID p_rid, bool p_enable) override;
|
||||
void light_update_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders) override;
|
||||
void light_update_directional_shadow(RID p_rid, int p_shadow_index, const Transform2D &p_light_xform, int p_light_mask, float p_cull_distance, const Rect2 &p_clip_rect, LightOccluderInstance *p_occluders) override;
|
||||
|
||||
void render_sdf(RID p_render_target, LightOccluderInstance *p_occluders) override;
|
||||
RID occluder_polygon_create() override;
|
||||
void occluder_polygon_set_shape(RID p_occluder, const Vector<Vector2> &p_points, bool p_closed) override;
|
||||
void occluder_polygon_set_cull_mode(RID p_occluder, RS::CanvasOccluderPolygonCullMode p_mode) override;
|
||||
void set_shadow_texture_size(int p_size) override;
|
||||
|
||||
bool free(RID p_rid) override;
|
||||
void update() override;
|
||||
// End copied from RasterizerCanvasDummy.
|
||||
|
||||
RasterizerStorageOpenGL::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map);
|
||||
void _set_texture_rect_mode(bool p_texture_rect, bool p_light_angle = false, bool p_modulate = false, bool p_large_vertex = false);
|
||||
|
||||
// NEW API
|
||||
@ -170,7 +188,9 @@ public:
|
||||
void initialize();
|
||||
void finalize();
|
||||
|
||||
RasterizerCanvasBaseGLES2();
|
||||
RasterizerCanvasBaseOpenGL();
|
||||
};
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
||||
|
||||
#endif // RASTERIZER_CANVAS_BASE_OPENGL_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_canvas_gles2.h */
|
||||
/* rasterizer_canvas_opengl.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
@ -28,53 +28,19 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RASTERIZERCANVASGLES2_H
|
||||
#define RASTERIZERCANVASGLES2_H
|
||||
#ifndef RASTERIZER_CANVAS_OPENGL_H
|
||||
#define RASTERIZER_CANVAS_OPENGL_H
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "drivers/gles_common/rasterizer_canvas_batcher.h"
|
||||
#include "drivers/gles_common/rasterizer_version.h"
|
||||
#include "rasterizer_canvas_base_gles2.h"
|
||||
#include "drivers/opengl/rasterizer_canvas_batcher.h"
|
||||
#include "rasterizer_canvas_base_opengl.h"
|
||||
|
||||
class RasterizerSceneGLES2;
|
||||
class RasterizerSceneOpenGL;
|
||||
|
||||
class RasterizerCanvasGLES2 : public RasterizerCanvasBaseGLES2, public RasterizerCanvasBatcher<RasterizerCanvasGLES2, RasterizerStorageGLES2> {
|
||||
friend class RasterizerCanvasBatcher<RasterizerCanvasGLES2, RasterizerStorageGLES2>;
|
||||
|
||||
public:
|
||||
virtual void canvas_render_items_begin(const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
|
||||
virtual void canvas_render_items_end();
|
||||
void canvas_render_items_internal(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
|
||||
virtual void canvas_begin() override;
|
||||
virtual void canvas_end() override;
|
||||
|
||||
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) override {
|
||||
storage->frame.current_rt = nullptr;
|
||||
|
||||
//if (p_to_render_target.is_valid())
|
||||
// print_line("canvas_render_items " + itos(p_to_render_target.get_id()) );
|
||||
// print_line("canvas_render_items ");
|
||||
|
||||
// first set the current render target
|
||||
storage->_set_current_render_target(p_to_render_target);
|
||||
|
||||
// binds the render target (framebuffer)
|
||||
canvas_begin();
|
||||
|
||||
canvas_render_items_begin(p_modulate, p_light_list, p_canvas_transform);
|
||||
canvas_render_items_internal(p_item_list, 0, p_modulate, p_light_list, p_canvas_transform);
|
||||
canvas_render_items_end();
|
||||
|
||||
canvas_end();
|
||||
|
||||
// not sure why these are needed to get frame to render?
|
||||
storage->_set_current_render_target(RID());
|
||||
// storage->frame.current_rt = nullptr;
|
||||
// canvas_begin();
|
||||
// canvas_end();
|
||||
}
|
||||
class RasterizerCanvasOpenGL : public RasterizerCanvasBaseOpenGL, public RasterizerCanvasBatcher<RasterizerCanvasOpenGL, RasterizerStorageOpenGL> {
|
||||
friend class RasterizerCanvasBatcher<RasterizerCanvasOpenGL, RasterizerStorageOpenGL>;
|
||||
|
||||
private:
|
||||
// legacy codepath .. to remove after testing
|
||||
@ -82,23 +48,24 @@ private:
|
||||
|
||||
// high level batch funcs
|
||||
void canvas_render_items_implementation(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
|
||||
//void render_joined_item(const BItemJoined &p_bij, RenderItemState &r_ris);
|
||||
//bool try_join_item(Item *p_ci, RenderItemState &r_ris, bool &r_batch_break);
|
||||
void render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageGLES2::Material *p_material);
|
||||
|
||||
// low level batch funcs
|
||||
// void _batch_upload_buffers();
|
||||
// void _batch_render_generic(const Batch &p_batch, RasterizerStorageGLES2::Material *p_material);
|
||||
// void _batch_render_lines(const Batch &p_batch, RasterizerStorageGLES2::Material *p_material, bool p_anti_alias);
|
||||
void render_batches(Item::Command *const *p_commands, Item *p_current_clip, bool &r_reclip, RasterizerStorageOpenGL::Material *p_material);
|
||||
|
||||
// funcs used from rasterizer_canvas_batcher template
|
||||
void gl_enable_scissor(int p_x, int p_y, int p_width, int p_height) const;
|
||||
void gl_disable_scissor() const;
|
||||
|
||||
public:
|
||||
void canvas_render_items_begin(const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
|
||||
void canvas_render_items_end();
|
||||
void canvas_render_items_internal(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform);
|
||||
void canvas_begin() override;
|
||||
void canvas_end() override;
|
||||
|
||||
void canvas_render_items(RID p_to_render_target, Item *p_item_list, const Color &p_modulate, Light *p_light_list, Light *p_directional_list, const Transform2D &p_canvas_transform, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool &r_sdf_used) override;
|
||||
|
||||
void initialize();
|
||||
RasterizerCanvasGLES2();
|
||||
RasterizerCanvasOpenGL();
|
||||
};
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // RASTERIZERCANVASGLES2_H
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
||||
#endif // RASTERIZER_CANVAS_OPENGL_H
|
@ -1,5 +1,5 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_gles2.cpp */
|
||||
/* rasterizer_opengl.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
@ -28,10 +28,10 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_gles2.h"
|
||||
#include "rasterizer_opengl.h"
|
||||
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "shader_gles2.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
#include "shader_opengl.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/os.h"
|
||||
@ -87,7 +87,7 @@
|
||||
#define strcpy strcpy_s
|
||||
#endif
|
||||
|
||||
void RasterizerGLES2::begin_frame(double frame_step) {
|
||||
void RasterizerOpenGL::begin_frame(double frame_step) {
|
||||
frame++;
|
||||
delta = frame_step;
|
||||
|
||||
@ -117,7 +117,7 @@ void RasterizerGLES2::begin_frame(double frame_step) {
|
||||
//scene->iteration();
|
||||
}
|
||||
|
||||
void RasterizerGLES2::end_frame(bool p_swap_buffers) {
|
||||
void RasterizerOpenGL::end_frame(bool p_swap_buffers) {
|
||||
// if (OS::get_singleton()->is_layered_allowed()) {
|
||||
// if (!OS::get_singleton()->get_window_per_pixel_transparency_enabled()) {
|
||||
//clear alpha
|
||||
@ -196,8 +196,8 @@ typedef void (*DEBUGPROCARB)(GLenum source,
|
||||
|
||||
typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam);
|
||||
|
||||
void RasterizerGLES2::initialize() {
|
||||
print_verbose("Using GLES2 video driver");
|
||||
void RasterizerOpenGL::initialize() {
|
||||
print_verbose("Using OpenGL video driver");
|
||||
|
||||
storage._main_thread_id = Thread::get_caller_id();
|
||||
|
||||
@ -252,7 +252,7 @@ void RasterizerGLES2::initialize() {
|
||||
#endif // GLES_OVER_GL
|
||||
#endif // CAN_DEBUG
|
||||
|
||||
print_line("OpenGL ES 2.0 Renderer: " + GD_VS::get_singleton()->get_video_adapter_name());
|
||||
print_line("OpenGL Renderer: " + RS::get_singleton()->get_video_adapter_name());
|
||||
storage.initialize();
|
||||
canvas.initialize();
|
||||
// scene.initialize();
|
||||
@ -261,7 +261,7 @@ void RasterizerGLES2::initialize() {
|
||||
OS::get_singleton()->set_render_main_thread_mode(OS::RENDER_MAIN_THREAD_ONLY);
|
||||
}
|
||||
|
||||
RasterizerGLES2::RasterizerGLES2() {
|
||||
RasterizerOpenGL::RasterizerOpenGL() {
|
||||
canvas.storage = &storage;
|
||||
canvas.scene_render = &scene;
|
||||
storage.canvas = &canvas;
|
||||
@ -269,15 +269,15 @@ RasterizerGLES2::RasterizerGLES2() {
|
||||
storage.scene = &scene;
|
||||
}
|
||||
|
||||
void RasterizerGLES2::prepare_for_blitting_render_targets() {
|
||||
void RasterizerOpenGL::prepare_for_blitting_render_targets() {
|
||||
}
|
||||
|
||||
void RasterizerGLES2::_blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
void RasterizerOpenGL::_blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
ERR_FAIL_COND(storage.frame.current_rt);
|
||||
|
||||
// print_line("_blit_render_target_to_screen " + itos (p_screen) + ", rect " + String(Variant(p_screen_rect)));
|
||||
|
||||
RasterizerStorageGLES2::RenderTarget *rt = storage.render_target_owner.getornull(p_render_target);
|
||||
RasterizerStorageOpenGL::RenderTarget *rt = storage.render_target_owner.get_or_null(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
|
||||
canvas._set_texture_rect_mode(true);
|
||||
@ -300,7 +300,7 @@ void RasterizerGLES2::_blit_render_target_to_screen(RID p_render_target, const R
|
||||
}
|
||||
|
||||
// is this p_screen useless in a multi window environment?
|
||||
void RasterizerGLES2::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
|
||||
void RasterizerOpenGL::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
|
||||
// do this once off for all blits
|
||||
storage.bind_framebuffer_system();
|
||||
|
||||
@ -316,7 +316,7 @@ void RasterizerGLES2::blit_render_targets_to_screen(DisplayServer::WindowID p_sc
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
|
||||
void RasterizerOpenGL::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
|
||||
if (p_image.is_null() || p_image->is_empty())
|
||||
return;
|
||||
|
||||
@ -339,7 +339,7 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
|
||||
|
||||
RID texture = storage.texture_create();
|
||||
//storage.texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_use_filter ? VS::TEXTURE_FLAG_FILTER : 0);
|
||||
storage._texture_allocate_internal(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), GD_RD::TEXTURE_TYPE_2D);
|
||||
storage._texture_allocate_internal(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), RenderingDevice::TEXTURE_TYPE_2D);
|
||||
storage.texture_set_data(texture, p_image);
|
||||
|
||||
Rect2 imgrect(0, 0, p_image->get_width(), p_image->get_height());
|
||||
@ -362,7 +362,7 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
|
||||
screenrect.position += ((Size2(window_w, window_h) - screenrect.size) / 2.0).floor();
|
||||
}
|
||||
|
||||
RasterizerStorageGLES2::Texture *t = storage.texture_owner.getornull(texture);
|
||||
RasterizerStorageOpenGL::Texture *t = storage.texture_owner.get_or_null(texture);
|
||||
glActiveTexture(GL_TEXTURE0 + storage.config.max_texture_image_units - 1);
|
||||
glBindTexture(GL_TEXTURE_2D, t->tex_id);
|
||||
canvas.draw_generic_textured_rect(screenrect, Rect2(0, 0, 1, 1));
|
||||
@ -374,4 +374,4 @@ void RasterizerGLES2::set_boot_image(const Ref<Image> &p_image, const Color &p_c
|
||||
end_frame(true);
|
||||
}
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
@ -1,5 +1,5 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_gles2.h */
|
||||
/* rasterizer_opengl.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
@ -28,18 +28,18 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef RASTERIZER_OPENGL_H
|
||||
#define RASTERIZER_OPENGL_H
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "drivers/gles_common/rasterizer_version.h"
|
||||
#include "rasterizer_canvas_gles2.h"
|
||||
#include "rasterizer_scene_gles2.h"
|
||||
#include "rasterizer_storage_gles2.h"
|
||||
#include "rasterizer_canvas_opengl.h"
|
||||
#include "rasterizer_scene_opengl.h"
|
||||
#include "rasterizer_storage_opengl.h"
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
|
||||
class RasterizerGLES2 : public RendererCompositor {
|
||||
class RasterizerOpenGL : public RendererCompositor {
|
||||
private:
|
||||
uint64_t frame = 1;
|
||||
float delta = 0;
|
||||
@ -48,9 +48,9 @@ private:
|
||||
double time_scale = 1.0;
|
||||
|
||||
protected:
|
||||
RasterizerCanvasGLES2 canvas;
|
||||
RasterizerStorageGLES2 storage;
|
||||
RasterizerSceneGLES2 scene;
|
||||
RasterizerCanvasOpenGL canvas;
|
||||
RasterizerStorageOpenGL storage;
|
||||
RasterizerSceneOpenGL scene;
|
||||
|
||||
void _blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect);
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
void finalize() {}
|
||||
|
||||
static RendererCompositor *_create_current() {
|
||||
return memnew(RasterizerGLES2);
|
||||
return memnew(RasterizerOpenGL);
|
||||
}
|
||||
|
||||
static void make_current() {
|
||||
@ -83,8 +83,10 @@ public:
|
||||
uint64_t get_frame_number() const { return frame; }
|
||||
double get_frame_delta_time() const { return delta; }
|
||||
|
||||
RasterizerGLES2();
|
||||
~RasterizerGLES2() {}
|
||||
RasterizerOpenGL();
|
||||
~RasterizerOpenGL() {}
|
||||
};
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
||||
|
||||
#endif
|
@ -28,46 +28,21 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef RASTERIZER_PLATFORMS_H
|
||||
#define RASTERIZER_PLATFORMS_H
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// override for intellisense .. ONLY FOR DEVELOPMENT
|
||||
//#ifndef X11_ENABLED
|
||||
//#define X11_ENABLED
|
||||
//#endif
|
||||
//#define GLES2_BACKEND_ENABLED
|
||||
//#define OPENGL_BACKEND_ENABLED
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
|
||||
|
||||
// platform specific defines to compile in / out GLES support
|
||||
// these can later be made from Scons
|
||||
#ifdef X11_ENABLED
|
||||
#define GLES_X11_ENABLED
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
//#define GLES_WINDOWS_ENABLED
|
||||
#endif
|
||||
|
||||
#ifdef IPHONE_ENABLED
|
||||
//#define GLES_IPHONE_ENABLED
|
||||
#endif
|
||||
|
||||
#ifdef OSX_ENABLED
|
||||
//#define GLES_OSX_ENABLED
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
//#define GLES_ANDROID_ENABLED
|
||||
#endif
|
||||
|
||||
#if defined(GLES_X11_ENABLED) || defined(GLES_WINDOW_ENABLED) || defined(GLES_IPHONE_ENABLED) || defined(GLES_OSX_ENABLED) || defined(GLES_ANDROID_ENABLED)
|
||||
#define GLES2_BACKEND_ENABLED
|
||||
#endif
|
||||
|
||||
#if defined(GLES_X11_ENABLED) || defined(GLES_WINDOW_ENABLED) || defined(GLES_IPHONE_ENABLED) || defined(GLES_OSX_ENABLED) || defined(GLES_ANDROID_ENABLED)
|
||||
#define GLES3_BACKEND_ENABLED
|
||||
#endif
|
||||
#define OPENGL_BACKEND_ENABLED
|
||||
|
||||
#endif // defined(OPENGL_ENABLED) || defined(GLES_ENABLED)
|
||||
|
||||
#endif // RASTERIZER_PLATFORMS_H
|
439
drivers/opengl/rasterizer_scene_opengl.cpp
Normal file
439
drivers/opengl/rasterizer_scene_opengl.cpp
Normal file
@ -0,0 +1,439 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_scene_opengl.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "rasterizer_scene_opengl.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
// TODO: 3D support not implemented yet.
|
||||
|
||||
RasterizerSceneOpenGL::GeometryInstance *RasterizerSceneOpenGL::geometry_instance_create(RID p_base) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector<RID> &p_material) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) {
|
||||
}
|
||||
|
||||
uint32_t RasterizerSceneOpenGL::geometry_instance_get_pair_mask() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::geometry_instance_free(GeometryInstance *p_geometry_instance) {
|
||||
}
|
||||
|
||||
/* SHADOW ATLAS API */
|
||||
|
||||
RID RasterizerSceneOpenGL::shadow_atlas_create() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) {
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::directional_shadow_atlas_set_size(int p_size, bool p_16_bits) {
|
||||
}
|
||||
|
||||
int RasterizerSceneOpenGL::get_directional_light_shadow_size(RID p_light_intance) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::set_directional_shadow_count(int p_count) {
|
||||
}
|
||||
|
||||
/* SDFGI UPDATE */
|
||||
|
||||
void RasterizerSceneOpenGL::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) {
|
||||
}
|
||||
|
||||
int RasterizerSceneOpenGL::sdfgi_get_pending_region_count(RID p_render_buffers) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
AABB RasterizerSceneOpenGL::sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const {
|
||||
return AABB();
|
||||
}
|
||||
|
||||
uint32_t RasterizerSceneOpenGL::sdfgi_get_pending_region_cascade(RID p_render_buffers, int p_region) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* SKY API */
|
||||
|
||||
RID RasterizerSceneOpenGL::sky_allocate() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::sky_initialize(RID p_rid) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::sky_set_radiance_size(RID p_sky, int p_radiance_size) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::sky_set_mode(RID p_sky, RS::SkyMode p_samples) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::sky_set_material(RID p_sky, RID p_material) {
|
||||
}
|
||||
|
||||
Ref<Image> RasterizerSceneOpenGL::sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) {
|
||||
return Ref<Image>();
|
||||
}
|
||||
|
||||
/* ENVIRONMENT API */
|
||||
|
||||
RID RasterizerSceneOpenGL::environment_allocate() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_initialize(RID p_rid) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_sky(RID p_env, RID p_sky) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_sky_custom_fov(RID p_env, float p_scale) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_bg_color(RID p_env, const Color &p_color) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_bg_energy(RID p_env, float p_energy) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_canvas_max_layer(RID p_env, int p_max_layer) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_glow_set_use_bicubic_upscale(bool p_enable) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_glow_set_use_high_quality(bool p_enable) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_volumetric_fog_volume_size(int p_size, int p_depth) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::environment_set_volumetric_fog_filter_active(bool p_enable) {
|
||||
}
|
||||
|
||||
Ref<Image> RasterizerSceneOpenGL::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) {
|
||||
return Ref<Image>();
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::is_environment(RID p_env) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
RS::EnvironmentBG RasterizerSceneOpenGL::environment_get_background(RID p_env) const {
|
||||
return RS::ENV_BG_KEEP;
|
||||
}
|
||||
|
||||
int RasterizerSceneOpenGL::environment_get_canvas_max_layer(RID p_env) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::camera_effects_allocate() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::camera_effects_initialize(RID p_rid) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::shadows_quality_set(RS::ShadowQuality p_quality) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::directional_shadow_quality_set(RS::ShadowQuality p_quality) {
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::light_instance_create(RID p_light) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale, float p_range_begin, const Vector2 &p_uv_scale) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::light_instance_mark_visible(RID p_light_instance) {
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::reflection_atlas_create() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
int RasterizerSceneOpenGL::reflection_atlas_get_size(RID p_ref_atlas) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) {
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::reflection_probe_instance_create(RID p_probe) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::reflection_probe_release_atlas_index(RID p_instance) {
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::reflection_probe_instance_needs_redraw(RID p_instance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::reflection_probe_instance_has_reflection(RID p_instance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::reflection_probe_instance_postprocess_step(RID p_instance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::decal_instance_create(RID p_decal) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) {
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::lightmap_instance_create(RID p_lightmap) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) {
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::voxel_gi_instance_create(RID p_voxel_gi) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) {
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::voxel_gi_needs_update(RID p_probe) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::voxel_gi_set_quality(RS::VoxelGIQuality) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data, RendererScene::RenderInfo *r_info) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::set_scene_pass(uint64_t p_pass) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::set_time(double p_time, double p_step) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) {
|
||||
}
|
||||
|
||||
RID RasterizerSceneOpenGL::render_buffers_create() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::gi_set_use_half_resolution(bool p_enable) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) {
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::screen_space_roughness_limiter_is_active() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) {
|
||||
}
|
||||
|
||||
TypedArray<Image> RasterizerSceneOpenGL::bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) {
|
||||
return TypedArray<Image>();
|
||||
}
|
||||
|
||||
bool RasterizerSceneOpenGL::free(RID p_rid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::update() {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::decals_set_filter(RS::DecalFilter p_filter) {
|
||||
}
|
||||
|
||||
void RasterizerSceneOpenGL::light_projectors_set_filter(RS::LightProjectorFilter p_filter) {
|
||||
}
|
||||
|
||||
RasterizerSceneOpenGL::RasterizerSceneOpenGL() {
|
||||
}
|
||||
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
220
drivers/opengl/rasterizer_scene_opengl.h
Normal file
220
drivers/opengl/rasterizer_scene_opengl.h
Normal file
@ -0,0 +1,220 @@
|
||||
/*************************************************************************/
|
||||
/* rasterizer_scene_opengl.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RASTERIZER_SCENE_OPENGL_H
|
||||
#define RASTERIZER_SCENE_OPENGL_H
|
||||
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "core/math/camera_matrix.h"
|
||||
#include "core/templates/rid_owner.h"
|
||||
#include "core/templates/self_list.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
#include "servers/rendering/renderer_scene_render.h"
|
||||
#include "servers/rendering_server.h"
|
||||
#include "shaders/scene.glsl.gen.h"
|
||||
|
||||
class RasterizerSceneOpenGL : public RendererSceneRender {
|
||||
public:
|
||||
struct State {
|
||||
SceneShaderOpenGL scene_shader;
|
||||
} state;
|
||||
|
||||
GeometryInstance *geometry_instance_create(RID p_base) override;
|
||||
void geometry_instance_set_skeleton(GeometryInstance *p_geometry_instance, RID p_skeleton) override;
|
||||
void geometry_instance_set_material_override(GeometryInstance *p_geometry_instance, RID p_override) override;
|
||||
void geometry_instance_set_surface_materials(GeometryInstance *p_geometry_instance, const Vector<RID> &p_material) override;
|
||||
void geometry_instance_set_mesh_instance(GeometryInstance *p_geometry_instance, RID p_mesh_instance) override;
|
||||
void geometry_instance_set_transform(GeometryInstance *p_geometry_instance, const Transform3D &p_transform, const AABB &p_aabb, const AABB &p_transformed_aabbb) override;
|
||||
void geometry_instance_set_layer_mask(GeometryInstance *p_geometry_instance, uint32_t p_layer_mask) override;
|
||||
void geometry_instance_set_lod_bias(GeometryInstance *p_geometry_instance, float p_lod_bias) override;
|
||||
void geometry_instance_set_use_baked_light(GeometryInstance *p_geometry_instance, bool p_enable) override;
|
||||
void geometry_instance_set_use_dynamic_gi(GeometryInstance *p_geometry_instance, bool p_enable) override;
|
||||
void geometry_instance_set_use_lightmap(GeometryInstance *p_geometry_instance, RID p_lightmap_instance, const Rect2 &p_lightmap_uv_scale, int p_lightmap_slice_index) override;
|
||||
void geometry_instance_set_lightmap_capture(GeometryInstance *p_geometry_instance, const Color *p_sh9) override;
|
||||
void geometry_instance_set_instance_shader_parameters_offset(GeometryInstance *p_geometry_instance, int32_t p_offset) override;
|
||||
void geometry_instance_set_cast_double_sided_shadows(GeometryInstance *p_geometry_instance, bool p_enable) override;
|
||||
|
||||
uint32_t geometry_instance_get_pair_mask() override;
|
||||
void geometry_instance_pair_light_instances(GeometryInstance *p_geometry_instance, const RID *p_light_instances, uint32_t p_light_instance_count) override;
|
||||
void geometry_instance_pair_reflection_probe_instances(GeometryInstance *p_geometry_instance, const RID *p_reflection_probe_instances, uint32_t p_reflection_probe_instance_count) override;
|
||||
void geometry_instance_pair_decal_instances(GeometryInstance *p_geometry_instance, const RID *p_decal_instances, uint32_t p_decal_instance_count) override;
|
||||
void geometry_instance_pair_voxel_gi_instances(GeometryInstance *p_geometry_instance, const RID *p_voxel_gi_instances, uint32_t p_voxel_gi_instance_count) override;
|
||||
void geometry_instance_set_softshadow_projector_pairing(GeometryInstance *p_geometry_instance, bool p_softshadow, bool p_projector) override;
|
||||
|
||||
void geometry_instance_free(GeometryInstance *p_geometry_instance) override;
|
||||
|
||||
/* SHADOW ATLAS API */
|
||||
|
||||
RID shadow_atlas_create() override;
|
||||
void shadow_atlas_set_size(RID p_atlas, int p_size, bool p_16_bits = false) override;
|
||||
void shadow_atlas_set_quadrant_subdivision(RID p_atlas, int p_quadrant, int p_subdivision) override;
|
||||
bool shadow_atlas_update_light(RID p_atlas, RID p_light_intance, float p_coverage, uint64_t p_light_version) override;
|
||||
|
||||
void directional_shadow_atlas_set_size(int p_size, bool p_16_bits = false) override;
|
||||
int get_directional_light_shadow_size(RID p_light_intance) override;
|
||||
void set_directional_shadow_count(int p_count) override;
|
||||
|
||||
/* SDFGI UPDATE */
|
||||
|
||||
void sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) override;
|
||||
int sdfgi_get_pending_region_count(RID p_render_buffers) const override;
|
||||
AABB sdfgi_get_pending_region_bounds(RID p_render_buffers, int p_region) const override;
|
||||
uint32_t sdfgi_get_pending_region_cascade(RID p_render_buffers, int p_region) const override;
|
||||
|
||||
/* SKY API */
|
||||
|
||||
RID sky_allocate() override;
|
||||
void sky_initialize(RID p_rid) override;
|
||||
void sky_set_radiance_size(RID p_sky, int p_radiance_size) override;
|
||||
void sky_set_mode(RID p_sky, RS::SkyMode p_samples) override;
|
||||
void sky_set_material(RID p_sky, RID p_material) override;
|
||||
Ref<Image> sky_bake_panorama(RID p_sky, float p_energy, bool p_bake_irradiance, const Size2i &p_size) override;
|
||||
|
||||
/* ENVIRONMENT API */
|
||||
|
||||
RID environment_allocate() override;
|
||||
void environment_initialize(RID p_rid) override;
|
||||
void environment_set_background(RID p_env, RS::EnvironmentBG p_bg) override;
|
||||
void environment_set_sky(RID p_env, RID p_sky) override;
|
||||
void environment_set_sky_custom_fov(RID p_env, float p_scale) override;
|
||||
void environment_set_sky_orientation(RID p_env, const Basis &p_orientation) override;
|
||||
void environment_set_bg_color(RID p_env, const Color &p_color) override;
|
||||
void environment_set_bg_energy(RID p_env, float p_energy) override;
|
||||
void environment_set_canvas_max_layer(RID p_env, int p_max_layer) override;
|
||||
void environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient = RS::ENV_AMBIENT_SOURCE_BG, float p_energy = 1.0, float p_sky_contribution = 0.0, RS::EnvironmentReflectionSource p_reflection_source = RS::ENV_REFLECTION_SOURCE_BG) override;
|
||||
|
||||
void environment_set_glow(RID p_env, bool p_enable, Vector<float> p_levels, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) override;
|
||||
void environment_glow_set_use_bicubic_upscale(bool p_enable) override;
|
||||
void environment_glow_set_use_high_quality(bool p_enable) override;
|
||||
|
||||
void environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) override;
|
||||
void environment_set_ssr_roughness_quality(RS::EnvironmentSSRRoughnessQuality p_quality) override;
|
||||
void environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_power, float p_detail, float p_horizon, float p_sharpness, float p_light_affect, float p_ao_channel_affect) override;
|
||||
void environment_set_ssao_quality(RS::EnvironmentSSAOQuality p_quality, bool p_half_size, float p_adaptive_target, int p_blur_passes, float p_fadeout_from, float p_fadeout_to) override;
|
||||
|
||||
void environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, float p_bounce_feedback, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) override;
|
||||
|
||||
void environment_set_sdfgi_ray_count(RS::EnvironmentSDFGIRayCount p_ray_count) override;
|
||||
void environment_set_sdfgi_frames_to_converge(RS::EnvironmentSDFGIFramesToConverge p_frames) override;
|
||||
void environment_set_sdfgi_frames_to_update_light(RS::EnvironmentSDFGIFramesToUpdateLight p_update) override;
|
||||
|
||||
void environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) override;
|
||||
|
||||
void environment_set_adjustment(RID p_env, bool p_enable, float p_brightness, float p_contrast, float p_saturation, bool p_use_1d_color_correction, RID p_color_correction) override;
|
||||
|
||||
void environment_set_fog(RID p_env, bool p_enable, const Color &p_light_color, float p_light_energy, float p_sun_scatter, float p_density, float p_height, float p_height_density, float p_aerial_perspective) override;
|
||||
void environment_set_volumetric_fog(RID p_env, bool p_enable, float p_density, const Color &p_light, float p_light_energy, float p_length, float p_detail_spread, float p_gi_inject, bool p_temporal_reprojection, float p_temporal_reprojection_amount) override;
|
||||
void environment_set_volumetric_fog_volume_size(int p_size, int p_depth) override;
|
||||
void environment_set_volumetric_fog_filter_active(bool p_enable) override;
|
||||
|
||||
Ref<Image> environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) override;
|
||||
|
||||
bool is_environment(RID p_env) const override;
|
||||
RS::EnvironmentBG environment_get_background(RID p_env) const override;
|
||||
int environment_get_canvas_max_layer(RID p_env) const override;
|
||||
|
||||
RID camera_effects_allocate() override;
|
||||
void camera_effects_initialize(RID p_rid) override;
|
||||
void camera_effects_set_dof_blur_quality(RS::DOFBlurQuality p_quality, bool p_use_jitter) override;
|
||||
void camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape p_shape) override;
|
||||
|
||||
void camera_effects_set_dof_blur(RID p_camera_effects, bool p_far_enable, float p_far_distance, float p_far_transition, bool p_near_enable, float p_near_distance, float p_near_transition, float p_amount) override;
|
||||
void camera_effects_set_custom_exposure(RID p_camera_effects, bool p_enable, float p_exposure) override;
|
||||
|
||||
void shadows_quality_set(RS::ShadowQuality p_quality) override;
|
||||
void directional_shadow_quality_set(RS::ShadowQuality p_quality) override;
|
||||
|
||||
RID light_instance_create(RID p_light) override;
|
||||
void light_instance_set_transform(RID p_light_instance, const Transform3D &p_transform) override;
|
||||
void light_instance_set_aabb(RID p_light_instance, const AABB &p_aabb) override;
|
||||
void light_instance_set_shadow_transform(RID p_light_instance, const CameraMatrix &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale = 1.0, float p_range_begin = 0, const Vector2 &p_uv_scale = Vector2()) override;
|
||||
void light_instance_mark_visible(RID p_light_instance) override;
|
||||
|
||||
RID reflection_atlas_create() override;
|
||||
int reflection_atlas_get_size(RID p_ref_atlas) const override;
|
||||
void reflection_atlas_set_size(RID p_ref_atlas, int p_reflection_size, int p_reflection_count) override;
|
||||
|
||||
RID reflection_probe_instance_create(RID p_probe) override;
|
||||
void reflection_probe_instance_set_transform(RID p_instance, const Transform3D &p_transform) override;
|
||||
void reflection_probe_release_atlas_index(RID p_instance) override;
|
||||
bool reflection_probe_instance_needs_redraw(RID p_instance) override;
|
||||
bool reflection_probe_instance_has_reflection(RID p_instance) override;
|
||||
bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) override;
|
||||
bool reflection_probe_instance_postprocess_step(RID p_instance) override;
|
||||
|
||||
RID decal_instance_create(RID p_decal) override;
|
||||
void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override;
|
||||
|
||||
RID lightmap_instance_create(RID p_lightmap) override;
|
||||
void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) override;
|
||||
|
||||
RID voxel_gi_instance_create(RID p_voxel_gi) override;
|
||||
void voxel_gi_instance_set_transform_to_data(RID p_probe, const Transform3D &p_xform) override;
|
||||
bool voxel_gi_needs_update(RID p_probe) const override;
|
||||
void voxel_gi_update(RID p_probe, bool p_update_light_instances, const Vector<RID> &p_light_instances, const PagedArray<RendererSceneRender::GeometryInstance *> &p_dynamic_objects) override;
|
||||
|
||||
void voxel_gi_set_quality(RS::VoxelGIQuality) override;
|
||||
|
||||
void render_scene(RID p_render_buffers, const CameraData *p_camera_data, const PagedArray<GeometryInstance *> &p_instances, const PagedArray<RID> &p_lights, const PagedArray<RID> &p_reflection_probes, const PagedArray<RID> &p_voxel_gi_instances, const PagedArray<RID> &p_decals, const PagedArray<RID> &p_lightmaps, RID p_environment, RID p_camera_effects, RID p_shadow_atlas, RID p_occluder_debug_tex, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass, float p_screen_lod_threshold, const RenderShadowData *p_render_shadows, int p_render_shadow_count, const RenderSDFGIData *p_render_sdfgi_regions, int p_render_sdfgi_region_count, const RenderSDFGIUpdateData *p_sdfgi_update_data = nullptr, RendererScene::RenderInfo *r_info = nullptr) override;
|
||||
void render_material(const Transform3D &p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_ortogonal, const PagedArray<GeometryInstance *> &p_instances, RID p_framebuffer, const Rect2i &p_region) override;
|
||||
void render_particle_collider_heightfield(RID p_collider, const Transform3D &p_transform, const PagedArray<GeometryInstance *> &p_instances) override;
|
||||
|
||||
void set_scene_pass(uint64_t p_pass) override;
|
||||
void set_time(double p_time, double p_step) override;
|
||||
void set_debug_draw_mode(RS::ViewportDebugDraw p_debug_draw) override;
|
||||
|
||||
RID render_buffers_create() override;
|
||||
void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override;
|
||||
void gi_set_use_half_resolution(bool p_enable) override;
|
||||
|
||||
void screen_space_roughness_limiter_set_active(bool p_enable, float p_amount, float p_curve) override;
|
||||
bool screen_space_roughness_limiter_is_active() const override;
|
||||
|
||||
void sub_surface_scattering_set_quality(RS::SubSurfaceScatteringQuality p_quality) override;
|
||||
void sub_surface_scattering_set_scale(float p_scale, float p_depth_scale) override;
|
||||
|
||||
TypedArray<Image> bake_render_uv2(RID p_base, const Vector<RID> &p_material_overrides, const Size2i &p_image_size) override;
|
||||
|
||||
bool free(RID p_rid) override;
|
||||
void update() override;
|
||||
void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) override;
|
||||
|
||||
void decals_set_filter(RS::DecalFilter p_filter) override;
|
||||
void light_projectors_set_filter(RS::LightProjectorFilter p_filter) override;
|
||||
|
||||
RasterizerSceneOpenGL();
|
||||
};
|
||||
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
||||
|
||||
#endif // RASTERIZER_SCENE_OPENGL_H
|
File diff suppressed because it is too large
Load Diff
1440
drivers/opengl/rasterizer_storage_opengl.h
Normal file
1440
drivers/opengl/rasterizer_storage_opengl.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
||||
/*************************************************************************/
|
||||
/* shader_compiler_gles2.cpp */
|
||||
/* shader_compiler_opengl.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -28,24 +28,14 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "shader_compiler_gles2.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "shader_compiler_opengl.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
||||
//#ifdef GODOT_3
|
||||
|
||||
#ifdef GODOT_3
|
||||
#include "core/project_settings.h"
|
||||
#include "core/string_buffer.h"
|
||||
#include "core/string_builder.h"
|
||||
#else
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/string/string_buffer.h"
|
||||
#include "core/string/string_builder.h"
|
||||
|
||||
#endif
|
||||
|
||||
#define SL ShaderLanguage
|
||||
|
||||
static String _mktab(int p_level) {
|
||||
@ -216,7 +206,7 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, StringBuilder &r_to_add, Set<StringName> &r_added) {
|
||||
void ShaderCompilerOpenGL::_dump_function_deps(SL::ShaderNode *p_node, const StringName &p_for_func, const Map<StringName, String> &p_func_code, StringBuilder &r_to_add, Set<StringName> &r_added) {
|
||||
int fidx = -1;
|
||||
|
||||
for (int i = 0; i < p_node->functions.size(); i++) {
|
||||
@ -274,7 +264,7 @@ void ShaderCompilerGLES2::_dump_function_deps(SL::ShaderNode *p_node, const Stri
|
||||
}
|
||||
}
|
||||
|
||||
String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) {
|
||||
String ShaderCompilerOpenGL::_dump_node_code(SL::Node *p_node, int p_level, GeneratedCode &r_gen_code, IdentifierActions &p_actions, const DefaultIdentifierActions &p_default_actions, bool p_assigning, bool p_use_scope) {
|
||||
StringBuilder code;
|
||||
|
||||
switch (p_node->type) {
|
||||
@ -852,16 +842,15 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
|
||||
return code.as_string();
|
||||
}
|
||||
|
||||
ShaderLanguage::DataType ShaderCompilerGLES2::_get_variable_type(const StringName &p_type) {
|
||||
ShaderLanguage::DataType ShaderCompilerOpenGL::_get_variable_type(const StringName &p_type) {
|
||||
// RS::GlobalVariableType gvt = ((RasterizerStorageRD *)(RendererStorage::base_singleton))->global_variable_get_type_internal(p_type);
|
||||
RS::GlobalVariableType gvt = RS::GLOBAL_VAR_TYPE_MAX;
|
||||
return RS::global_variable_type_get_shader_datatype(gvt);
|
||||
}
|
||||
|
||||
Error ShaderCompilerGLES2::compile(GD_VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
|
||||
|
||||
Error ShaderCompilerOpenGL::compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code) {
|
||||
ShaderLanguage::VaryingFunctionNames var_names;
|
||||
|
||||
|
||||
Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), var_names, ShaderTypes::get_singleton()->get_types(), _get_variable_type);
|
||||
|
||||
// Error ShaderLanguage::compile(const String &p_code, const Map<StringName, FunctionInfo> &p_functions, const Vector<StringName> &p_render_modes, const Set<String> &p_shader_types, GlobalVariableGetTypeFunc p_global_variable_type_func) {
|
||||
@ -896,217 +885,223 @@ Error ShaderCompilerGLES2::compile(GD_VS::ShaderMode p_mode, const String &p_cod
|
||||
return OK;
|
||||
}
|
||||
|
||||
ShaderCompilerGLES2::ShaderCompilerGLES2() {
|
||||
ShaderCompilerOpenGL::ShaderCompilerOpenGL() {
|
||||
/** CANVAS ITEM SHADER **/
|
||||
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["UV"] = "uv";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["UV"] = "uv";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size";
|
||||
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix_instance";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["TIME"] = "time";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["EXTRA_MATRIX"] = "extra_matrix_instance";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["TIME"] = "time";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["PI"] = _MKSTR(Math_PI);
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["TAU"] = _MKSTR(Math_TAU);
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["E"] = _MKSTR(Math_E);
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["AT_LIGHT_PASS"] = "at_light_pass";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["INSTANCE_CUSTOM"] = "instance_custom";
|
||||
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["MODULATE"] = "final_modulate";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["NORMALMAP"] = "normal_map";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["NORMALMAP_DEPTH"] = "normal_depth";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["TEXTURE"] = "color_texture";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["NORMAL_TEXTURE"] = "normal_texture";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["COLOR"] = "color";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["MODULATE"] = "final_modulate";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["NORMAL"] = "normal";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["NORMALMAP"] = "normal_map";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["NORMALMAP_DEPTH"] = "normal_depth";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["TEXTURE"] = "color_texture";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["TEXTURE_PIXEL_SIZE"] = "color_texpixel_size";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["NORMAL_TEXTURE"] = "normal_texture";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_UV"] = "screen_uv";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_TEXTURE"] = "screen_texture";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["SCREEN_PIXEL_SIZE"] = "screen_pixel_size";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["POINT_COORD"] = "gl_PointCoord";
|
||||
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].renames["SHADOW_VEC"] = "shadow_vec";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_VEC"] = "light_vec";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color";
|
||||
actions[RS::SHADER_CANVAS_ITEM].renames["SHADOW_VEC"] = "shadow_vec";
|
||||
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["COLOR"] = "#define COLOR_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["MODULATE"] = "#define MODULATE_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_VEC"] = "#define SHADOW_VEC_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["COLOR"] = "#define COLOR_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["MODULATE"] = "#define MODULATE_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_VEC"] = "#define SHADOW_VEC_USED\n";
|
||||
|
||||
// Ported from GLES3
|
||||
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["sinh"] = "#define SINH_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["cosh"] = "#define COSH_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["tanh"] = "#define TANH_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["asinh"] = "#define ASINH_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["acosh"] = "#define ACOSH_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["atanh"] = "#define ATANH_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["inverse"] = "#define INVERSE_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n";
|
||||
actions[GD_VS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["sinh"] = "#define SINH_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["cosh"] = "#define COSH_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["tanh"] = "#define TANH_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["asinh"] = "#define ASINH_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["acosh"] = "#define ACOSH_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["atanh"] = "#define ATANH_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["inverse"] = "#define INVERSE_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n";
|
||||
actions[RS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n";
|
||||
|
||||
/** SPATIAL SHADER **/
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "projection_inverse_matrix";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview";
|
||||
actions[RS::SHADER_SPATIAL].renames["WORLD_MATRIX"] = "world_transform";
|
||||
actions[RS::SHADER_SPATIAL].renames["INV_CAMERA_MATRIX"] = "camera_inverse_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["CAMERA_MATRIX"] = "camera_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["PROJECTION_MATRIX"] = "projection_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["INV_PROJECTION_MATRIX"] = "projection_inverse_matrix";
|
||||
actions[RS::SHADER_SPATIAL].renames["MODELVIEW_MATRIX"] = "modelview";
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["NORMAL"] = "normal";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["TANGENT"] = "tangent";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["POSITION"] = "position";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size";
|
||||
actions[RS::SHADER_SPATIAL].renames["VERTEX"] = "vertex.xyz";
|
||||
actions[RS::SHADER_SPATIAL].renames["NORMAL"] = "normal";
|
||||
actions[RS::SHADER_SPATIAL].renames["TANGENT"] = "tangent";
|
||||
actions[RS::SHADER_SPATIAL].renames["BINORMAL"] = "binormal";
|
||||
actions[RS::SHADER_SPATIAL].renames["POSITION"] = "position";
|
||||
actions[RS::SHADER_SPATIAL].renames["UV"] = "uv_interp";
|
||||
actions[RS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp";
|
||||
actions[RS::SHADER_SPATIAL].renames["COLOR"] = "color_interp";
|
||||
actions[RS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size";
|
||||
// gl_InstanceID is not available in OpenGL ES 2.0
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0";
|
||||
actions[RS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0";
|
||||
|
||||
//builtins
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["TIME"] = "time";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
|
||||
actions[RS::SHADER_SPATIAL].renames["TIME"] = "time";
|
||||
actions[RS::SHADER_SPATIAL].renames["PI"] = _MKSTR(Math_PI);
|
||||
actions[RS::SHADER_SPATIAL].renames["TAU"] = _MKSTR(Math_TAU);
|
||||
actions[RS::SHADER_SPATIAL].renames["E"] = _MKSTR(Math_E);
|
||||
actions[RS::SHADER_SPATIAL].renames["VIEWPORT_SIZE"] = "viewport_size";
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["SPECULAR"] = "specular";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["RIM"] = "rim";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["AO"] = "ao";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_texture";
|
||||
actions[RS::SHADER_SPATIAL].renames["FRAGCOORD"] = "gl_FragCoord";
|
||||
actions[RS::SHADER_SPATIAL].renames["FRONT_FACING"] = "gl_FrontFacing";
|
||||
actions[RS::SHADER_SPATIAL].renames["NORMALMAP"] = "normalmap";
|
||||
actions[RS::SHADER_SPATIAL].renames["NORMALMAP_DEPTH"] = "normaldepth";
|
||||
actions[RS::SHADER_SPATIAL].renames["ALBEDO"] = "albedo";
|
||||
actions[RS::SHADER_SPATIAL].renames["ALPHA"] = "alpha";
|
||||
actions[RS::SHADER_SPATIAL].renames["METALLIC"] = "metallic";
|
||||
actions[RS::SHADER_SPATIAL].renames["SPECULAR"] = "specular";
|
||||
actions[RS::SHADER_SPATIAL].renames["ROUGHNESS"] = "roughness";
|
||||
actions[RS::SHADER_SPATIAL].renames["RIM"] = "rim";
|
||||
actions[RS::SHADER_SPATIAL].renames["RIM_TINT"] = "rim_tint";
|
||||
actions[RS::SHADER_SPATIAL].renames["CLEARCOAT"] = "clearcoat";
|
||||
actions[RS::SHADER_SPATIAL].renames["CLEARCOAT_GLOSS"] = "clearcoat_gloss";
|
||||
actions[RS::SHADER_SPATIAL].renames["ANISOTROPY"] = "anisotropy";
|
||||
actions[RS::SHADER_SPATIAL].renames["ANISOTROPY_FLOW"] = "anisotropy_flow";
|
||||
actions[RS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
|
||||
actions[RS::SHADER_SPATIAL].renames["TRANSMISSION"] = "transmission";
|
||||
actions[RS::SHADER_SPATIAL].renames["AO"] = "ao";
|
||||
actions[RS::SHADER_SPATIAL].renames["AO_LIGHT_AFFECT"] = "ao_light_affect";
|
||||
actions[RS::SHADER_SPATIAL].renames["EMISSION"] = "emission";
|
||||
actions[RS::SHADER_SPATIAL].renames["POINT_COORD"] = "gl_PointCoord";
|
||||
actions[RS::SHADER_SPATIAL].renames["INSTANCE_CUSTOM"] = "instance_custom";
|
||||
actions[RS::SHADER_SPATIAL].renames["SCREEN_UV"] = "screen_uv";
|
||||
actions[RS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
|
||||
actions[RS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_texture";
|
||||
// Defined in GLES3, but not available in GLES2
|
||||
//actions[GD_VS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
|
||||
//actions[RS::SHADER_SPATIAL].renames["DEPTH"] = "gl_FragDepth";
|
||||
actions[RS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
|
||||
actions[RS::SHADER_SPATIAL].renames["OUTPUT_IS_SRGB"] = "SHADER_IS_SRGB";
|
||||
|
||||
//for light
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["VIEW"] = "view";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["LIGHT"] = "light";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light";
|
||||
actions[GD_VS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light";
|
||||
actions[RS::SHADER_SPATIAL].renames["VIEW"] = "view";
|
||||
actions[RS::SHADER_SPATIAL].renames["LIGHT_COLOR"] = "light_color";
|
||||
actions[RS::SHADER_SPATIAL].renames["LIGHT"] = "light";
|
||||
actions[RS::SHADER_SPATIAL].renames["ATTENUATION"] = "attenuation";
|
||||
actions[RS::SHADER_SPATIAL].renames["DIFFUSE_LIGHT"] = "diffuse_light";
|
||||
actions[RS::SHADER_SPATIAL].renames["SPECULAR_LIGHT"] = "specular_light";
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["RIM"] = "#define LIGHT_USE_RIM\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["RIM_TINT"] = "@RIM";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT"] = "#define LIGHT_USE_CLEARCOAT\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["CLEARCOAT_GLOSS"] = "@CLEARCOAT";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY"] = "#define LIGHT_USE_ANISOTROPY\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["ANISOTROPY_FLOW"] = "@ANISOTROPY";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["AO"] = "#define ENABLE_AO\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["AO_LIGHT_AFFECT"] = "#define ENABLE_AO\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["UV"] = "#define ENABLE_UV_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["UV2"] = "#define ENABLE_UV2_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP"] = "#define ENABLE_NORMALMAP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["POSITION"] = "#define OVERRIDE_POSITION\n";
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["DEPTH_TEXTURE"] = "#define DEPTH_TEXTURE_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["TRANSMISSION"] = "#define TRANSMISSION_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["DEPTH_TEXTURE"] = "#define DEPTH_TEXTURE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
|
||||
|
||||
// Ported from GLES3
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["sinh"] = "#define SINH_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["cosh"] = "#define COSH_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["tanh"] = "#define TANH_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["asinh"] = "#define ASINH_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["acosh"] = "#define ACOSH_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["atanh"] = "#define ATANH_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["sinh"] = "#define SINH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["cosh"] = "#define COSH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["tanh"] = "#define TANH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["asinh"] = "#define ASINH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["acosh"] = "#define ACOSH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["atanh"] = "#define ATANH_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["determinant"] = "#define DETERMINANT_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["transpose"] = "#define TRANSPOSE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n";
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["world_vertex_coords"] = "#define VERTEX_WORLD_COORDS_USED\n";
|
||||
|
||||
// Defined in GLES3, could be implemented in GLES2 too if there's a need for it
|
||||
//actions[GD_VS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
|
||||
//actions[RS::SHADER_SPATIAL].render_mode_defines["ensure_correct_normals"] = "#define ENSURE_CORRECT_NORMALS\n";
|
||||
// Defined in GLES3, might not be possible in GLES2 as gl_FrontFacing is not available
|
||||
//actions[GD_VS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
|
||||
//actions[GD_VS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
|
||||
//actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
|
||||
//actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
|
||||
|
||||
bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley");
|
||||
|
||||
if (!force_lambert) {
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
|
||||
}
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
|
||||
|
||||
bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx");
|
||||
|
||||
if (!force_blinn) {
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n";
|
||||
} else {
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_BLINN\n";
|
||||
}
|
||||
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n";
|
||||
actions[GD_VS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n";
|
||||
actions[RS::SHADER_SPATIAL].render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n";
|
||||
|
||||
// No defines for particle shaders in GLES2, there are no GPU particles
|
||||
// No defines for particle shaders in OpenGL, there are no GPU particles
|
||||
|
||||
vertex_name = "vertex";
|
||||
fragment_name = "fragment";
|
||||
@ -1122,4 +1117,4 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
@ -1,5 +1,5 @@
|
||||
/*************************************************************************/
|
||||
/* shader_compiler_gles2.h */
|
||||
/* shader_compiler_opengl.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
@ -28,27 +28,19 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef SHADER_COMPILER_OPENGL_H
|
||||
#define SHADER_COMPILER_OPENGL_H
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "drivers/gles_common/rasterizer_version.h"
|
||||
#ifdef GODOT_3
|
||||
#include "core/pair.h"
|
||||
#include "core/string_builder.h"
|
||||
#include "servers/visual/shader_language.h"
|
||||
#include "servers/visual/shader_types.h"
|
||||
#include "servers/visual_server.h"
|
||||
#else
|
||||
#include "core/string/string_builder.h"
|
||||
#include "core/templates/pair.h"
|
||||
#include "servers/rendering/shader_language.h"
|
||||
#include "servers/rendering/shader_types.h"
|
||||
#include "servers/rendering_server.h"
|
||||
#endif
|
||||
|
||||
class ShaderCompilerGLES2 {
|
||||
class ShaderCompilerOpenGL {
|
||||
public:
|
||||
struct IdentifierActions {
|
||||
Map<StringName, Pair<int *, int>> render_mode_values;
|
||||
@ -98,15 +90,17 @@ private:
|
||||
Set<StringName> used_rmode_defines;
|
||||
Set<StringName> internal_functions;
|
||||
|
||||
DefaultIdentifierActions actions[GD_VS::SHADER_MAX];
|
||||
DefaultIdentifierActions actions[RS::SHADER_MAX];
|
||||
|
||||
// compatibility with godot 4
|
||||
static ShaderLanguage::DataType _get_variable_type(const StringName &p_type);
|
||||
|
||||
public:
|
||||
Error compile(GD_VS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code);
|
||||
Error compile(RS::ShaderMode p_mode, const String &p_code, IdentifierActions *p_actions, const String &p_path, GeneratedCode &r_gen_code);
|
||||
|
||||
ShaderCompilerGLES2();
|
||||
ShaderCompilerOpenGL();
|
||||
};
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
||||
|
||||
#endif // SHADER_COMPILER_OPENGL_H
|
@ -1,12 +1,12 @@
|
||||
/*************************************************************************/
|
||||
/* shader_gles2.cpp */
|
||||
/* shader_opengl.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -28,23 +28,17 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "shader_gles2.h"
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "shader_opengl.h"
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "core/os/memory.h"
|
||||
#include "rasterizer_gles2.h"
|
||||
#include "rasterizer_storage_gles2.h"
|
||||
#include "rasterizer_opengl.h"
|
||||
#include "rasterizer_storage_opengl.h"
|
||||
|
||||
#ifdef GODOT_3
|
||||
#include "core/print_string.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "core/string_builder.h"
|
||||
#else
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "core/string/print_string.h"
|
||||
#include "core/string/string_builder.h"
|
||||
#endif
|
||||
|
||||
// #define DEBUG_OPENGL
|
||||
|
||||
@ -65,7 +59,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
ShaderGLES2 *ShaderGLES2::active = NULL;
|
||||
ShaderOpenGL *ShaderOpenGL::active = NULL;
|
||||
|
||||
//#define DEBUG_SHADER
|
||||
|
||||
@ -79,15 +73,13 @@ ShaderGLES2 *ShaderGLES2::active = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
GLint ShaderGLES2::get_uniform_location(int p_index) const {
|
||||
GLint ShaderOpenGL::get_uniform_location(int p_index) const {
|
||||
ERR_FAIL_COND_V(!version, -1);
|
||||
|
||||
return version->uniform_location[p_index];
|
||||
}
|
||||
|
||||
//#ifdef GODOT_3
|
||||
|
||||
bool ShaderGLES2::bind() {
|
||||
bool ShaderOpenGL::bind() {
|
||||
if (active != this || !version || new_conditional_version.key != conditional_version.key) {
|
||||
conditional_version = new_conditional_version;
|
||||
version = get_current_version();
|
||||
@ -112,7 +104,7 @@ bool ShaderGLES2::bind() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShaderGLES2::unbind() {
|
||||
void ShaderOpenGL::unbind() {
|
||||
version = NULL;
|
||||
glUseProgram(0);
|
||||
uniforms_dirty = true;
|
||||
@ -142,7 +134,7 @@ static String _mkid(const String &p_id) {
|
||||
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
|
||||
}
|
||||
|
||||
ShaderGLES2::Version *ShaderGLES2::get_current_version() {
|
||||
ShaderOpenGL::Version *ShaderOpenGL::get_current_version() {
|
||||
if (!valid)
|
||||
return nullptr;
|
||||
|
||||
@ -201,8 +193,8 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() {
|
||||
strings.push_back("#define USE_HIGHP_PRECISION\n");
|
||||
#endif
|
||||
|
||||
if (GLOBAL_GET("rendering/gles2/compatibility/enable_high_float.Android")) {
|
||||
// enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in GLES2
|
||||
if (GLOBAL_GET("rendering/opengl/compatibility/enable_high_float.Android")) {
|
||||
// enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in OpenGL
|
||||
// see Section 4.5.4 of the GLSL_ES_Specification_1.00
|
||||
strings.push_back("#ifdef GL_FRAGMENT_PRECISION_HIGH\n #define USE_HIGHP_PRECISION\n#endif\n");
|
||||
}
|
||||
@ -492,12 +484,12 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() {
|
||||
return &v;
|
||||
}
|
||||
|
||||
GLint ShaderGLES2::get_uniform_location(const String &p_name) const {
|
||||
GLint ShaderOpenGL::get_uniform_location(const String &p_name) const {
|
||||
ERR_FAIL_COND_V(!version, -1);
|
||||
return glGetUniformLocation(version->id, p_name.ascii().get_data());
|
||||
}
|
||||
|
||||
void ShaderGLES2::setup(
|
||||
void ShaderOpenGL::setup(
|
||||
const char **p_conditional_defines,
|
||||
int p_conditional_count,
|
||||
const char **p_uniform_names,
|
||||
@ -587,7 +579,7 @@ void ShaderGLES2::setup(
|
||||
valid = true;
|
||||
}
|
||||
|
||||
void ShaderGLES2::finish() {
|
||||
void ShaderOpenGL::finish() {
|
||||
const VersionKey *V = NULL;
|
||||
|
||||
while ((V = version_map.next(V))) {
|
||||
@ -601,7 +593,7 @@ void ShaderGLES2::finish() {
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderGLES2::clear_caches() {
|
||||
void ShaderOpenGL::clear_caches() {
|
||||
const VersionKey *V = NULL;
|
||||
|
||||
while ((V = version_map.next(V))) {
|
||||
@ -620,13 +612,13 @@ void ShaderGLES2::clear_caches() {
|
||||
uniforms_dirty = true;
|
||||
}
|
||||
|
||||
uint32_t ShaderGLES2::create_custom_shader() {
|
||||
uint32_t ShaderOpenGL::create_custom_shader() {
|
||||
custom_code_map[last_custom_code] = CustomCode();
|
||||
custom_code_map[last_custom_code].version = 1;
|
||||
return last_custom_code++;
|
||||
}
|
||||
|
||||
void ShaderGLES2::set_custom_shader_code(uint32_t p_code_id,
|
||||
void ShaderOpenGL::set_custom_shader_code(uint32_t p_code_id,
|
||||
const String &p_vertex,
|
||||
const String &p_vertex_globals,
|
||||
const String &p_fragment,
|
||||
@ -649,11 +641,11 @@ void ShaderGLES2::set_custom_shader_code(uint32_t p_code_id,
|
||||
cc->version++;
|
||||
}
|
||||
|
||||
void ShaderGLES2::set_custom_shader(uint32_t p_code_id) {
|
||||
void ShaderOpenGL::set_custom_shader(uint32_t p_code_id) {
|
||||
new_conditional_version.code_version = p_code_id;
|
||||
}
|
||||
|
||||
void ShaderGLES2::free_custom_shader(uint32_t p_code_id) {
|
||||
void ShaderOpenGL::free_custom_shader(uint32_t p_code_id) {
|
||||
ERR_FAIL_COND(!custom_code_map.has(p_code_id));
|
||||
if (conditional_version.code_version == p_code_id) {
|
||||
conditional_version.code_version = 0; //do not keep using a version that is going away
|
||||
@ -679,8 +671,8 @@ void ShaderGLES2::free_custom_shader(uint32_t p_code_id) {
|
||||
custom_code_map.erase(p_code_id);
|
||||
}
|
||||
|
||||
void ShaderGLES2::use_material(void *p_material) {
|
||||
RasterizerStorageGLES2::Material *material = (RasterizerStorageGLES2::Material *)p_material;
|
||||
void ShaderOpenGL::use_material(void *p_material) {
|
||||
RasterizerStorageOpenGL::Material *material = (RasterizerStorageOpenGL::Material *)p_material;
|
||||
|
||||
if (!material) {
|
||||
return;
|
||||
@ -989,7 +981,7 @@ void ShaderGLES2::use_material(void *p_material) {
|
||||
case ShaderLanguage::TYPE_SAMPLER3D:
|
||||
case ShaderLanguage::TYPE_ISAMPLER3D:
|
||||
case ShaderLanguage::TYPE_USAMPLER3D: {
|
||||
// Not implemented in GLES2
|
||||
// Not implemented in OpenGL
|
||||
} break;
|
||||
|
||||
case ShaderLanguage::TYPE_VOID: {
|
||||
@ -1109,7 +1101,7 @@ void ShaderGLES2::use_material(void *p_material) {
|
||||
case ShaderLanguage::TYPE_SAMPLER3D:
|
||||
case ShaderLanguage::TYPE_ISAMPLER3D:
|
||||
case ShaderLanguage::TYPE_USAMPLER3D: {
|
||||
// Not implemented in GLES2
|
||||
// Not implemented in OpenGL
|
||||
} break;
|
||||
|
||||
case ShaderLanguage::TYPE_VOID: {
|
||||
@ -1123,14 +1115,14 @@ void ShaderGLES2::use_material(void *p_material) {
|
||||
}
|
||||
}
|
||||
|
||||
ShaderGLES2::ShaderGLES2() {
|
||||
ShaderOpenGL::ShaderOpenGL() {
|
||||
version = NULL;
|
||||
last_custom_code = 1;
|
||||
uniforms_dirty = true;
|
||||
}
|
||||
|
||||
ShaderGLES2::~ShaderGLES2() {
|
||||
ShaderOpenGL::~ShaderOpenGL() {
|
||||
finish();
|
||||
}
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
@ -1,5 +1,5 @@
|
||||
/*************************************************************************/
|
||||
/* shader_gles2.h */
|
||||
/* shader_opengl.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
@ -28,40 +28,32 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef SHADER_OPENGL_H
|
||||
#define SHADER_OPENGL_H
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
// This must come first to avoid windows.h mess
|
||||
#include "platform_config.h"
|
||||
#ifndef GLES2_INCLUDE_H
|
||||
#include <GLES2/gl2.h>
|
||||
#ifndef OPENGL_INCLUDE_H
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include GLES2_INCLUDE_H
|
||||
#include OPENGL_INCLUDE_H
|
||||
#endif
|
||||
|
||||
#include "core/math/camera_matrix.h"
|
||||
#ifdef GODOT_3
|
||||
#include "core/hash_map.h"
|
||||
#include "core/map.h"
|
||||
#include "core/pair.h"
|
||||
#include "core/variant.h"
|
||||
#include "servers/visual/shader_language.h"
|
||||
#else
|
||||
#include "core/templates/hash_map.h"
|
||||
#include "core/templates/map.h"
|
||||
#include "core/templates/pair.h"
|
||||
#include "core/variant/variant.h"
|
||||
#include "servers/rendering/shader_language.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class RasterizerStorageGLES2;
|
||||
//#ifdef GODOT_3
|
||||
class RasterizerStorageOpenGL;
|
||||
|
||||
class ShaderGLES2 {
|
||||
class ShaderOpenGL {
|
||||
protected:
|
||||
struct Enum {
|
||||
uint64_t mask;
|
||||
@ -180,7 +172,7 @@ private:
|
||||
|
||||
Version *get_current_version();
|
||||
|
||||
static ShaderGLES2 *active;
|
||||
static ShaderOpenGL *active;
|
||||
|
||||
int max_image_units;
|
||||
|
||||
@ -203,7 +195,7 @@ protected:
|
||||
int p_vertex_code_start,
|
||||
int p_fragment_code_start);
|
||||
|
||||
ShaderGLES2();
|
||||
ShaderOpenGL();
|
||||
|
||||
public:
|
||||
enum {
|
||||
@ -213,7 +205,7 @@ public:
|
||||
GLint get_uniform_location(const String &p_name) const;
|
||||
GLint get_uniform_location(int p_index) const;
|
||||
|
||||
static _FORCE_INLINE_ ShaderGLES2 *get_active() { return active; }
|
||||
static _FORCE_INLINE_ ShaderOpenGL *get_active() { return active; }
|
||||
bool bind();
|
||||
void unbind();
|
||||
|
||||
@ -237,7 +229,7 @@ public:
|
||||
|
||||
uint32_t get_version_key() const { return conditional_version.version; }
|
||||
|
||||
// this void* is actually a RasterizerStorageGLES2::Material, but C++ doesn't
|
||||
// this void* is actually a RasterizerStorageOpenGL::Material, but C++ doesn't
|
||||
// like forward declared nested classes.
|
||||
void use_material(void *p_material);
|
||||
|
||||
@ -261,18 +253,18 @@ public:
|
||||
custom_defines.erase(p_define.utf8());
|
||||
}
|
||||
|
||||
virtual ~ShaderGLES2();
|
||||
virtual ~ShaderOpenGL();
|
||||
};
|
||||
|
||||
// called a lot, made inline
|
||||
|
||||
int ShaderGLES2::_get_uniform(int p_which) const {
|
||||
int ShaderOpenGL::_get_uniform(int p_which) const {
|
||||
ERR_FAIL_INDEX_V(p_which, uniform_count, -1);
|
||||
ERR_FAIL_COND_V(!version, -1);
|
||||
return version->uniform_location[p_which];
|
||||
}
|
||||
|
||||
void ShaderGLES2::_set_conditional(int p_which, bool p_value) {
|
||||
void ShaderOpenGL::_set_conditional(int p_which, bool p_value) {
|
||||
ERR_FAIL_INDEX(p_which, conditional_count);
|
||||
if (p_value)
|
||||
new_conditional_version.version |= (1 << p_which);
|
||||
@ -280,4 +272,6 @@ void ShaderGLES2::_set_conditional(int p_which, bool p_value) {
|
||||
new_conditional_version.version &= ~(1 << p_which);
|
||||
}
|
||||
|
||||
#endif // GLES2_BACKEND_ENABLED
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
||||
|
||||
#endif // SHADER_OPENGL_H
|
14
drivers/opengl/shaders/SCsub
Normal file
14
drivers/opengl/shaders/SCsub
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
|
||||
if "OpenGL_GLSL" in env["BUILDERS"]:
|
||||
env.OpenGL_GLSL("copy.glsl")
|
||||
env.OpenGL_GLSL("canvas.glsl")
|
||||
env.OpenGL_GLSL("canvas_shadow.glsl")
|
||||
env.OpenGL_GLSL("scene.glsl")
|
||||
env.OpenGL_GLSL("cubemap_filter.glsl")
|
||||
env.OpenGL_GLSL("cube_to_dp.glsl")
|
||||
env.OpenGL_GLSL("effect_blur.glsl")
|
||||
env.OpenGL_GLSL("tonemap.glsl")
|
||||
env.OpenGL_GLSL("lens_distorted.glsl")
|
@ -1,12 +1,12 @@
|
||||
/*************************************************************************/
|
||||
/* texture_loader_gles2.cpp */
|
||||
/* texture_loader_opengl.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@ -28,15 +28,15 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "texture_loader_gles2.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "texture_loader_opengl.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/string/print_string.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
RES ResourceFormatGLES2Texture::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
|
||||
RES ResourceFormatGLES2Texture::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
|
||||
unsigned int width = 8;
|
||||
unsigned int height = 8;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*************************************************************************/
|
||||
/* texture_loader_gles2.h */
|
||||
/* texture_loader_opengl.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
@ -28,17 +28,18 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef TEXTURE_LOADER_OPENGL_H
|
||||
#define TEXTURE_LOADER_OPENGL_H
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#ifdef GLES2_BACKEND_ENABLED
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
#ifdef OPENGL_BACKEND_ENABLED
|
||||
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
class ResourceFormatGLES2Texture : public ResourceFormatLoader {
|
||||
public:
|
||||
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
|
||||
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE);
|
||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||
virtual bool handles_type(const String &p_type) const;
|
||||
virtual String get_resource_type(const String &p_path) const;
|
||||
@ -46,4 +47,6 @@ public:
|
||||
virtual ~ResourceFormatGLES2Texture() {}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // OPENGL_BACKEND_ENABLED
|
||||
|
||||
#endif // TEXTURE_LOADER_OPENGL_H
|
@ -1491,15 +1491,15 @@ void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, in
|
||||
}
|
||||
|
||||
String EditorExportPlatform::test_etc2() const {
|
||||
// String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
// bool etc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc");
|
||||
// bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
|
||||
// String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
// bool etc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc");
|
||||
// bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
|
||||
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
bool etc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc");
|
||||
bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
|
||||
|
||||
if (driver == "GLES2" && !etc_supported) {
|
||||
return TTR("Target platform requires 'ETC' texture compression for GLES2. Enable 'Import Etc' in Project Settings.");
|
||||
if (driver == "OpenGL" && !etc_supported) {
|
||||
return TTR("Target platform requires 'ETC' texture compression for OpenGL. Enable 'Import Etc' in Project Settings.");
|
||||
} else if (driver == "Vulkan" && !etc2_supported) {
|
||||
// FIXME: Review if this is true for Vulkan.
|
||||
return TTR("Target platform requires 'ETC2' texture compression for Vulkan. Enable 'Import Etc 2' in Project Settings.");
|
||||
@ -1511,12 +1511,12 @@ String EditorExportPlatform::test_etc2_or_pvrtc() const {
|
||||
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
|
||||
bool pvrtc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_pvrtc");
|
||||
// String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
// bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
|
||||
// bool pvrtc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_pvrtc");
|
||||
// String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
// bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2");
|
||||
// bool pvrtc_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_pvrtc");
|
||||
|
||||
if (driver == "GLES2" && !pvrtc_supported) {
|
||||
return TTR("Target platform requires 'PVRTC' texture compression for GLES2. Enable 'Import Pvrtc' in Project Settings.");
|
||||
if (driver == "OpenGL" && !pvrtc_supported) {
|
||||
return TTR("Target platform requires 'PVRTC' texture compression for OpenGL. Enable 'Import Pvrtc' in Project Settings.");
|
||||
} else if (driver == "Vulkan" && !etc2_supported && !pvrtc_supported) {
|
||||
// FIXME: Review if this is true for Vulkan.
|
||||
return TTR("Target platform requires 'ETC2' or 'PVRTC' texture compression for Vulkan. Enable 'Import Etc 2' or 'Import Pvrtc' in Project Settings.");
|
||||
|
@ -5596,14 +5596,9 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) {
|
||||
}
|
||||
|
||||
void EditorNode::_update_rendering_driver_color() {
|
||||
// TODO: Probably should de-hardcode this and add to editor settings.
|
||||
// if (video_driver->get_text() == "GLES2") {
|
||||
// video_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff));
|
||||
// } else if (video_driver->get_text() == "Vulkan") {
|
||||
// video_driver->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor")));
|
||||
if (rendering_driver->get_text() == "GLES2") {
|
||||
if (rendering_driver->get_text() == "opengl") {
|
||||
rendering_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff));
|
||||
} else if (rendering_driver->get_text() == "Vulkan") {
|
||||
} else if (rendering_driver->get_text() == "vulkan") {
|
||||
rendering_driver->add_theme_color_override("font_color", theme_base->get_theme_color("vulkan_color", "Editor"));
|
||||
}
|
||||
}
|
||||
@ -6652,8 +6647,6 @@ EditorNode::EditorNode() {
|
||||
rendering_driver->add_theme_font_override("font", gui_base->get_theme_font("bold", "EditorFonts"));
|
||||
rendering_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size("bold_size", "EditorFonts"));
|
||||
|
||||
// TODO re-enable when GLES2 is ported
|
||||
// video_driver->set_disabled(true);
|
||||
right_menu_hb->add_child(rendering_driver);
|
||||
|
||||
// only display the render drivers that are available for this display driver
|
||||
|
@ -4376,7 +4376,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
|
||||
const int wireframe_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME);
|
||||
const int overdraw_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_OVERDRAW);
|
||||
const int shadeless_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_SHADELESS);
|
||||
const String unsupported_tooltip = TTR("Not available when using the GLES2 renderer.");
|
||||
const String unsupported_tooltip = TTR("Not available when using the OpenGL renderer.");
|
||||
|
||||
view_menu->get_popup()->set_item_disabled(normal_idx, true);
|
||||
view_menu->get_popup()->set_item_tooltip(normal_idx, unsupported_tooltip);
|
||||
|
@ -1246,7 +1246,7 @@ void VisualShaderEditor::_update_options_menu() {
|
||||
Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor"));
|
||||
Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor"));
|
||||
|
||||
static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "GLES2";
|
||||
static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "opengl";
|
||||
|
||||
Map<String, TreeItem *> folders;
|
||||
|
||||
|
@ -478,7 +478,7 @@ private:
|
||||
if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") {
|
||||
initial_settings["rendering/driver/driver_name"] = "Vulkan";
|
||||
} else {
|
||||
initial_settings["rendering/driver/driver_name"] = "GLES2";
|
||||
initial_settings["rendering/driver/driver_name"] = "OpenGL";
|
||||
initial_settings["rendering/textures/vram_compression/import_etc2"] = false;
|
||||
initial_settings["rendering/textures/vram_compression/import_etc"] = true;
|
||||
}
|
||||
|
@ -1275,14 +1275,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
register_core_extensions(); //before display
|
||||
// possibly be worth changing the default from vulkan to something lower spec,
|
||||
// for the project manager, depending on how smooth the fallback is.
|
||||
GLOBAL_DEF("rendering/driver/driver_name", "Vulkan");
|
||||
GLOBAL_DEF_RST("rendering/driver/driver_name", "Vulkan");
|
||||
|
||||
// this list is hard coded, which makes it more difficult to add new backends.
|
||||
// can potentially be changed to more of a plugin system at a later date.
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/driver/driver_name",
|
||||
PropertyInfo(Variant::STRING,
|
||||
"rendering/driver/driver_name",
|
||||
PROPERTY_HINT_ENUM, "Vulkan,GLES2,GLES3"));
|
||||
PROPERTY_HINT_ENUM, "Vulkan,OpenGL"));
|
||||
|
||||
// if not set on the command line
|
||||
if (rendering_driver == "") {
|
||||
@ -1294,10 +1294,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
// shows the correct driver string.
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
|
||||
// always convert to lower case vulkan for consistency in the code
|
||||
if (rendering_driver == "Vulkan") {
|
||||
rendering_driver = "vulkan";
|
||||
}
|
||||
// always convert to lower case for consistency in the code
|
||||
rendering_driver = rendering_driver.to_lower();
|
||||
|
||||
GLOBAL_DEF_BASIC("display/window/size/width", 1024);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/width",
|
||||
|
@ -203,7 +203,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
|
||||
format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
|
||||
imgfmt = Image::FORMAT_ETC2_RGBA8;
|
||||
} else {
|
||||
//gles2 most likely
|
||||
//opengl most likely
|
||||
format = basist::transcoder_texture_format::cTFRGBA4444; // get this from renderer
|
||||
imgfmt = Image::FORMAT_RGBA4444;
|
||||
}
|
||||
@ -216,7 +216,7 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
|
||||
format = basist::transcoder_texture_format::cTFETC2; // get this from renderer
|
||||
imgfmt = Image::FORMAT_ETC2_RGBA8;
|
||||
} else {
|
||||
//gles2 most likely, bad for normal maps, nothing to do about this.
|
||||
//opengl most likely, bad for normal maps, nothing to do about this.
|
||||
format = basist::transcoder_texture_format::cTFRGBA32;
|
||||
imgfmt = Image::FORMAT_RGBA8;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@
|
||||
uint8_t *w = img_data[1].ptrw();
|
||||
memcpy(w, dataCbCr, 2 * new_width * new_height);
|
||||
|
||||
///TODO GLES2 doesn't support FORMAT_RG8, need to do some form of conversion
|
||||
///TODO OpenGL doesn't support FORMAT_RG8, need to do some form of conversion
|
||||
img[1].instantiate();
|
||||
img[1]->create(new_width, new_height, 0, Image::FORMAT_RG8, img_data[1]);
|
||||
}
|
||||
|
@ -201,11 +201,11 @@ String str_format(const char *p_format, ...) {
|
||||
}
|
||||
|
||||
#if defined(MINGW_ENABLED)
|
||||
#define gd_vsnprintf(m_buffer, m_count, m_format, m_args_copy) vsnprintf_s(m_buffer, m_count, _TRUNCATE, m_format, m_args_copy)
|
||||
#define gd_vscprintf(m_format, m_args_copy) _vscprintf(m_format, m_args_copy)
|
||||
#define RSnprintf(m_buffer, m_count, m_format, m_args_copy) vsnprintf_s(m_buffer, m_count, _TRUNCATE, m_format, m_args_copy)
|
||||
#define RScprintf(m_format, m_args_copy) _vscprintf(m_format, m_args_copy)
|
||||
#else
|
||||
#define gd_vsnprintf(m_buffer, m_count, m_format, m_args_copy) vsnprintf(m_buffer, m_count, m_format, m_args_copy)
|
||||
#define gd_vscprintf(m_format, m_args_copy) vsnprintf(nullptr, 0, p_format, m_args_copy)
|
||||
#define RSnprintf(m_buffer, m_count, m_format, m_args_copy) vsnprintf(m_buffer, m_count, m_format, m_args_copy)
|
||||
#define RScprintf(m_format, m_args_copy) vsnprintf(nullptr, 0, p_format, m_args_copy)
|
||||
#endif
|
||||
|
||||
String str_format(const char *p_format, va_list p_list) {
|
||||
@ -231,7 +231,7 @@ char *str_format_new(const char *p_format, va_list p_list) {
|
||||
va_list list;
|
||||
|
||||
va_copy(list, p_list);
|
||||
int len = gd_vscprintf(p_format, list);
|
||||
int len = RScprintf(p_format, list);
|
||||
va_end(list);
|
||||
|
||||
len += 1; // for the trailing '/0'
|
||||
@ -239,7 +239,7 @@ char *str_format_new(const char *p_format, va_list p_list) {
|
||||
char *buffer(memnew_arr(char, len));
|
||||
|
||||
va_copy(list, p_list);
|
||||
gd_vsnprintf(buffer, len, p_format, list);
|
||||
RSnprintf(buffer, len, p_format, list);
|
||||
va_end(list);
|
||||
|
||||
return buffer;
|
||||
|
@ -187,7 +187,7 @@ def include_file_in_legacygl_header(filename, header_data, depth):
|
||||
return header_data
|
||||
|
||||
|
||||
def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2=False):
|
||||
def build_legacygl_header(filename, include, class_suffix, output_attribs):
|
||||
header_data = LegacyGLHeaderStruct()
|
||||
include_file_in_legacygl_header(filename, header_data, 0)
|
||||
|
||||
@ -286,9 +286,9 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
||||
)
|
||||
|
||||
fd.write(
|
||||
"""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU
|
||||
"""\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform3D& p_transform) { _FU
|
||||
|
||||
const Transform &tr = p_transform;
|
||||
const Transform3D &tr = p_transform;
|
||||
|
||||
GLfloat matrix[16]={ /* build a 16x16 matrix */
|
||||
tr.basis.elements[0][0],
|
||||
@ -449,26 +449,6 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
||||
|
||||
feedback_count = 0
|
||||
|
||||
if not gles2 and len(header_data.feedbacks):
|
||||
|
||||
fd.write("\t\tstatic const Feedback _feedbacks[]={\n")
|
||||
for x in header_data.feedbacks:
|
||||
name = x[0]
|
||||
cond = x[1]
|
||||
if cond in conditionals_found:
|
||||
fd.write('\t\t\t{"' + name + '",' + str(conditionals_found.index(cond)) + "},\n")
|
||||
else:
|
||||
fd.write('\t\t\t{"' + name + '",-1},\n')
|
||||
|
||||
feedback_count += 1
|
||||
|
||||
fd.write("\t\t};\n\n")
|
||||
else:
|
||||
if gles2:
|
||||
pass
|
||||
else:
|
||||
fd.write("\t\tstatic const Feedback* _feedbacks=NULL;\n")
|
||||
|
||||
if header_data.texunits:
|
||||
fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")
|
||||
for x in header_data.texunits:
|
||||
@ -477,17 +457,6 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
||||
else:
|
||||
fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n")
|
||||
|
||||
if not gles2 and header_data.ubos:
|
||||
fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n")
|
||||
for x in header_data.ubos:
|
||||
fd.write('\t\t\t{"' + x[0] + '",' + x[1] + "},\n")
|
||||
fd.write("\t\t};\n\n")
|
||||
else:
|
||||
if gles2:
|
||||
pass
|
||||
else:
|
||||
fd.write("\t\tstatic UBOPair *_ubo_pairs=NULL;\n")
|
||||
|
||||
fd.write("\t\tstatic const char _vertex_code[]={\n")
|
||||
for x in header_data.vertex_lines:
|
||||
for c in x:
|
||||
@ -509,67 +478,31 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
||||
fd.write("\t\tstatic const int _fragment_code_start=" + str(header_data.fragment_offset) + ";\n")
|
||||
|
||||
if output_attribs:
|
||||
if gles2:
|
||||
fd.write(
|
||||
"\t\tsetup(_conditional_strings,"
|
||||
+ str(len(header_data.conditionals))
|
||||
+ ",_uniform_strings,"
|
||||
+ str(len(header_data.uniforms))
|
||||
+ ",_attribute_pairs,"
|
||||
+ str(len(header_data.attributes))
|
||||
+ ", _texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
|
||||
)
|
||||
else:
|
||||
fd.write(
|
||||
"\t\tsetup(_conditional_strings,"
|
||||
+ str(len(header_data.conditionals))
|
||||
+ ",_uniform_strings,"
|
||||
+ str(len(header_data.uniforms))
|
||||
+ ",_attribute_pairs,"
|
||||
+ str(len(header_data.attributes))
|
||||
+ ", _texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ",_ubo_pairs,"
|
||||
+ str(len(header_data.ubos))
|
||||
+ ",_feedbacks,"
|
||||
+ str(feedback_count)
|
||||
+ ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
|
||||
)
|
||||
fd.write(
|
||||
"\t\tsetup(_conditional_strings,"
|
||||
+ str(len(header_data.conditionals))
|
||||
+ ",_uniform_strings,"
|
||||
+ str(len(header_data.uniforms))
|
||||
+ ",_attribute_pairs,"
|
||||
+ str(len(header_data.attributes))
|
||||
+ ", _texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
|
||||
)
|
||||
else:
|
||||
if gles2:
|
||||
fd.write(
|
||||
"\t\tsetup(_conditional_strings,"
|
||||
+ str(len(header_data.conditionals))
|
||||
+ ",_uniform_strings,"
|
||||
+ str(len(header_data.uniforms))
|
||||
+ ",_texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ",_enums,"
|
||||
+ str(len(header_data.enums))
|
||||
+ ",_enum_values,"
|
||||
+ str(enum_value_count)
|
||||
+ ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
|
||||
)
|
||||
else:
|
||||
fd.write(
|
||||
"\t\tsetup(_conditional_strings,"
|
||||
+ str(len(header_data.conditionals))
|
||||
+ ",_uniform_strings,"
|
||||
+ str(len(header_data.uniforms))
|
||||
+ ",_texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ",_enums,"
|
||||
+ str(len(header_data.enums))
|
||||
+ ",_enum_values,"
|
||||
+ str(enum_value_count)
|
||||
+ ",_ubo_pairs,"
|
||||
+ str(len(header_data.ubos))
|
||||
+ ",_feedbacks,"
|
||||
+ str(feedback_count)
|
||||
+ ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
|
||||
)
|
||||
fd.write(
|
||||
"\t\tsetup(_conditional_strings,"
|
||||
+ str(len(header_data.conditionals))
|
||||
+ ",_uniform_strings,"
|
||||
+ str(len(header_data.uniforms))
|
||||
+ ",_texunit_pairs,"
|
||||
+ str(len(header_data.texunits))
|
||||
+ ",_enums,"
|
||||
+ str(len(header_data.enums))
|
||||
+ ",_enum_values,"
|
||||
+ str(enum_value_count)
|
||||
+ ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
|
||||
)
|
||||
|
||||
fd.write("\t}\n\n")
|
||||
|
||||
@ -586,15 +519,10 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
||||
fd.close()
|
||||
|
||||
|
||||
def build_gles3_headers(target, source, env):
|
||||
for x in source:
|
||||
build_legacygl_header(str(x), include="drivers/gles3/shader_gles3.h", class_suffix="GLES3", output_attribs=True)
|
||||
|
||||
|
||||
def build_gles2_headers(target, source, env):
|
||||
def build_opengl_headers(target, source, env):
|
||||
for x in source:
|
||||
build_legacygl_header(
|
||||
str(x), include="drivers/gles2/shader_gles2.h", class_suffix="GLES2", output_attribs=True, gles2=True
|
||||
str(x), include="drivers/opengl/shader_opengl.h", class_suffix="OpenGL", output_attribs=True
|
||||
)
|
||||
|
||||
|
@ -411,9 +411,9 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
|
||||
if (rendering_driver == "opengl") {
|
||||
bool gl_initialization_error = false;
|
||||
|
||||
if (RasterizerGLES2::is_viable() == OK) {
|
||||
RasterizerGLES2::register_config();
|
||||
RasterizerGLES2::make_current();
|
||||
if (RasterizerOpenGLis_viable() == OK) {
|
||||
RasterizerOpenGLregister_config();
|
||||
RasterizerOpenGLmake_current();
|
||||
} else {
|
||||
gl_initialization_error = true;
|
||||
}
|
||||
|
@ -1599,7 +1599,7 @@
|
||||
//public:
|
||||
// virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override {
|
||||
// String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
// if (driver == "GLES2") {
|
||||
// if (driver == "OpenGL") {
|
||||
// r_features->push_back("etc");
|
||||
// }
|
||||
// // FIXME: Review what texture formats are used for Vulkan.
|
||||
@ -1769,10 +1769,10 @@
|
||||
|
||||
// String tmp_export_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport.apk");
|
||||
|
||||
//#define CLEANUP_AND_RETURN(m_err) \
|
||||
// { \
|
||||
// DirAccess::remove_file_or_error(tmp_export_path); \
|
||||
// return m_err; \
|
||||
//#define CLEANUP_AND_RETURN(m_err)
|
||||
// {
|
||||
// DirAccess::remove_file_or_error(tmp_export_path);
|
||||
// return m_err;
|
||||
// }
|
||||
|
||||
// // Export to temporary APK before sending to device.
|
||||
@ -2565,10 +2565,10 @@
|
||||
|
||||
// String tmp_unaligned_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport-unaligned.apk");
|
||||
|
||||
//#define CLEANUP_AND_RETURN(m_err) \
|
||||
// { \
|
||||
// DirAccess::remove_file_or_error(tmp_unaligned_path); \
|
||||
// return m_err; \
|
||||
//#define CLEANUP_AND_RETURN(m_err)
|
||||
// {
|
||||
// DirAccess::remove_file_or_error(tmp_unaligned_path);
|
||||
// return m_err;
|
||||
// }
|
||||
|
||||
// zipFile unaligned_apk = zipOpen2(tmp_unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2);
|
||||
|
@ -1612,7 +1612,7 @@ Vector<String> EditorExportPlatformAndroid::get_enabled_abis(const Ref<EditorExp
|
||||
|
||||
void EditorExportPlatformAndroid::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
|
||||
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
if (driver == "GLES2") {
|
||||
if (driver == "OpenGL") {
|
||||
r_features->push_back("etc");
|
||||
}
|
||||
// FIXME: Review what texture formats are used for Vulkan.
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
@class ViewController;
|
||||
|
||||
// FIXME: Add support for both GLES2 and Vulkan when GLES2 is implemented again,
|
||||
// FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented again,
|
||||
// so it can't be done with compilation time branching.
|
||||
//#if defined(OPENGL_ENABLED)
|
||||
//@interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> {
|
||||
|
@ -89,7 +89,7 @@
|
||||
// FIXME: Add Vulkan support via MoltenVK. Add fallback code back?
|
||||
|
||||
// Create GL ES 2 context
|
||||
if (GLOBAL_GET("rendering/driver/driver_name") == "GLES2") {
|
||||
if (GLOBAL_GET("rendering/driver/driver_name") == "opengl") {
|
||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
NSLog(@"Setting up an OpenGL ES 2.0 context.");
|
||||
if (!context) {
|
||||
|
@ -52,7 +52,7 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
|
||||
rendering_driver = p_rendering_driver;
|
||||
|
||||
#if defined(OPENGL_ENABLED)
|
||||
// FIXME: Add support for both GLES2 and Vulkan when GLES2 is implemented
|
||||
// FIXME: Add support for both OpenGL and Vulkan when OpenGL is implemented
|
||||
// again,
|
||||
|
||||
if (rendering_driver == "opengl_es") {
|
||||
@ -60,9 +60,9 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
|
||||
|
||||
// FIXME: Add Vulkan support via MoltenVK. Add fallback code back?
|
||||
|
||||
if (RasterizerGLES2::is_viable() == OK) {
|
||||
RasterizerGLES2::register_config();
|
||||
RasterizerGLES2::make_current();
|
||||
if (RasterizerOpenGLis_viable() == OK) {
|
||||
RasterizerOpenGLregister_config();
|
||||
RasterizerOpenGLmake_current();
|
||||
} else {
|
||||
gl_initialization_error = true;
|
||||
}
|
||||
@ -83,7 +83,7 @@ DisplayServerIPhone::DisplayServerIPhone(const String &p_rendering_driver, Windo
|
||||
|
||||
// reset this to what it should be, it will have been set to 0 after
|
||||
// rendering_server->init() is called
|
||||
// RasterizerStorageGLES2::system_fbo = gl_view_base_fb;
|
||||
// RasterizerStorageOpenGLsystem_fbo = gl_view_base_fb;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -30,8 +30,7 @@
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
#define GLES2_INCLUDE_H <ES2/gl.h>
|
||||
#define GLES3_INCLUDE_H <ES3/gl.h>
|
||||
#define OPENGL_INCLUDE_H <ES3/gl.h>
|
||||
|
||||
#define PLATFORM_REFCOUNT
|
||||
|
||||
|
@ -677,7 +677,7 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
|
||||
// Expose method for requesting quit.
|
||||
godot_js_os_request_quit_cb(request_quit_callback);
|
||||
|
||||
RasterizerDummy::make_current(); // TODO GLES2 in Godot 4.0... or webgpu?
|
||||
RasterizerDummy::make_current(); // TODO OpenGL in Godot 4.0... or webgpu?
|
||||
#if 0
|
||||
EmscriptenWebGLContextAttributes attributes;
|
||||
emscripten_webgl_init_context_attributes(&attributes);
|
||||
@ -691,10 +691,10 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
|
||||
|
||||
bool gl_initialization_error = false;
|
||||
|
||||
if (RasterizerGLES2::is_viable() == OK) {
|
||||
if (RasterizerOpenGLis_viable() == OK) {
|
||||
attributes.majorVersion = 1;
|
||||
RasterizerGLES2::register_config();
|
||||
RasterizerGLES2::make_current();
|
||||
RasterizerOpenGLregister_config();
|
||||
RasterizerOpenGLmake_current();
|
||||
} else {
|
||||
gl_initialization_error = true;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
|
||||
|
||||
if (p_preset->get("vram_texture_compression/for_mobile")) {
|
||||
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
if (driver == "GLES2") {
|
||||
if (driver == "OpenGL") {
|
||||
r_features->push_back("etc");
|
||||
} else if (driver == "Vulkan") {
|
||||
// FIXME: Review if this is correct.
|
||||
|
@ -300,7 +300,7 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
|
||||
|
||||
if (p_preset->get("vram_texture_compression/for_mobile")) {
|
||||
String driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name");
|
||||
if (driver == "GLES2") {
|
||||
if (driver == "OpenGL") {
|
||||
r_features->push_back("etc");
|
||||
} else if (driver == "Vulkan") {
|
||||
// FIXME: Review if this is correct.
|
||||
|
@ -20,8 +20,6 @@ if "x11" in env and env["x11"]:
|
||||
"key_mapping_x11.cpp",
|
||||
]
|
||||
|
||||
#"context_gl_x11.cpp",
|
||||
|
||||
if "vulkan" in env and env["vulkan"]:
|
||||
common_linuxbsd.append("vulkan_context_x11.cpp")
|
||||
|
||||
|
@ -44,8 +44,8 @@
|
||||
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
|
||||
#endif
|
||||
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#if defined(OPENGL_ENABLED)
|
||||
#include "drivers/opengl/rasterizer_opengl.h"
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
@ -889,7 +889,7 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) {
|
||||
context_vulkan->window_destroy(p_id);
|
||||
}
|
||||
#endif
|
||||
#ifdef GLES_X11_ENABLED
|
||||
#ifdef OPENGL_ENABLED
|
||||
if (gl_manager) {
|
||||
gl_manager->window_destroy(p_id);
|
||||
}
|
||||
@ -1064,7 +1064,7 @@ int DisplayServerX11::window_get_current_screen(WindowID p_window) const {
|
||||
}
|
||||
|
||||
void DisplayServerX11::gl_window_make_current(DisplayServer::WindowID p_window_id) {
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
if (gl_manager)
|
||||
gl_manager->window_make_current(p_window_id);
|
||||
#endif
|
||||
@ -2666,7 +2666,7 @@ void DisplayServerX11::_window_changed(XEvent *event) {
|
||||
context_vulkan->window_resize(window_id, wd.size.width, wd.size.height);
|
||||
}
|
||||
#endif
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
if (gl_manager) {
|
||||
gl_manager->window_resize(window_id, wd.size.width, wd.size.height);
|
||||
}
|
||||
@ -3547,19 +3547,19 @@ void DisplayServerX11::process_events() {
|
||||
}
|
||||
|
||||
void DisplayServerX11::release_rendering_thread() {
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
// gl_manager->release_current();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DisplayServerX11::make_rendering_thread() {
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
// gl_manager->make_current();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DisplayServerX11::swap_buffers() {
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
if (gl_manager) {
|
||||
gl_manager->swap_buffers();
|
||||
}
|
||||
@ -3710,7 +3710,7 @@ void DisplayServerX11::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mo
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
if (gl_manager) {
|
||||
gl_manager->set_use_vsync(p_vsync_mode == DisplayServer::VSYNC_ENABLED);
|
||||
}
|
||||
@ -3724,7 +3724,7 @@ DisplayServer::VSyncMode DisplayServerX11::window_get_vsync_mode(WindowID p_wind
|
||||
return context_vulkan->get_vsync_mode(p_window);
|
||||
}
|
||||
#endif
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
if (gl_manager) {
|
||||
return gl_manager->is_using_vsync() ? DisplayServer::VSYNC_ENABLED : DisplayServer::VSYNC_DISABLED;
|
||||
}
|
||||
@ -3738,10 +3738,8 @@ Vector<String> DisplayServerX11::get_rendering_drivers_func() {
|
||||
#ifdef VULKAN_ENABLED
|
||||
drivers.push_back("vulkan");
|
||||
#endif
|
||||
#ifdef GLES_X11_ENABLED
|
||||
// drivers.push_back("opengl");
|
||||
drivers.push_back("GLES2");
|
||||
drivers.push_back("GLES3");
|
||||
#ifdef OPENGL_ENABLED
|
||||
drivers.push_back("opengl");
|
||||
#endif
|
||||
|
||||
return drivers;
|
||||
@ -3750,7 +3748,7 @@ Vector<String> DisplayServerX11::get_rendering_drivers_func() {
|
||||
DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
|
||||
DisplayServer *ds = memnew(DisplayServerX11(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error));
|
||||
if (r_error != OK) {
|
||||
OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.\n"
|
||||
OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan or OpenGL versions.\n"
|
||||
"Please update your drivers or if you have a very old or integrated GPU, upgrade it.\n"
|
||||
"If you have updated your graphics drivers recently, try rebooting.",
|
||||
"Unable to initialize Video driver");
|
||||
@ -3926,11 +3924,11 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V
|
||||
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window");
|
||||
}
|
||||
#endif
|
||||
#ifdef GLES_X11_ENABLED
|
||||
#ifdef OPENGL_ENABLED
|
||||
print_line("rendering_driver " + rendering_driver);
|
||||
if (gl_manager) {
|
||||
Error err = gl_manager->window_create(id, wd.x11_window, x11_display, p_rect.size.width, p_rect.size.height);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a GLES2 window");
|
||||
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create an OpenGL window");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -4114,15 +4112,13 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||
xdnd_selection = XInternAtom(x11_display, "XdndSelection", False);
|
||||
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//TODO - do Vulkan and GLES2 support checks, driver selection and fallback
|
||||
//TODO - do Vulkan and OpenGL support checks, driver selection and fallback
|
||||
rendering_driver = p_rendering_driver;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
//#warning Forcing vulkan rendering driver because OpenGL not implemented yet
|
||||
//#warning Forcing opengl rendering driver because selecting properly is too much effort
|
||||
#endif
|
||||
// rendering_driver = "vulkan";
|
||||
//rendering_driver = "GLES2";
|
||||
|
||||
bool driver_found = false;
|
||||
#if defined(VULKAN_ENABLED)
|
||||
@ -4138,9 +4134,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||
}
|
||||
#endif
|
||||
// Init context and rendering device
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
print_line("rendering_driver " + rendering_driver);
|
||||
if (rendering_driver == "GLES2") {
|
||||
if (rendering_driver == "opengl") {
|
||||
if (getenv("DRI_PRIME") == nullptr) {
|
||||
int use_prime = -1;
|
||||
|
||||
@ -4182,7 +4178,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||
}
|
||||
}
|
||||
|
||||
GLManager_X11::ContextType opengl_api_type = GLManager_X11::GLES_2_0_COMPATIBLE;
|
||||
GLManager_X11::ContextType opengl_api_type = GLManager_X11::GLES_3_0_COMPATIBLE;
|
||||
|
||||
gl_manager = memnew(GLManager_X11(p_resolution, opengl_api_type));
|
||||
|
||||
@ -4197,9 +4193,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||
// gl_manager->set_use_vsync(current_videomode.use_vsync);
|
||||
|
||||
if (true) {
|
||||
// if (RasterizerGLES2::is_viable() == OK) {
|
||||
// RasterizerGLES2::register_config();
|
||||
RasterizerGLES2::make_current();
|
||||
// if (RasterizerOpenGL::is_viable() == OK) {
|
||||
// RasterizerOpenGL::register_config();
|
||||
RasterizerOpenGL::make_current();
|
||||
} else {
|
||||
memdelete(gl_manager);
|
||||
gl_manager = nullptr;
|
||||
@ -4415,9 +4411,9 @@ DisplayServerX11::~DisplayServerX11() {
|
||||
context_vulkan->window_destroy(E.key);
|
||||
}
|
||||
#endif
|
||||
#ifdef GLES_X11_ENABLED
|
||||
if (rendering_driver == "GLES2") {
|
||||
gl_manager->window_destroy(E->key());
|
||||
#ifdef OPENGL_ENABLED
|
||||
if (rendering_driver == "opengl") {
|
||||
gl_manager->window_destroy(E.key);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -4444,7 +4440,7 @@ DisplayServerX11::~DisplayServerX11() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GLES_X11_ENABLED
|
||||
#ifdef OPENGL_ENABLED
|
||||
if (gl_manager) {
|
||||
memdelete(gl_manager);
|
||||
gl_manager = nullptr;
|
||||
|
@ -31,7 +31,7 @@
|
||||
#ifndef DISPLAY_SERVER_X11_H
|
||||
#define DISPLAY_SERVER_X11_H
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
|
||||
#ifdef X11_ENABLED
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
#include "servers/rendering/renderer_compositor.h"
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
#include "gl_manager_x11.h"
|
||||
#endif
|
||||
|
||||
@ -101,7 +101,7 @@ class DisplayServerX11 : public DisplayServer {
|
||||
Atom requested;
|
||||
int xdnd_version;
|
||||
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
GLManager_X11 *gl_manager = nullptr;
|
||||
#endif
|
||||
#if defined(VULKAN_ENABLED)
|
||||
@ -339,7 +339,7 @@ public:
|
||||
|
||||
virtual void window_set_max_size(const Size2i p_size, WindowID p_window = MAIN_WINDOW_ID) override;
|
||||
virtual Size2i window_get_max_size(WindowID p_window = MAIN_WINDOW_ID) const override;
|
||||
virtual void gl_window_make_current(DisplayServer::WindowID p_window_id);
|
||||
virtual void gl_window_make_current(DisplayServer::WindowID p_window_id) override;
|
||||
|
||||
virtual void window_set_transient(WindowID p_window, WindowID p_parent) override;
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "gl_manager_x11.h"
|
||||
|
||||
#ifdef X11_ENABLED
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -174,9 +174,19 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) {
|
||||
int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&ctxErrorHandler);
|
||||
|
||||
switch (context_type) {
|
||||
case GLES_2_0_COMPATIBLE: {
|
||||
gl_display.context->glx_context = glXCreateNewContext(gl_display.x11_display, fbconfig, GLX_RGBA_TYPE, 0, true);
|
||||
ERR_FAIL_COND_V(!gl_display.context->glx_context, ERR_UNCONFIGURED);
|
||||
case GLES_3_0_COMPATIBLE: {
|
||||
// FIXME: Use `GLX_CONTEXT_CORE_PROFILE_BIT_ARB` instead of compatibility profile
|
||||
// once deprecated API usages are fixed.
|
||||
static int context_attribs[] = {
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*|GLX_CONTEXT_DEBUG_BIT_ARB*/,
|
||||
None
|
||||
};
|
||||
|
||||
gl_display.context->glx_context = glXCreateContextAttribsARB(x11_display, fbconfig, nullptr, true, context_attribs);
|
||||
ERR_FAIL_COND_V(ctxErrorOccurred || !gl_display.context->glx_context, ERR_UNCONFIGURED);
|
||||
} break;
|
||||
}
|
||||
|
||||
|
@ -28,13 +28,14 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef GL_MANAGER_X11_H
|
||||
#define GL_MANAGER_X11_H
|
||||
|
||||
#ifdef X11_ENABLED
|
||||
|
||||
#include "drivers/gles_common/rasterizer_platforms.h"
|
||||
#include "drivers/opengl/rasterizer_platforms.h"
|
||||
|
||||
#if defined(GLES_X11_ENABLED)
|
||||
#ifdef OPENGL_ENABLED
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "core/templates/local_vector.h"
|
||||
@ -47,7 +48,7 @@ struct GLManager_X11_Private;
|
||||
class GLManager_X11 {
|
||||
public:
|
||||
enum ContextType {
|
||||
GLES_2_0_COMPATIBLE,
|
||||
GLES_3_0_COMPATIBLE,
|
||||
};
|
||||
|
||||
private:
|
||||
@ -123,5 +124,7 @@ public:
|
||||
~GLManager_X11();
|
||||
};
|
||||
|
||||
#endif // GLES_X11_ENABLED
|
||||
#endif // OPENGL_ENABLED
|
||||
#endif // X11_ENABLED
|
||||
|
||||
#endif // GL_MANAGER_X11_H
|
||||
|
@ -44,5 +44,4 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GLES3_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
#define OPENGL_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
|
@ -3750,7 +3750,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
|
||||
[main_menu setSubmenu:apple_menu forItem:menu_item];
|
||||
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//TODO - do Vulkan and GLES2 support checks, driver selection and fallback
|
||||
//TODO - do Vulkan and OpenGL support checks, driver selection and fallback
|
||||
rendering_driver = p_rendering_driver;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
@ -30,6 +30,5 @@
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
#define GLES3_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
#define OPENGL_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
#define PTHREAD_RENAME_SELF
|
||||
|
@ -161,7 +161,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
||||
outside = true;
|
||||
|
||||
// FIXME: Hardcoded for now, add Vulkan support.
|
||||
p_video_driver = VIDEO_DRIVER_GLES2;
|
||||
p_video_driver = VIDEO_DRIVER_OPENGL;
|
||||
ContextEGL_UWP::Driver opengl_api_type = ContextEGL_UWP::GLES_2_0;
|
||||
|
||||
bool gl_initialization_error = false;
|
||||
@ -175,9 +175,9 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
||||
}
|
||||
|
||||
if (opengl_api_type == ContextEGL_UWP::GLES_2_0) {
|
||||
if (RasterizerGLES2::is_viable() == OK) {
|
||||
RasterizerGLES2::register_config();
|
||||
RasterizerGLES2::make_current();
|
||||
if (RasterizerOpenGLis_viable() == OK) {
|
||||
RasterizerOpenGLregister_config();
|
||||
RasterizerOpenGLmake_current();
|
||||
} else {
|
||||
gl_initialization_error = true;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ def configure_msvc(env, manual_msvc_config):
|
||||
if not env["use_volk"]:
|
||||
LIBS += ["vulkan"]
|
||||
|
||||
# env.AppendUnique(CPPDEFINES = ['OPENGL_ENABLED'])
|
||||
env.AppendUnique(CPPDEFINES=["OPENGL_ENABLED"])
|
||||
LIBS += ["opengl32"]
|
||||
|
||||
env.Append(LINKFLAGS=[p + env["LIBSUFFIX"] for p in LIBS])
|
||||
|
@ -38,8 +38,8 @@
|
||||
|
||||
#include <avrt.h>
|
||||
|
||||
#if defined(GLES_WINDOWS_ENABLED)
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#if defined(OPENGL_ENABLED)
|
||||
#include "drivers/opengl/rasterizer_opengl.h"
|
||||
#endif
|
||||
|
||||
static String format_error_message(DWORD id) {
|
||||
@ -537,8 +537,8 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
|
||||
context_vulkan->window_destroy(p_window);
|
||||
}
|
||||
#endif
|
||||
#ifdef GLES_WINDOWS_ENABLED
|
||||
if (rendering_driver == "GLES2") {
|
||||
#ifdef OPENGL_ENABLED
|
||||
if (rendering_driver == "opengl") {
|
||||
gl_manager->window_destroy(p_window);
|
||||
}
|
||||
#endif
|
||||
@ -552,7 +552,7 @@ void DisplayServerWindows::delete_sub_window(WindowID p_window) {
|
||||
}
|
||||
|
||||
void DisplayServerWindows::gl_window_make_current(DisplayServer::WindowID p_window_id) {
|
||||
#if defined(GLES_WINDOWS_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
gl_manager->window_make_current(p_window_id);
|
||||
#endif
|
||||
}
|
||||
@ -827,8 +827,8 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
|
||||
context_vulkan->window_resize(p_window, w, h);
|
||||
}
|
||||
#endif
|
||||
#if defined(GLES_WINDOWS_ENABLED)
|
||||
if (rendering_driver == "GLES2") {
|
||||
#if defined(OPENGL_ENABLED)
|
||||
if (rendering_driver == "opengl") {
|
||||
gl_manager->window_resize(p_window, w, h);
|
||||
}
|
||||
#endif
|
||||
@ -1611,7 +1611,7 @@ void DisplayServerWindows::make_rendering_thread() {
|
||||
}
|
||||
|
||||
void DisplayServerWindows::swap_buffers() {
|
||||
#if defined(GLES_WINDOWS_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
gl_manager->swap_buffers();
|
||||
#endif
|
||||
}
|
||||
@ -1765,17 +1765,18 @@ void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) {
|
||||
void DisplayServerWindows::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
#if defined(VULKAN_ENABLED)
|
||||
context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
|
||||
// TODO disabling for now
|
||||
//context_vulkan->set_vsync_mode(p_window, p_vsync_mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
DisplayServer::VSyncMode DisplayServerWindows::window_get_vsync_mode(WindowID p_window) const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
#if defined(VULKAN_ENABLED)
|
||||
return context_vulkan->get_vsync_mode(p_window);
|
||||
#else
|
||||
return DisplayServer::VSYNC_ENABLED;
|
||||
//TODO disabling for now
|
||||
//return context_vulkan->get_vsync_mode(p_window);
|
||||
#endif
|
||||
return DisplayServer::VSYNC_ENABLED;
|
||||
}
|
||||
|
||||
void DisplayServerWindows::set_context(Context p_context) {
|
||||
@ -3109,11 +3110,11 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GLES_WINDOWS_ENABLED
|
||||
#ifdef OPENGL_ENABLED
|
||||
print_line("rendering_driver " + rendering_driver);
|
||||
if (rendering_driver == "GLES2") {
|
||||
if (rendering_driver == "opengl") {
|
||||
Error err = gl_manager->window_create(id, wd.hWnd, hInstance, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);
|
||||
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a GLES2 window");
|
||||
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Failed to create an OpenGL window.");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3247,6 +3248,8 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
|
||||
outside = true;
|
||||
|
||||
rendering_driver = p_rendering_driver;
|
||||
|
||||
// Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
|
||||
HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
|
||||
if (wintab_lib) {
|
||||
@ -3323,9 +3326,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
use_raw_input = false;
|
||||
}
|
||||
|
||||
// hard coded render drivers...
|
||||
// rendering_driver = "vulkan";
|
||||
// rendering_driver = "GLES2";
|
||||
print_line("rendering_driver " + rendering_driver);
|
||||
|
||||
#if defined(VULKAN_ENABLED)
|
||||
@ -3340,10 +3340,10 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
}
|
||||
#endif
|
||||
// Init context and rendering device
|
||||
#if defined(GLES_WINDOWS_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
|
||||
if (rendering_driver == "GLES2") {
|
||||
GLManager_Windows::ContextType opengl_api_type = GLManager_Windows::GLES_2_0_COMPATIBLE;
|
||||
if (rendering_driver == "opengl") {
|
||||
GLManager_Windows::ContextType opengl_api_type = GLManager_Windows::GLES_3_0_COMPATIBLE;
|
||||
|
||||
gl_manager = memnew(GLManager_Windows(opengl_api_type));
|
||||
|
||||
@ -3357,7 +3357,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
// gl_manager->set_use_vsync(current_videomode.use_vsync);
|
||||
|
||||
if (true) {
|
||||
RasterizerGLES2::make_current();
|
||||
RasterizerOpenGL::make_current();
|
||||
} else {
|
||||
memdelete(gl_manager);
|
||||
gl_manager = nullptr;
|
||||
@ -3380,9 +3380,9 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
|
||||
context_gles2->set_use_vsync(video_mode.use_vsync);
|
||||
|
||||
if (RasterizerGLES2::is_viable() == OK) {
|
||||
RasterizerGLES2::register_config();
|
||||
RasterizerGLES2::make_current();
|
||||
if (RasterizerOpenGL::is_viable() == OK) {
|
||||
RasterizerOpenGL::register_config();
|
||||
RasterizerOpenGL::make_current();
|
||||
} else {
|
||||
memdelete(context_gles2);
|
||||
context_gles2 = nullptr;
|
||||
@ -3448,8 +3448,8 @@ Vector<String> DisplayServerWindows::get_rendering_drivers_func() {
|
||||
#ifdef VULKAN_ENABLED
|
||||
drivers.push_back("vulkan");
|
||||
#endif
|
||||
#ifdef GLES_WINDOWS_ENABLED
|
||||
drivers.push_back("GLES2");
|
||||
#ifdef OPENGL_ENABLED
|
||||
drivers.push_back("opengl");
|
||||
#endif
|
||||
|
||||
return drivers;
|
||||
@ -3458,7 +3458,7 @@ Vector<String> DisplayServerWindows::get_rendering_drivers_func() {
|
||||
DisplayServer *DisplayServerWindows::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error) {
|
||||
DisplayServer *ds = memnew(DisplayServerWindows(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_resolution, r_error));
|
||||
if (r_error != OK) {
|
||||
OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan versions.\n"
|
||||
OS::get_singleton()->alert("Your video card driver does not support any of the supported Vulkan or OpenGL versions.\n"
|
||||
"Please update your drivers or if you have a very old or integrated GPU upgrade it.",
|
||||
"Unable to initialize Video driver");
|
||||
}
|
||||
@ -3479,7 +3479,7 @@ DisplayServerWindows::~DisplayServerWindows() {
|
||||
SetWindowLongPtr(windows[MAIN_WINDOW_ID].hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc);
|
||||
};
|
||||
|
||||
#ifdef GLES_WINDOWS_ENABLED
|
||||
#ifdef OPENGL_ENABLED
|
||||
// destroy windows .. NYI?
|
||||
#endif
|
||||
|
||||
@ -3511,7 +3511,7 @@ DisplayServerWindows::~DisplayServerWindows() {
|
||||
if (restore_mouse_trails > 1) {
|
||||
SystemParametersInfoA(SPI_SETMOUSETRAILS, restore_mouse_trails, 0, 0);
|
||||
}
|
||||
#ifdef GLES_WINDOWS_ENABLED
|
||||
#ifdef OPENGL_ENABLED
|
||||
if (gl_manager) {
|
||||
memdelete(gl_manager);
|
||||
gl_manager = nullptr;
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "platform/windows/vulkan_context_win.h"
|
||||
#endif
|
||||
|
||||
#if defined(GLES_WINDOWS_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
#include "gl_manager_windows.h"
|
||||
#endif
|
||||
|
||||
@ -304,7 +304,7 @@ class DisplayServerWindows : public DisplayServer {
|
||||
int old_x, old_y;
|
||||
Point2i center;
|
||||
|
||||
#if defined(GLES_WINDOWS_ENABLED)
|
||||
#if defined(OPENGL_ENABLED)
|
||||
GLManager_Windows *gl_manager;
|
||||
#endif
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "gl_manager_windows.h"
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
#ifdef GLES_WINDOWS_ENABLED
|
||||
#ifdef OPENGL_ENABLED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -66,7 +66,7 @@ int GLManager_Windows::_find_or_create_display(GLWindow &win) {
|
||||
// }
|
||||
|
||||
// create
|
||||
GLDisplay d_temp;
|
||||
GLDisplay d_temp = {};
|
||||
_displays.push_back(d_temp);
|
||||
int new_display_id = _displays.size() - 1;
|
||||
|
||||
|
@ -28,11 +28,10 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#ifndef GL_MANAGER_WINDOWS_H
|
||||
#define GL_MANAGER_WINDOWS_H
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
#ifdef GLES_WINDOWS_ENABLED
|
||||
#if defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED)
|
||||
|
||||
#include "core/error/error_list.h"
|
||||
#include "core/os/os.h"
|
||||
@ -47,7 +46,7 @@ typedef int(APIENTRY *PFNWGLGETSWAPINTERVALEXTPROC)(void);
|
||||
class GLManager_Windows {
|
||||
public:
|
||||
enum ContextType {
|
||||
GLES_2_0_COMPATIBLE,
|
||||
GLES_3_0_COMPATIBLE,
|
||||
};
|
||||
|
||||
private:
|
||||
@ -124,6 +123,6 @@ public:
|
||||
~GLManager_Windows();
|
||||
};
|
||||
|
||||
#endif // OPENGL_ENABLED
|
||||
#endif // defined(WINDOWS_ENABLED) && defined(OPENGL_ENABLED)
|
||||
|
||||
#endif // WINDOWS
|
||||
#endif // GL_MANAGER_WINDOWS_H
|
||||
|
@ -30,5 +30,4 @@
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
#define GLES3_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
#define GLES2_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
#define OPENGL_INCLUDE_H "thirdparty/glad/glad/glad.h"
|
||||
|
@ -284,7 +284,7 @@ TypedArray<String> GPUParticles2D::get_configuration_warnings() const {
|
||||
TypedArray<String> warnings = Node::get_configuration_warnings();
|
||||
|
||||
if (RenderingServer::get_singleton()->is_low_end()) {
|
||||
warnings.push_back(TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles2D\" option for this purpose."));
|
||||
warnings.push_back(TTR("GPU-based particles are not supported by the OpenGL video driver.\nUse the CPUParticles2D node instead. You can use the \"Convert to CPUParticles2D\" option for this purpose."));
|
||||
}
|
||||
|
||||
if (process_material.is_null()) {
|
||||
|
@ -277,7 +277,7 @@ TypedArray<String> GPUParticles3D::get_configuration_warnings() const {
|
||||
TypedArray<String> warnings = Node::get_configuration_warnings();
|
||||
|
||||
if (RenderingServer::get_singleton()->is_low_end()) {
|
||||
warnings.push_back(TTR("GPU-based particles are not supported by the GLES2 video driver.\nUse the CPUParticles3D node instead. You can use the \"Convert to CPUParticles3D\" option for this purpose."));
|
||||
warnings.push_back(TTR("GPU-based particles are not supported by the OpenGL video driver.\nUse the CPUParticles3D node instead. You can use the \"Convert to CPUParticles3D\" option for this purpose."));
|
||||
}
|
||||
|
||||
bool meshes_found = false;
|
||||
|
@ -458,7 +458,7 @@ TypedArray<String> VoxelGI::get_configuration_warnings() const {
|
||||
TypedArray<String> warnings = Node::get_configuration_warnings();
|
||||
|
||||
if (RenderingServer::get_singleton()->is_low_end()) {
|
||||
warnings.push_back(TTR("VoxelGIs are not supported by the GLES2 video driver.\nUse a LightmapGI instead."));
|
||||
warnings.push_back(TTR("VoxelGIs are not supported by the OpenGL video driver.\nUse a LightmapGI instead."));
|
||||
} else if (probe_data.is_null()) {
|
||||
warnings.push_back(TTR("No VoxelGI data set, so this node is disabled. Bake static objects to enable GI."));
|
||||
}
|
||||
|
@ -2722,7 +2722,7 @@ void RenderForwardClustered::_geometry_instance_update(GeometryInstance *p_geome
|
||||
} break;
|
||||
#if 0
|
||||
case RS::INSTANCE_IMMEDIATE: {
|
||||
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
|
||||
RasterizerStorageOpenGL::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
|
||||
ERR_CONTINUE(!immediate);
|
||||
|
||||
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);
|
||||
|
@ -2440,7 +2440,7 @@ void RenderForwardMobile::_geometry_instance_update(GeometryInstance *p_geometry
|
||||
} break;
|
||||
#if 0
|
||||
case RS::INSTANCE_IMMEDIATE: {
|
||||
RasterizerStorageGLES3::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
|
||||
RasterizerStorageOpenGL::Immediate *immediate = storage->immediate_owner.get_or_null(inst->base);
|
||||
ERR_CONTINUE(!immediate);
|
||||
|
||||
_add_geometry(immediate, inst, nullptr, -1, p_depth_pass, p_shadow_pass);
|
||||
|
@ -129,8 +129,10 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) {
|
||||
timestamp_vp_map[rt_id] = p_viewport->self;
|
||||
}
|
||||
|
||||
// This is currently needed for GLES to keep the current window being rendered to up to date
|
||||
DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen);
|
||||
if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl") {
|
||||
// This is currently needed for GLES to keep the current window being rendered to up to date
|
||||
DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen);
|
||||
}
|
||||
|
||||
/* Camera should always be BEFORE any other 3D */
|
||||
|
||||
@ -750,7 +752,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_
|
||||
ERR_FAIL_COND(!viewport);
|
||||
|
||||
if (p_screen != DisplayServer::INVALID_WINDOW_ID) {
|
||||
// If using GLES2 we can optimize this operation by rendering directly to system_fbo
|
||||
// If using OpenGL we can optimize this operation by rendering directly to system_fbo
|
||||
// instead of rendering to fbo and copying to system_fbo after
|
||||
if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) {
|
||||
RSG::storage->render_target_set_size(viewport->render_target, p_rect.size.x, p_rect.size.y, viewport->get_view_count());
|
||||
|
Loading…
Reference in New Issue
Block a user