#author("2024-07-29T21:41:57+00:00","default:J4Y","J4Y") #author("2024-07-29T22:26:14+00:00","default:J4Y","J4Y") * Shader customization [#xfcc3915] The post-process effects shader is customizable with four global variables (window object). | ''Variables'' | ''Description'' | | ------------------- | ----------------------------------------- | | __POST_SLOT_NAMES__ | The custom slot names scene scoped | | __POST_VERT_BEGIN__ | Insert code at begin of vertex shader | | __POST_FRAG_BEGIN__ | Insert code at begin of fragment shader | | __POST_VERT_END__ | Insert code at end of vertex shader. | | __POST_FRAG_END__ | Insert code at end of fragment shader. | | ''Variables'' | ''Description'' | ''Type'' | | ------------------- | ----------------------------------------- | ------------- | | __POST_SLOT_NAMES__ | The custom slot names scene scoped | Array<string> | | __POST_VERT_BEGIN__ | Insert code at begin of vertex shader | string | | __POST_FRAG_BEGIN__ | Insert code at begin of fragment shader | string | | __POST_VERT_END__ | Insert code at end of vertex shader. | string | | __POST_FRAG_END__ | Insert code at end of fragment shader. | string | Create a ''shader.ts'' file at the same level of your ''main.ts''.~ Set variables of your choices and import the script in ''index.html'' on top of ''main.ts''.~ By this way all these variables are set before the engine start and by extension before the shader program compilation start. * Table fragment vars [#j60e0591] | ''Variables'' | ''Scope'' | ''Type'' | ''Description'' | ''BEGIN'' | ''END'' | | ------------------------ | ------- | -------------- | --------------------------------------------- | ------------- | -------------- | | fragUV | Var | vec2 | The pixel position. |BGCOLOR(green):|BGCOLOR(green):| | outputColor | Var | vec4 | Output color |BGCOLOR(green):|BGCOLOR(green):| | id | Var | vec4 | The pixel id coming from id buffer |BGCOLOR(red):|BGCOLOR(green):| | flags | Var | integer | The pixel id bitmask (a) |BGCOLOR(red):|BGCOLOR(green):| | normal | Var | vec3 | The pixel normal coming from normal buffer |BGCOLOR(red):|BGCOLOR(green):| | depth | Var | float | The pixel depth |BGCOLOR(red):|BGCOLOR(green):| | shadowFactor | Var | float | The pixel shadow factor (shadow-volume) |BGCOLOR(red):|BGCOLOR(green):| | shadowDepthCW | Var | float | The pixel depth clock-wise |BGCOLOR(red):|BGCOLOR(green):| | shadowDepthCCW | Var | float | The pixel depth counter clock-wise |BGCOLOR(red):|BGCOLOR(green):| | s0 | Var | float | Texel from free texture 0 |BGCOLOR(red):|BGCOLOR(green):| | s1 | Var | float | Texel from free texture 1 |BGCOLOR(red):|BGCOLOR(green):| | ------------- | ------- | -------------- | --------------------------------------------- | ------------- | -------------- | | PARAMS | Uniform | Params | Global parameters |BGCOLOR(green):|BGCOLOR(green):| | INFOS | Uniform | Infos | Various infos (screen resolution, time ...) |BGCOLOR(green):|BGCOLOR(green):| | SOURCE_TEXTURE | Uniform | Texture | Colored source texture (with lit) |BGCOLOR(green):|BGCOLOR(green):| | NORMALS_TEXTURE | Uniform | Texture | Normals source texture |BGCOLOR(green):|BGCOLOR(green):| | IDS_TEXTURE | Uniform | Texture | Drawable Indexes source texture |BGCOLOR(green):|BGCOLOR(green):| | DEPTH_TEXTURE | Uniform | Texture | Depth source texture |BGCOLOR(green):|BGCOLOR(green):| | SHADOW_FACTOR_TEXTURE | Uniform | Texture | Shadow-volume texture |BGCOLOR(green):|BGCOLOR(green):| | SHADOW_DEPTH_CCW_TEXTURE | Uniform | Texture | Shadow-volume ccw depth texture |BGCOLOR(green):|BGCOLOR(green):| | SHADOW_DEPTH_CW_TEXTURE | Uniform | Texture | Shadow-volume cw depth texture |BGCOLOR(green):|BGCOLOR(green):| | S0_TEXTURE | Uniform | Texture | Free texture 0 |BGCOLOR(green):|BGCOLOR(green):| | S1_TEXTURE | Uniform | Texture | Free texture 1 |BGCOLOR(green):|BGCOLOR(green):| * What about new uniforms ? [#xfcc3915] For numeric there is: - 16 built-in floats available in ''PARAMS'' from ''S00'' to ''S15'' you can set by '''Gfx3PPERenderer.setCustomParam'''. About texture there is: - 2 built-in texture available in ''S0_TEXTURE'' and ''S1_TEXTURE'' you can set by '''Gfx3PPERenderer.setCustomTextures'''.