- 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;
- }
-
- ERR_FAIL_COND_MSG(storage->frame.current_rt->copy_screen_effect.color == 0, "Can't use screen texture copying in a render target configured without copy buffers.");
- // materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing
- // materials are ignored in 2D meshes, could be added but many things (ie, lighting mode, reading from screen, etc) would break as they are not meant be set up at this point of drawing
- if (r_ris.current_clip != p_ci->final_clip_owner) {
- r_ris.current_clip = p_ci->final_clip_owner;
-
- if (r_ris.current_clip) {
- glEnable(GL_SCISSOR_TEST);
- int y = storage->_dims.rt_height - (r_ris.current_clip->final_clip_rect.position.y + r_ris.current_clip->final_clip_rect.size.y);
- // int y = storage->frame.current_rt->height - (r_ris.current_clip->final_clip_rect.position.y + r_ris.current_clip->final_clip_rect.size.y);
- // FTODO
- // if (storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_VFLIP])
- // y = r_ris.current_clip->final_clip_rect.position.y;
- glScissor(r_ris.current_clip->final_clip_rect.position.x, y, r_ris.current_clip->final_clip_rect.size.width, r_ris.current_clip->final_clip_rect.size.height);
-
- // debug VFLIP
- // if ((r_ris.current_clip->final_clip_rect.position.x == 223)
- int y = storage->frame.current_rt->height - (r_ris.current_clip->final_clip_rect.position.y + r_ris.current_clip->final_clip_rect.size.y);
- // FTODO
- // if (storage->frame.current_rt->flags[RendererStorage::RENDER_TARGET_VFLIP])
- // y = r_ris.current_clip->final_clip_rect.position.y;
- glScissor(r_ris.current_clip->final_clip_rect.position.x, y, r_ris.current_clip->final_clip_rect.size.width, r_ris.current_clip->final_clip_rect.size.height);
+ for (OAHashMap<uint64_t, Version::Specialization>::Iterator it = p_version->variants[i].iter(); it.valid; it = p_version->variants[i].next_iter(it)) {
- //@TODO Optimize to a fixed set of shader pools and use a LRU
- int uniform_count;
- int texunit_pair_count;
- int conditional_count;
- int vertex_code_start;
- int fragment_code_start;
- int attribute_pair_count;
-
- struct CustomCode {
- String vertex;
- String vertex_globals;
- String fragment;
- String fragment_globals;
- String light;
- uint32_t version;
- Vector<StringName> texture_uniforms;
- Vector<StringName> custom_uniforms;
- Vector<CharString> custom_defines;
- Set<uint32_t> versions;
- };
+ //versions
+ CharString general_defines;
+ // A version is a high-level construct which is a combination of built-in and user-defined shader code
+ // Variants use #idefs to toggle behaviour on and off to change behaviour of the shader
+ // Specializations use #ifdefs to toggle behaviour on and off for performance, on supporting hardware, they will compile a version with everything enabled, and then compile more copies to improve performance
+ // Use specializations to enable and disabled advanced features, use variants to toggle behaviour when different data may be used (e.g. using a samplerArray vs a sampler)
+ vec2 pos_rot = pos_norm * mat2(vec2(0.7071067811865476, -0.7071067811865476), vec2(0.7071067811865476, 0.7071067811865476)); //is there a faster way to 45 degrees rot?