Skip to content
This repository was archived by the owner on Jul 11, 2025. It is now read-only.
This repository was archived by the owner on Jul 11, 2025. It is now read-only.

Refactor Shader / DrawTechnique Resources #489

@ilexp

Description

@ilexp

Summary

The current rendering resources related to shaders are needlessly convoluted: For a simple shader, the user needs to create a new FragmentShader, VertexShader, ShaderProgram and DrawTechnique resource, two of which don't really add a lot of value. Find a way to unify them.

Analysis

This feature is very much wip / concept phase. Feedback and contributions to the thought process appreciated.

First Draft

  • All four of the above resources could be unified into a single text-based drawing technique description file.
  • The file format could simply consist of a flat list of sections, each with one parameter subsection and one shader subsection.
  • There is one subsection per shader(-program) and one general subsection that is shared by all in both parameters and code.
    • Internally, every shader subsection is compiled into a distinct shader program.
    • Each program section must contain at least one of vertex or a fragment shader main functions, and can contain both, if both are needed.
    • The general section must not contain any main functions, but can contain shared code for all of the programs.
  • Parameters include the blending mode to use, depth- and alpha test settings and similar.
    • Which function are main functions for vertex and fragment shaders is specified via parameter.
    • Custom parameters can be added to be evaluated by the core.
    • If a parameter is present in both the general section and a shader section, the value from the shader section will be used.
  • Allow to specify "base techniques".
    • The general section will be merged with the current one's.
    • The shader sections will be included as-is.
    • Ideally, this would happen at the resource level (rename resources, etc.), but there could be a hint parameter in the source file that gets parsed by the importer to form a bridge.
  • Whatever the format will look like in the end, it should not throw off syntax highlighters for GLSL, so they can still be used.

Benefits

  • Unified file that fully describes how a material is rendered.
  • Full overview in the text editor.
  • Less noise in the Project View.
  • Opportunity to easily sneak in shared base functionality.
  • Potential for future multi-pass rendering of objects by specifying a RenderStep ID (or similar) per shader section and letting the graphics backend pick the appropriate one.

Attachments

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeBreaks binary or source compatibilityCoreArea: Duality runtime or launcherFeatureIt doesn't exist yet, but I want itRenderingRelated to rendering / graphics

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions