diff --git a/gatsby-config.js b/gatsby-config.js index 53818408..df0df95a 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -39,7 +39,25 @@ module.exports = { }, { title: "Shader API", - path: "/api/" + path: "/api/", + pages: [ + { + title : "Changelog", + path: "/api/changelog/", + }, + { + title : "Libraries", + path: "/api/libraries/", + }, + { + title : "Parameters", + path: "/api/parameters/", + }, + { + title : "Shaders", + path: "/api/shaders/", + } + ] }, ] }, diff --git a/src/pages/api/changelog.md b/src/pages/api/changelog.md index 828813da..bed09846 100644 --- a/src/pages/api/changelog.md +++ b/src/pages/api/changelog.md @@ -25,6 +25,7 @@ keywords: + diff --git a/src/pages/api/index.md b/src/pages/api/index.md index 73ce7cf6..4c40b956 100644 --- a/src/pages/api/index.md +++ b/src/pages/api/index.md @@ -46,6 +46,7 @@ In Substance 3D Painter, you can write your own shaders in *GLSL*. We allow + ```glsl void shade(V2F inputs) { diffuseShadingOutput(vec3(1.0, 0.0, 1.0)); @@ -159,6 +160,7 @@ You can declare additional non required information to give some hint to the + ```glsl //: metadata { //: "key1":"value1", diff --git a/src/pages/api/libraries/lib-alpha.md b/src/pages/api/libraries/lib-alpha.md index 0ad9bcc2..bb6ffbaf 100644 --- a/src/pages/api/libraries/lib-alpha.md +++ b/src/pages/api/libraries/lib-alpha.md @@ -25,6 +25,7 @@ keywords: + @@ -46,6 +47,7 @@ keywords: + ```glsl @@ -65,6 +67,7 @@ Opacity map, provided by the engine. + ```glsl //: param auto channel_opacity uniform SamplerSparse opacity_tex; @@ -84,6 +87,7 @@ Alpha test threshold. + ```glsl //: param custom { //: "default": 0.33, @@ -109,6 +113,7 @@ Alpha test dithering. + ```glsl //: param custom { //: "default": false, @@ -134,6 +139,7 @@ Emulate alpha test : discard current fragment if + ```glsl void alphaKill(float alpha) { diff --git a/src/pages/api/libraries/lib-bayer.md b/src/pages/api/libraries/lib-bayer.md index 7a77020f..90bdc506 100644 --- a/src/pages/api/libraries/lib-bayer.md +++ b/src/pages/api/libraries/lib-bayer.md @@ -25,6 +25,7 @@ keywords: + @@ -46,6 +47,7 @@ keywords: + ```glsl float bayerMatrix8(uvec2 coords) { return (float(bayer(coords.x, coords.y)) + 0.5) / 64.0; diff --git a/src/pages/api/libraries/lib-bent-normal.md b/src/pages/api/libraries/lib-bent-normal.md index d5cb788a..8a14445b 100644 --- a/src/pages/api/libraries/lib-bent-normal.md +++ b/src/pages/api/libraries/lib-bent-normal.md @@ -25,6 +25,7 @@ keywords: + @@ -52,6 +53,7 @@ Import from library + ```glsl @@ -104,6 +106,7 @@ Helper to compute the bent normal from tangent space normal given by + ```glsl vec3 computeWSBentNormal(SparseCoord coord, vec3 tangent, vec3 bitangent, vec3 normal) { @@ -131,6 +134,7 @@ Compute bent normals + ```glsl void computeBentNormal(inout LocalVectors vectors, V2F inputs) { if (use_bent_normal) { diff --git a/src/pages/api/libraries/lib-coat.md b/src/pages/api/libraries/lib-coat.md index d978cd52..ffcef8bd 100644 --- a/src/pages/api/libraries/lib-coat.md +++ b/src/pages/api/libraries/lib-coat.md @@ -25,6 +25,7 @@ keywords: + @@ -50,6 +51,7 @@ Import from library + ```glsl ``` @@ -68,6 +70,7 @@ All engine parameters useful for coat. + ```glsl //: param custom { //: "group": "Coat", @@ -114,6 +117,7 @@ Import from library + ```glsl @@ -133,6 +137,7 @@ Compute an f0 at the interface between to materials from their indices of refrac + ```glsl float iorToSpecularLevel(float iorFrom, float iorTo) { @@ -155,6 +160,7 @@ Return the coat normal in world space. + ```glsl vec3 getWSCoatNormal(SparseCoord coord, vec3 tangent, vec3 bitangent, vec3 normal) { @@ -183,6 +189,7 @@ Compute the approximate colored coat absorption for a given view direction. + ```glsl vec3 coatPassageColorMultiplier(vec3 coatColor, float coatOpacity, float ndv) { diff --git a/src/pages/api/libraries/lib-defines.md b/src/pages/api/libraries/lib-defines.md index f8e8c472..c29e71a9 100644 --- a/src/pages/api/libraries/lib-defines.md +++ b/src/pages/api/libraries/lib-defines.md @@ -25,6 +25,7 @@ keywords: + @@ -50,6 +51,7 @@ keywords: + ```glsl #ifndef uniform_specialization #define uniform_specialization uniform @@ -70,6 +72,7 @@ Some useful constants + ```glsl const float M_PI = 3.14159265; const float M_2PI = 2.0 * M_PI; @@ -92,6 +95,7 @@ Blending modes constants + ```glsl const int BlendingMode_Disable = 0; const int BlendingMode_Replace = 1; diff --git a/src/pages/api/libraries/lib-emissive.md b/src/pages/api/libraries/lib-emissive.md index 759fc4d7..12537c5c 100644 --- a/src/pages/api/libraries/lib-emissive.md +++ b/src/pages/api/libraries/lib-emissive.md @@ -25,6 +25,7 @@ keywords: + @@ -49,6 +50,7 @@ Import from library + ```glsl ``` @@ -67,6 +69,7 @@ The emissive channel texture. + ```glsl //: param auto channel_emissive uniform SamplerSparse emissive_tex; @@ -86,6 +89,7 @@ A value used to tweak the emissive intensity. + ```glsl //: param custom { //: "default": 1.0, @@ -113,6 +117,7 @@ Compute the emissive radiance to the viewer's eye + ```glsl vec3 pbrComputeEmissive(SamplerSparse emissive, SparseCoord coord) { diff --git a/src/pages/api/libraries/lib-env.md b/src/pages/api/libraries/lib-env.md index 86847786..984af90a 100644 --- a/src/pages/api/libraries/lib-env.md +++ b/src/pages/api/libraries/lib-env.md @@ -25,6 +25,7 @@ keywords: + @@ -51,6 +52,7 @@ Needed for math constants + ```glsl ``` @@ -69,6 +71,7 @@ Engine provided parameters + ```glsl //: param auto texture_environment uniform sampler2D environment_texture; @@ -101,6 +104,7 @@ Helper that allows one to sample environment. Rotation is taken into + ```glsl vec3 envSample(vec3 dir, float lod) { @@ -128,6 +132,7 @@ Transform a direction from world to environment space + ```glsl vec3 worldToEnvSpace(vec3 dirW) { @@ -151,6 +156,7 @@ Return the irradiance for a given direction. The computation is based on + ```glsl vec3 envIrradiance(vec3 dirW) { diff --git a/src/pages/api/libraries/lib-normal.md b/src/pages/api/libraries/lib-normal.md index 7d072cf7..3bc026c9 100644 --- a/src/pages/api/libraries/lib-normal.md +++ b/src/pages/api/libraries/lib-normal.md @@ -25,6 +25,7 @@ keywords: + @@ -58,6 +59,7 @@ Import from library + ```glsl @@ -77,6 +79,7 @@ All engine parameters useful for normal-centric operations. + ```glsl //: param auto channel_height uniform SamplerSparse height_texture; @@ -104,6 +107,7 @@ Used to invert the Y axis of the normal map + ```glsl //: param auto normal_y_coeff uniform float base_normal_y_coeff; @@ -123,6 +127,7 @@ Empirically determined by our artists... + ```glsl const float HEIGHT_FACTOR = 400.0; ``` @@ -145,6 +150,7 @@ This is based on Whiteout blending + ```glsl vec3 normalBlend(vec3 baseNormal, vec3 overNormal) { @@ -172,6 +178,7 @@ This is based on Detail Oriented blending + ```glsl vec3 normalBlendOriented(vec3 baseNormal, vec3 overNormal) { @@ -196,6 +203,7 @@ Returns a normal flattened by an attenuation factor + ```glsl vec3 normalFade(vec3 normal,float attenuation) { @@ -224,6 +232,7 @@ Unpack a normal w/ alpha channel + ```glsl vec3 normalUnpack(vec4 normal_alpha, float y_coeff) { @@ -256,6 +265,7 @@ Unpack a normal w/ alpha channel, no Y invertion + ```glsl vec3 normalUnpack(vec4 normal_alpha) { @@ -277,6 +287,7 @@ Compute the tangent space normal from document's height channel + ```glsl vec3 normalFromHeight(SparseCoord coord, float height_force) { @@ -328,6 +339,7 @@ Helper to compute the tangent space normal from base normal and a height + ```glsl vec3 getTSNormal(SparseCoord coord, SamplerSparse texture, vec3 normalFromHeight) { @@ -362,6 +374,7 @@ Overload that use base_normal_texture + ```glsl vec3 getTSNormal(SparseCoord coord, vec3 normalFromHeight) { @@ -384,6 +397,7 @@ Helper to compute the tangent space normal from base normal and height, and + ```glsl vec3 getTSNormal(SparseCoord coord, SamplerSparse texture) { @@ -407,6 +421,7 @@ Overload that use base_normal_texture + ```glsl vec3 getTSNormal(SparseCoord coord) { @@ -428,6 +443,7 @@ Helper to compute the world space normal from tangent space base normal. + ```glsl vec3 computeWSBaseNormal(SparseCoord coord, vec3 tangent, vec3 bitangent, vec3 normal) { @@ -455,6 +471,7 @@ Helper to compute the world space normal from tangent space normal given by + ```glsl vec3 computeWSNormal(SparseCoord coord, vec3 tangent, vec3 bitangent, vec3 normal) { diff --git a/src/pages/api/libraries/lib-pbr-aniso.md b/src/pages/api/libraries/lib-pbr-aniso.md index 38e06947..956410e8 100644 --- a/src/pages/api/libraries/lib-pbr-aniso.md +++ b/src/pages/api/libraries/lib-pbr-aniso.md @@ -25,6 +25,7 @@ keywords: + @@ -55,6 +56,7 @@ Import from library + ```glsl ``` @@ -73,6 +75,7 @@ BRDF related functions + ```glsl float normal_distrib( vec3 localH, diff --git a/src/pages/api/libraries/lib-pbr.md b/src/pages/api/libraries/lib-pbr.md index b156e96e..e5a4ea2f 100644 --- a/src/pages/api/libraries/lib-pbr.md +++ b/src/pages/api/libraries/lib-pbr.md @@ -25,6 +25,7 @@ keywords: + @@ -55,6 +56,7 @@ Number of miplevels in the envmap. + ```glsl //: param auto environment_max_lod uniform float maxLod; @@ -75,6 +77,7 @@ An int representing the number of samples made for specular contribution + ```glsl //: param custom { //: "default": 16, @@ -108,6 +111,7 @@ Value used to control specular reflection leaking through the surface. + ```glsl //: param custom { //: "default": 1.3, @@ -134,6 +138,7 @@ Import from library, other parameters + ```glsl @@ -155,6 +160,7 @@ BRDF related functions + ```glsl const float EPSILON_COEF = 1e-4; @@ -293,6 +299,7 @@ Horizon fading trick from + ```glsl float horizonFading(float ndl, float horizonFade) { @@ -315,6 +322,7 @@ Compute the lambertian diffuse radiance to the viewer's eye + ```glsl vec3 pbrComputeDiffuse(vec3 normal, vec3 diffColor) { @@ -336,6 +344,7 @@ Compute the microfacets specular reflection to the viewer's eye + ```glsl vec3 pbrComputeSpecular( LocalVectors vectors, diff --git a/src/pages/api/libraries/lib-pom.md b/src/pages/api/libraries/lib-pom.md index dde79873..91c89a4f 100644 --- a/src/pages/api/libraries/lib-pom.md +++ b/src/pages/api/libraries/lib-pom.md @@ -25,6 +25,7 @@ keywords: + @@ -50,6 +51,7 @@ Import from library + ```glsl ``` @@ -68,6 +70,7 @@ Parallax occlusion mapping related uniforms + ```glsl //: param auto is_2d_view uniform bool isTextureView; @@ -131,6 +134,7 @@ Compute the offset of texture coordinates based on parallax + ```glsl vec2 getParallaxOffset(SparseCoord coord, vec3 viewTS) { @@ -196,6 +200,7 @@ Update input texture coordinates with parallax offset + ```glsl void applyParallaxOffset(inout V2F inputs, vec3 viewTS) { diff --git a/src/pages/api/libraries/lib-random.md b/src/pages/api/libraries/lib-random.md index 2fe703a5..55b0177c 100644 --- a/src/pages/api/libraries/lib-random.md +++ b/src/pages/api/libraries/lib-random.md @@ -25,6 +25,7 @@ keywords: + @@ -53,6 +54,7 @@ Import from library + ```glsl ``` @@ -71,6 +73,7 @@ A 2D blue noise texture containing scalar values + ```glsl //: param auto texture_blue_noise uniform sampler2D texture_blue_noise; @@ -90,6 +93,7 @@ Blue noise texture resolution + ```glsl const ivec2 texture_blue_noise_size = ivec2(256); ``` @@ -108,6 +112,7 @@ Current frame random seed + ```glsl //: param auto random_seed uniform int alg_random_seed; @@ -127,6 +132,7 @@ Get an uniform random value based on pixel coordinates. + ```glsl float getBlueNoiseThreshold() { @@ -148,6 +154,7 @@ Get an uniform random value based on pixel coordinates and frame id. + ```glsl float getBlueNoiseThresholdTemporal() { @@ -169,6 +176,7 @@ Return the i*th* number from fibonacci sequence. + ```glsl float fibonacci1D(int i) { @@ -191,6 +199,7 @@ Return the i*th* couple from the fibonacci sequence. + ```glsl vec2 fibonacci2D(int i, int nbSamples) { @@ -217,6 +226,7 @@ Return the i*th* couple from the fibonacci sequence. + ```glsl vec2 fibonacci2DDitheredTemporal(int i, int nbSamples) { diff --git a/src/pages/api/libraries/lib-sampler.md b/src/pages/api/libraries/lib-sampler.md index e2e9f733..c3e0631d 100644 --- a/src/pages/api/libraries/lib-sampler.md +++ b/src/pages/api/libraries/lib-sampler.md @@ -25,6 +25,7 @@ keywords: + @@ -78,6 +79,7 @@ Import from library + ```glsl @@ -97,6 +99,7 @@ Default background colors when there is no data in channel (alpha is 0) + ```glsl const vec3 DEFAULT_BASE_COLOR = vec3(0.5); const float DEFAULT_ROUGHNESS = 0.3; @@ -138,6 +141,7 @@ AO map. + ```glsl //: param auto ao_blending_mode uniform int ao_blending_mode; @@ -161,6 +165,7 @@ A value used to tweak the Ambient Occlusion intensity. + ```glsl //: param custom { //: "default": 0.75, @@ -187,6 +192,7 @@ Shadowmask. + ```glsl //: param auto shadow_mask_enable uniform bool sm_enable; @@ -212,6 +218,7 @@ Return sampled glossiness or a default value + ```glsl float getGlossiness(vec4 sampledValue) { @@ -238,6 +245,7 @@ Return sampled roughness or a default value + ```glsl float getRoughness(vec4 sampledValue) { @@ -264,6 +272,7 @@ Return sampled metallic or a default value + ```glsl float getMetallic(vec4 sampledValue) { @@ -290,6 +299,7 @@ Return sampled anisotropy level or a default value + ```glsl float getAnisotropyLevel(vec4 sampledValue) { @@ -316,6 +326,7 @@ Return sampled anisotropy angle or a default value + ```glsl float getAnisotropyAngle(vec4 sampledValue) { @@ -381,6 +392,7 @@ Return sampled opacity or a default value + ```glsl float getOpacity(vec4 sampledValue) { @@ -407,6 +419,7 @@ Return sampled height or a default value + ```glsl float getHeight(vec4 sampledValue) { @@ -433,6 +446,7 @@ Return sampled displacement or a default value + ```glsl float getDisplacement(vec4 sampledValue) { @@ -459,6 +473,7 @@ Return ambient occlusion + ```glsl float getAO(SparseCoord coord, bool is_premult, bool is_full_strength) { @@ -506,6 +521,7 @@ Return specular level + ```glsl float getSpecularLevel(vec4 sampledValue) { @@ -532,6 +548,7 @@ Fetch the shadowing factor (screen-space) + ```glsl float getShadowFactor() { @@ -563,6 +580,7 @@ Return sampled base color or a default value + ```glsl vec3 getBaseColor(vec4 sampledValue) { @@ -589,6 +607,7 @@ Return sampled diffuse color or a default value + ```glsl vec3 getDiffuse(vec4 sampledValue) { @@ -616,6 +635,7 @@ Return sampled specular color or a default value + ```glsl vec3 getSpecularColor(vec4 sampledValue) { @@ -644,6 +664,7 @@ Generate anisotropic roughness from roughness and anisotropy level + ```glsl vec2 generateAnisotropicRoughness(float roughness, float anisoLevel) { @@ -666,6 +687,7 @@ Generate anisotropic roughness from roughness and anisotropy level, + ```glsl vec2 generateAnisotropicRoughnessASM(float roughness, float anisoLevel) { @@ -688,6 +710,7 @@ Generate diffuse color from base color and metallic factor + ```glsl vec3 generateDiffuseColor(vec3 baseColor, float metallic) { @@ -709,6 +732,7 @@ Generate specular color from dielectric specular level, base color and metallic + ```glsl vec3 generateSpecularColor(float specularLevel, vec3 baseColor, float metallic) { @@ -731,6 +755,7 @@ Generate specular color from base color and metallic factor, using default + ```glsl vec3 generateSpecularColor(vec3 baseColor, float metallic) { @@ -752,6 +777,7 @@ Return sampled transmissive value or a default value + ```glsl float getTranslucency(vec4 sampledValue) { @@ -789,6 +815,7 @@ Return sampled scattering value per component or a default value + ```glsl vec3 getScatteringPerComponent(SamplerSparse smp, SparseCoord coord) { @@ -813,6 +840,7 @@ Return sampled scatter color or a default value + ```glsl vec3 getScatteringColor(vec4 sampledValue) { @@ -839,6 +867,7 @@ Return sampled specular tint value or a default value + ```glsl vec3 getSpecularTint(vec4 sampledValue) { @@ -875,6 +904,7 @@ Return sampled sheen opacity (sheen weight) value or a default value + ```glsl float getSheenOpacity(vec4 sampledValue) { @@ -901,6 +931,7 @@ Return sampled sheen color value or a default value + ```glsl vec3 getSheenColor(vec4 sampledValue) { @@ -927,6 +958,7 @@ Return sampled sheen roughness value or a default value + ```glsl float getSheenRoughness(vec4 sampledValue) { @@ -953,6 +985,7 @@ Return sampled coat opacity (coat weight) value or a default value + ```glsl float getCoatOpacity(vec4 sampledValue) { @@ -979,6 +1012,7 @@ Return sampled coat color value or a default value + ```glsl vec3 getCoatColor(vec4 sampledValue) { @@ -1005,6 +1039,7 @@ Return sampled coat roughness value or a default value + ```glsl float getCoatRoughness(vec4 sampledValue) { @@ -1031,6 +1066,7 @@ Return sampled coat specular level value or a default value + ```glsl float getCoatSpecularLevel(vec4 sampledValue) { diff --git a/src/pages/api/libraries/lib-sheen.md b/src/pages/api/libraries/lib-sheen.md index 6bf829eb..fb6ac495 100644 --- a/src/pages/api/libraries/lib-sheen.md +++ b/src/pages/api/libraries/lib-sheen.md @@ -25,6 +25,7 @@ keywords: + @@ -49,6 +50,7 @@ Import from library + ```glsl ``` @@ -67,6 +69,7 @@ All engine parameters useful for sheen. + ```glsl //: param custom { //: "group": "Base Surface", @@ -98,6 +101,7 @@ Import from library + ```glsl ``` @@ -116,6 +120,7 @@ Compute the sheen BRDF contribution for importance sampling. + ```glsl vec3 sheen_contrib(float ndh, float ndl, float ndv, vec3 Ks, float roughness) { @@ -153,6 +158,7 @@ Compute the microfacets sheen specular reflection to the viewer's eye. + ```glsl vec3 pbrComputeSheen(LocalVectors vectors, vec3 specColor, float roughness) { diff --git a/src/pages/api/libraries/lib-sparse.md b/src/pages/api/libraries/lib-sparse.md index a8e4df77..8b2a0ac7 100644 --- a/src/pages/api/libraries/lib-sparse.md +++ b/src/pages/api/libraries/lib-sparse.md @@ -25,6 +25,7 @@ keywords: + @@ -65,6 +66,7 @@ If enabled, process additional texture lookup checks to climb up mipmap pyramid + ```glsl #ifdef FEATURE_SPARSE_TEXTURE //: param auto material_lod_check_needed @@ -99,6 +101,7 @@ Used to query all sampler related uniforms with a single auto binding + ```glsl struct SamplerSparse { sampler2D tex; @@ -126,6 +129,7 @@ Store the UV coordinates & material-wise sparse LoD mask + ```glsl struct SparseCoord { vec2 tex_coord; @@ -157,6 +161,7 @@ Example: `SparseCoord uv1coord = getSparseCoord(inputs.multi_tex_coord[1]);` + ```glsl SparseCoord getSparseCoord(vec2 tex_coord) { SparseCoord res; @@ -189,6 +194,7 @@ Build texture coordinates structure used by `textureSparse()` sampling function + ```glsl SparseCoord getSparseCoordLod0(vec2 tex_coord) { SparseCoord res; @@ -225,6 +231,7 @@ Climb up mipmap pyramid if texels are missing + ```glsl float textureSparseQueryLod(SamplerSparse smp, SparseCoord coord) { #ifdef FEATURE_SPARSE_TEXTURE @@ -260,6 +267,7 @@ Climb up mipmap pyramid if texels are missing + ```glsl void textureSparseQueryGrad(out vec2 dfdx, out vec2 dfdy, SamplerSparse smp, SparseCoord coord) { #ifdef FEATURE_SPARSE_TEXTURE @@ -296,6 +304,7 @@ This function replaces the standard `texture(sampler2D, vec2)` to retrieve texel + ```glsl vec4 textureSparse(SamplerSparse smp, SparseCoord coord) { vec2 dfdx,dfdy; @@ -321,6 +330,7 @@ We are providing alternatives versions of this helper for up to N=4 + ```glsl void textureSparseOffsets(SamplerSparse smp, SparseCoord coord, vec2 offsets[N], out vec4 results[N]) { vec2 dfdx,dfdy; diff --git a/src/pages/api/libraries/lib-sss.md b/src/pages/api/libraries/lib-sss.md index 58c52e83..021325cf 100644 --- a/src/pages/api/libraries/lib-sss.md +++ b/src/pages/api/libraries/lib-sss.md @@ -25,6 +25,7 @@ keywords: + @@ -50,6 +51,7 @@ Import from library + ```glsl ``` @@ -68,6 +70,7 @@ The translucency texture, used as SSS weight + ```glsl //: param auto channel_translucency uniform SamplerSparse sss_translucency_tex; @@ -87,6 +90,7 @@ The scalar or per component (R,G & B) SSS coefficient texture + ```glsl //: param auto channel_scattering uniform SamplerSparse sss_scattering_tex; @@ -106,6 +110,7 @@ The scatter color texture, used as SSS albedo + ```glsl //: param auto channel_scatteringcolor uniform SamplerSparse sss_scatteringcolor_tex; @@ -139,6 +144,7 @@ Select whether the light penetrates straight through the material (translucent) + ```glsl //: param custom { //: "default": 2, @@ -171,6 +177,7 @@ Select which channel is used for scatter color. + ```glsl //: param custom { //: "default": 0, @@ -202,6 +209,7 @@ Enable subsurface weighting using translucency channel + ```glsl //: param custom { //: "default": false, @@ -228,6 +236,7 @@ Global scale to the subsurface scattering effect + ```glsl //: param custom { //: "default": 0.5, @@ -256,6 +265,7 @@ Wavelength dependency of the SSS of the material + ```glsl //: param custom { //: "default": [0.701, 0.301, 0.305], @@ -282,6 +292,7 @@ Red shift scattering + ```glsl //: param custom { //: "default": 0.0, @@ -310,6 +321,7 @@ Rayleigh scattering + ```glsl //: param custom { //: "default": 0.0, @@ -338,6 +350,7 @@ Return the material SSS coefficients from scattering value (per component) + ```glsl vec4 getSSSCoefficients(vec3 scattering) { vec4 coeffs = vec4(0.0); @@ -369,6 +382,7 @@ Return the material SSS coefficients + ```glsl vec4 getSSSCoefficients(SparseCoord coord) { if (sssEnabled) { @@ -392,6 +406,7 @@ Return the material SSS color from scatter color and weight (translucency) + ```glsl vec4 getSSSColor(vec3 color, float weight) { return vec4(color,weight); @@ -413,6 +428,7 @@ Return the material SSS color and weight (translucency) + ```glsl vec4 getSSSColor(SparseCoord coord) { if (sssEnabled) { diff --git a/src/pages/api/libraries/lib-utils.md b/src/pages/api/libraries/lib-utils.md index 90a8638a..badf5a17 100644 --- a/src/pages/api/libraries/lib-utils.md +++ b/src/pages/api/libraries/lib-utils.md @@ -25,6 +25,7 @@ keywords: + @@ -54,6 +55,7 @@ Perform the S-curve tone mapping based on the parameters sigma and n. + ```glsl vec3 tonemapSCurve(vec3 value, float sigma, float n) { @@ -83,6 +85,7 @@ sRGB to linear color conversion. Scalar version. + ```glsl float sRGB2linear(float x) { @@ -106,6 +109,7 @@ sRGB to linear color conversion. RGB version. + ```glsl vec3 sRGB2linear(vec3 rgb) { @@ -130,6 +134,7 @@ sRGB to linear color conversion. RGB + Alpha version. + ```glsl vec4 sRGB2linear(vec4 rgba) { @@ -151,6 +156,7 @@ Linear to sRGB color conversion. Scalar version. + ```glsl float linear2sRGB(float x) { @@ -174,6 +180,7 @@ Linear to sRGB color conversion. RGB version. + ```glsl vec3 linear2sRGB(vec3 rgb) { @@ -198,6 +205,7 @@ Linear to sRGB color conversion. RGB + Alpha version. + ```glsl vec4 linear2sRGB(vec4 rgba) { @@ -219,6 +227,7 @@ Linear to sRGB color conversion optional. Scalar version. + ```glsl //: param auto conversion_linear_to_srgb uniform bool convert_to_srgb_opt; @@ -242,6 +251,7 @@ Linear to sRGB color conversion optional. RGB version. + ```glsl vec3 linear2sRGBOpt(vec3 rgb) { @@ -263,6 +273,7 @@ Linear to sRGB color conversion optional. RGB + Alpha version. + ```glsl vec4 linear2sRGBOpt(vec4 rgba) { @@ -284,6 +295,7 @@ Color conversion. Scalar version. + ```glsl uniform int output_conversion_method; float convertOutput(float x) @@ -308,6 +320,7 @@ Color conversion. RGB version. + ```glsl vec3 convertOutput(vec3 rgb) { @@ -331,6 +344,7 @@ Color conversion. RGB + Alpha version. + ```glsl vec4 convertOutput(vec4 rgba) { @@ -361,6 +375,7 @@ Use 8x8 Bayer matrix for dithering mode + ```glsl @@ -391,6 +406,7 @@ Remove AO and shadows on glossy metallic surfaces (close to mirrors) + ```glsl float specularOcclusionCorrection(float diffuseOcclusion, float metallic, float roughness) { diff --git a/src/pages/api/libraries/lib-vectors.md b/src/pages/api/libraries/lib-vectors.md index 71cb29ca..71f719ab 100644 --- a/src/pages/api/libraries/lib-vectors.md +++ b/src/pages/api/libraries/lib-vectors.md @@ -25,6 +25,7 @@ keywords: + @@ -52,6 +53,7 @@ Import from library + ```glsl ``` @@ -70,6 +72,7 @@ Which view is shaded. + ```glsl //: param auto is_2d_view uniform bool is2DView; @@ -89,6 +92,7 @@ What kind of projection is used. + ```glsl //: param auto is_perspective_projection uniform bool is_perspective; @@ -108,6 +112,7 @@ Eye position in world space. + ```glsl //: param auto world_eye_position uniform vec3 camera_pos; @@ -127,6 +132,7 @@ Camera orientation in world space. + ```glsl //: param auto world_camera_direction uniform vec3 camera_dir; @@ -153,6 +159,7 @@ Compute the world space eye vector + ```glsl vec3 getEyeVec(vec3 position) { return is_perspective ? @@ -175,6 +182,7 @@ Convert a vector from tangent space to world space + ```glsl vec3 tangentSpaceToWorldSpace(vec3 vecTS, V2F inputs) { return normalize( @@ -198,6 +206,7 @@ Convert a vector from world space to tangent space + ```glsl vec3 worldSpaceToTangentSpace(vec3 vecWS, V2F inputs) { // Assume the transformation is orthogonal @@ -219,6 +228,7 @@ Local frame of vertex in world space + ```glsl struct LocalVectors { vec3 vertexNormal; @@ -240,6 +250,7 @@ Compute local frame from custom world space normal and anisotropy angle + ```glsl LocalVectors computeLocalFrame(V2F inputs, vec3 normal, float anisoAngle) { LocalVectors vectors; @@ -297,6 +308,7 @@ Compute local frame from mesh and document height and normals + ```glsl LocalVectors computeLocalFrame(V2F inputs) { // Get world space normal diff --git a/src/pages/api/parameters/all-custom-params.md b/src/pages/api/parameters/all-custom-params.md index d2757abd..40626ab4 100644 --- a/src/pages/api/parameters/all-custom-params.md +++ b/src/pages/api/parameters/all-custom-params.md @@ -25,6 +25,7 @@ keywords: + @@ -66,6 +67,7 @@ One can hide or show the parameter in the UI, depending on other parameters valu + ```glsl //: param custom { "default": 0, "label": "Int slider", "min": 0, "max": 10 } uniform int u_slider_param1; @@ -88,6 +90,7 @@ Color parameters + ```glsl //: param custom { "default": 0, "label": "Color RGB", "widget": "color" } uniform vec3 u_color_float3; @@ -110,6 +113,7 @@ Spinboxes parameters + ```glsl //: param custom { "default": 0, "label": "Int spinbox" } uniform int u_spin_int1; @@ -144,6 +148,7 @@ Slider parameters + ```glsl //: param custom { "default": 0, "label": "Int slider", "min": 0, "max": 10 } uniform int u_slider_int1; @@ -180,6 +185,7 @@ Bool parameters + ```glsl //: param custom { "default": false, "label": "Boolean" } uniform bool u_bool; @@ -203,6 +209,7 @@ The texture is defined by its name in the shelf and must be in the `Textures` or + ```glsl //: param custom { "default": "", "default_color": [1.0, 1.0, 0.0, 1.0], "label": "Texture" } uniform sampler2D u_sampler1; @@ -229,6 +236,7 @@ Combobox parameters + ```glsl //: param custom { //: "default": -1, @@ -257,6 +265,7 @@ Shader entry point + ```glsl vec4 shade(V2F inputs) { diff --git a/src/pages/api/parameters/all-custom-qualifiers.md b/src/pages/api/parameters/all-custom-qualifiers.md index fee9c4e3..78a4bfb1 100644 --- a/src/pages/api/parameters/all-custom-qualifiers.md +++ b/src/pages/api/parameters/all-custom-qualifiers.md @@ -25,6 +25,7 @@ keywords: + @@ -61,6 +62,7 @@ Basic usage: + ```glsl //: param custom { "default": false, "label": "Heavy feature" } uniform_specialization bool u_enable_heavy_featureA; @@ -85,6 +87,7 @@ Shader entry point + ```glsl vec4 shade(V2F inputs) { diff --git a/src/pages/api/parameters/all-engine-params.md b/src/pages/api/parameters/all-engine-params.md index d5c857c1..e6b36e79 100644 --- a/src/pages/api/parameters/all-engine-params.md +++ b/src/pages/api/parameters/all-engine-params.md @@ -25,6 +25,7 @@ keywords: + @@ -63,6 +64,7 @@ Basic usage: + ```glsl // Defines the SamplerSparse structure @@ -85,6 +87,7 @@ Texture parameters allow to use 'or' operator to define a fallback: + ```glsl //: param auto TEXTURE_TAG_1 or TEXTURE_TAG_2 uniform SamplerSparse uniform_tex; // if TEXTURE_TAG_1 exists then TEXTURE_TAG_1 else TEXTURE_TAG_2 @@ -180,6 +183,7 @@ Basic usage: + ```glsl //: param auto TEXTURE_TAG uniform sampler2D uniform_tex; // The texture itself @@ -202,6 +206,7 @@ Texture parameters allow to use 'or' operator to define a fallback: + ```glsl //: param auto TEXTURE_TAG_1 or TEXTURE_TAG_2 uniform sampler2D uniform_tex; // if TEXTURE_TAG_1 exists then TEXTURE_TAG_1 else TEXTURE_TAG_2 @@ -238,6 +243,7 @@ Other parameters + ```glsl //: param auto aspect_ratio uniform float uniform_aspect_ratio; @@ -258,6 +264,7 @@ Other parameters + ```glsl //: param auto camera_view_matrix uniform mat4 uniform_camera_view_matrix; @@ -278,6 +285,7 @@ Other parameters + ```glsl //: param auto camera_view_matrix_it uniform mat4 uniform_camera_view_matrix_it; @@ -298,6 +306,7 @@ Other parameters + ```glsl //: param auto camera_vp_matrix_inverse uniform mat4 uniform_camera_vp_matrix_inverse; @@ -318,6 +327,7 @@ Other parameters + ```glsl //: param auto environment_exposure uniform float uniform_environment_exposure; @@ -338,6 +348,7 @@ Other parameters + ```glsl //: param auto environment_max_lod uniform float uniform_max_lod; @@ -358,6 +369,7 @@ Other parameters + ```glsl //: param auto environment_matrix uniform mat3 uniform_environment_matrix; @@ -380,6 +392,7 @@ Other parameters + ```glsl //: param auto facing uniform int uniform_facing; @@ -400,6 +413,7 @@ Other parameters + ```glsl //: param auto fovy uniform float uniform_fovy; @@ -420,6 +434,7 @@ Other parameters + ```glsl //: param auto is_2d_view uniform bool uniform_2d_view; @@ -440,6 +455,7 @@ Other parameters + ```glsl //: param auto is_perspective_projection uniform bool uniform_perspective_projection; @@ -460,6 +476,7 @@ Other parameters + ```glsl //: param auto main_light uniform vec4 uniform_main_light; @@ -480,6 +497,7 @@ Other parameters + ```glsl //: param auto mvp_matrix uniform mat4 uniform_mvp_matrix; @@ -500,6 +518,7 @@ Other parameters + ```glsl //: param auto scene_original_radius uniform float uniform_scene_original_radius; @@ -520,6 +539,7 @@ Other parameters + ```glsl //: param auto screen_size uniform vec4 uniform_screen_size; @@ -540,6 +560,7 @@ Other parameters + ```glsl //: param auto world_camera_direction uniform vec3 uniform_world_camera_direction; @@ -560,6 +581,7 @@ Other parameters + ```glsl //: param auto world_eye_position uniform vec3 uniform_world_eye_position; diff --git a/src/pages/api/parameters/all-rendering-states-params.md b/src/pages/api/parameters/all-rendering-states-params.md index 33825f18..035714a5 100644 --- a/src/pages/api/parameters/all-rendering-states-params.md +++ b/src/pages/api/parameters/all-rendering-states-params.md @@ -25,6 +25,7 @@ keywords: + @@ -53,6 +54,7 @@ Cull back faces: + ```glsl //: state cull_face on ``` @@ -71,6 +73,7 @@ Draw front and back faces: + ```glsl //: state cull_face off ``` @@ -93,6 +96,7 @@ No blending, fully opaque objects: + ```glsl //: state blend none ``` @@ -111,6 +115,7 @@ Standard blending mode for back to front draw order: + ```glsl //: state blend over ``` @@ -130,6 +135,7 @@ Standard blending mode for back to front draw order. + ```glsl //: state blend over_premult ``` @@ -148,6 +154,7 @@ Additive blending mode: + ```glsl //: state blend add ``` @@ -166,6 +173,7 @@ Multiplicative blending mode: + ```glsl //: state blend multiply ``` @@ -191,6 +199,7 @@ If artifacts appear set the `nonlocal` state to `on`. + ```glsl //: state nonlocal on diff --git a/src/pages/api/parameters/layering_bind_materials.md b/src/pages/api/parameters/layering_bind_materials.md index 7740bbfa..a28c0484 100644 --- a/src/pages/api/parameters/layering_bind_materials.md +++ b/src/pages/api/parameters/layering_bind_materials.md @@ -25,6 +25,7 @@ keywords: + @@ -53,6 +54,7 @@ Example: + ```glsl //: materials [ //: { @@ -84,6 +86,7 @@ To bind a channel from a material to a sampler, define an auto param with the id + ```glsl //: param auto Material1.channel_basecolor uniform sampler2D basecolor_tex1; diff --git a/src/pages/api/parameters/layering_declare_stacks.md b/src/pages/api/parameters/layering_declare_stacks.md index 7ec7c405..31599131 100644 --- a/src/pages/api/parameters/layering_declare_stacks.md +++ b/src/pages/api/parameters/layering_declare_stacks.md @@ -25,6 +25,7 @@ keywords: + @@ -109,6 +110,7 @@ Example: + ```glsl //: stacks [ //: { @@ -140,6 +142,7 @@ To bind a channel from a stack to a sampler parameter, prefix the channel tag wi + ```glsl //: param auto Mask1.channel_opacity uniform sampler2D mask_tex1; diff --git a/src/pages/api/shaders/asm-metal-rough.md b/src/pages/api/shaders/asm-metal-rough.md index 4b620c7e..fc5c2c29 100644 --- a/src/pages/api/shaders/asm-metal-rough.md +++ b/src/pages/api/shaders/asm-metal-rough.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -143,6 +145,7 @@ Declare the iray mdl material to use with this shader. + ```glsl //: metadata { //: "mdl":"mdl::alg::materials::painter::standard" @@ -163,6 +166,7 @@ Disable culling if double sided option is enabled + ```glsl //: state cull_face off {"enable":"input.doubleSided"} ``` @@ -181,6 +185,7 @@ Enable 'over' alpha blending if opacity alpha blend + ```glsl //: state blend over {"enable":"input.alphaBlendEnabled && !input.sssEnabled && !input.translucencyEnabled"} ``` @@ -199,6 +204,7 @@ Enable 'premultiplied over' alpha blending if translucency + ```glsl //: state blend over_premult {"enable":"input.translucencyEnabled && !input.absorptionEnabled && !input.sssEnabled"} ``` @@ -217,6 +223,7 @@ Enable 'add multiply' alpha blending if absorption is required + ```glsl //: state blend add_multiply {"enable":"input.translucencyEnabled && input.absorptionEnabled && !input.sssEnabled"} ``` @@ -235,6 +242,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -268,6 +276,7 @@ Shader entry point. + ```glsl void shade(V2F inputs) { diff --git a/src/pages/api/shaders/clay.md b/src/pages/api/shaders/clay.md index 5c4d6766..cdbf7e70 100644 --- a/src/pages/api/shaders/clay.md +++ b/src/pages/api/shaders/clay.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -79,6 +81,7 @@ Entry point of the shader. + ```glsl void shade(V2F inputs) { @@ -98,6 +101,7 @@ We generate local world space vectors + ```glsl LocalVectors vectors = computeLocalFrame(inputs); ``` @@ -116,6 +120,7 @@ Simulate camera aligned lighting + ```glsl float NdV = max(0.0, dot(vectors.normal, vectors.eye)); ``` @@ -134,6 +139,7 @@ We generate main color from screen-space curvature + ```glsl vec3 dNdx = dFdx(vectors.normal); vec3 dNdy = dFdy(vectors.normal); @@ -163,6 +169,7 @@ Ambient and diffuse contribution + ```glsl diffuseShadingOutput((ambient + NdV) * diffuse); ``` @@ -181,6 +188,7 @@ Specular contribution + ```glsl specularShadingOutput(vec3(specular * pow(NdV, 64.0 * clayGloss))); } diff --git a/src/pages/api/shaders/dota-2.md b/src/pages/api/shaders/dota-2.md index b6d82e6b..db590c23 100644 --- a/src/pages/api/shaders/dota-2.md +++ b/src/pages/api/shaders/dota-2.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -69,6 +71,7 @@ Import from libraries. + ```glsl //: param auto channel_basecolor uniform SamplerSparse diffuseMapSampler; @@ -88,6 +91,7 @@ Import from libraries. + ```glsl //: param auto channel_user0 uniform SamplerSparse detail_tex; @@ -113,6 +117,7 @@ Import from libraries. + ```glsl //: param auto channel_specular uniform SamplerSparse specularWarpSampler; @@ -138,6 +143,7 @@ Import from libraries. + ```glsl //: param custom { "default": 1, "label": "Specular Color", "widget": "color" } uniform vec3 fSpecularColor; @@ -163,6 +169,7 @@ Import from libraries. + ```glsl //: param custom { "default": 1, "label": "Rim Light Color", "widget": "color" } uniform vec3 fRimLightColor; @@ -188,6 +195,7 @@ Import from libraries. + ```glsl //: param custom { "default": 0, "label": "Ambient Color", "widget": "color" } uniform vec3 fAmbientColor; @@ -216,6 +224,7 @@ Import from libraries. + ```glsl //: param custom { "default": false, "label": "Diffuse Warp" } uniform bool bDoDiffuseWarp; @@ -242,6 +251,7 @@ Import from libraries. + ```glsl //: param custom { "default": [10.0, 10.0, 10.0], "label": "Light Position", "min": -20, "max": 20 } uniform vec3 lightPosition_1; @@ -266,6 +276,7 @@ Import from libraries. + ```glsl struct lightProp { diff --git a/src/pages/api/shaders/non-pbr-spec-gloss.md b/src/pages/api/shaders/non-pbr-spec-gloss.md index 1ea400ee..9f02ce70 100644 --- a/src/pages/api/shaders/non-pbr-spec-gloss.md +++ b/src/pages/api/shaders/non-pbr-spec-gloss.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl diff --git a/src/pages/api/shaders/pbr-car-paint.md b/src/pages/api/shaders/pbr-car-paint.md index ae20bcf4..0987264c 100644 --- a/src/pages/api/shaders/pbr-car-paint.md +++ b/src/pages/api/shaders/pbr-car-paint.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -71,6 +73,7 @@ Import from libraries. + ```glsl //: param custom { "default": "flakes", "label": "Flakes Texture", "usage": "texture" } uniform sampler2D flakes_tex; diff --git a/src/pages/api/shaders/pbr-coated.md b/src/pages/api/shaders/pbr-coated.md index 6501ad93..00519b28 100644 --- a/src/pages/api/shaders/pbr-coated.md +++ b/src/pages/api/shaders/pbr-coated.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl diff --git a/src/pages/api/shaders/pbr-material-layering-10-mats.md b/src/pages/api/shaders/pbr-material-layering-10-mats.md index b57c225a..24b98306 100644 --- a/src/pages/api/shaders/pbr-material-layering-10-mats.md +++ b/src/pages/api/shaders/pbr-material-layering-10-mats.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -252,6 +254,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto texture_normal; uniform sampler2D mesh_normal_texture; @@ -617,6 +620,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Global textures ``` @@ -637,6 +641,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl // Get detail (ambient occlusion) and global (shadow) occlusion factors float occlusion = getAO(inputs.sparse_coord) * getShadowFactor(); @@ -659,6 +664,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Materials Masks ``` @@ -679,6 +685,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl float UVscale[NB_MATERIALS] = float[NB_MATERIALS]( u_coords1, u_coords2, u_coords3, u_coords4, u_coords5, @@ -723,6 +730,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Mixing ``` @@ -743,6 +751,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl float roughSampled[NB_MATERIALS] = float[NB_MATERIALS]( getRoughness(rough1, inputs.tex_coord*UVscale[0]), @@ -845,6 +854,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Final ``` @@ -865,6 +875,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Debug mode display result of combined channels or Masks if( !DebugMode ) { diff --git a/src/pages/api/shaders/pbr-material-layering.md b/src/pages/api/shaders/pbr-material-layering.md index bc735c64..790fbdc9 100644 --- a/src/pages/api/shaders/pbr-material-layering.md +++ b/src/pages/api/shaders/pbr-material-layering.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -162,6 +164,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto texture_normal; uniform sampler2D mesh_normal_texture; @@ -358,6 +361,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Global textures ``` @@ -378,6 +382,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl // Get detail (ambient occlusion) and global (shadow) occlusion factors float occlusion = getAO(inputs.sparse_coord) * getShadowFactor(); @@ -400,6 +405,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Materials Masks ``` @@ -420,6 +426,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl float UVscale[NB_MATERIALS] = float[NB_MATERIALS]( u_coords1, u_coords2, u_coords3, u_coords4); @@ -483,6 +490,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Mixing ``` @@ -503,6 +511,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl float roughness = mixGrayscale(roughSampled, Masks); float metallic = mixGrayscale(metallicSampled, Masks); @@ -547,6 +556,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Final ``` @@ -567,6 +577,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //Debug mode display result of combined channels or Masks if( !DebugMode ) { diff --git a/src/pages/api/shaders/pbr-metal-rough-anisotropy-angle.md b/src/pages/api/shaders/pbr-metal-rough-anisotropy-angle.md index bb75fbdb..3399cdb1 100644 --- a/src/pages/api/shaders/pbr-metal-rough-anisotropy-angle.md +++ b/src/pages/api/shaders/pbr-metal-rough-anisotropy-angle.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -69,6 +71,7 @@ Declare the iray mdl material to use with this shader. + ```glsl //: metadata { //: "mdl":"mdl::alg::materials::skin_metallic_roughness::skin_metallic_roughness" @@ -89,6 +92,7 @@ Show back faces as there may be holes in front faces. + ```glsl //: state cull_face off ``` @@ -107,6 +111,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -134,6 +139,7 @@ Shader entry point. + ```glsl void shade(V2F inputs) { diff --git a/src/pages/api/shaders/pbr-metal-rough-with-alpha-blending.md b/src/pages/api/shaders/pbr-metal-rough-with-alpha-blending.md index 084b4d37..76e6ca13 100644 --- a/src/pages/api/shaders/pbr-metal-rough-with-alpha-blending.md +++ b/src/pages/api/shaders/pbr-metal-rough-with-alpha-blending.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -72,6 +74,7 @@ Show back faces as there may be holes in front faces. + ```glsl //: state cull_face off ``` @@ -90,6 +93,7 @@ Enable alpha blending + ```glsl //: state blend over ``` @@ -108,6 +112,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -135,6 +140,7 @@ Shader entry point. + ```glsl void shade(V2F inputs) { diff --git a/src/pages/api/shaders/pbr-metal-rough-with-alpha-test.md b/src/pages/api/shaders/pbr-metal-rough-with-alpha-test.md index 3d0c8285..f33cf82a 100644 --- a/src/pages/api/shaders/pbr-metal-rough-with-alpha-test.md +++ b/src/pages/api/shaders/pbr-metal-rough-with-alpha-test.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -74,6 +76,7 @@ Show back faces as there may be holes in front faces. + ```glsl //: state cull_face off ``` @@ -92,6 +95,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -117,6 +121,7 @@ Shader entry point. + ```glsl void shade(V2F inputs) { diff --git a/src/pages/api/shaders/pbr-metal-rough.md b/src/pages/api/shaders/pbr-metal-rough.md index a1735635..0944dfa1 100644 --- a/src/pages/api/shaders/pbr-metal-rough.md +++ b/src/pages/api/shaders/pbr-metal-rough.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -68,6 +70,7 @@ Declare the iray mdl material to use with this shader. + ```glsl //: metadata { //: "mdl":"mdl::alg::materials::skin_metallic_roughness::skin_metallic_roughness" @@ -88,6 +91,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -113,6 +117,7 @@ Shader entry point. + ```glsl void shade(V2F inputs) { diff --git a/src/pages/api/shaders/pbr-spec-gloss.md b/src/pages/api/shaders/pbr-spec-gloss.md index 1f52bade..9d4f8037 100644 --- a/src/pages/api/shaders/pbr-spec-gloss.md +++ b/src/pages/api/shaders/pbr-spec-gloss.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -73,6 +75,7 @@ Channels needed for spec/gloss workflow are bound here. + ```glsl //: param auto channel_diffuse uniform SamplerSparse diffuse_tex; diff --git a/src/pages/api/shaders/pbr-velvet.md b/src/pages/api/shaders/pbr-velvet.md index f92e7298..75e7b671 100644 --- a/src/pages/api/shaders/pbr-velvet.md +++ b/src/pages/api/shaders/pbr-velvet.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl @@ -75,6 +77,7 @@ Import from libraries. + ```glsl //: param custom { "default": "fibers", "label": "Fibers Texture", "usage": "texture" } uniform sampler2D fiber_tex; diff --git a/src/pages/api/shaders/pixelated.md b/src/pages/api/shaders/pixelated.md index 0d919bca..89bdd166 100644 --- a/src/pages/api/shaders/pixelated.md +++ b/src/pages/api/shaders/pixelated.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl ``` @@ -63,6 +65,7 @@ We define the global light position + ```glsl const vec3 light_pos = vec3(10.0, 10.0, 10.0); ``` @@ -81,6 +84,7 @@ We **bind** the auto param world eye position to our uniform **camera_pos**. + ```glsl //: param auto world_eye_position uniform vec3 camera_pos; @@ -100,6 +104,7 @@ We **bind** the document's channel **base color** to our uniform **basecolor_tex + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -120,6 +125,7 @@ We define a new custom tweak for this shader, along with its default value. + ```glsl //: param custom { //: "default": 0.4, @@ -145,6 +151,7 @@ We define a new custom tweak for this shader, along with its default value. + ```glsl //: param custom { //: "default": 0.1, @@ -169,6 +176,7 @@ Entry point of the shader. + ```glsl void shade(V2F inputs) { @@ -188,6 +196,7 @@ We compute a few useful values. + ```glsl vec3 V = normalize(camera_pos - inputs.position); vec3 N = normalize(inputs.normal); @@ -211,6 +220,7 @@ We compute a few useful values. + ```glsl if (NdV < mix(unlit_outline_thickness, lit_outline_thickness, NdL)) { return; @@ -233,6 +243,7 @@ Introduce some jitter to mask size, based on base color luminance + ```glsl float maskRadiusJitter = pow(dot(baseColor, vec3(0.3333)), 0.1); ``` @@ -252,6 +263,7 @@ Compute a mask value, based on screen space position of fragment. + ```glsl float mask = pow(1.0 - length(fract(gl_FragCoord.xy / 7.0) - vec2(0.5)), maskRadiusJitter * 5.0) * 5.0; ``` @@ -270,6 +282,7 @@ Here, we sample the base color and apply a simple diffuse attenuation + ```glsl vec3 color = baseColor * NdL; diff --git a/src/pages/api/shaders/surface-shader.md b/src/pages/api/shaders/surface-shader.md index ed68162e..6139a9a7 100644 --- a/src/pages/api/shaders/surface-shader.md +++ b/src/pages/api/shaders/surface-shader.md @@ -25,6 +25,7 @@ keywords: + @@ -46,6 +47,7 @@ To create a shader resource that can be used in Substance 3D Painter, just creat + ```glsl void shade(V2F inputs); ``` @@ -65,6 +67,7 @@ V2F input type definition: + ```glsl struct V2F { vec3 normal; // interpolated normal @@ -99,6 +102,7 @@ The following functions can be called from within the *shade* function to descri + ```glsl // fragment opacity. default value: 1.0 void alphaOutput(float); diff --git a/src/pages/api/shaders/toon.md b/src/pages/api/shaders/toon.md index fde092e2..ae105270 100644 --- a/src/pages/api/shaders/toon.md +++ b/src/pages/api/shaders/toon.md @@ -25,6 +25,7 @@ keywords: + @@ -45,6 +46,7 @@ Import from libraries. + ```glsl ``` @@ -63,6 +65,7 @@ We define the global light position + ```glsl const vec3 light_pos = vec3(10.0, 10.0, 10.0); ``` @@ -81,6 +84,7 @@ We **bind** the auto param world eye position to our uniform **camera_pos**. + ```glsl //: param auto world_eye_position uniform vec3 camera_pos; @@ -100,6 +104,7 @@ We **bind** the document's channel **base color** to our uniform **basecolor_tex + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -120,6 +125,7 @@ We **bind** the **mesh curvature** to our uniform **curvature_tex**. + ```glsl //: param auto texture_curvature uniform SamplerSparse curvature_tex; @@ -140,6 +146,7 @@ We define a new custom tweak for this shader, along with its default value. + ```glsl //: param custom { //: "default": 0.4, @@ -165,6 +172,7 @@ We define a new custom tweak for this shader, along with its default value. + ```glsl //: param custom { //: "default": 0.1, @@ -189,6 +197,7 @@ Whether we prefer using the curvature or not. + ```glsl //: param custom { //: "default": false, @@ -211,6 +220,7 @@ Entry point of the shader. + ```glsl void shade(V2F inputs) { @@ -230,6 +240,7 @@ We compute a few useful values. + ```glsl vec3 V = normalize(camera_pos - inputs.position); vec3 N = normalize(inputs.normal); @@ -254,6 +265,7 @@ We compute a few useful values. + ```glsl if (use_curvature) { float curv = textureSparse(curvature_tex, inputs.sparse_coord).r; @@ -275,6 +287,7 @@ If outline condition is reach, exit with black color. + ```glsl if (NdV < mix(unlit_outline_thickness, lit_outline_thickness, NdL)) { return; @@ -295,6 +308,7 @@ Here, we perform a 4 steps discretization of color. + ```glsl vec3 color = getBaseColor(basecolor_tex, inputs.sparse_coord); if (NdL > 0.75) { @@ -321,6 +335,7 @@ Fallback is black. + ```glsl color = vec3(0.0); diff --git a/src/pages/api/shaders/vraymtl-metallic.md b/src/pages/api/shaders/vraymtl-metallic.md index 703b4c8f..c6ec0ddb 100644 --- a/src/pages/api/shaders/vraymtl-metallic.md +++ b/src/pages/api/shaders/vraymtl-metallic.md @@ -25,6 +25,7 @@ keywords: + @@ -56,6 +57,7 @@ Channels needed for metal/rough workflow are bound here. + ```glsl //: param auto channel_basecolor uniform SamplerSparse basecolor_tex; @@ -95,6 +97,7 @@ Parameters from Substance + ```glsl //: param auto main_light uniform vec4 uniform_main_light; @@ -137,6 +140,7 @@ VRayMtl specific options + ```glsl // Group basic options //: param custom { "default": 1, "label": "Base color amount", "min": 0, "max": 1, "group": "Base color" } @@ -1133,6 +1137,7 @@ Shader entry point. + ```glsl void shade(V2F inputs) { diff --git a/src/pages/api/shaders/vraymtl-specular.md b/src/pages/api/shaders/vraymtl-specular.md index 0e1261ff..855548f1 100644 --- a/src/pages/api/shaders/vraymtl-specular.md +++ b/src/pages/api/shaders/vraymtl-specular.md @@ -25,6 +25,7 @@ keywords: + @@ -56,6 +57,7 @@ Channels needed for diffuse/specular workflow are bound here. + ```glsl //: param auto channel_diffuse uniform SamplerSparse diffuse_tex; @@ -95,6 +97,7 @@ Parameters from Substance + ```glsl //: param auto main_light uniform vec4 uniform_main_light; @@ -137,6 +140,7 @@ VRayMtl specific options + ```glsl // Group basic options //: param custom { "default": 1, "label": "Base color amount", "min": 0, "max": 1, "group": "Base color" } @@ -1132,6 +1136,7 @@ Shader entry point. + ```glsl void shade(V2F inputs) {