summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@qt.io>2017-12-07 10:56:06 +0100
committerTomi Korpipää <tomi.korpipaa@qt.io>2017-12-14 06:56:38 +0000
commitf28c93051d3bb9a800a4a3a04209aea5f16ab1a9 (patch)
tree9ca98aa63d57dea1adb6313f9a745a39caf1278d
parent611f47ded9a119edb3a8bed39387958f5fc3a655 (diff)
Convert Tabs -> Spaces and Removed trailing whitespace from effectlib
This was done to make syncing the effectlib shaders in 3D Studio with the effectlib shaders in the 2.0 runtime where they had already been sanitized. This makes the diffing process easier, and will also bring things into line with the Qt coding standard. Change-Id: I0c45dcb7110cc31a24cce24d72b53e1d451b701b Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Runtime/res/effectlib/Fxaa3_11.glsllib76
-rw-r--r--src/Runtime/res/effectlib/Fxaa3_8.glsllib182
-rw-r--r--src/Runtime/res/effectlib/SMAA.glsllib118
-rw-r--r--src/Runtime/res/effectlib/SSAOCustomMaterial.glsllib24
-rw-r--r--src/Runtime/res/effectlib/blendColorLayers.glsllib56
-rw-r--r--src/Runtime/res/effectlib/blur.glsllib222
-rw-r--r--src/Runtime/res/effectlib/customCurveLayer.glsllib4
-rw-r--r--src/Runtime/res/effectlib/customMaterialFragBody.glsllib10
-rw-r--r--src/Runtime/res/effectlib/customMaterialFragBodyAO.glsllib18
-rw-r--r--src/Runtime/res/effectlib/defaultMaterialFresnel.glsllib4
-rw-r--r--src/Runtime/res/effectlib/defaultMaterialLighting.glsllib88
-rw-r--r--src/Runtime/res/effectlib/depthpass.glsllib34
-rw-r--r--src/Runtime/res/effectlib/diffuseReflectionBSDF.glsllib6
-rw-r--r--src/Runtime/res/effectlib/directionalFactor.glsllib14
-rw-r--r--src/Runtime/res/effectlib/effect.glsllib40
-rw-r--r--src/Runtime/res/effectlib/evalBakedShadowMap.glsllib4
-rw-r--r--src/Runtime/res/effectlib/evalEnvironmentMap.glsllib30
-rw-r--r--src/Runtime/res/effectlib/evalLightmaps.glsllib16
-rw-r--r--src/Runtime/res/effectlib/fileBumpTexture.glsllib86
-rw-r--r--src/Runtime/res/effectlib/fileDisplacementTexture.glsllib14
-rw-r--r--src/Runtime/res/effectlib/flakeNoiseTexture.glsllib4
-rw-r--r--src/Runtime/res/effectlib/fresnelLayer.glsllib10
-rw-r--r--src/Runtime/res/effectlib/luminance.glsllib20
-rw-r--r--src/Runtime/res/effectlib/microfacetBSDF.glsllib240
-rw-r--r--src/Runtime/res/effectlib/perlinNoise.glsllib4
-rw-r--r--src/Runtime/res/effectlib/physGlossyBSDF.glsllib38
-rw-r--r--src/Runtime/res/effectlib/refraction.glsllib22
-rw-r--r--src/Runtime/res/effectlib/sampleArea.glsllib44
-rw-r--r--src/Runtime/res/effectlib/sampleLight.glsllib4
-rw-r--r--src/Runtime/res/effectlib/sampleProbe.glsllib126
-rw-r--r--src/Runtime/res/effectlib/screenSpaceAO.glsllib40
-rw-r--r--src/Runtime/res/effectlib/screenSpaceDO.glsllib42
-rw-r--r--src/Runtime/res/effectlib/shadowMapping.glsllib52
-rw-r--r--src/Runtime/res/effectlib/shadowMappingFragment.glsllib12
-rw-r--r--src/Runtime/res/effectlib/simpleGlossyBSDF.glsllib6
-rw-r--r--src/Runtime/res/effectlib/spotEdf.glsllib2
-rw-r--r--src/Runtime/res/effectlib/tessellationLinear.glsllib60
-rw-r--r--src/Runtime/res/effectlib/tessellationLinearCM.glsllib52
-rw-r--r--src/Runtime/res/effectlib/tessellationNPatch.glsllib358
-rw-r--r--src/Runtime/res/effectlib/tessellationNPatchCM.glsllib74
-rw-r--r--src/Runtime/res/effectlib/tessellationPath.glsllib198
-rw-r--r--src/Runtime/res/effectlib/tessellationPhong.glsllib154
-rw-r--r--src/Runtime/res/effectlib/tessellationPhongCM.glsllib58
-rw-r--r--src/Runtime/res/effectlib/vertexFragmentBase.glsllib4
44 files changed, 1335 insertions, 1335 deletions
diff --git a/src/Runtime/res/effectlib/Fxaa3_11.glsllib b/src/Runtime/res/effectlib/Fxaa3_11.glsllib
index 52053c0d..f5de2089 100644
--- a/src/Runtime/res/effectlib/Fxaa3_11.glsllib
+++ b/src/Runtime/res/effectlib/Fxaa3_11.glsllib
@@ -49,11 +49,11 @@ Example,
Or,
#define FXAA_360 1
-
+
Or,
#define FXAA_PS3 1
-
+
Etc.
(2.)
@@ -62,7 +62,7 @@ Then include this file,
(3.)
Then call the FXAA pixel shader from within your desired shader.
Look at the FXAA Quality FxaaPixelShader() for docs on inputs.
-As for FXAA 3.11 all inputs for all shaders are the same
+As for FXAA 3.11 all inputs for all shaders are the same
to enable easy porting between platforms.
return FxaaPixelShader(...);
@@ -93,7 +93,7 @@ Look at the FXAA Quality FxaaPixelShader() for docs on inputs.
(6.)
Have FXAA vertex shader run as a full screen triangle,
-and output "pos" and "fxaaConsolePosPos"
+and output "pos" and "fxaaConsolePosPos"
such that inputs in the pixel shader provide,
// {xy} = center of pixel
@@ -110,7 +110,7 @@ Insure the texture sampler(s) used by FXAA are set to bilinear filtering.
------------------------------------------------------------------------------
INTEGRATION - RGBL AND COLORSPACE
------------------------------------------------------------------------------
-FXAA3 requires RGBL as input unless the following is set,
+FXAA3 requires RGBL as input unless the following is set,
#define FXAA_GREEN_AS_LUMA 1
@@ -163,7 +163,7 @@ Getting luma correct is required for the algorithm to work correctly.
------------------------------------------------------------------------------
Applying FXAA to a framebuffer with linear RGB color will look worse.
This is very counter intuitive, but happends to be true in this case.
-The reason is because dithering artifacts will be more visiable
+The reason is because dithering artifacts will be more visiable
in a linear colorspace.
@@ -258,7 +258,7 @@ A. Or use FXAA_GREEN_AS_LUMA.
// Might want to lower the settings for both,
// fxaaConsoleEdgeThresholdMin
// fxaaQualityEdgeThresholdMin
- // In order to insure AA does not get turned off on colors
+ // In order to insure AA does not get turned off on colors
// which contain a minor amount of green.
//
// 1 = On.
@@ -343,7 +343,7 @@ A. Or use FXAA_GREEN_AS_LUMA.
#ifndef FXAA_GATHER4_ALPHA
#define FXAA_GATHER4_ALPHA 0
#endif
- #endif
+ #endif
#endif
/*============================================================================
@@ -406,14 +406,14 @@ NOTE the other tuning knobs are now in the shader function inputs!
//
// Choose the quality preset.
// This needs to be compiled into the shader as it effects code.
- // Best option to include multiple presets is to
+ // Best option to include multiple presets is to
// in each shader define the preset, then include this file.
- //
+ //
// OPTIONS
// -----------------------------------------------------------------------
// 10 to 15 - default medium dither (10=fastest, 15=highest quality)
// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
- // 39 - no dither, very expensive
+ // 39 - no dither, very expensive
//
// NOTES
// -----------------------------------------------------------------------
@@ -422,7 +422,7 @@ NOTE the other tuning knobs are now in the shader function inputs!
// 23 = closest to FXAA 3.9 visually and performance wise
// _ = the lowest digit is directly related to performance
// _ = the highest digit is directly related to style
- //
+ //
#define FXAA_QUALITY__PRESET 12
#endif
@@ -732,7 +732,7 @@ NOTE the other tuning knobs are now in the shader function inputs!
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }
#else
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
-#endif
+#endif
@@ -786,28 +786,28 @@ FxaaFloat4 FxaaPixelShader(
// Where N ranges between,
// N = 0.50 (default)
// N = 0.33 (sharper)
- // {x___} = -N/screenWidthInPixels
+ // {x___} = -N/screenWidthInPixels
// {_y__} = -N/screenHeightInPixels
- // {__z_} = N/screenWidthInPixels
- // {___w} = N/screenHeightInPixels
+ // {__z_} = N/screenWidthInPixels
+ // {___w} = N/screenHeightInPixels
FxaaFloat4 fxaaConsoleRcpFrameOpt,
//
// Only used on FXAA Console.
// Not used on 360, but used on PS3 and PC.
// This must be from a constant/uniform.
- // {x___} = -2.0/screenWidthInPixels
+ // {x___} = -2.0/screenWidthInPixels
// {_y__} = -2.0/screenHeightInPixels
- // {__z_} = 2.0/screenWidthInPixels
- // {___w} = 2.0/screenHeightInPixels
+ // {__z_} = 2.0/screenWidthInPixels
+ // {___w} = 2.0/screenHeightInPixels
FxaaFloat4 fxaaConsoleRcpFrameOpt2,
//
// Only used on FXAA Console.
// Only used on 360 in place of fxaaConsoleRcpFrameOpt2.
// This must be from a constant/uniform.
- // {x___} = 8.0/screenWidthInPixels
+ // {x___} = 8.0/screenWidthInPixels
// {_y__} = 8.0/screenHeightInPixels
- // {__z_} = -4.0/screenWidthInPixels
- // {___w} = -4.0/screenHeightInPixels
+ // {__z_} = -4.0/screenWidthInPixels
+ // {___w} = -4.0/screenHeightInPixels
FxaaFloat4 fxaaConsole360RcpFrameOpt2,
//
// Only used on FXAA Quality.
@@ -829,7 +829,7 @@ FxaaFloat4 FxaaPixelShader(
// 0.333 - too little (faster)
// 0.250 - low quality
// 0.166 - default
- // 0.125 - high quality
+ // 0.125 - high quality
// 0.063 - overkill (slower)
FxaaFloat fxaaQualityEdgeThreshold,
//
@@ -847,7 +847,7 @@ FxaaFloat4 FxaaPixelShader(
// Tune by looking at mostly non-green content,
// then start at zero and increase until aliasing is a problem.
FxaaFloat fxaaQualityEdgeThresholdMin,
- //
+ //
// Only used on FXAA Console.
// This used to be the FXAA_CONSOLE__EDGE_SHARPNESS define.
// It is here now to allow easier tuning.
@@ -882,7 +882,7 @@ FxaaFloat4 FxaaPixelShader(
// Trims the algorithm from processing darks.
// The console setting has a different mapping than the quality setting.
// This only applies when FXAA_EARLY_EXIT is 1.
- // This does not apply to PS3,
+ // This does not apply to PS3,
// PS3 was simplified to avoid more shader instructions.
// 0.06 - faster but more aliasing in darks
// 0.05 - default
@@ -894,7 +894,7 @@ FxaaFloat4 FxaaPixelShader(
// Tune by looking at mostly non-green content,
// then start at zero and increase until aliasing is a problem.
FxaaFloat fxaaConsoleEdgeThresholdMin,
- //
+ //
// Extra constants for 360 FXAA Console only.
// Use zeros or anything else for other platforms.
// These must be in physical constant registers and NOT immedates.
@@ -1271,11 +1271,11 @@ FxaaFloat4 FxaaPixelShader(
/*============================================================================
FXAA3 CONSOLE - PC VERSION
-
+
------------------------------------------------------------------------------
Instead of using this on PC, I'd suggest just using FXAA Quality with
#define FXAA_QUALITY__PRESET 10
-Or
+Or
#define FXAA_QUALITY__PRESET 20
Either are higher qualilty and almost as fast as this on modern PC GPUs.
============================================================================*/
@@ -1364,7 +1364,7 @@ FxaaFloat4 FxaaPixelShader(
/*============================================================================
- FXAA3 CONSOLE - 360 PIXEL SHADER
+ FXAA3 CONSOLE - 360 PIXEL SHADER
------------------------------------------------------------------------------
This optimized version thanks to suggestions from Andy Luedke.
@@ -1399,14 +1399,14 @@ float4 FxaaPixelShader(
/*--------------------------------------------------------------------------*/
float4 lumaNwNeSwSe;
#if (FXAA_GREEN_AS_LUMA == 0)
- asm {
+ asm {
tfetch2D lumaNwNeSwSe.w___, tex, pos.xy, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=false
tfetch2D lumaNwNeSwSe._w__, tex, pos.xy, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=false
tfetch2D lumaNwNeSwSe.__w_, tex, pos.xy, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=false
tfetch2D lumaNwNeSwSe.___w, tex, pos.xy, OffsetX = 0.5, OffsetY = 0.5, UseComputedLOD=false
};
#else
- asm {
+ asm {
tfetch2D lumaNwNeSwSe.y___, tex, pos.xy, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=false
tfetch2D lumaNwNeSwSe._y__, tex, pos.xy, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=false
tfetch2D lumaNwNeSwSe.__y_, tex, pos.xy, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=false
@@ -1427,7 +1427,7 @@ float4 FxaaPixelShader(
#else
float lumaMinM = min(lumaMin, rgbyM.y);
float lumaMaxM = max(lumaMax, rgbyM.y);
- #endif
+ #endif
if((lumaMaxM - lumaMinM) < max(fxaaConsoleEdgeThresholdMin, lumaMax * fxaaConsoleEdgeThreshold)) return rgbyM;
/*--------------------------------------------------------------------------*/
float2 dir;
@@ -1450,8 +1450,8 @@ float4 FxaaPixelShader(
float4 rgbyA = rgbyN1 + rgbyP1;
float4 rgbyB = rgbyN2 + rgbyP2 + rgbyA * 0.5;
/*--------------------------------------------------------------------------*/
- float4 rgbyR = ((FxaaLuma(rgbyB) - lumaMax) > 0.0) ? rgbyA : rgbyB;
- rgbyR = ((FxaaLuma(rgbyB) - lumaMin) > 0.0) ? rgbyR : rgbyA;
+ float4 rgbyR = ((FxaaLuma(rgbyB) - lumaMax) > 0.0) ? rgbyA : rgbyB;
+ rgbyR = ((FxaaLuma(rgbyB) - lumaMin) > 0.0) ? rgbyR : rgbyA;
return rgbyR; }
/*==========================================================================*/
#endif
@@ -1576,7 +1576,7 @@ Pass | Unit | uOp | PC: Op
| | |
13 | SCT0 | mad | 48: ADDxc0_s rc, h2, h2.w---;
| SCB0/1 | mul | 49: MOVh h0(NE0.xxxx), h1;
-
+
Pass SCT TEX SCB
1: 0% 100% 25%
2: 0% 100% 25%
@@ -1662,7 +1662,7 @@ half4 FxaaPixelShader(
#else
dir.x += lumaSw.y;
dir.z += lumaSw.y;
- #endif
+ #endif
/*--------------------------------------------------------------------------*/
// (3)
half4 lumaNw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xy, 0, 0));
@@ -1725,7 +1725,7 @@ half4 FxaaPixelShader(
#else
half lumaMin = min(min(lumaNw.y, lumaSw.y), min(lumaNe.y, lumaSe.y));
half lumaMax = max(max(lumaNw.y, lumaSw.y), max(lumaNe.y, lumaSe.y));
- #endif
+ #endif
rgby2 = (rgby2 + rgby1) * 0.5;
/*--------------------------------------------------------------------------*/
// (12)
@@ -1881,7 +1881,7 @@ Pass | Unit | uOp | PC: Op
| | |
15 | SCT0/1 | mul | 55: MOVh h0(NE0.wwww), h2;
| SCB0/1 | mul | 56: MOVh h0(NE0.xxxx), h1;
-
+
Pass SCT TEX SCB
1: 0% 100% 25%
2: 0% 100% 25%
diff --git a/src/Runtime/res/effectlib/Fxaa3_8.glsllib b/src/Runtime/res/effectlib/Fxaa3_8.glsllib
index aa25c293..7e76ecde 100644
--- a/src/Runtime/res/effectlib/Fxaa3_8.glsllib
+++ b/src/Runtime/res/effectlib/Fxaa3_8.glsllib
@@ -34,34 +34,34 @@
NVIDIA FXAA III.8 by TIMOTHY LOTTES
-
+
------------------------------------------------------------------------------
INTEGRATION CHECKLIST
------------------------------------------------------------------------------
-(1.)
+(1.)
In the shader source,
-setup defines for the desired configuration.
+setup defines for the desired configuration.
Example,
#define FXAA_PC 1
#define FXAA_HLSL_3 1
#define FXAA_LINEAR 1
-(2.)
+(2.)
Then include this file,
-
-(3.)
+
+(3.)
Then call the FXAA pixel shader from within your desired shader,
return FxaaPixelShader(pos, posPos, tex, rcpFrame, rcpFrameOpt);
-(4.)
+(4.)
Insure pass prior to FXAA outputs RGBL.
See next section.
-(5.)
+(5.)
Setup engine to provide "rcpFrame" and "rcpFrameOpt" constants.
Not using constants will result in a performance loss.
@@ -74,20 +74,20 @@ Not using constants will result in a performance loss.
// {_y__} = 2.0/screenHeightInPixels
// {__z_} = 0.5/screenWidthInPixels
// {___w} = 0.5/screenHeightInPixels
- float4 rcpFrameOpt
-
-(6.)
+ float4 rcpFrameOpt
+
+(6.)
Have FXAA vertex shader run as a full screen triangle,
and output "pos" and "posPos" such that inputs in the pixel shader provide,
-
+
// {xy} = center of pixel
float2 pos,
-
+
// {xy__} = upper left of pixel
// {__zw} = lower right of pixel
float4 posPos,
-(7.)
+(7.)
Insure the texture sampler used by FXAA is set to bilinear filtering.
@@ -96,16 +96,16 @@ Insure the texture sampler used by FXAA is set to bilinear filtering.
------------------------------------------------------------------------------
FXAA3 requires RGBL as input.
-RGB should be LDR (low dynamic range).
+RGB should be LDR (low dynamic range).
Specifically do FXAA after tonemapping.
RGB data as returned by a texture fetch can be linear or non-linear.
-Note an "sRGB format" texture counts as linear,
+Note an "sRGB format" texture counts as linear,
because the result of a texture fetch is linear data.
Regular "RGBA8" textures in the sRGB colorspace are non-linear.
-If a texture fetch results linear data the following is required,
+If a texture fetch results linear data the following is required,
- #define FXAA_LINEAR 1
+ #define FXAA_LINEAR 1
Otherwise,
@@ -152,7 +152,7 @@ Q. What if the engine is blending into RGB before wanting to run FXAA?
A. In the last opaque pass prior to FXAA,
have the pass write out luma into alpha.
Then blend into RGB only.
- FXAA should be able to run ok
+ FXAA should be able to run ok
assuming the blending pass did not any add aliasing.
This should be the common case for particles and common blending passes.
@@ -180,7 +180,7 @@ A. In the last opaque pass prior to FXAA,
/*==========================================================================*/
#ifndef FXAA_PC
//
- // FXAA Quality
+ // FXAA Quality
// The high quality PC algorithm.
//
#define FXAA_PC 0
@@ -188,7 +188,7 @@ A. In the last opaque pass prior to FXAA,
/*--------------------------------------------------------------------------*/
#ifndef FXAA_PC_CONSOLE
//
- // The console algorithm for PC is included
+ // The console algorithm for PC is included
// for developers targeting really low spec machines.
//
#define FXAA_PC_CONSOLE 0
@@ -208,36 +208,36 @@ A. In the last opaque pass prior to FXAA,
/*--------------------------------------------------------------------------*/
#ifndef FXAA_HLSL_4
#define FXAA_HLSL_4 0
-#endif
+#endif
/*--------------------------------------------------------------------------*/
#ifndef FXAA_HLSL_5
#define FXAA_HLSL_5 0
-#endif
+#endif
/*==========================================================================*/
#ifndef FXAA_EARLY_EXIT
- //
+ //
// Controls algorithm's early exit path.
// On PS3 turning this on adds 2 cycles to the shader.
// On 360 turning this off adds 10ths of a millisecond to the shader.
// Turning this off on console will result in a more blurry image.
// So this defaults to on.
- //
+ //
// 1 = On.
// 0 = Off.
- //
+ //
#define FXAA_EARLY_EXIT 1
#endif
/*--------------------------------------------------------------------------*/
#ifndef FXAA_DISCARD
- //
+ //
// Only valid for PC OpenGL currently.
- //
+ //
// 1 = Use discard on pixels which don't need AA.
// For APIs which enable concurrent TEX+ROP from same surface.
// 0 = Return unchanged color on pixels which don't need AA.
- //
+ //
#define FXAA_DISCARD 0
-#endif
+#endif
/*--------------------------------------------------------------------------*/
#ifndef FXAA_LINEAR
//
@@ -245,8 +245,8 @@ A. In the last opaque pass prior to FXAA,
// Use this for standard 32-bit RGBA formats.
//
// 1 = Work in RGB=linear, A=non-linear luma.
- // Use this for sRGB and FP16 formats.
- // Works with either FXAA_ALGORITHM = 1 or 0.
+ // Use this for sRGB and FP16 formats.
+ // Works with either FXAA_ALGORITHM = 1 or 0.
//
#define FXAA_LINEAR 0
#endif
@@ -257,7 +257,7 @@ A. In the last opaque pass prior to FXAA,
//
// 1 = GL API supports fast pixel offsets
// 0 = do not use fast pixel offsets
- //
+ //
#ifdef GL_EXT_gpu_shader4
#define FXAA_FAST_PIXEL_OFFSET 1
#endif
@@ -302,7 +302,7 @@ A. In the last opaque pass prior to FXAA,
#ifndef FXAA_GATHER4_ALPHA
#define FXAA_GATHER4_ALPHA 0
#endif
-#endif
+#endif
#endif
/*============================================================================
@@ -311,15 +311,15 @@ A. In the last opaque pass prior to FXAA,
#ifndef FXAA_CONSOLE__EDGE_SHARPNESS
//
// Consoles the sharpness of edges.
- //
- // Due to the PS3 being ALU bound,
+ //
+ // Due to the PS3 being ALU bound,
// there are only two safe values here: 4 and 8.
// These options use the shaders ability to a free *|/ by 4|8.
//
// 8.0 is sharper
// 4.0 is softer
//
- #if 1
+ #if 1
#define FXAA_CONSOLE__EDGE_SHARPNESS 8.0
#else
#define FXAA_CONSOLE__EDGE_SHARPNESS 4.0
@@ -333,7 +333,7 @@ A. In the last opaque pass prior to FXAA,
//
// This only applies when FXAA_EARLY_EXIT is 1.
//
- // Due to the PS3 being ALU bound,
+ // Due to the PS3 being ALU bound,
// there are only two safe values here: 0.25 and 0.125.
// These options use the shaders ability to a free *|/ by 4|8.
//
@@ -344,7 +344,7 @@ A. In the last opaque pass prior to FXAA,
#define FXAA_CONSOLE__EDGE_THRESHOLD 0.125
#else
#define FXAA_CONSOLE__EDGE_THRESHOLD 0.25
- #endif
+ #endif
#endif
/*--------------------------------------------------------------------------*/
#ifndef FXAA_CONSOLE__EDGE_THRESHOLD_MIN
@@ -356,7 +356,7 @@ A. In the last opaque pass prior to FXAA,
//
// This does not apply to PS3.
// PS3 was simplified to avoid more shader instructions.
- //
+ //
#define FXAA_CONSOLE__EDGE_THRESHOLD_MIN 0.05
#endif
@@ -416,14 +416,14 @@ A. In the last opaque pass prior to FXAA,
/*============================================================================
API PORTING
-
+
============================================================================*/
#if FXAA_GLSL_120
// Requires,
// #version 120
// And at least,
// #extension GL_EXT_gpu_shader4 : enable
- // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)
+ // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)
#define half float
#define half2 vec2
#define half3 vec3
@@ -451,7 +451,7 @@ A. In the last opaque pass prior to FXAA,
// use #extension GL_ARB_gpu_shader5 : enable
#define FxaaTexAlpha4(t, p, r) textureGather(t, p, 3)
#define FxaaTexOffAlpha4(t, p, o, r) textureGatherOffset(t, p, o, 3)
- #endif
+ #endif
#endif
/*--------------------------------------------------------------------------*/
#if FXAA_GLSL_130
@@ -479,7 +479,7 @@ A. In the last opaque pass prior to FXAA,
// use #extension GL_ARB_gpu_shader5 : enable
#define FxaaTexAlpha4(t, p, r) textureGather(t, p, 3)
#define FxaaTexOffAlpha4(t, p, o, r) textureGatherOffset(t, p, o, 3)
- #endif
+ #endif
#endif
/*--------------------------------------------------------------------------*/
#if (FXAA_HLSL_3 == 1) || (FXAA_360 == 1)
@@ -507,7 +507,7 @@ A. In the last opaque pass prior to FXAA,
#define FxaaSat(x) saturate(x)
#define FxaaLerp(x,y,s) lerp(x,y,s)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
- #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
+ #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#endif
/*--------------------------------------------------------------------------*/
@@ -521,7 +521,7 @@ A. In the last opaque pass prior to FXAA,
#define FxaaSat(x) saturate(x)
#define FxaaLerp(x,y,s) lerp(x,y,s)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
- #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
+ #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaTexAlpha4(t, p, r) t.tex.GatherAlpha(t.smpl, p)
#define FxaaTexOffAlpha4(t, p, o, r) t.tex.GatherAlpha(t.smpl, p, o)
@@ -556,8 +556,8 @@ half4 FxaaPixelShader(
// {_y__} = 2.0/screenHeightInPixels
// {__z_} = 0.5/screenWidthInPixels
// {___w} = 0.5/screenHeightInPixels
- float4 rcpFrameOpt
-) {
+ float4 rcpFrameOpt
+) {
/*--------------------------------------------------------------------------*/
half4 lumaNwNeSwSe;
lumaNwNeSwSe.x = FxaaTexTop(tex, posPos.xy).w;
@@ -569,7 +569,7 @@ half4 FxaaPixelShader(
/*--------------------------------------------------------------------------*/
lumaNwNeSwSe.y += 1.0/384.0;
/*--------------------------------------------------------------------------*/
- half2 lumaMinTemp = min(lumaNwNeSwSe.xy, lumaNwNeSwSe.zw);
+ half2 lumaMinTemp = min(lumaNwNeSwSe.xy, lumaNwNeSwSe.zw);
half2 lumaMaxTemp = max(lumaNwNeSwSe.xy, lumaNwNeSwSe.zw);
/*--------------------------------------------------------------------------*/
half lumaMin = min(lumaMinTemp.x, lumaMinTemp.y);
@@ -588,7 +588,7 @@ half4 FxaaPixelShader(
dir.x = dot(lumaNwNeSwSe, float4(-1.0, -1.0, 1.0, 1.0));
dir.y = dot(lumaNwNeSwSe, float4( 1.0, -1.0, 1.0,-1.0));
/*--------------------------------------------------------------------------*/
- half2 dir1;
+ half2 dir1;
dir1 = normalize(dir.xy);
/*--------------------------------------------------------------------------*/
half dirAbsMinTimesC = min(abs(dir1.x), abs(dir1.y)) * FXAA_CONSOLE__EDGE_SHARPNESS;
@@ -600,7 +600,7 @@ half4 FxaaPixelShader(
half4 rgbyN2 = FxaaTexTop(tex, pos.xy - dir2 * rcpFrameOpt.xy);
half4 rgbyP2 = FxaaTexTop(tex, pos.xy + dir2 * rcpFrameOpt.xy);
/*--------------------------------------------------------------------------*/
- half4 rgbyA = rgbyN1 * 0.5 + rgbyP1 * 0.5;
+ half4 rgbyA = rgbyN1 * 0.5 + rgbyP1 * 0.5;
half4 rgbyB = rgbyN2 * 0.25 + rgbyP2 * 0.25 + rgbyA * 0.5;
/*--------------------------------------------------------------------------*/
bool twoTap = (rgbyB.w < lumaMin) || (rgbyB.w > lumaMax);
@@ -781,7 +781,7 @@ half4 FxaaPixelShader(
// {__zw} = lower right of pixel
float4 posPos,
// {rgb_} = color in linear or perceptual color space
- // {___a} = luma in perceptual color space (not linear)
+ // {___a} = luma in perceptual color space (not linear)
sampler2D tex,
// This must be from a constant/uniform.
// {xy} = rcpFrame not used on PS3
@@ -791,12 +791,12 @@ half4 FxaaPixelShader(
// {_y__} = 2.0/screenHeightInPixels
// {__z_} = 0.5/screenWidthInPixels
// {___w} = 0.5/screenHeightInPixels
- float4 rcpFrameOpt
-) {
+ float4 rcpFrameOpt
+) {
/*--------------------------------------------------------------------------*/
// (1)
half4 dir;
- half4 lumaNe = h4tex2Dlod(tex, half4(posPos.zy, 0, 0));
+ half4 lumaNe = h4tex2Dlod(tex, half4(posPos.zy, 0, 0));
lumaNe.w += half(1.0/512.0);
dir.x = -lumaNe.w;
dir.z = -lumaNe.w;
@@ -830,24 +830,24 @@ half4 FxaaPixelShader(
temp1N.xy = dir1_pos.zw - dir1_pos.xy * rcpFrameOpt.zw;
/*--------------------------------------------------------------------------*/
// (7)
- temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
+ temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
half4 rgby1;
rgby1.xy = dir1_pos.zw + dir1_pos.xy * rcpFrameOpt.zw;
/*--------------------------------------------------------------------------*/
// (8)
- rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
+ rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
rgby1 = (temp1N + rgby1) * 0.5;
/*--------------------------------------------------------------------------*/
// (9)
half4 temp2N;
temp2N.xy = dir2_pos.zw - dir2_pos.xy * rcpFrameOpt.xy;
- temp2N = h4tex2Dlod(tex, half4(temp2N.xy, 0.0, 0.0));
+ temp2N = h4tex2Dlod(tex, half4(temp2N.xy, 0.0, 0.0));
/*--------------------------------------------------------------------------*/
// (10)
half4 rgby2;
rgby2.xy = dir2_pos.zw + dir2_pos.xy * rcpFrameOpt.xy;
rgby2 = h4tex2Dlod(tex, half4(rgby2.xy, 0.0, 0.0));
- rgby2 = (temp2N + rgby2) * 0.5;
+ rgby2 = (temp2N + rgby2) * 0.5;
/*--------------------------------------------------------------------------*/
// (11)
// compilier moves these scalar ops up to other cycles
@@ -856,8 +856,8 @@ half4 FxaaPixelShader(
rgby2 = (rgby2 + rgby1) * 0.5;
/*--------------------------------------------------------------------------*/
// (12)
- bool twoTapLt = rgby2.w < lumaMin;
- bool twoTapGt = rgby2.w > lumaMax;
+ bool twoTapLt = rgby2.w < lumaMin;
+ bool twoTapGt = rgby2.w > lumaMax;
/*--------------------------------------------------------------------------*/
// (13)
if(twoTapLt || twoTapGt) rgby2 = rgby1;
@@ -1056,7 +1056,7 @@ half4 FxaaPixelShader(
// {__zw} = lower right of pixel
float4 posPos,
// {rgb_} = color in linear or perceptual color space
- // {___a} = luma in perceptual color space (not linear)
+ // {___a} = luma in perceptual color space (not linear)
sampler2D tex,
// This must be from a constant/uniform.
// {xy} = rcpFrame not used on PS3
@@ -1066,11 +1066,11 @@ half4 FxaaPixelShader(
// {_y__} = 2.0/screenHeightInPixels
// {__z_} = 0.5/screenWidthInPixels
// {___w} = 0.5/screenHeightInPixels
- float4 rcpFrameOpt
-) {
+ float4 rcpFrameOpt
+) {
/*--------------------------------------------------------------------------*/
// (1)
- half4 rgbyNe = h4tex2Dlod(tex, half4(posPos.zy, 0, 0));
+ half4 rgbyNe = h4tex2Dlod(tex, half4(posPos.zy, 0, 0));
half lumaNe = rgbyNe.w + half(1.0/512.0);
/*--------------------------------------------------------------------------*/
// (2)
@@ -1084,8 +1084,8 @@ half4 FxaaPixelShader(
/*--------------------------------------------------------------------------*/
// (4)
half4 lumaSe = h4tex2Dlod(tex, half4(posPos.zw, 0, 0));
- half dirZ = lumaNw.w + lumaSwNegNe;
- half dirX = -lumaNw.w + lumaSwNegNe;
+ half dirZ = lumaNw.w + lumaSwNegNe;
+ half dirX = -lumaNw.w + lumaSwNegNe;
/*--------------------------------------------------------------------------*/
// (5)
half3 dir;
@@ -1109,14 +1109,14 @@ half4 FxaaPixelShader(
// (8)
half4 temp1N;
temp1N.xy = dir1_pos.zw - dir1_pos.xy * rcpFrameOpt.zw;
- temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
+ temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
half lumaMax = max(lumaMaxNwSw, lumaMaxNeSe);
half lumaMin = min(lumaMinNwSw, lumaMinNeSe);
/*--------------------------------------------------------------------------*/
// (9)
half4 rgby1;
rgby1.xy = dir1_pos.zw + dir1_pos.xy * rcpFrameOpt.zw;
- rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
+ rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
rgby1 = (temp1N + rgby1) * 0.5;
/*--------------------------------------------------------------------------*/
// (10)
@@ -1134,7 +1134,7 @@ half4 FxaaPixelShader(
/*--------------------------------------------------------------------------*/
// (12)
rgby2 = h4tex2Dlod(tex, half4(rgby2.xy, 0.0, 0.0));
- rgby2 = (temp2N + rgby2) * 0.5;
+ rgby2 = (temp2N + rgby2) * 0.5;
/*--------------------------------------------------------------------------*/
// (13)
rgby2 = (rgby2 + rgby1) * 0.5;
@@ -1181,12 +1181,12 @@ half4 FxaaPixelShader(
// {_y__} = 2.0/screenHeightInPixels
// {__z_} = 0.5/screenWidthInPixels
// {___w} = 0.5/screenHeightInPixels
- float4 rcpFrameOpt
+ float4 rcpFrameOpt
) {
/*--------------------------------------------------------------------------*/
half4 dir;
dir.y = 0.0;
- half4 lumaNe = FxaaTexTop(tex, posPos.zy);
+ half4 lumaNe = FxaaTexTop(tex, posPos.zy);
lumaNe.w += half(1.0/384.0);
dir.x = -lumaNe.w;
dir.z = -lumaNe.w;
@@ -1209,8 +1209,8 @@ half4 FxaaPixelShader(
half lumaMin = min(min(lumaNw.w, lumaSw.w), min(lumaNe.w, lumaSe.w));
half lumaMax = max(max(lumaNw.w, lumaSw.w), max(lumaNe.w, lumaSe.w));
/*--------------------------------------------------------------------------*/
- half lumaMinM = min(lumaMin, rgbyM.w);
- half lumaMaxM = max(lumaMax, rgbyM.w);
+ half lumaMinM = min(lumaMin, rgbyM.w);
+ half lumaMaxM = max(lumaMax, rgbyM.w);
/*--------------------------------------------------------------------------*/
if((lumaMaxM - lumaMinM) < max(FXAA_CONSOLE__EDGE_THRESHOLD_MIN, lumaMax * FXAA_CONSOLE__EDGE_THRESHOLD))
#if (FXAA_DISCARD == 1)
@@ -1231,21 +1231,21 @@ half4 FxaaPixelShader(
half4 temp1N;
temp1N.xy = dir1_pos.zw - dir1_pos.xy * rcpFrameOpt.zw;
/*--------------------------------------------------------------------------*/
- temp1N = FxaaTexTop(tex, temp1N.xy);
+ temp1N = FxaaTexTop(tex, temp1N.xy);
half4 rgby1;
rgby1.xy = dir1_pos.zw + dir1_pos.xy * rcpFrameOpt.zw;
/*--------------------------------------------------------------------------*/
- rgby1 = FxaaTexTop(tex, rgby1.xy);
+ rgby1 = FxaaTexTop(tex, rgby1.xy);
rgby1 = (temp1N + rgby1) * 0.5;
/*--------------------------------------------------------------------------*/
half4 temp2N;
temp2N.xy = dir2_pos.zw - dir2_pos.xy * rcpFrameOpt.xy;
- temp2N = FxaaTexTop(tex, temp2N.xy);
+ temp2N = FxaaTexTop(tex, temp2N.xy);
/*--------------------------------------------------------------------------*/
half4 rgby2;
rgby2.xy = dir2_pos.zw + dir2_pos.xy * rcpFrameOpt.xy;
rgby2 = FxaaTexTop(tex, rgby2.xy);
- rgby2 = (temp2N + rgby2) * 0.5;
+ rgby2 = (temp2N + rgby2) * 0.5;
/*--------------------------------------------------------------------------*/
#if (FXAA_EARLY_EXIT == 0)
half lumaMin = min(min(lumaNw.w, lumaSw.w), min(lumaNe.w, lumaSe.w));
@@ -1253,8 +1253,8 @@ half4 FxaaPixelShader(
#endif
rgby2 = (rgby2 + rgby1) * 0.5;
/*--------------------------------------------------------------------------*/
- bool twoTapLt = rgby2.w < lumaMin;
- bool twoTapGt = rgby2.w > lumaMax;
+ bool twoTapLt = rgby2.w < lumaMin;
+ bool twoTapGt = rgby2.w > lumaMax;
/*--------------------------------------------------------------------------*/
if(twoTapLt || twoTapGt) rgby2 = rgby1;
/*--------------------------------------------------------------------------*/
@@ -1275,17 +1275,17 @@ float4 FxaaPixelShader(
// {xy} = center of pixel
float2 pos,
// {xyzw} = not used on FXAA3 Quality
- float4 posPos,
+ float4 posPos,
// {rgb_} = color in linear or perceptual color space
- // {___a} = luma in perceptual color space (not linear)
+ // {___a} = luma in perceptual color space (not linear)
FxaaTex tex,
// This must be from a constant/uniform.
// {x_} = 1.0/screenWidthInPixels
// {_y} = 1.0/screenHeightInPixels
float2 rcpFrame,
// {xyzw} = not used on FXAA3 Quality
- float4 rcpFrameOpt
-) {
+ float4 rcpFrameOpt
+) {
/*--------------------------------------------------------------------------*/
#if (FXAA_GATHER4_ALPHA == 1)
float4 luma4A = FxaaTexOffAlpha4(tex, pos.xy, FxaaInt2(-1, -1), rcpFrame.xy);
@@ -1322,7 +1322,7 @@ float4 FxaaPixelShader(
return rgbyM;
#endif
/*--------------------------------------------------------------------------*/
- #if (FXAA_GATHER4_ALPHA == 0)
+ #if (FXAA_GATHER4_ALPHA == 0)
float lumaNW = FxaaTexOff(tex, pos.xy, FxaaInt2(-1,-1), rcpFrame.xy).w;
float lumaNE = FxaaTexOff(tex, pos.xy, FxaaInt2( 1,-1), rcpFrame.xy).w;
float lumaSW = FxaaTexOff(tex, pos.xy, FxaaInt2(-1, 1), rcpFrame.xy).w;
@@ -1333,14 +1333,14 @@ float4 FxaaPixelShader(
/*--------------------------------------------------------------------------*/
float lumaL = (lumaN + lumaW + lumaE + lumaS) * 0.25;
float rangeL = abs(lumaL - lumaM);
- float blendL = FxaaSat((rangeL / range) - FXAA_QUALITY__SUBPIX_TRIM) * FXAA_QUALITY__SUBPIX_TRIM_SCALE;
+ float blendL = FxaaSat((rangeL / range) - FXAA_QUALITY__SUBPIX_TRIM) * FXAA_QUALITY__SUBPIX_TRIM_SCALE;
blendL = min(FXAA_QUALITY__SUBPIX_CAP, blendL);
/*--------------------------------------------------------------------------*/
- float edgeVert =
+ float edgeVert =
abs(lumaNW + (-2.0 * lumaN) + lumaNE) +
2.0 * abs(lumaW + (-2.0 * lumaM) + lumaE ) +
abs(lumaSW + (-2.0 * lumaS) + lumaSE);
- float edgeHorz =
+ float edgeHorz =
abs(lumaNW + (-2.0 * lumaW) + lumaSW) +
2.0 * abs(lumaN + (-2.0 * lumaM) + lumaS ) +
abs(lumaNE + (-2.0 * lumaE) + lumaSE);
@@ -1368,9 +1368,9 @@ float4 FxaaPixelShader(
gradientN *= FXAA_SEARCH_THRESHOLD;
/*--------------------------------------------------------------------------*/
float2 posP = posN;
- float2 offNP = horzSpan ?
+ float2 offNP = horzSpan ?
FxaaFloat2(rcpFrame.x, 0.0) :
- FxaaFloat2(0.0f, rcpFrame.y);
+ FxaaFloat2(0.0f, rcpFrame.y);
float lumaEndN;
float lumaEndP;
bool doneN = false;
@@ -1396,7 +1396,7 @@ float4 FxaaPixelShader(
bool directionN = dstN < dstP;
lumaEndN = directionN ? lumaEndN : lumaEndP;
/*--------------------------------------------------------------------------*/
- if(((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))
+ if(((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))
lengthSign = 0.0;
/*--------------------------------------------------------------------------*/
float spanLength = (dstP + dstN);
diff --git a/src/Runtime/res/effectlib/SMAA.glsllib b/src/Runtime/res/effectlib/SMAA.glsllib
index cadbbdf0..97e0153a 100644
--- a/src/Runtime/res/effectlib/SMAA.glsllib
+++ b/src/Runtime/res/effectlib/SMAA.glsllib
@@ -30,9 +30,9 @@
/**
* Copyright (C) 2011 Jorge Jimenez (jorge@iryoku.com)
- * Copyright (C) 2011 Jose I. Echevarria (joseignacioechevarria@gmail.com)
- * Copyright (C) 2011 Belen Masia (bmasia@unizar.es)
- * Copyright (C) 2011 Fernando Navarro (fernandn@microsoft.com)
+ * Copyright (C) 2011 Jose I. Echevarria (joseignacioechevarria@gmail.com)
+ * Copyright (C) 2011 Belen Masia (bmasia@unizar.es)
+ * Copyright (C) 2011 Fernando Navarro (fernandn@microsoft.com)
* Copyright (C) 2011 Diego Gutierrez (diegog@unizar.es)
* All rights reserved.
*
@@ -43,25 +43,25 @@
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the following disclaimer
- * in the documentation and/or other materials provided with the
+ * in the documentation and/or other materials provided with the
* distribution:
*
* "Uses SMAA. Copyright (C) 2011 by Jorge Jimenez, Jose I. Echevarria,
* Tiago Sousa, Belen Masia, Fernando Navarro and Diego Gutierrez."
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
- * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+ * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * The views and conclusions contained in the software and documentation are
+ * The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holders.
*/
@@ -74,14 +74,14 @@
* \ \ | |\/| | / /_\ \ / /_\ \
* ----) | | | | | / _____ \ / _____ \
* |_______/ |__| |__| /__/ \__\ /__/ \__\
- *
+ *
* E N H A N C E D
* S U B P I X E L M O R P H O L O G I C A L A N T I A L I A S I N G
*
* http://www.iryoku.com/smaa/
*
* Hi, welcome aboard!
- *
+ *
* Here you'll find instructions to get the shader up and running as fast as
* possible.
*
@@ -90,7 +90,7 @@
*
* The shader has three passes, chained together as follows:
*
- * |input|------------------·
+ * |input|------------------
* v |
* [ SMAA*EdgeDetection ] |
* v |
@@ -100,7 +100,7 @@
* v |
* |blendTex| |
* v |
- * [ SMAANeighborhoodBlending ] <------·
+ * [ SMAANeighborhoodBlending ] <------
* v
* |output|
*
@@ -149,19 +149,19 @@
* exception of 'searchTex', which must be set to point filtering.
*
* 5. All texture reads and buffer writes must be non-sRGB, with the exception
- * of the input read and the output write of input in
+ * of the input read and the output write of input in
* 'SMAANeighborhoodBlending' (and only in this pass!). If sRGB reads in
* this last pass are not possible, the technique will work anyway, but
- * will perform antialiasing in gamma space.
+ * will perform antialiasing in gamma space.
*
- * IMPORTANT: for best results the input read for the color/luma edge
+ * IMPORTANT: for best results the input read for the color/luma edge
* detection should *NOT* be sRGB.
*
* 6. Before including SMAA.h you'll have to setup the framebuffer pixel size,
* the target and any optional configuration defines. Optionally you can
* use a preset.
*
- * You have three targets available:
+ * You have three targets available:
* SMAA_HLSL_3
* SMAA_HLSL_4
* SMAA_HLSL_4_1
@@ -178,7 +178,7 @@
*
* For example:
* #define SMAA_PIXEL_SIZE float2(1.0 / 1280.0, 1.0 / 720.0)
- * #define SMAA_HLSL_4 1
+ * #define SMAA_HLSL_4 1
* #define SMAA_PRESET_HIGH 1
* include "SMAA.h"
*
@@ -337,7 +337,7 @@
/**
* SMAA_THRESHOLD specifies the threshold or sensitivity to edges.
* Lowering this value you will be able to detect more edges at the expense of
- * performance.
+ * performance.
*
* Range: [0, 0.5]
* 0.1 is a reasonable value, and allows to catch most visible edges.
@@ -352,7 +352,7 @@
/**
* SMAA_DEPTH_THRESHOLD specifies the threshold for depth edge detection.
- *
+ *
* Range: depends on the depth range of the scene.
*/
#ifndef SMAA_DEPTH_THRESHOLD
@@ -380,7 +380,7 @@
*
* Range: [0, 20]; set it to 0 to disable diagonal processing.
*
- * On high-end machines it is cheap (between a 0.8x and 0.9x slower for 16
+ * On high-end machines it is cheap (between a 0.8x and 0.9x slower for 16
* steps), but it can have a significant impact on older machines.
*/
#ifndef SMAA_MAX_SEARCH_STEPS_DIAG
@@ -406,16 +406,16 @@
* It locally decreases the luma or color threshold if an edge is found in an
* additional buffer (so the global threshold can be higher).
*
- * This method was developed by Playstation EDGE MLAA team, and used in
+ * This method was developed by Playstation EDGE MLAA team, and used in
* Killzone 3, by using the light accumulation buffer. More information here:
- * http://iryoku.com/aacourse/downloads/06-MLAA-on-PS3.pptx
+ * http://iryoku.com/aacourse/downloads/06-MLAA-on-PS3.pptx
*/
#ifndef SMAA_PREDICATION
#define SMAA_PREDICATION 0
#endif
/**
- * Threshold to be used in the additional predication buffer.
+ * Threshold to be used in the additional predication buffer.
*
* Range: depends on the input, so you'll have to find the magic number that
* works for you.
@@ -581,7 +581,7 @@ SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; Addres
/**
* Gathers current pixel, and the top-left neighbors.
*/
-float3 SMAAGatherNeighbours(float2 texcoord,
+float3 SMAAGatherNeighbors(float2 texcoord,
float4 offset[3],
SMAATexture2D tex) {
#if SMAA_HLSL_4_1 == 1 || SMAA_GLSL_4 == 1
@@ -601,8 +601,8 @@ float2 SMAACalculatePredicatedThreshold(float2 texcoord,
float4 offset[3],
SMAATexture2D colorTex,
SMAATexture2D predicationTex) {
- float3 neighbours = SMAAGatherNeighbours(texcoord, offset, predicationTex);
- float2 delta = abs(neighbours.xx - neighbours.yz);
+ float3 neighbors = SMAAGatherNeighbors(texcoord, offset, predicationTex);
+ float2 delta = abs(neighbors.xx - neighbors.yz);
float2 edges = step(SMAA_PREDICATION_THRESHOLD, delta);
return SMAA_PREDICATION_SCALE * SMAA_THRESHOLD * (1.0 - SMAA_PREDICATION_STRENGTH * edges);
}
@@ -642,7 +642,7 @@ void SMAABlendingWeightCalculationVS(float4 position,
offset[1] = texcoord.xyxy + SMAA_PIXEL_SIZE.xyxy * float4(-0.125, -0.25, -0.125, 1.25);
// And these for the searches, they indicate the ends of the loops:
- offset[2] = float4(offset[0].xz, offset[1].yw) +
+ offset[2] = float4(offset[0].xz, offset[1].yw) +
float4(-2.0, 2.0, -2.0, 2.0) *
SMAA_PIXEL_SIZE.xxyy * float(SMAA_MAX_SEARCH_STEPS);
}
@@ -742,7 +742,7 @@ float4 SMAALumaEdgeDetectionPS(float2 texcoord,
* contrast in a direction, that will hide contrast in the other
* neighbors.
* This is done after the discard intentionally as this situation doesn't
- * happen too frequently (but it's important to do as it prevents some
+ * happen too frequently (but it's important to do as it prevents some
* edges from going undetected).
*/
edges.xy *= step(0.5 * maxDelta, delta.xy);
@@ -871,7 +871,7 @@ float4 SMAASingleChannelEdgeDetectionPS(float2 texcoord,
* contrast in a direction, that will hide contrast in the other
* neighbors.
* This is done after the discard intentionally as this situation doesn't
- * happen too frequently (but it's important to do as it prevents some
+ * happen too frequently (but it's important to do as it prevents some
* edges from going undetected).
*/
edges.xy *= step(0.5 * maxDelta, delta.xy);
@@ -885,8 +885,8 @@ float4 SMAASingleChannelEdgeDetectionPS(float2 texcoord,
float4 SMAADepthEdgeDetectionPS(float2 texcoord,
float4 offset[3],
SMAATexture2D depthTex) {
- float3 neighbours = SMAAGatherNeighbours(texcoord, offset, depthTex);
- float2 delta = abs(neighbours.xx - float2(neighbours.y, neighbours.z));
+ float3 neighbors = SMAAGatherNeighbors(texcoord, offset, depthTex);
+ float2 delta = abs(neighbors.xx - float2(neighbors.y, neighbors.z));
float2 edges = step(SMAA_DEPTH_THRESHOLD, delta);
if (dot(edges, float2(1.0, 1.0)) == 0.0)
@@ -928,7 +928,7 @@ float SMAASearchDiag2(SMAATexture2D edgesTex, float2 texcoord, float2 dir, float
return i + float(e.g > 0.9) * c;
}
-/**
+/**
* Similar to SMAAArea, this calculates the area corresponding to a certain
* diagonal distance and crossing edges 'e'.
*/
@@ -1002,14 +1002,14 @@ float2 SMAACalculateDiagWeights(SMAATexture2D edgesTex, SMAATexture2D areaTex, f
/**
* This allows to determine how much length should we add in the last step
- * of the searches. It takes the bilinearly interpolated edge (see
+ * of the searches. It takes the bilinearly interpolated edge (see
* @PSEUDO_GATHER4), and adds 0, 1 or 2, depending on which edges and
* crossing edges are active.
*/
float SMAASearchLength(SMAATexture2D searchTex, float2 e, float bias, float scale) {
// Not required if searchTex accesses are set to point:
// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);
- // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
+ // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
// e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
e.r = bias + e.r * scale;
return 255.0 * SMAASampleLevelZeroPoint(searchTex, e).r;
@@ -1027,7 +1027,7 @@ float SMAASearchXLeft(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 te
* which edges are active from the four fetched ones.
*/
float2 e = float2(0.0, 1.0);
- while (texcoord.x > end &&
+ while (texcoord.x > end &&
e.g > 0.8281 && // Is there some edge not activated?
e.r == 0.0) { // Or is there a crossing edge that breaks the line?
e = SMAASampleLevelZero(edgesTex, texcoord).rg;
@@ -1049,7 +1049,7 @@ float SMAASearchXLeft(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 te
float SMAASearchXRight(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 texcoord, float end) {
float2 e = float2(0.0, 1.0);
- while (texcoord.x < end &&
+ while (texcoord.x < end &&
e.g > 0.8281 && // Is there some edge not activated?
e.r == 0.0) { // Or is there a crossing edge that breaks the line?
e = SMAASampleLevelZero(edgesTex, texcoord).rg;
@@ -1065,7 +1065,7 @@ float SMAASearchXRight(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 t
float SMAASearchYUp(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 texcoord, float end) {
float2 e = float2(1.0, 0.0);
- while (texcoord.y > end &&
+ while (texcoord.y > end &&
e.r > 0.8281 && // Is there some edge not activated?
e.g == 0.0) { // Or is there a crossing edge that breaks the line?
e = SMAASampleLevelZero(edgesTex, texcoord).rg;
@@ -1081,13 +1081,13 @@ float SMAASearchYUp(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 texc
float SMAASearchYDown(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 texcoord, float end) {
float2 e = float2(1.0, 0.0);
- while (texcoord.y < end &&
+ while (texcoord.y < end &&
e.r > 0.8281 && // Is there some edge not activated?
e.g == 0.0) { // Or is there a crossing edge that breaks the line?
e = SMAASampleLevelZero(edgesTex, texcoord).rg;
texcoord += float2(0.0, 2.0) * SMAA_PIXEL_SIZE;
}
-
+
texcoord.y -= 0.25 * SMAA_PIXEL_SIZE.y;
texcoord.y -= SMAA_PIXEL_SIZE.y;
texcoord.y -= 2.0 * SMAA_PIXEL_SIZE.y;
@@ -1095,14 +1095,14 @@ float SMAASearchYDown(SMAATexture2D edgesTex, SMAATexture2D searchTex, float2 te
return texcoord.y;
}
-/**
+/**
* Ok, we have the distance and both crossing edges. So, what are the areas
* at each side of current edge?
*/
float2 SMAAArea(SMAATexture2D areaTex, float2 dist, float e1, float e2, float offset) {
// Rounding prevents precision errors of bilinear filtering:
float2 texcoord = float(SMAA_AREATEX_MAX_DISTANCE) * round(4.0 * float2(e1, e2)) + dist;
-
+
// We do a scale and bias for mapping to texel space:
texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + (0.5 * SMAA_AREATEX_PIXEL_SIZE);
@@ -1154,8 +1154,8 @@ void SMAADetectVerticalCornerPattern(SMAATexture2D edgesTex, inout float2 weight
float4 SMAABlendingWeightCalculationPS(float2 texcoord,
float2 pixcoord,
float4 offset[3],
- SMAATexture2D edgesTex,
- SMAATexture2D areaTex,
+ SMAATexture2D edgesTex,
+ SMAATexture2D areaTex,
SMAATexture2D searchTex,
int4 subsampleIndices) { // Just pass zero for SMAA 1x, see @SUBSAMPLE_INDICES.
float4 weights = float4(0.0, 0.0, 0.0, 0.0);
@@ -1169,7 +1169,7 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord,
// one of the boundaries is enough.
weights.rg = SMAACalculateDiagWeights(edgesTex, areaTex, texcoord, e, subsampleIndices);
- // We give priority to diagonals, so if we find a diagonal we skip
+ // We give priority to diagonals, so if we find a diagonal we skip
// horizontal/vertical processing.
SMAA_BRANCH
if (dot(weights.rg, float2(1.0, 1.0)) == 0.0) {
@@ -1196,7 +1196,7 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord,
// better interleave arithmetic and memory accesses):
d = d / SMAA_PIXEL_SIZE.x - pixcoord.x;
- // SMAAArea below needs a sqrt, as the areas texture is compressed
+ // SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically:
float2 sqrt_d = sqrt(abs(d));
@@ -1236,7 +1236,7 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord,
// We want the distances to be in pixel units:
d = d / SMAA_PIXEL_SIZE.y - pixcoord.y;
- // SMAAArea below needs a sqrt, as the areas texture is compressed
+ // SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically:
float2 sqrt_d = sqrt(abs(d));
@@ -1277,7 +1277,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,
// favor blending by choosing the line with the maximum weight for each
// direction:
float2 offset;
- offset.x = a.a > a.b? a.a : -a.b; // left vs. right
+ offset.x = a.a > a.b? a.a : -a.b; // left vs. right
offset.y = a.g > a.r? a.g : -a.r; // top vs. bottom
// Then we go in the direction that has the maximum weight:
@@ -1320,16 +1320,16 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,
}
float4 SMAASampleLevelZeroResolve( SMAATexture2D currentTex,
- SMAATexture2D previousTex,
- float2 texcoord )
+ SMAATexture2D previousTex,
+ float2 texcoord )
{
- return SMAALerp( SMAASampleLevelZero( currentTex, texcoord ), SMAASampleLevelZero( previousTex, texcoord ), .5 );
+ return SMAALerp( SMAASampleLevelZero( currentTex, texcoord ), SMAASampleLevelZero( previousTex, texcoord ), .5 );
}
float4 SMAANeighborhoodBlendingTemporalPS(float2 texcoord,
float4 offset[2],
SMAATexture2D colorTex,
- SMAATexture2D previousTex,
+ SMAATexture2D previousTex,
SMAATexture2D blendTex) {
// Fetch the blending weights for current pixel:
float4 a;
@@ -1348,7 +1348,7 @@ float4 SMAANeighborhoodBlendingTemporalPS(float2 texcoord,
// favor blending by choosing the line with the maximum weight for each
// direction:
float2 offset;
- offset.x = a.a > a.b? a.a : -a.b; // left vs. right
+ offset.x = a.a > a.b? a.a : -a.b; // left vs. right
offset.y = a.g > a.r? a.g : -a.r; // top vs. bottom
// Then we go in the direction that has the maximum weight:
diff --git a/src/Runtime/res/effectlib/SSAOCustomMaterial.glsllib b/src/Runtime/res/effectlib/SSAOCustomMaterial.glsllib
index 8683a4bd..1d8a1c39 100644
--- a/src/Runtime/res/effectlib/SSAOCustomMaterial.glsllib
+++ b/src/Runtime/res/effectlib/SSAOCustomMaterial.glsllib
@@ -36,13 +36,13 @@
#if QT3DS_ENABLE_SSDO
#include "screenSpaceDO.glsllib"
-layout (std140) uniform cbAoShadow {
- vec4 ao_properties;
- vec4 ao_properties2;
- vec4 shadow_properties;
- vec4 aoScreenConst;
- vec4 UvToEyeConst;
- };
+layout (std140) uniform cbAoShadow {
+ vec4 ao_properties;
+ vec4 ao_properties2;
+ vec4 shadow_properties;
+ vec4 aoScreenConst;
+ vec4 UvToEyeConst;
+ };
uniform sampler2D depth_sampler;
#endif
@@ -55,12 +55,12 @@ uniform sampler2D ao_sampler;
float customMaterialAO()
{
#if QT3DS_ENABLE_SSDO
- vec2 smpUV = (gl_FragCoord.xy) * aoScreenConst.zw;
+ vec2 smpUV = (gl_FragCoord.xy) * aoScreenConst.zw;
#else
- ivec2 iSize = textureSize(ao_sampler, 0);
- vec2 smpUV = (gl_FragCoord.xy) / vec2(iSize);
+ ivec2 iSize = textureSize(ao_sampler, 0);
+ vec2 smpUV = (gl_FragCoord.xy) / vec2(iSize);
#endif
- return texture(ao_sampler, smpUV).x;
+ return texture(ao_sampler, smpUV).x;
}
#else
@@ -76,7 +76,7 @@ float customMaterialAO()
float customMaterialShadow( vec3 lightDir, vec3 varWorldPos )
{
- return shadowOcclusion( depth_sampler, lightDir, varWorldPos, view_matrix, view_projection_matrix, shadow_properties, camera_properties, aoScreenConst, UvToEyeConst );
+ return shadowOcclusion( depth_sampler, lightDir, varWorldPos, view_matrix, view_projection_matrix, shadow_properties, camera_properties, aoScreenConst, UvToEyeConst );
}
#else
diff --git a/src/Runtime/res/effectlib/blendColorLayers.glsllib b/src/Runtime/res/effectlib/blendColorLayers.glsllib
index 395b2f50..e07fe613 100644
--- a/src/Runtime/res/effectlib/blendColorLayers.glsllib
+++ b/src/Runtime/res/effectlib/blendColorLayers.glsllib
@@ -3,43 +3,43 @@
float maxValue( in vec3 t )
{
- return max( max( t.x, t.y ), t.z );
+ return max( max( t.x, t.y ), t.z );
}
vec3 blendColor( in vec3 t, in vec3 b, in float weight, in int blendMode)
{
- vec3 blendResult = t;
- switch( blendMode )
- {
- case color_layer_add :
- blendResult += b;
- break;
- case color_layer_multiply :
- blendResult *= b;
- break;
- case color_layer_screen :
- blendResult += t - t * b;
- break;
- case color_layer_overlay:
- blendResult = (maxValue(t) >= 0.5) ? 2.0 * (t+b - t*b - 0.5) : 2.0 * t*b;
- break;
- case color_layer_blend:
- default:
- // nothing to be done
- break;
- }
+ vec3 blendResult = t;
+ switch( blendMode )
+ {
+ case color_layer_add :
+ blendResult += b;
+ break;
+ case color_layer_multiply :
+ blendResult *= b;
+ break;
+ case color_layer_screen :
+ blendResult += t - t * b;
+ break;
+ case color_layer_overlay:
+ blendResult = (maxValue(t) >= 0.5) ? 2.0 * (t+b - t*b - 0.5) : 2.0 * t*b;
+ break;
+ case color_layer_blend:
+ default:
+ // nothing to be done
+ break;
+ }
- return mix( b, blendResult, weight );
+ return mix( b, blendResult, weight );
}
texture_return blendColorLayers( in color_layer colorLayer[1], in vec3 base, in int monoSource )
-{
- vec3 result = blendColor( colorLayer[0].layer_color, base, colorLayer[0].weight, colorLayer[0].mode );
+{
+ vec3 result = blendColor( colorLayer[0].layer_color, base, colorLayer[0].weight, colorLayer[0].mode );
- texture_return tr;
- tr.tint = result;
- tr.mono = monoChannel( vec4( result, 1.0 ), monoSource );
- return( tr );
+ texture_return tr;
+ tr.tint = result;
+ tr.mono = monoChannel( vec4( result, 1.0 ), monoSource );
+ return( tr );
}
#endif
diff --git a/src/Runtime/res/effectlib/blur.glsllib b/src/Runtime/res/effectlib/blur.glsllib
index c139e13e..1f3abc86 100644
--- a/src/Runtime/res/effectlib/blur.glsllib
+++ b/src/Runtime/res/effectlib/blur.glsllib
@@ -68,18 +68,18 @@ uniform vec2 CameraClipRange;
float GetDepthMultiplier(vec2 inTexCoord, sampler2D inDepthSampler, float inFocusDistance, float inFocusWidth, float inFocusPenumbra)
{
- float depthTap = getDepthValue( texture2D(inDepthSampler, inTexCoord), CameraClipRange );
- float linearDepth = depthValueToLinearDistance( depthTap, CameraClipRange );
- float depthDiff = max( 0.0, abs( linearDepth - inFocusDistance ) - (inFocusWidth/2.0) ) / inFocusPenumbra;
- return clamp( depthDiff, 0.0, 1.0 );
+ float depthTap = getDepthValue( texture2D(inDepthSampler, inTexCoord), CameraClipRange );
+ float linearDepth = depthValueToLinearDistance( depthTap, CameraClipRange );
+ float depthDiff = max( 0.0, abs( linearDepth - inFocusDistance ) - (inFocusWidth/2.0) ) / inFocusPenumbra;
+ return clamp( depthDiff, 0.0, 1.0 );
}
float GetTiltShiftMultiplier(vec2 inTexCoord, float inFocusBarHeight, float inFocusWidth )
{
- //For now, you can't rotate the focus blur but in time you will be able to.
- float texPos = inTexCoord.y;
- float focusDiff = max( 0.0, abs( texPos - inFocusBarHeight ) - (inFocusWidth/2.0) ) / inFocusWidth;
- return clamp( focusDiff, 0.0, 1.0 );
+ //For now, you can't rotate the focus blur but in time you will be able to.
+ float texPos = inTexCoord.y;
+ float focusDiff = max( 0.0, abs( texPos - inFocusBarHeight ) - (inFocusWidth/2.0) ) / inFocusWidth;
+ return clamp( focusDiff, 0.0, 1.0 );
}
#ifdef VERTEX_SHADER
@@ -87,43 +87,43 @@ float GetTiltShiftMultiplier(vec2 inTexCoord, float inFocusBarHeight, float inFo
void SetupBoxBlurCoords(vec2 inTexInfo)
{
xIncrement = .5 / inTexInfo.x;
- yIncrement = .5 / inTexInfo.y;
- TexCoord0 = vec2( TexCoord.x + xIncrement, TexCoord.y + yIncrement );
- TexCoord1 = vec2( TexCoord.x - xIncrement, TexCoord.y - yIncrement );
- TexCoord2 = vec2( TexCoord.x - xIncrement, TexCoord.y + yIncrement );
- TexCoord3 = vec2( TexCoord.x + xIncrement, TexCoord.y - yIncrement );
+ yIncrement = .5 / inTexInfo.y;
+ TexCoord0 = vec2( TexCoord.x + xIncrement, TexCoord.y + yIncrement );
+ TexCoord1 = vec2( TexCoord.x - xIncrement, TexCoord.y - yIncrement );
+ TexCoord2 = vec2( TexCoord.x - xIncrement, TexCoord.y + yIncrement );
+ TexCoord3 = vec2( TexCoord.x + xIncrement, TexCoord.y - yIncrement );
}
void SetupPoissonBlurCoords(float inBlurAmount, vec2 inTexInfo )
{
- float incX = inBlurAmount / inTexInfo.x;
- float incY = inBlurAmount / inTexInfo.y;
- TexCoord0 = vec2( TexCoord.x + poisson0.x * incX, TexCoord.y + poisson0.y * incY );
- TexCoord1 = vec2( TexCoord.x + poisson1.x * incX, TexCoord.y + poisson1.y * incY );
- TexCoord2 = vec2( TexCoord.x + poisson2.x * incX, TexCoord.y + poisson2.y * incY );
- TexCoord3 = vec2( TexCoord.x + poisson3.x * incX, TexCoord.y + poisson3.y * incY );
- TexCoord4 = vec2( TexCoord.x + poisson4.x * incX, TexCoord.y + poisson4.y * incY );
- TexCoord5 = vec2( TexCoord.x + poisson5.x * incX, TexCoord.y + poisson5.y * incY );
- TexCoord6 = vec2( TexCoord.x + poisson6.x * incX, TexCoord.y + poisson6.y * incY );
- TexCoord7 = vec2( TexCoord.x + poisson7.x * incX, TexCoord.y + poisson7.y * incY );
+ float incX = inBlurAmount / inTexInfo.x;
+ float incY = inBlurAmount / inTexInfo.y;
+ TexCoord0 = vec2( TexCoord.x + poisson0.x * incX, TexCoord.y + poisson0.y * incY );
+ TexCoord1 = vec2( TexCoord.x + poisson1.x * incX, TexCoord.y + poisson1.y * incY );
+ TexCoord2 = vec2( TexCoord.x + poisson2.x * incX, TexCoord.y + poisson2.y * incY );
+ TexCoord3 = vec2( TexCoord.x + poisson3.x * incX, TexCoord.y + poisson3.y * incY );
+ TexCoord4 = vec2( TexCoord.x + poisson4.x * incX, TexCoord.y + poisson4.y * incY );
+ TexCoord5 = vec2( TexCoord.x + poisson5.x * incX, TexCoord.y + poisson5.y * incY );
+ TexCoord6 = vec2( TexCoord.x + poisson6.x * incX, TexCoord.y + poisson6.y * incY );
+ TexCoord7 = vec2( TexCoord.x + poisson7.x * incX, TexCoord.y + poisson7.y * incY );
}
void SetupHorizontalGaussianBlur( float inDestWidth, float inBlurAmount, vec2 inTexCoord )
{
- float increment = inBlurAmount/inDestWidth;
- TexCoord0 = vec2(inTexCoord.x + increment , inTexCoord.y );
- TexCoord1 = vec2(inTexCoord.x + increment * 2.0 , inTexCoord.y);
- TexCoord2 = vec2(inTexCoord.x + increment * 3.0 , inTexCoord.y);
- TexCoord3 = vec2(inTexCoord.x , inTexCoord.y);
- TexCoord4 = vec2(inTexCoord.x - increment , inTexCoord.y);
- TexCoord5 = vec2(inTexCoord.x - increment * 2.0 , inTexCoord.y);
- TexCoord6 = vec2(inTexCoord.x - increment * 3.0 , inTexCoord.y);
+ float increment = inBlurAmount/inDestWidth;
+ TexCoord0 = vec2(inTexCoord.x + increment , inTexCoord.y );
+ TexCoord1 = vec2(inTexCoord.x + increment * 2.0 , inTexCoord.y);
+ TexCoord2 = vec2(inTexCoord.x + increment * 3.0 , inTexCoord.y);
+ TexCoord3 = vec2(inTexCoord.x , inTexCoord.y);
+ TexCoord4 = vec2(inTexCoord.x - increment , inTexCoord.y);
+ TexCoord5 = vec2(inTexCoord.x - increment * 2.0 , inTexCoord.y);
+ TexCoord6 = vec2(inTexCoord.x - increment * 3.0 , inTexCoord.y);
}
void SetupVerticalGaussianBlur( float inDestHeight, float inBlurAmount, vec2 inTexCoord )
{
- float increment = inBlurAmount/inDestHeight;
- TexCoord0 = vec2(inTexCoord.x, inTexCoord.y + increment );
+ float increment = inBlurAmount/inDestHeight;
+ TexCoord0 = vec2(inTexCoord.x, inTexCoord.y + increment );
TexCoord1 = vec2(inTexCoord.x, inTexCoord.y + increment * 2.0 );
TexCoord2 = vec2(inTexCoord.x, inTexCoord.y + increment * 3.0);
TexCoord3 = vec2(inTexCoord.x, inTexCoord.y);
@@ -134,16 +134,16 @@ void SetupVerticalGaussianBlur( float inDestHeight, float inBlurAmount, vec2 inT
void SetupHorizontalGaussianBlur3Tap( float inDestWidth, float inBlurAmount, vec2 inTexCoord )
{
- float increment = inBlurAmount/inDestWidth;
- TexCoord0 = vec2(inTexCoord.x + increment , inTexCoord.y );
- TexCoord1 = vec2(inTexCoord.x , inTexCoord.y);
- TexCoord2 = vec2(inTexCoord.x - increment , inTexCoord.y);
+ float increment = inBlurAmount/inDestWidth;
+ TexCoord0 = vec2(inTexCoord.x + increment , inTexCoord.y );
+ TexCoord1 = vec2(inTexCoord.x , inTexCoord.y);
+ TexCoord2 = vec2(inTexCoord.x - increment , inTexCoord.y);
}
void SetupVerticalGaussianBlur3Tap( float inDestHeight, float inBlurAmount, vec2 inTexCoord )
{
- float increment = inBlurAmount/inDestHeight;
- TexCoord0 = vec2(inTexCoord.x, inTexCoord.y + increment );
+ float increment = inBlurAmount/inDestHeight;
+ TexCoord0 = vec2(inTexCoord.x, inTexCoord.y + increment );
TexCoord1 = vec2(inTexCoord.x, inTexCoord.y);
TexCoord2 = vec2(inTexCoord.x, inTexCoord.y - increment);
}
@@ -153,75 +153,75 @@ void SetupVerticalGaussianBlur3Tap( float inDestHeight, float inBlurAmount, vec2
#ifdef FRAGMENT_SHADER
vec4 BoxDepthBlur(sampler2D inDepthSampler, sampler2D inBlurSampler, float inBlurSamplerAlphaFlag
- , float inFocusDistance, float inFocusWidth, float inFocusPenumbra )
+ , float inFocusDistance, float inFocusWidth, float inFocusPenumbra )
{
- float mult0 = .25 * GetDepthMultiplier( TexCoord0, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
- float mult1 = .25 * GetDepthMultiplier( TexCoord1, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
- float mult2 = .25 * GetDepthMultiplier( TexCoord2, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
- float mult3 = .25 * GetDepthMultiplier( TexCoord3, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
- float multTotal = mult0 + mult1 + mult2 + mult3;
- float totalDivisor = multTotal != 0.0 ? 1.0 / multTotal : 0.0;
- vec4 OutCol = GetTextureValue(inBlurSampler, TexCoord0, inBlurSamplerAlphaFlag) * mult0;
- OutCol += GetTextureValue(inBlurSampler, TexCoord1, inBlurSamplerAlphaFlag) * mult1;
- OutCol += GetTextureValue(inBlurSampler, TexCoord2, inBlurSamplerAlphaFlag) * mult2;
- OutCol += GetTextureValue(inBlurSampler, TexCoord3, inBlurSamplerAlphaFlag) * mult3;
- return OutCol * totalDivisor;
+ float mult0 = .25 * GetDepthMultiplier( TexCoord0, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
+ float mult1 = .25 * GetDepthMultiplier( TexCoord1, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
+ float mult2 = .25 * GetDepthMultiplier( TexCoord2, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
+ float mult3 = .25 * GetDepthMultiplier( TexCoord3, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra );
+ float multTotal = mult0 + mult1 + mult2 + mult3;
+ float totalDivisor = multTotal != 0.0 ? 1.0 / multTotal : 0.0;
+ vec4 OutCol = GetTextureValue(inBlurSampler, TexCoord0, inBlurSamplerAlphaFlag) * mult0;
+ OutCol += GetTextureValue(inBlurSampler, TexCoord1, inBlurSamplerAlphaFlag) * mult1;
+ OutCol += GetTextureValue(inBlurSampler, TexCoord2, inBlurSamplerAlphaFlag) * mult2;
+ OutCol += GetTextureValue(inBlurSampler, TexCoord3, inBlurSamplerAlphaFlag) * mult3;
+ return OutCol * totalDivisor;
}
vec4 BoxTiltShiftBlur( sampler2D inBlurSampler, float inBlurSamplerAlphaFlag
- , float inFocusBarHeight, float inFocusWidth )
+ , float inFocusBarHeight, float inFocusWidth )
{
- float mult0 = .25 * GetTiltShiftMultiplier( TexCoord0, inFocusBarHeight, inFocusWidth );
- float mult1 = .25 * GetTiltShiftMultiplier( TexCoord1, inFocusBarHeight, inFocusWidth );
- float mult2 = .25 * GetTiltShiftMultiplier( TexCoord2, inFocusBarHeight, inFocusWidth );
- float mult3 = .25 * GetTiltShiftMultiplier( TexCoord3, inFocusBarHeight, inFocusWidth );
- float multTotal = mult0 + mult1 + mult2 + mult3;
- float totalDivisor = multTotal != 0.0 ? 1.0 / multTotal : 0.0;
- vec4 OutCol = GetTextureValuePreMult(inBlurSampler, TexCoord0) * mult0;
- OutCol += GetTextureValuePreMult(inBlurSampler, TexCoord1) * mult1;
- OutCol += GetTextureValuePreMult(inBlurSampler, TexCoord2) * mult2;
- OutCol += GetTextureValuePreMult(inBlurSampler, TexCoord3) * mult3;
- return OutCol * totalDivisor;
+ float mult0 = .25 * GetTiltShiftMultiplier( TexCoord0, inFocusBarHeight, inFocusWidth );
+ float mult1 = .25 * GetTiltShiftMultiplier( TexCoord1, inFocusBarHeight, inFocusWidth );
+ float mult2 = .25 * GetTiltShiftMultiplier( TexCoord2, inFocusBarHeight, inFocusWidth );
+ float mult3 = .25 * GetTiltShiftMultiplier( TexCoord3, inFocusBarHeight, inFocusWidth );
+ float multTotal = mult0 + mult1 + mult2 + mult3;
+ float totalDivisor = multTotal != 0.0 ? 1.0 / multTotal : 0.0;
+ vec4 OutCol = GetTextureValuePreMult(inBlurSampler, TexCoord0) * mult0;
+ OutCol += GetTextureValuePreMult(inBlurSampler, TexCoord1) * mult1;
+ OutCol += GetTextureValuePreMult(inBlurSampler, TexCoord2) * mult2;
+ OutCol += GetTextureValuePreMult(inBlurSampler, TexCoord3) * mult3;
+ return OutCol * totalDivisor;
}
vec4 PoissonDepthBlur(sampler2D inSampler, float inAlphaFlag, sampler2D inDepthSampler
- , float inFocusDistance, float inFocusWidth, float inFocusPenumbra )
+ , float inFocusDistance, float inFocusWidth, float inFocusPenumbra )
{
- float mult0 = (1.0 - poisson0.z) * GetDepthMultiplier(TexCoord0,inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra);
- float mult1 = (1.0 - poisson1.z) * GetDepthMultiplier(TexCoord1,inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra);
- float mult2 = (1.0 - poisson2.z) * GetDepthMultiplier(TexCoord2,inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra);
-
- float multTotal = mult0 + mult1 + mult2;
- float multMultiplier = multTotal > 0.0 ? 1.0 / multTotal : 0.0;
-
- vec4 outColor = GetTextureValue( inSampler, TexCoord0, inAlphaFlag ) * (mult0 * multMultiplier);
- outColor += GetTextureValue( inSampler, TexCoord1, inAlphaFlag ) * (mult1 * multMultiplier);
- outColor += GetTextureValue( inSampler, TexCoord2, inAlphaFlag ) * (mult2 * multMultiplier);
- return outColor;
+ float mult0 = (1.0 - poisson0.z) * GetDepthMultiplier(TexCoord0,inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra);
+ float mult1 = (1.0 - poisson1.z) * GetDepthMultiplier(TexCoord1,inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra);
+ float mult2 = (1.0 - poisson2.z) * GetDepthMultiplier(TexCoord2,inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra);
+
+ float multTotal = mult0 + mult1 + mult2;
+ float multMultiplier = multTotal > 0.0 ? 1.0 / multTotal : 0.0;
+
+ vec4 outColor = GetTextureValue( inSampler, TexCoord0, inAlphaFlag ) * (mult0 * multMultiplier);
+ outColor += GetTextureValue( inSampler, TexCoord1, inAlphaFlag ) * (mult1 * multMultiplier);
+ outColor += GetTextureValue( inSampler, TexCoord2, inAlphaFlag ) * (mult2 * multMultiplier);
+ return outColor;
}
vec4 PoissonTiltShiftBlur(sampler2D inSampler, float inAlphaFlag, float inBarHeight, float inFocusWidth )
{
- float mult0 = (1.0 - poisson0.z) * GetTiltShiftMultiplier(TexCoord0, inBarHeight, inFocusWidth );
- float mult1 = (1.0 - poisson1.z) * GetTiltShiftMultiplier(TexCoord1, inBarHeight, inFocusWidth );
- float mult2 = (1.0 - poisson2.z) * GetTiltShiftMultiplier(TexCoord2, inBarHeight, inFocusWidth );
- float mult3 = (1.0 - poisson3.z) * GetTiltShiftMultiplier(TexCoord3, inBarHeight, inFocusWidth );
- float mult4 = (1.0 - poisson4.z) * GetTiltShiftMultiplier(TexCoord4, inBarHeight, inFocusWidth );
-
- float multTotal = mult0 + mult1 + mult2 + mult3 + mult4;
- float multMultiplier = multTotal > 0.0 ? 1.0 / multTotal : 0.0;
-
- vec4 outColor = GetTextureValuePreMult( inSampler, TexCoord0 ) * (mult0 * multMultiplier);
- outColor += GetTextureValuePreMult( inSampler, TexCoord1 ) * (mult1 * multMultiplier);
- outColor += GetTextureValuePreMult( inSampler, TexCoord2 ) * (mult2 * multMultiplier);
- outColor += GetTextureValuePreMult( inSampler, TexCoord3 ) * (mult3 * multMultiplier);
- outColor += GetTextureValuePreMult( inSampler, TexCoord4 ) * (mult4 * multMultiplier);
- return outColor;
+ float mult0 = (1.0 - poisson0.z) * GetTiltShiftMultiplier(TexCoord0, inBarHeight, inFocusWidth );
+ float mult1 = (1.0 - poisson1.z) * GetTiltShiftMultiplier(TexCoord1, inBarHeight, inFocusWidth );
+ float mult2 = (1.0 - poisson2.z) * GetTiltShiftMultiplier(TexCoord2, inBarHeight, inFocusWidth );
+ float mult3 = (1.0 - poisson3.z) * GetTiltShiftMultiplier(TexCoord3, inBarHeight, inFocusWidth );
+ float mult4 = (1.0 - poisson4.z) * GetTiltShiftMultiplier(TexCoord4, inBarHeight, inFocusWidth );
+
+ float multTotal = mult0 + mult1 + mult2 + mult3 + mult4;
+ float multMultiplier = multTotal > 0.0 ? 1.0 / multTotal : 0.0;
+
+ vec4 outColor = GetTextureValuePreMult( inSampler, TexCoord0 ) * (mult0 * multMultiplier);
+ outColor += GetTextureValuePreMult( inSampler, TexCoord1 ) * (mult1 * multMultiplier);
+ outColor += GetTextureValuePreMult( inSampler, TexCoord2 ) * (mult2 * multMultiplier);
+ outColor += GetTextureValuePreMult( inSampler, TexCoord3 ) * (mult3 * multMultiplier);
+ outColor += GetTextureValuePreMult( inSampler, TexCoord4 ) * (mult4 * multMultiplier);
+ return outColor;
}
float GaussianAlphaBlur( sampler2D inSampler, float inAlphaFlag )
{
- float OutCol = 0.0;
+ float OutCol = 0.0;
OutCol += GetTextureValue(inSampler, TexCoord0, inAlphaFlag).a * ( WT7_1/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord1, inAlphaFlag).a * ( WT7_2/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord2, inAlphaFlag).a * ( WT7_3/WT7_NORMALIZE );
@@ -229,12 +229,12 @@ float GaussianAlphaBlur( sampler2D inSampler, float inAlphaFlag )
OutCol += GetTextureValue(inSampler, TexCoord4, inAlphaFlag).a * ( WT7_1/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord5, inAlphaFlag).a * ( WT7_2/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord6, inAlphaFlag).a * ( WT7_3/WT7_NORMALIZE );
- return OutCol;
+ return OutCol;
}
vec4 GaussianBlur( sampler2D inSampler, float inAlphaFlag )
{
- vec4 OutCol = vec4(0.0);
+ vec4 OutCol = vec4(0.0);
OutCol += GetTextureValue(inSampler, TexCoord0, inAlphaFlag) * ( WT7_1/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord1, inAlphaFlag) * ( WT7_2/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord2, inAlphaFlag) * ( WT7_3/WT7_NORMALIZE );
@@ -242,42 +242,42 @@ vec4 GaussianBlur( sampler2D inSampler, float inAlphaFlag )
OutCol += GetTextureValue(inSampler, TexCoord4, inAlphaFlag) * ( WT7_1/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord5, inAlphaFlag) * ( WT7_2/WT7_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord6, inAlphaFlag) * ( WT7_3/WT7_NORMALIZE );
- return OutCol;
+ return OutCol;
}
vec4 GaussianBlur3Tap( sampler2D inSampler, float inAlphaFlag )
{
- vec4 OutCol = vec4(0.0);
+ vec4 OutCol = vec4(0.0);
OutCol += GetTextureValue(inSampler, TexCoord0, inAlphaFlag) * ( WT3_1/WT3_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord1, inAlphaFlag) * ( WT3_0/WT3_NORMALIZE );
OutCol += GetTextureValue(inSampler, TexCoord2, inAlphaFlag) * ( WT3_1/WT3_NORMALIZE );
- return OutCol;
+ return OutCol;
}
//Get texture data for a texture we know is premultiplied.
vec4 GaussianBlur3TapPremultiplied( sampler2D inSampler )
{
- vec4 OutCol = vec4(0.0);
+ vec4 OutCol = vec4(0.0);
OutCol += texture2D(inSampler, TexCoord0) * ( WT3_1/WT3_NORMALIZE );
OutCol += texture2D(inSampler, TexCoord1) * ( WT3_0/WT3_NORMALIZE );
OutCol += texture2D(inSampler, TexCoord2) * ( WT3_1/WT3_NORMALIZE );
- return OutCol;
+ return OutCol;
}
vec4 GaussianDepthBlur( sampler2D inSampler, float inTextureAlphaInfo, sampler2D inDepthSampler
- , float inFocusDistance, float inFocusWidth, float inFocusPenumbra )
+ , float inFocusDistance, float inFocusWidth, float inFocusPenumbra )
{
- //We modulate each sample weight by the depth value so that we minimize bleeding of the focused
- //area into the non-focused area.
- float mult0 = GetDepthMultiplier(TexCoord0, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_1;
- float mult1 = GetDepthMultiplier(TexCoord1, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_2;
- float mult2 = GetDepthMultiplier(TexCoord2, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_3;
- float mult3 = GetDepthMultiplier(TexCoord3, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_0;
- float mult4 = GetDepthMultiplier(TexCoord4, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_1;
- float mult5 = GetDepthMultiplier(TexCoord5, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_2;
- float mult6 = GetDepthMultiplier(TexCoord6, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_3;
- float multTotal = mult0 + mult1 + mult2 + mult3 + mult4 + mult5 + mult6;
- float multMultiplier = multTotal > 0.0 ? 1.0 / multTotal : 0.0;
+ //We modulate each sample weight by the depth value so that we minimize bleeding of the focused
+ //area into the non-focused area.
+ float mult0 = GetDepthMultiplier(TexCoord0, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_1;
+ float mult1 = GetDepthMultiplier(TexCoord1, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_2;
+ float mult2 = GetDepthMultiplier(TexCoord2, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_3;
+ float mult3 = GetDepthMultiplier(TexCoord3, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_0;
+ float mult4 = GetDepthMultiplier(TexCoord4, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_1;
+ float mult5 = GetDepthMultiplier(TexCoord5, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_2;
+ float mult6 = GetDepthMultiplier(TexCoord6, inDepthSampler, inFocusDistance, inFocusWidth, inFocusPenumbra) * WT7_3;
+ float multTotal = mult0 + mult1 + mult2 + mult3 + mult4 + mult5 + mult6;
+ float multMultiplier = multTotal > 0.0 ? 1.0 / multTotal : 0.0;
vec4 OutCol = vec4(0.0);
OutCol += GetTextureValue(inSampler, TexCoord0, inTextureAlphaInfo) * (mult0 * multMultiplier);
OutCol += GetTextureValue(inSampler, TexCoord1, inTextureAlphaInfo) * (mult1 * multMultiplier);
@@ -286,7 +286,7 @@ vec4 GaussianDepthBlur( sampler2D inSampler, float inTextureAlphaInfo, sampler2D
OutCol += GetTextureValue(inSampler, TexCoord4, inTextureAlphaInfo) * (mult4 * multMultiplier);
OutCol += GetTextureValue(inSampler, TexCoord5, inTextureAlphaInfo) * (mult5 * multMultiplier);
OutCol += GetTextureValue(inSampler, TexCoord6, inTextureAlphaInfo) * (mult6 * multMultiplier);
- return OutCol;
+ return OutCol;
}
#endif
diff --git a/src/Runtime/res/effectlib/customCurveLayer.glsllib b/src/Runtime/res/effectlib/customCurveLayer.glsllib
index 87c1def8..2bc1780e 100644
--- a/src/Runtime/res/effectlib/customCurveLayer.glsllib
+++ b/src/Runtime/res/effectlib/customCurveLayer.glsllib
@@ -33,10 +33,10 @@ vec4 customCurveLayer( in vec3 L, in float normal_reflectivity, in float grazing
vec3 H = normalize( viewDir + L );
vec3 refl = reflect( -viewDir, H );
float reflWt = clamp( dot( surfNormal, refl ) + 1.0, 0.0, 1.0 );
-
+
float curveFactor = mix( normal_reflectivity, grazing_reflectivity, pow(1.0 - abs(dot( viewDir, H )), exponent) );
curveFactor *= weight * reflWt;
-
+
return( vec4( mix( base.rgb, layercolor * layer.rgb, curveFactor ), mix(alpha, 1.0, curveFactor) ) );
}
diff --git a/src/Runtime/res/effectlib/customMaterialFragBody.glsllib b/src/Runtime/res/effectlib/customMaterialFragBody.glsllib
index 0de59261..d237bc02 100644
--- a/src/Runtime/res/effectlib/customMaterialFragBody.glsllib
+++ b/src/Runtime/res/effectlib/customMaterialFragBody.glsllib
@@ -52,25 +52,25 @@
}
vec4 rgba = vec4( materialEmissive, 0.0f );
-
+
vec3 lightAmbient, lightDiffuse, lightSpecular, L;
for ( int i=0 ; i<uNumLights ; i++ )
{
sampleLight( lights[i], varWorldPos, L, lightAmbient, lightDiffuse, lightSpecular);
//evalTemporariesPerLightSource( normal, L, lightDiffuse, lightSpecular, materialIOR );
- if (gl_FrontFacing)
+ if (gl_FrontFacing)
computeFrontLayerColor( normal, L, viewDir, lightDiffuse, lightSpecular, materialIOR, 1.0 );
else
- computeBackLayerColor( normal, L, viewDir, lightDiffuse, lightSpecular, materialIOR, 1.0 );
+ computeBackLayerColor( normal, L, viewDir, lightDiffuse, lightSpecular, materialIOR, 1.0 );
}
for ( int i=0 ; i < uNumAreaLights; ++i )
{
if (gl_FrontFacing)
computeFrontAreaColor( i, arealights[i].diffuse, arealights[i].specular );
else
- computeBackAreaColor( i, arealights[i].diffuse, arealights[i].specular );
+ computeBackAreaColor( i, arealights[i].diffuse, arealights[i].specular );
}
-
+
if ( 0.0f < alpha )
{
if (gl_FrontFacing)
diff --git a/src/Runtime/res/effectlib/customMaterialFragBodyAO.glsllib b/src/Runtime/res/effectlib/customMaterialFragBodyAO.glsllib
index 08b2c788..19302191 100644
--- a/src/Runtime/res/effectlib/customMaterialFragBodyAO.glsllib
+++ b/src/Runtime/res/effectlib/customMaterialFragBodyAO.glsllib
@@ -55,28 +55,28 @@
// compute ambient occlusion
float aoFactor = customMaterialAO( );
-
- vec3 lightAmbient, lightDiffuse, lightSpecular, L;
+
+ vec3 lightAmbient, lightDiffuse, lightSpecular, L;
for ( int i=0 ; i<uNumLights ; i++ )
{
sampleLight( lights[i], varWorldPos, L, lightAmbient, lightDiffuse, lightSpecular);
lightAmbient *= aoFactor;
lightDiffuse *= aoFactor;
-
+
//evalTemporariesPerLightSource( normal, L, lightDiffuse, lightSpecular, materialIOR );
- if (gl_FrontFacing)
+ if (gl_FrontFacing)
computeFrontLayerColor( normal, L, viewDir, lightDiffuse, lightSpecular, materialIOR, aoFactor );
else
- computeBackLayerColor( normal, L, viewDir, lightDiffuse, lightSpecular, materialIOR, aoFactor );
+ computeBackLayerColor( normal, L, viewDir, lightDiffuse, lightSpecular, materialIOR, aoFactor );
}
for ( int i=0 ; i < uNumAreaLights; ++i )
{
if (gl_FrontFacing)
computeFrontAreaColor( i, arealights[i].diffuse, arealights[i].specular );
else
- computeBackAreaColor( i, arealights[i].diffuse, arealights[i].specular );
- }
-
+ computeBackAreaColor( i, arealights[i].diffuse, arealights[i].specular );
+ }
+
if ( 0.0f < alpha )
{
if (gl_FrontFacing)
@@ -86,5 +86,5 @@
}
rgba += computeLayerWeights( alpha );
-
+
#endif
diff --git a/src/Runtime/res/effectlib/defaultMaterialFresnel.glsllib b/src/Runtime/res/effectlib/defaultMaterialFresnel.glsllib
index d7e9fa15..303a55b1 100644
--- a/src/Runtime/res/effectlib/defaultMaterialFresnel.glsllib
+++ b/src/Runtime/res/effectlib/defaultMaterialFresnel.glsllib
@@ -38,8 +38,8 @@ float defaultMaterialSimpleFresnel( in vec3 N, in vec3 viewDir, in float ior, fl
float dvn = abs( dFdx(VdotN) * dFdy(VdotN) );
VdotN = clamp( VdotN, 0.0, 1.0 );
float ratio = F + (1.0 - F) * pow(1.0 - VdotN, fresnelPower);
-
+
return clamp( ratio * pow( VdotN, dvn * fresnelPower ), 0.0, 1.0 );
}
-#endif \ No newline at end of file
+#endif
diff --git a/src/Runtime/res/effectlib/defaultMaterialLighting.glsllib b/src/Runtime/res/effectlib/defaultMaterialLighting.glsllib
index 1097c766..e96a4509 100644
--- a/src/Runtime/res/effectlib/defaultMaterialLighting.glsllib
+++ b/src/Runtime/res/effectlib/defaultMaterialLighting.glsllib
@@ -1,5 +1,5 @@
/**
- * UICViewer lighting equation implementations
+ * UICViewer lighting equation implementations
*/
#ifndef DEFAULT_MATERIAL_LIGHTING
@@ -14,67 +14,67 @@
vec2 calculateLightParameters( vec3 lightDir, vec3 normalDir )
{
- vec2 retval;
- retval.x = max( 0.0, -1.0 * dot( lightDir, normalDir ) ); //diffuseIntensity
- retval.y = clamp( retval.x * 4.0, 0.0, 1.0 ); //selfShadowTerm
- return retval;
+ vec2 retval;
+ retval.x = max( 0.0, -1.0 * dot( lightDir, normalDir ) ); //diffuseIntensity
+ retval.y = clamp( retval.x * 4.0, 0.0, 1.0 ); //selfShadowTerm
+ return retval;
}
vec2 calculateWrapLightParameters( vec3 lightDir, vec3 normalDir, float wrap )
{
- vec2 retval;
- retval.x = max( 0.0, -1.0 * ((dot(lightDir, normalDir) + wrap)/ (1.0 + wrap)) ); //diffuseIntensity
- retval.y = clamp( retval.x, 0.0, 1.0 ); //selfShadowTerm
- return retval;
+ vec2 retval;
+ retval.x = max( 0.0, -1.0 * ((dot(lightDir, normalDir) + wrap)/ (1.0 + wrap)) ); //diffuseIntensity
+ retval.y = clamp( retval.x, 0.0, 1.0 ); //selfShadowTerm
+ return retval;
}
vec3 calculateDirectionalAddition( vec3 lightColor, vec2 lightParameters ) {
- return ( lightColor * lightParameters.x * lightParameters.y );
+ return ( lightColor * lightParameters.x * lightParameters.y );
}
vec3 calculateSpecularAddition( vec3 lightDir, vec3 normalDir, vec3 viewVec, vec3 lightSpecularColor, float specularAmount
- , float specularRoughness, vec2 lightParameters )
+ , float specularRoughness, vec2 lightParameters )
{
- vec3 reflection = normalize( 2.0 * lightParameters.x * normalDir + lightDir );
- return ( lightParameters.y * specularAmount * lightSpecularColor * pow( clamp( dot( reflection, viewVec ), 0.0, 1.0 ), specularRoughness ) );
+ vec3 reflection = normalize( 2.0 * lightParameters.x * normalDir + lightDir );
+ return ( lightParameters.y * specularAmount * lightSpecularColor * pow( clamp( dot( reflection, viewVec ), 0.0, 1.0 ), specularRoughness ) );
}
float calculateDiffuseAreaFactors( in vec3 lightDir, in vec3 lightPos, in vec4 lightUp, in vec4 lightRt, in vec3 worldPos, out vec3 outDir )
{
- vec3 v0 = lightPos - (lightRt.xyz * lightRt.w * 0.5) - (lightUp.xyz * lightUp.w * 0.5);
- vec3 v1 = lightPos - (lightRt.xyz * lightRt.w * 0.5) + (lightUp.xyz * lightUp.w * 0.5);
- vec3 v2 = lightPos + (lightRt.xyz * lightRt.w * 0.5) + (lightUp.xyz * lightUp.w * 0.5);
- vec3 v3 = lightPos + (lightRt.xyz * lightRt.w * 0.5) - (lightUp.xyz * lightUp.w * 0.5);
- v0 = normalize( v0 - worldPos ); v1 = normalize( v1 - worldPos );
- v2 = normalize( v2 - worldPos ); v3 = normalize( v3 - worldPos );
- float a01 = acos( clamp( dot(v0, v1), -1.0, 1.0 ) );
- float a12 = acos( clamp( dot(v1, v2), -1.0, 1.0 ) );
- float a23 = acos( clamp( dot(v2, v3), -1.0, 1.0 ) );
- float a30 = acos( clamp( dot(v3, v0), -1.0, 1.0 ) );
- outDir = vec3( 0.0 );
- outDir -= normalize(cross( v0, v1 )) * a01;
- outDir -= normalize(cross( v1, v2 )) * a12;
- outDir -= normalize(cross( v2, v3 )) * a23;
- outDir -= normalize(cross( v3, v0 )) * a30;
- float retVal = length(outDir) * 0.15915494309; // solid angle / 2*pi
- outDir = -normalize(outDir);
- retVal *= clamp( dot( worldPos-lightPos, lightDir), 0.0, 1.0 );
- return retVal;
+ vec3 v0 = lightPos - (lightRt.xyz * lightRt.w * 0.5) - (lightUp.xyz * lightUp.w * 0.5);
+ vec3 v1 = lightPos - (lightRt.xyz * lightRt.w * 0.5) + (lightUp.xyz * lightUp.w * 0.5);
+ vec3 v2 = lightPos + (lightRt.xyz * lightRt.w * 0.5) + (lightUp.xyz * lightUp.w * 0.5);
+ vec3 v3 = lightPos + (lightRt.xyz * lightRt.w * 0.5) - (lightUp.xyz * lightUp.w * 0.5);
+ v0 = normalize( v0 - worldPos ); v1 = normalize( v1 - worldPos );
+ v2 = normalize( v2 - worldPos ); v3 = normalize( v3 - worldPos );
+ float a01 = acos( clamp( dot(v0, v1), -1.0, 1.0 ) );
+ float a12 = acos( clamp( dot(v1, v2), -1.0, 1.0 ) );
+ float a23 = acos( clamp( dot(v2, v3), -1.0, 1.0 ) );
+ float a30 = acos( clamp( dot(v3, v0), -1.0, 1.0 ) );
+ outDir = vec3( 0.0 );
+ outDir -= normalize(cross( v0, v1 )) * a01;
+ outDir -= normalize(cross( v1, v2 )) * a12;
+ outDir -= normalize(cross( v2, v3 )) * a23;
+ outDir -= normalize(cross( v3, v0 )) * a30;
+ float retVal = length(outDir) * 0.15915494309; // solid angle / 2*pi
+ outDir = -normalize(outDir);
+ retVal *= clamp( dot( worldPos-lightPos, lightDir), 0.0, 1.0 );
+ return retVal;
}
vec3 calculateSpecDirection( in vec3 lightDir, in vec3 lightPos, in vec4 lightUp, in vec4 lightRt, in vec3 worldPos, in vec3 worldNorm, in vec3 viewDir )
{
- vec3 reflDir = reflect(viewDir, worldNorm);
- vec3 ldir = normalize( lightPos - worldPos );
- if ( dot( ldir, lightDir ) > 0.0 ) { return vec3(0.0001); }
- float t = (dot(lightDir, worldPos) - dot(lightDir, lightPos)) / dot(lightDir, reflDir);
- if ( t < 0.0 ) { return vec3(0.0001); }
- vec3 xsectPos = worldPos - t * reflDir;
- float tx = dot( xsectPos - lightPos, lightRt.xyz );
- float ty = dot( xsectPos - lightPos, lightUp.xyz );
- tx = clamp(tx, -lightRt.w*0.5, lightRt.w*0.5);
- ty = clamp(ty, -lightUp.w*0.5, lightUp.w*0.5);
- xsectPos = lightPos + lightUp.xyz * ty + lightRt.xyz * tx;
- return normalize( worldPos - xsectPos );
+ vec3 reflDir = reflect(viewDir, worldNorm);
+ vec3 ldir = normalize( lightPos - worldPos );
+ if ( dot( ldir, lightDir ) > 0.0 ) { return vec3(0.0001); }
+ float t = (dot(lightDir, worldPos) - dot(lightDir, lightPos)) / dot(lightDir, reflDir);
+ if ( t < 0.0 ) { return vec3(0.0001); }
+ vec3 xsectPos = worldPos - t * reflDir;
+ float tx = dot( xsectPos - lightPos, lightRt.xyz );
+ float ty = dot( xsectPos - lightPos, lightUp.xyz );
+ tx = clamp(tx, -lightRt.w*0.5, lightRt.w*0.5);
+ ty = clamp(ty, -lightUp.w*0.5, lightUp.w*0.5);
+ xsectPos = lightPos + lightUp.xyz * ty + lightRt.xyz * tx;
+ return normalize( worldPos - xsectPos );
}
#endif
diff --git a/src/Runtime/res/effectlib/depthpass.glsllib b/src/Runtime/res/effectlib/depthpass.glsllib
index 59849701..cbd45c24 100644
--- a/src/Runtime/res/effectlib/depthpass.glsllib
+++ b/src/Runtime/res/effectlib/depthpass.glsllib
@@ -33,8 +33,8 @@
float calculateVertexDepth( vec2 camera_properties, vec4 position )
{
- float camera_range = camera_properties.y - camera_properties.x;
- return 1.0 - ((position.w - camera_properties.x) / (camera_range));
+ float camera_range = camera_properties.y - camera_properties.x;
+ return 1.0 - ((position.w - camera_properties.x) / (camera_range));
}
#if __VERSION__ <= 120
@@ -47,34 +47,34 @@ float modf(in float val, out float integer)
vec4 outputDepth( float vert_depth )
{
- float integer_portion = 0.0;
- float fraction = modf((vert_depth * 255.0), integer_portion);
- return vec4( integer_portion / 255.0, fraction, 0, 1.0 );
+ float integer_portion = 0.0;
+ float fraction = modf((vert_depth * 255.0), integer_portion);
+ return vec4( integer_portion / 255.0, fraction, 0, 1.0 );
}
float getDepthValue( vec4 depth_texture_sample, vec2 camera_properties )
{
#if __VERSION__ >= 300
- float zNear = camera_properties.x;
- float zFar = camera_properties.y;
- float zRange = zFar - zNear;
- float z_b = depth_texture_sample.x;
- float z_n = 2.0 * z_b - 1.0;
+ float zNear = camera_properties.x;
+ float zFar = camera_properties.y;
+ float zRange = zFar - zNear;
+ float z_b = depth_texture_sample.x;
+ float z_n = 2.0 * z_b - 1.0;
float z_e = 2.0 * zNear * zFar / (zFar + zNear - z_n * (zRange));
- return 1.0 - ((z_e - camera_properties.x) / (zRange));
+ return 1.0 - ((z_e - camera_properties.x) / (zRange));
#else
- return depth_texture_sample.x + (depth_texture_sample.y / 255.0);
+ return depth_texture_sample.x + (depth_texture_sample.y / 255.0);
#endif
}
float depthValueToLinearDistance( float depth_value, vec2 camera_properties )
{
- float FarClipDistance = camera_properties.y;
- float NearClipDistance = camera_properties.x;
- float DepthRange = FarClipDistance - NearClipDistance;
- float linearDepth = NearClipDistance + (DepthRange * (1.0 - depth_value));
- return linearDepth;
+ float FarClipDistance = camera_properties.y;
+ float NearClipDistance = camera_properties.x;
+ float DepthRange = FarClipDistance - NearClipDistance;
+ float linearDepth = NearClipDistance + (DepthRange * (1.0 - depth_value));
+ return linearDepth;
}
#endif
diff --git a/src/Runtime/res/effectlib/diffuseReflectionBSDF.glsllib b/src/Runtime/res/effectlib/diffuseReflectionBSDF.glsllib
index 0f4aaed2..9a66aef1 100644
--- a/src/Runtime/res/effectlib/diffuseReflectionBSDF.glsllib
+++ b/src/Runtime/res/effectlib/diffuseReflectionBSDF.glsllib
@@ -48,7 +48,7 @@ vec4 diffuseReflectionBSDFEnvironment( in vec3 N, in float roughness )
// RNM radiosity normal maps
vec4 diffuseRNM( in vec3 N, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ )
{
- // we use a fixed basis like Half Life
+ // we use a fixed basis like Half Life
vec3 B0 = vec3( -0.40825, 0.70711, 0.57735);
vec3 B1 = vec3( -0.40825, -0.70711, 0.57735);
vec3 B2 = vec3( 0.8165, 0.0, 0.57735);
@@ -59,8 +59,8 @@ vec4 diffuseRNM( in vec3 N, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ )
dp.z = clamp( dot ( N , B2 ), 0.0, 1.0);
float sum = 1.0 / dot( dp, vec3(1.0, 1.0, 1.0) );
- vec3 diffuseLight = dp.x * rnmX + dp.y * rnmY + dp.z * rnmZ;
- //vec3 diffuseLight = N.x * rnmX + N.y * rnmY + N.z * rnmZ;
+ vec3 diffuseLight = dp.x * rnmX + dp.y * rnmY + dp.z * rnmZ;
+ //vec3 diffuseLight = N.x * rnmX + N.y * rnmY + N.z * rnmZ;
return (vec4(diffuseLight, 1.0) * sum);
}
diff --git a/src/Runtime/res/effectlib/directionalFactor.glsllib b/src/Runtime/res/effectlib/directionalFactor.glsllib
index da3d310e..78af8839 100644
--- a/src/Runtime/res/effectlib/directionalFactor.glsllib
+++ b/src/Runtime/res/effectlib/directionalFactor.glsllib
@@ -30,13 +30,13 @@
vec4 directionalFactor( in vec3 normal, in vec3 viewDir, in vec3 normal_col, in vec3 grazing_col, in float exponent, in vec4 base )
{
- float f;
+ float f;
- f = clamp(dot(viewDir, normal),0.0, 1.0 );
- f = 1.0 - pow(f, 1.0/exponent);
- vec3 directionalColor = mix( normal_col, grazing_col, f );
+ f = clamp(dot(viewDir, normal),0.0, 1.0 );
+ f = 1.0 - pow(f, 1.0/exponent);
+ vec3 directionalColor = mix( normal_col, grazing_col, f );
- vec4 color = base * vec4(directionalColor, 1.0);
+ vec4 color = base * vec4(directionalColor, 1.0);
- return color;
-} \ No newline at end of file
+ return color;
+}
diff --git a/src/Runtime/res/effectlib/effect.glsllib b/src/Runtime/res/effectlib/effect.glsllib
index c5bfee5a..802a8460 100644
--- a/src/Runtime/res/effectlib/effect.glsllib
+++ b/src/Runtime/res/effectlib/effect.glsllib
@@ -35,14 +35,14 @@
vec4 GetTextureValue( sampler2D sampler, vec2 inUVCoords, float inTextureAlphaInfo )
{
- vec4 c = texture2D(sampler, inUVCoords);
- c.rgb = mix( c.rgb*c.a, c.rgb, inTextureAlphaInfo );
- return c;
+ vec4 c = texture2D(sampler, inUVCoords);
+ c.rgb = mix( c.rgb*c.a, c.rgb, inTextureAlphaInfo );
+ return c;
}
vec4 GetTextureValuePreMult( sampler2D sampler, vec2 inUVCoords )
{
- return texture2D(sampler, inUVCoords);
+ return texture2D(sampler, inUVCoords);
}
#define SNAPPER_TITLE( title )
@@ -53,14 +53,14 @@ vec4 GetTextureValuePreMult( sampler2D sampler, vec2 inUVCoords )
#define SNAPPER_CHECKBOX(propName, propNiceName, defaultValue) uniform float propName;
#define SNAPPER_ENUM_BEGIN(propName, propNiceName, defaultValueAsIndex) uniform int propName;
-#define SNAPPER_ENUM_VALUE(valueNiceName)
+#define SNAPPER_ENUM_VALUE(valueNiceName)
#define SNAPPER_ENUM_END()
#define SNAPPER_POINT2(propName, propNiceName, defaultValue) uniform vec2 propName;
#define SNAPPER_COLOR(propName, propNiceName, defaultValue) uniform vec3 propName;
-#define TEXTURE_LOOKUP_FUNC(name) \
+#define TEXTURE_LOOKUP_FUNC(name) \
//texType = one of: ubyte, ushort, float
@@ -70,7 +70,7 @@ vec4 GetTextureValuePreMult( sampler2D sampler, vec2 inUVCoords )
#define SNAPPER_EXTERNAL_PARAMETER(propName, datatype, rangeMin, rangeMax, propNiceName, defaultValue)
#define SNAPPER_EXTERNAL_ANGLE(propName, propNiceName, defaultValueAsFloat)
-// Provide the ability to render outside a effect boundary.
+// Provide the ability to render outside a effect boundary.
// Total size = The original effect size * Overrendering value
// Overrendering value needs to be >= 1.0
#define SNAPPER_OVERRENDERING(value) const float OverrenderingValue = value;
@@ -94,24 +94,24 @@ uniform vec2 FragColorAlphaSettings; //x > 0.0 premultiply result, y is an alpha
vec4 Transform( mat4 ModelViewProjectionMatrix, vec2 inDestSize, vec4 inVertex )
{
- vec4 temp = ModelViewProjectionMatrix * vec4( inDestSize.x * .5 * inVertex.x, inDestSize.y * .5 * inVertex.y, inVertex.z, inVertex.w );
- return temp;
+ vec4 temp = ModelViewProjectionMatrix * vec4( inDestSize.x * .5 * inVertex.x, inDestSize.y * .5 * inVertex.y, inVertex.z, inVertex.w );
+ return temp;
}
////////////////////////////////////////////////////////////
// provide the texture lookup functions for the default
// texture (Texture0).
-vec4 texture2D_0(vec2 uv)
-{
+vec4 texture2D_0(vec2 uv)
+{
return GetTextureValue( Texture0, uv, Texture0Info.z );
}
#ifdef FRAGMENT_SHADER
////////////////////////////////////////////////////////////
// the functions to set the final frag result.
-void colorOutput(vec4 c)
+void colorOutput(vec4 c)
{
- c *= FragColorAlphaSettings.x;
- gl_FragColor = clamp(c, 0.0, c.a );
+ c *= FragColorAlphaSettings.x;
+ gl_FragColor = clamp(c, 0.0, c.a );
}
#endif
@@ -126,9 +126,9 @@ void colorOutput(vec4 c)
void vert();
void main()
-{
- gl_Position = Transform( ModelViewProjectionMatrix, DestSize, vec4(attr_pos, 1.0) );
- TexCoord = attr_uv;
+{
+ gl_Position = Transform( ModelViewProjectionMatrix, DestSize, vec4(attr_pos, 1.0) );
+ TexCoord = attr_uv;
vert();
}
@@ -138,9 +138,9 @@ void main()
#ifdef FRAGMENT_SHADER
#ifndef NO_FRAG_MAIN
void frag();
-void main()
-{
- frag();
+void main()
+{
+ frag();
}
#endif // NO_FRAG_MAIN
#endif // FRAGMENT_SHADER
diff --git a/src/Runtime/res/effectlib/evalBakedShadowMap.glsllib b/src/Runtime/res/effectlib/evalBakedShadowMap.glsllib
index 8bbe4036..a283d8a8 100644
--- a/src/Runtime/res/effectlib/evalBakedShadowMap.glsllib
+++ b/src/Runtime/res/effectlib/evalBakedShadowMap.glsllib
@@ -30,7 +30,7 @@
vec4 evalBakedShadowMap( in vec3 inCoords )
{
- vec4 shadowCol = (uShadowMappingEnabled) ? texture( uBakedShadowTexture, inCoords.xy ) : vec4( 1.0, 1.0, 1.0, 1.0 );
+ vec4 shadowCol = (uShadowMappingEnabled) ? texture( uBakedShadowTexture, inCoords.xy ) : vec4( 1.0, 1.0, 1.0, 1.0 );
- return shadowCol;
+ return shadowCol;
}
diff --git a/src/Runtime/res/effectlib/evalEnvironmentMap.glsllib b/src/Runtime/res/effectlib/evalEnvironmentMap.glsllib
index df62c3b8..18431c70 100644
--- a/src/Runtime/res/effectlib/evalEnvironmentMap.glsllib
+++ b/src/Runtime/res/effectlib/evalEnvironmentMap.glsllib
@@ -30,26 +30,26 @@
vec3 evalEnvironmentMap( in vec3 R, float roughness )
{
- // convert R to spherical texture coordinates
- vec2 tc = vec2( ( atan( R.x, -R.z ) + PI ) / ( PI_TWO ), acos( -R.y ) / PI );
+ // convert R to spherical texture coordinates
+ vec2 tc = vec2( ( atan( R.x, -R.z ) + PI ) / ( PI_TWO ), acos( -R.y ) / PI );
- vec2 envMapSize = vec2( textureSize( uEnvironmentTexture, 0 ) );
- float envMapLevels = log2( max( envMapSize.x, envMapSize.y ) );
+ vec2 envMapSize = vec2( textureSize( uEnvironmentTexture, 0 ) );
+ float envMapLevels = log2( max( envMapSize.x, envMapSize.y ) );
- // simulate textureQueryLod
- vec2 dx = dFdx( tc * envMapSize.x );
- vec2 dy = dFdy( tc * envMapSize.y );
+ // simulate textureQueryLod
+ vec2 dx = dFdx( tc * envMapSize.x );
+ vec2 dy = dFdy( tc * envMapSize.y );
- float px = dot( dx, dx );
- float py = dot( dy, dy );
+ float px = dot( dx, dx );
+ float py = dot( dy, dy );
- float maxlod = 0.5 * log2( max( px, py ) ); // log2(sqrt()) = 0.5*log2()
- float minlod = 0.5 * log2( min( px, py ) );
+ float maxlod = 0.5 * log2( max( px, py ) ); // log2(sqrt()) = 0.5*log2()
+ float minlod = 0.5 * log2( min( px, py ) );
- //float lod = max(0.0, maxlod - min( maxlod - minlod, envMapLevels ));
- float lod = max(0.0, min( minlod, envMapLevels ));
+ //float lod = max(0.0, maxlod - min( maxlod - minlod, envMapLevels ));
+ float lod = max(0.0, min( minlod, envMapLevels ));
- float roughLevel = mix( lod , envMapLevels, roughness );
+ float roughLevel = mix( lod , envMapLevels, roughness );
- return( textureLod( uEnvironmentTexture, tc, roughLevel ).rgb );
+ return( textureLod( uEnvironmentTexture, tc, roughLevel ).rgb );
}
diff --git a/src/Runtime/res/effectlib/evalLightmaps.glsllib b/src/Runtime/res/effectlib/evalLightmaps.glsllib
index 1486cadc..1a9bc997 100644
--- a/src/Runtime/res/effectlib/evalLightmaps.glsllib
+++ b/src/Runtime/res/effectlib/evalLightmaps.glsllib
@@ -30,27 +30,27 @@
vec4 evalLightmap( in sampler2D sampler, in vec3 inCoords, in vec4 rotScale, in vec3 offset )
{
- vec3 uTransform = vec3(rotScale.x, rotScale.y, offset.x);
- vec3 vTransform = vec3(rotScale.z, rotScale.w, offset.y);
+ vec3 uTransform = vec3(rotScale.x, rotScale.y, offset.x);
+ vec3 vTransform = vec3(rotScale.z, rotScale.w, offset.y);
- vec2 transfCoord = vec2( dot( uTransform, inCoords ), dot( vTransform, inCoords ) );
+ vec2 transfCoord = vec2( dot( uTransform, inCoords ), dot( vTransform, inCoords ) );
- vec4 value = texture( sampler, transfCoord.xy);
+ vec4 value = texture( sampler, transfCoord.xy);
- return value;
+ return value;
}
vec4 evalIndirectLightmap( in sampler2D sampler, in vec3 inCoords, in vec4 rotScale, in vec3 offset )
{
- return evalLightmap( sampler, inCoords, rotScale, offset );
+ return evalLightmap( sampler, inCoords, rotScale, offset );
}
vec4 evalRadiosityLightmap( in sampler2D sampler, in vec3 inCoords, in vec4 rotScale, in vec3 offset )
{
- return evalLightmap( sampler, inCoords, rotScale, offset );
+ return evalLightmap( sampler, inCoords, rotScale, offset );
}
vec4 evalShadowLightmap( in sampler2D sampler, in vec3 inCoords, in vec4 rotScale, in vec3 offset )
{
- return evalLightmap( sampler, inCoords, rotScale, offset );
+ return evalLightmap( sampler, inCoords, rotScale, offset );
} \ No newline at end of file
diff --git a/src/Runtime/res/effectlib/fileBumpTexture.glsllib b/src/Runtime/res/effectlib/fileBumpTexture.glsllib
index fb041d68..0f27fd80 100644
--- a/src/Runtime/res/effectlib/fileBumpTexture.glsllib
+++ b/src/Runtime/res/effectlib/fileBumpTexture.glsllib
@@ -47,59 +47,59 @@
// compute a normal based on a heightfield style bump texture
// example call:
// fileBumpTexture(bump_texture, bump_amount, mono_average
-// , transformCoordinate(
-// rotationTranslationScale(
-// vec3( 0.000000, 0.000000, 0.000000 )
-// , vec3( 0.000000, 0.000000, 0.000000 )
-// , vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) )
-// , textureCoordinateInfo( texCoord0, tangent, binormal ) )
-// , vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 )
-// , wrap_repeat, wrap_repeat, normal );
+// , transformCoordinate(
+// rotationTranslationScale(
+// vec3( 0.000000, 0.000000, 0.000000 )
+// , vec3( 0.000000, 0.000000, 0.000000 )
+// , vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) )
+// , textureCoordinateInfo( texCoord0, tangent, binormal ) )
+// , vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 )
+// , wrap_repeat, wrap_repeat, normal );
vec3 fileBumpTexture( in sampler2D sampler, in float factor, in int bumpSource
- , in texture_coordinate_info uvw
+ , in texture_coordinate_info uvw
, in vec2 cropU, in vec2 cropV
- , in int wrapU, in int wrapV, in vec3 normal )
+ , in int wrapU, in int wrapV, in vec3 normal )
{
- vec2 bumpMapSize = vec2( textureSize( sampler, 0 ) );
- float bumpMapLevels = log2( max( bumpMapSize.x, bumpMapSize.y ) );
- // simulate textureQueryLod
- vec2 dx = dFdx( uvw.position.xy * bumpMapSize.x );
- vec2 dy = dFdy( uvw.position.xy * bumpMapSize.y );
+ vec2 bumpMapSize = vec2( textureSize( sampler, 0 ) );
+ float bumpMapLevels = log2( max( bumpMapSize.x, bumpMapSize.y ) );
+ // simulate textureQueryLod
+ vec2 dx = dFdx( uvw.position.xy * bumpMapSize.x );
+ vec2 dy = dFdy( uvw.position.xy * bumpMapSize.y );
- float px = dot( dx, dx );
- float py = dot( dy, dy );
+ float px = dot( dx, dx );
+ float py = dot( dy, dy );
- float maxlod = 0.5 * log2( max( px, py ) ); // log2(sqrt()) = 0.5*log2()
- float minlod = 0.5 * log2( min( px, py ) );
+ float maxlod = 0.5 * log2( max( px, py ) ); // log2(sqrt()) = 0.5*log2()
+ float minlod = 0.5 * log2( min( px, py ) );
- float lod = max(0.0, min( maxlod, bumpMapLevels ));
+ float lod = max(0.0, min( maxlod, bumpMapLevels ));
- // invert factor
- float invFactor = -factor;
+ // invert factor
+ float invFactor = -factor;
- // currently no lod supported we use 3.3 GL
- //float lod = textureQueryLod( sampler, uvw.position.xy ).x;
- vec2 size = mix( vec2( textureSize( sampler, int( floor( lod ) ) ) ), vec2( textureSize( sampler, int( ceil( lod ) ) ) ), fract( lod ) );
- vec2 unitStep = 1.0f / size;
+ // currently no lod supported we use 3.3 GL
+ //float lod = textureQueryLod( sampler, uvw.position.xy ).x;
+ vec2 size = mix( vec2( textureSize( sampler, int( floor( lod ) ) ) ), vec2( textureSize( sampler, int( ceil( lod ) ) ) ), fract( lod ) );
+ vec2 unitStep = 1.0f / size;
- // Add an inveres scale to keep the original gradient values
- // this makes the bumps a lot smoother.
- // Or we could do it like in iRay and sample always at original size.
- // But this makes me feel better.
- vec2 scale = size / bumpMapSize;
+ // Add an inveres scale to keep the original gradient values
+ // this makes the bumps a lot smoother.
+ // Or we could do it like in iRay and sample always at original size.
+ // But this makes me feel better.
+ vec2 scale = size / bumpMapSize;
- float du = monoChannel( textureLod( sampler, vec2( uvw.position.x + unitStep.x, uvw.position.y ), lod ), bumpSource )
- - monoChannel( textureLod( sampler, vec2( uvw.position.x, uvw.position.y ), lod ), bumpSource );
- float dv = monoChannel( textureLod( sampler, vec2( uvw.position.x, uvw.position.y + unitStep.y ), lod ), bumpSource )
- - monoChannel( textureLod( sampler, vec2( uvw.position.x, uvw.position.y ), lod ), bumpSource );
+ float du = monoChannel( textureLod( sampler, vec2( uvw.position.x + unitStep.x, uvw.position.y ), lod ), bumpSource )
+ - monoChannel( textureLod( sampler, vec2( uvw.position.x, uvw.position.y ), lod ), bumpSource );
+ float dv = monoChannel( textureLod( sampler, vec2( uvw.position.x, uvw.position.y + unitStep.y ), lod ), bumpSource )
+ - monoChannel( textureLod( sampler, vec2( uvw.position.x, uvw.position.y ), lod ), bumpSource );
- vec3 n = normalize(vec3(invFactor * scale.x * du, invFactor * scale.x * dv, 1.0));
- n = n.x*uvw.tangent_u + n.y*uvw.tangent_v + n.z*normal;
- return normalize(normal + n);
+ vec3 n = normalize(vec3(invFactor * scale.x * du, invFactor * scale.x * dv, 1.0));
+ n = n.x*uvw.tangent_u + n.y*uvw.tangent_v + n.z*normal;
+ return normalize(normal + n);
}
#include "textureCoordinateInfo.glsllib"
@@ -109,11 +109,11 @@ vec3 fileBumpTexture( in sampler2D sampler, in float factor, in int bumpSource
//TODO - figure out if we need to manipulate tangent_u, tangent_v.
vec3 simplerFileBumpTexture( in sampler2D sampler, in float factor, vec2 texCoord, vec3 tangent, vec3 binormal, vec3 normal )
{
- return fileBumpTexture( sampler, factor, mono_average
- , textureCoordinateInfo( vec3( texCoord.x, texCoord.y, 0.0 ), tangent, binormal )
- , vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 )
- , wrap_repeat, wrap_repeat, normal );
+ return fileBumpTexture( sampler, factor, mono_average
+ , textureCoordinateInfo( vec3( texCoord.x, texCoord.y, 0.0 ), tangent, binormal )
+ , vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 )
+ , wrap_repeat, wrap_repeat, normal );
}
-#endif \ No newline at end of file
+#endif
diff --git a/src/Runtime/res/effectlib/fileDisplacementTexture.glsllib b/src/Runtime/res/effectlib/fileDisplacementTexture.glsllib
index 15aa645f..a38d701d 100644
--- a/src/Runtime/res/effectlib/fileDisplacementTexture.glsllib
+++ b/src/Runtime/res/effectlib/fileDisplacementTexture.glsllib
@@ -50,21 +50,21 @@
vec3 fileDisplacementTexture( in sampler2D sampler, in float factor, in int displaceSource
- , in texture_coordinate_info uvw, in vec3 normal, in vec3 pos )
+ , in texture_coordinate_info uvw, in vec3 normal, in vec3 pos )
{
- // compute displace factor
- float df = monoChannel( texture( sampler, uvw.position.xy ), displaceSource );
+ // compute displace factor
+ float df = monoChannel( texture( sampler, uvw.position.xy ), displaceSource );
- return( normal * df * factor + pos );
+ return( normal * df * factor + pos );
}
//default material path version
vec3 defaultMaterialFileDisplacementTexture( in sampler2D sampler, in float factor, vec2 texCoord, in vec3 normal, vec3 pos )
{
- return fileDisplacementTexture( sampler, factor, mono_luminance
- , textureCoordinateInfo( vec3( texCoord.x, texCoord.y, 0.0 ), vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0) )
- , normal, pos );
+ return fileDisplacementTexture( sampler, factor, mono_luminance
+ , textureCoordinateInfo( vec3( texCoord.x, texCoord.y, 0.0 ), vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0) )
+ , normal, pos );
}
diff --git a/src/Runtime/res/effectlib/flakeNoiseTexture.glsllib b/src/Runtime/res/effectlib/flakeNoiseTexture.glsllib
index 219b2950..7a73968e 100644
--- a/src/Runtime/res/effectlib/flakeNoiseTexture.glsllib
+++ b/src/Runtime/res/effectlib/flakeNoiseTexture.glsllib
@@ -41,7 +41,7 @@ texture_return flakeNoiseTexture( in texture_coordinate_info uvw, in float inten
float s = pow( noise.w, 1.0f / density ) * intensity;
texture_return tr;
- tr.tint = vec3( noise.x, noise.y, noise.z );
+ tr.tint = vec3( noise.x, noise.y, noise.z );
tr.mono = clamp(s, 0.0, 1.0);
return( tr );
}
@@ -60,7 +60,7 @@ texture_return flakeNoiseAndBumpTexture( in texture_coordinate_info uvw, in floa
float s = pow( noise.w, 1.0f / density ) * intensity;
texture_return tr;
- tr.tint = normalize( normal/strength + ( uvw.tangent_u * grad.x + uvw.tangent_v * grad.y + normal * abs( grad.z ) ) );
+ tr.tint = normalize( normal/strength + ( uvw.tangent_u * grad.x + uvw.tangent_v * grad.y + normal * abs( grad.z ) ) );
tr.mono = s;
return( tr );
}
diff --git a/src/Runtime/res/effectlib/fresnelLayer.glsllib b/src/Runtime/res/effectlib/fresnelLayer.glsllib
index 123c38b5..a9b4087b 100644
--- a/src/Runtime/res/effectlib/fresnelLayer.glsllib
+++ b/src/Runtime/res/effectlib/fresnelLayer.glsllib
@@ -32,7 +32,7 @@
float simpleFresnel( in vec3 N, in float ior, float fresnelPower )
{
float F = ((1.0-ior) * (1.0-ior)) / ((1.0+ior) * (1.0+ior));
- float fresnelGlancingAngle = clamp( 1.0 - dot(viewDir, N), 0.0, 1.0 );
+ float fresnelGlancingAngle = clamp( 1.0 - dot(viewDir, N), 0.0, 1.0 );
float ratio = F + (1.0 - F) * pow(fresnelGlancingAngle, fresnelPower);
return ratio;
@@ -46,9 +46,9 @@ float simpleFresnel( in vec3 N, in float ior, float fresnelPower )
vec3 pseudoFresnel( in vec3 N, in vec3 ior, float fresnelPower )
{
vec3 F0 = ((vec3(1.0)-ior) * (vec3(1.0)-ior)) / ((vec3(1.0)+ior) * (vec3(1.0)+ior));
-
- float fresnelGlancingAngle = clamp( 1.0 - dot(viewDir, N), 0.0, 1.0 );
-
+
+ float fresnelGlancingAngle = clamp( 1.0 - dot(viewDir, N), 0.0, 1.0 );
+
float fresCurve = pow(fresnelGlancingAngle, fresnelPower);
vec3 dipCurve = F0 * sin( 3.1415926535 * fresCurve ) * 0.31830988618;
@@ -101,7 +101,7 @@ vec4 fresnelLayer( in vec3 N, in vec3 ior, in float weight, in vec3 layercolor,
{
vec3 refl = reflect( -viewDir, N );
float reflWt = clamp( dot( surfNormal, refl ) + 1.0, 0.0, 1.0 );
-
+
vec3 fresColor = reflWt * weight * layercolor * pseudoFresnel( N, ior, 5.0 );
return( vec4( mix( base.rgb, layer.rgb, fresColor ), mix(alpha, 1.0, luminance(fresColor)) ) );
diff --git a/src/Runtime/res/effectlib/luminance.glsllib b/src/Runtime/res/effectlib/luminance.glsllib
index 92648970..067dc184 100644
--- a/src/Runtime/res/effectlib/luminance.glsllib
+++ b/src/Runtime/res/effectlib/luminance.glsllib
@@ -41,22 +41,22 @@ float luminance( in vec3 v )
vec3 RGBToYPbPr( in vec3 v )
{
- vec3 ypp;
- ypp.x = luminance( v );
- ypp.y = 0.5 * (v.b - ypp.x) / (1.0 - yCoeff_709.b);
- ypp.z = 0.5 * (v.r - ypp.x) / (1.0 - yCoeff_709.r);
+ vec3 ypp;
+ ypp.x = luminance( v );
+ ypp.y = 0.5 * (v.b - ypp.x) / (1.0 - yCoeff_709.b);
+ ypp.z = 0.5 * (v.r - ypp.x) / (1.0 - yCoeff_709.r);
- return ypp;
+ return ypp;
}
vec3 YPbPrToRGB( in vec3 v )
{
- vec3 outRGB;
- outRGB.x = dot(vec3(1.0, 0.0, 1.575), v);
- outRGB.y = dot(vec3(1.0, -0.187, -0.468), v);
- outRGB.z = dot(vec3(1.0, 1.856, 0.0), v);
+ vec3 outRGB;
+ outRGB.x = dot(vec3(1.0, 0.0, 1.575), v);
+ outRGB.y = dot(vec3(1.0, -0.187, -0.468), v);
+ outRGB.z = dot(vec3(1.0, 1.856, 0.0), v);
- return outRGB;
+ return outRGB;
}
#endif \ No newline at end of file
diff --git a/src/Runtime/res/effectlib/microfacetBSDF.glsllib b/src/Runtime/res/effectlib/microfacetBSDF.glsllib
index 1bdd2fee..e164fcad 100644
--- a/src/Runtime/res/effectlib/microfacetBSDF.glsllib
+++ b/src/Runtime/res/effectlib/microfacetBSDF.glsllib
@@ -34,91 +34,91 @@
float GtermSchlick( in mat3 tanFrame, in vec3 l, in vec3 v, in float roughness )
{
- float NdotV = clamp(dot(tanFrame[2], v), 0.0, 1.0);
- float NdotL = clamp(dot(tanFrame[2], l), 0.0, 1.0);
- float k = roughness*roughness*0.79788;
+ float NdotV = clamp(dot(tanFrame[2], v), 0.0, 1.0);
+ float NdotL = clamp(dot(tanFrame[2], l), 0.0, 1.0);
+ float k = roughness*roughness*0.79788;
- float G_V = NdotV / (NdotV * (1.0 + k) + k);
- float G_L = NdotL / (NdotL * (1.0 + k) + k);
+ float G_V = NdotV / (NdotV * (1.0 + k) + k);
+ float G_L = NdotL / (NdotL * (1.0 + k) + k);
- return clamp(( G_V * G_L ), 0.0, 1.0);
+ return clamp(( G_V * G_L ), 0.0, 1.0);
}
float GtermGGX( in mat3 tanFrame, in vec3 l, in vec3 v, in float roughness )
{
- float NdotV = clamp(dot(tanFrame[2], v), 0.0, 1.0);
- float NdotL = clamp(dot(tanFrame[2], l), 0.0, 1.0);
- float k = clamp(roughness*roughness, 0.00, 1.0);
+ float NdotV = clamp(dot(tanFrame[2], v), 0.0, 1.0);
+ float NdotL = clamp(dot(tanFrame[2], l), 0.0, 1.0);
+ float k = clamp(roughness*roughness, 0.00, 1.0);
- float G_V = NdotV + sqrt( (NdotV - NdotV * k) * NdotV + k );
- float G_L = NdotL + sqrt( (NdotL - NdotL * k) * NdotL + k );
+ float G_V = NdotV + sqrt( (NdotV - NdotV * k) * NdotV + k );
+ float G_L = NdotL + sqrt( (NdotL - NdotL * k) * NdotL + k );
- return clamp( 2.0 / ( G_V * G_L ), 0.0, 1.0);
+ return clamp( 2.0 / ( G_V * G_L ), 0.0, 1.0);
}
float DtermGGX( in mat3 tanFrame, in vec3 L, in vec3 V, in float roughness )
{
- float m = clamp(roughness, 0.04, 1.0);
- float m2 = m*m;
+ float m = clamp(roughness, 0.04, 1.0);
+ float m2 = m*m;
- vec3 H = normalize(L + V);
- float NdotH = clamp(dot( tanFrame[2], H ), 0.0001, 1.0);
- float NdotH2 = NdotH * NdotH;
+ vec3 H = normalize(L + V);
+ float NdotH = clamp(dot( tanFrame[2], H ), 0.0001, 1.0);
+ float NdotH2 = NdotH * NdotH;
- float denom = NdotH2 * (m2 - 1.0) + 1.0;
- float D = m2 / (PI * denom * denom);
+ float denom = NdotH2 * (m2 - 1.0) + 1.0;
+ float D = m2 / (PI * denom * denom);
- return max( 0.0, D);
+ return max( 0.0, D);
}
float DtermGGXAniso( in mat3 tanFrame, in vec3 L, in vec3 V, in float roughnessU, float roughnessV )
{
- float roughU = clamp(roughnessU, 0.04, 1.0);
- float roughV = clamp(roughnessV, 0.04, 1.0);
- vec3 H = normalize(L + V);
- float NdotH = clamp( dot(tanFrame[2], H), 0.0001, 1.0 );
- float m = PI * roughU * roughV;
- float HdotX = clamp( abs(dot(H, tanFrame[0])), 0.0001, 1.0 );
+ float roughU = clamp(roughnessU, 0.04, 1.0);
+ float roughV = clamp(roughnessV, 0.04, 1.0);
+ vec3 H = normalize(L + V);
+ float NdotH = clamp( dot(tanFrame[2], H), 0.0001, 1.0 );
+ float m = PI * roughU * roughV;
+ float HdotX = clamp( abs(dot(H, tanFrame[0])), 0.0001, 1.0 );
float HdotY = clamp( abs(dot(H, tanFrame[1])), 0.0001, 1.0 );
- float x2 = roughU*roughU;
- float y2 = roughV*roughV;
+ float x2 = roughU*roughU;
+ float y2 = roughV*roughV;
- float D = (HdotX*HdotX/x2) + (HdotY*HdotY/y2) + (NdotH*NdotH);
- D = 1.0 / ( m * D * D );
+ float D = (HdotX*HdotX/x2) + (HdotY*HdotY/y2) + (NdotH*NdotH);
+ D = 1.0 / ( m * D * D );
- return max( 0.0, D);
+ return max( 0.0, D);
}
vec4 microfacetBSDF( in mat3 tanFrame, in vec3 L, in vec3 V, in vec3 lightSpecular, float ior,
in float roughnessU, in float roughnessV, int mode )
-{
- vec4 rgba = vec4( 0.0f, 0.0f, 0.0f, 1.0f );
- vec3 H = normalize(L + V);
- float HdotL = clamp(dot(H, L), 0.0, 1.0);
- float NdotL = dot(tanFrame[2], L);
-
- if ( NdotL > 0.0 )
- {
- if ( ( mode == scatter_reflect ) || ( mode == scatter_reflect_transmit ) )
- {
- float roughness = calculateRoughness( tanFrame[2], roughnessU, roughnessV, tanFrame[0] );
- // G term
- //float G = GtermSchlick( tanFrame, L, V, roughness );
- float G = GtermGGX( tanFrame, L, V, roughness );
-
- //float D = DtermGGX( tanFrame, L, V, roughness );
- float D = DtermGGXAniso( tanFrame, L, V, roughnessU, roughnessV );
- rgba.rgb = G * D * NdotL * lightSpecular;
- }
-
- if ( ( mode == scatter_transmit ) || ( mode == scatter_reflect_transmit ) )
- {
- rgba.a = pow(1.0 - clamp(HdotL, 0.0, 1.0), 5.0);
- }
- }
-
- return rgba;
+{
+ vec4 rgba = vec4( 0.0f, 0.0f, 0.0f, 1.0f );
+ vec3 H = normalize(L + V);
+ float HdotL = clamp(dot(H, L), 0.0, 1.0);
+ float NdotL = dot(tanFrame[2], L);
+
+ if ( NdotL > 0.0 )
+ {
+ if ( ( mode == scatter_reflect ) || ( mode == scatter_reflect_transmit ) )
+ {
+ float roughness = calculateRoughness( tanFrame[2], roughnessU, roughnessV, tanFrame[0] );
+ // G term
+ //float G = GtermSchlick( tanFrame, L, V, roughness );
+ float G = GtermGGX( tanFrame, L, V, roughness );
+
+ //float D = DtermGGX( tanFrame, L, V, roughness );
+ float D = DtermGGXAniso( tanFrame, L, V, roughnessU, roughnessV );
+ rgba.rgb = G * D * NdotL * lightSpecular;
+ }
+
+ if ( ( mode == scatter_transmit ) || ( mode == scatter_reflect_transmit ) )
+ {
+ rgba.a = pow(1.0 - clamp(HdotL, 0.0, 1.0), 5.0);
+ }
+ }
+
+ return rgba;
}
vec4 microfacetBSDFEnvironment( in mat3 tanFrame, in vec3 viewDir, in float roughnessU, in float roughnessV, int mode )
@@ -130,7 +130,7 @@ vec4 microfacetBSDFEnvironment( in mat3 tanFrame, in vec3 viewDir, in float roug
float roughness = calculateRoughness( tanFrame[2], roughnessU, roughnessV, tanFrame[0] );
vec3 R = reflect( -viewDir, tanFrame[2] );
rgb = 0.01 * evalEnvironmentMap( R, roughness );
- rgb = microfacetBSDF( tanFrame, R, viewDir, rgb, 1.0f, roughnessU, roughnessV, scatter_reflect ).rgb;
+ rgb = microfacetBSDF( tanFrame, R, viewDir, rgb, 1.0f, roughnessU, roughnessV, scatter_reflect ).rgb;
}
#endif
return( vec4( rgb, 1.0f ) );
@@ -139,7 +139,7 @@ vec4 microfacetBSDFEnvironment( in mat3 tanFrame, in vec3 viewDir, in float roug
// see http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
-float radicalInverse_VdC( uint bits)
+float radicalInverse_VdC( uint bits)
{
bits = (bits << 16u) | (bits >> 16u);
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
@@ -149,74 +149,74 @@ float radicalInverse_VdC( uint bits)
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
}
-vec2 hammersley2d(uint i, uint N)
+vec2 hammersley2d(uint i, uint N)
{
return vec2(float(i)/float(N), radicalInverse_VdC(i));
}
vec2 hammersly[4] = vec2[4] (
- vec2(0.0, 0.0),
- vec2(0.25, 0.5),
- vec2(0.5, 0.25),
- vec2(0.75, 0.75)
- );
+ vec2(0.0, 0.0),
+ vec2(0.25, 0.5),
+ vec2(0.5, 0.25),
+ vec2(0.75, 0.75)
+ );
vec3 ImportanceGGX( in mat3 tanFrame, vec2 Xi, float roughness , vec3 N )
{
- float a = roughness * roughness;
- float Phi = 2.0 * PI * Xi.y;
- float CosTheta = (1.0 - Xi.x);
- float SinTheta = sqrt( 1.0 - CosTheta * CosTheta );
-
- vec3 H;
- H.x = SinTheta * cos( Phi );
- H.y = SinTheta * sin( Phi );
- H.z = CosTheta;
-
- // Tangent to world space
- return tanFrame[0] * H.x + tanFrame[1] * H.y + tanFrame[2] * H.z;
+ float a = roughness * roughness;
+ float Phi = 2.0 * PI * Xi.y;
+ float CosTheta = (1.0 - Xi.x);
+ float SinTheta = sqrt( 1.0 - CosTheta * CosTheta );
+
+ vec3 H;
+ H.x = SinTheta * cos( Phi );
+ H.y = SinTheta * sin( Phi );
+ H.z = CosTheta;
+
+ // Tangent to world space
+ return tanFrame[0] * H.x + tanFrame[1] * H.y + tanFrame[2] * H.z;
}
float DtermGGXAnisoSampled( in mat3 tanFrame, in vec3 H, in float roughnessU, float roughnessV )
{
#if (MATERIAL_IS_NON_DIELECTRIC == 1)
- float roughU = clamp(roughnessU*roughnessU, 0.01, 1.0);
- float roughV = clamp(roughnessV*roughnessV, 0.01, 1.0);
+ float roughU = clamp(roughnessU*roughnessU, 0.01, 1.0);
+ float roughV = clamp(roughnessV*roughnessV, 0.01, 1.0);
#else
- float roughU = clamp(roughnessU, 0.02, 1.0);
- float roughV = clamp(roughnessV, 0.02, 1.0);
+ float roughU = clamp(roughnessU, 0.02, 1.0);
+ float roughV = clamp(roughnessV, 0.02, 1.0);
#endif
-
- float NdotH = clamp( dot(tanFrame[2], H), 0.0001, 1.0 );
- float m = PI * roughU * roughV;
- float HdotX = clamp( abs(dot(H, tanFrame[0])), 0.0001, 1.0 );
+
+ float NdotH = clamp( dot(tanFrame[2], H), 0.0001, 1.0 );
+ float m = PI * roughU * roughV;
+ float HdotX = clamp( abs(dot(H, tanFrame[0])), 0.0001, 1.0 );
float HdotY = clamp( abs(dot(H, tanFrame[1])), 0.0001, 1.0 );
- float x2 = roughU*roughU;
- float y2 = roughV*roughV;
+ float x2 = roughU*roughU;
+ float y2 = roughV*roughV;
- float pdf = (HdotX*HdotX/x2) + (HdotY*HdotY/y2) + (NdotH*NdotH);
- float D = 1.0 / ( m * pdf * pdf );
+ float pdf = (HdotX*HdotX/x2) + (HdotY*HdotY/y2) + (NdotH*NdotH);
+ float D = 1.0 / ( m * pdf * pdf );
- return max( 0.0, D);
+ return max( 0.0, D);
}
vec3 sampleEnv(in vec3 L, float pdf, uint sampleCount, float roughness )
{
- vec2 envMapSize = vec2( textureSize( uEnvironmentTexture, 0 ) );
- float envMapLevels = log2( max( envMapSize.x, envMapSize.y ) );
+ vec2 envMapSize = vec2( textureSize( uEnvironmentTexture, 0 ) );
+ float envMapLevels = log2( max( envMapSize.x, envMapSize.y ) );
- float a = 0.5*log2( float(envMapSize.x*envMapSize.y) / float(sampleCount) );
- float d = 4.0 * (abs(L.z) + 1.0) * (abs(L.z) + 1.0);
- float b = 0.5*log2( pdf * d );
+ float a = 0.5*log2( float(envMapSize.x*envMapSize.y) / float(sampleCount) );
+ float d = 4.0 * (abs(L.z) + 1.0) * (abs(L.z) + 1.0);
+ float b = 0.5*log2( pdf * d );
- // convert coord to 2D
- vec2 tc = vec2( ( atan( L.x, -L.z ) + PI ) / ( 2.0f * PI ), acos( -L.y ) / PI );
- float weight = step( 0.0001, roughness );
+ // convert coord to 2D
+ vec2 tc = vec2( ( atan( L.x, -L.z ) + PI ) / ( 2.0f * PI ), acos( -L.y ) / PI );
+ float weight = step( 0.0001, roughness );
- float lod = max( 0.0, min( (a - b)*weight, envMapLevels ));
+ float lod = max( 0.0, min( (a - b)*weight, envMapLevels ));
- return( textureLod( uEnvironmentTexture, tc, lod ).rgb );
+ return( textureLod( uEnvironmentTexture, tc, lod ).rgb );
}
vec4 microfacetSampledBSDF( in mat3 tanFrame, in vec3 viewDir, in float roughnessU, in float roughnessV, int mode )
@@ -230,25 +230,25 @@ vec4 microfacetSampledBSDF( in mat3 tanFrame, in vec3 viewDir, in float roughnes
const uint NumSamples = 4u;
for( uint i = 0u; i < NumSamples; i++ )
{
- vec2 Xi = hammersly[i]; // pre computed values
- //vec2 Xi = hammersley2d(i, NumSamples);
- vec3 Half = ImportanceGGX( tanFrame, Xi, roughness , tanFrame[2] );
- vec3 H = normalize( Half );
-
- vec3 L = 2.0 * dot( viewDir, Half ) * Half - viewDir;
- float NdotV = clamp( dot( tanFrame[2], viewDir ), 0.0001, 1.0 );
- float NdotR = clamp( dot( tanFrame[2], R ), 0.0, 1.0 );
- float NdotH = clamp( dot( tanFrame[2], H ), 0.0001, 1.0 );
-
- if( NdotV > 0.0001 )
- {
- float G = GtermGGX( tanFrame, L, viewDir, roughness );
- float D = DtermGGXAnisoSampled( tanFrame, H, roughnessU, roughnessV);
-
- vec3 envColor = 0.01 * sampleEnv( L, D, NumSamples, roughness );
-
- rgb += (envColor * G * D * NdotR) / ( 4.0 * NdotV * NdotH);
- }
+ vec2 Xi = hammersly[i]; // pre computed values
+ //vec2 Xi = hammersley2d(i, NumSamples);
+ vec3 Half = ImportanceGGX( tanFrame, Xi, roughness , tanFrame[2] );
+ vec3 H = normalize( Half );
+
+ vec3 L = 2.0 * dot( viewDir, Half ) * Half - viewDir;
+ float NdotV = clamp( dot( tanFrame[2], viewDir ), 0.0001, 1.0 );
+ float NdotR = clamp( dot( tanFrame[2], R ), 0.0, 1.0 );
+ float NdotH = clamp( dot( tanFrame[2], H ), 0.0001, 1.0 );
+
+ if( NdotV > 0.0001 )
+ {
+ float G = GtermGGX( tanFrame, L, viewDir, roughness );
+ float D = DtermGGXAnisoSampled( tanFrame, H, roughnessU, roughnessV);
+
+ vec3 envColor = 0.01 * sampleEnv( L, D, NumSamples, roughness );
+
+ rgb += (envColor * G * D * NdotR) / ( 4.0 * NdotV * NdotH);
+ }
}
rgb /= float(NumSamples);
diff --git a/src/Runtime/res/effectlib/perlinNoise.glsllib b/src/Runtime/res/effectlib/perlinNoise.glsllib
index 0445fef6..1fef880d 100644
--- a/src/Runtime/res/effectlib/perlinNoise.glsllib
+++ b/src/Runtime/res/effectlib/perlinNoise.glsllib
@@ -28,7 +28,7 @@
**
****************************************************************************/
-// check out implementation from GPU Gems 1 and 2
+// check out implementation from GPU Gems 1 and 2
float fade( in float x )
{
@@ -117,7 +117,7 @@ float perlinNoise( in vec3 pos )
int bxay = bx ^ ay;
int axby = ax ^ by;
int bxby = bx ^ by;
-
+
return( mix( mix( mix( influence( axay^az, fracPos.x, fracPos.y, fracPos.z )
, influence( bxay^az, fracPos.x - 1.0f, fracPos.y, fracPos.z ), fadedPos.x )
, mix( influence( axby^az, fracPos.x, fracPos.y - 1.0f, fracPos.z )
diff --git a/src/Runtime/res/effectlib/physGlossyBSDF.glsllib b/src/Runtime/res/effectlib/physGlossyBSDF.glsllib
index ad805960..ff0eb8cb 100644
--- a/src/Runtime/res/effectlib/physGlossyBSDF.glsllib
+++ b/src/Runtime/res/effectlib/physGlossyBSDF.glsllib
@@ -38,7 +38,7 @@ float sqr(float v)
float Gterm( float cosTheta, float roughness )
{
- float k = roughness * 0.31830988618; // roughness / pi
+ float k = roughness * 0.31830988618; // roughness / pi
return clamp( ( cosTheta / (cosTheta*(1.0-k) + k) + (1.0 - k*k) ) * 0.5, 0.0, 1.0 );
}
@@ -62,18 +62,18 @@ vec4 kggxGlossyBSDF( in mat3 tanFrame, in vec3 L, in vec3 V, in vec3 lightSpecul
// in the range of 0..1
float ax = clamp(roughnessU, 0.0001, 2.0);
float ay = clamp(roughnessV, 0.0001, 2.0);
-
+
float NdotL = dot(tanFrame[2], L);
float HdotL = clamp(dot(H, L), 0.0, 1.0);
-
- // if (0.0f < NdotL)
+
+ // if (0.0f < NdotL)
// {
vec3 Haf = L + V;
-
+
float HdotN = clamp( dot(H, tanFrame[2]), 0.0001, 1.0 );
float HdotX = clamp( abs(dot(H, tanFrame[0])), 0.0001, 1.0 );
float HdotY = clamp( abs(dot(H, tanFrame[1])), 0.0001, 1.0 );
-
+
float sigma = sqrt(ax * ay);
float sigma2 = ax * ay * HdotN;
@@ -81,13 +81,13 @@ vec4 kggxGlossyBSDF( in mat3 tanFrame, in vec3 L, in vec3 V, in vec3 lightSpecul
float maxThetaI = (thetaI + 1.57079632679) * 0.5;
float minThetaI = (thetaI - 1.57079632679) * 0.5;
float range = atan(maxThetaI / sigma) - atan(minThetaI / sigma);
- range = max( range, ax*ay );
-
+ range = max( range, ax*ay );
+
if ( ( mode == scatter_reflect ) || ( mode == scatter_reflect_transmit ) )
{
- float PDF = sigma2 / (sigma2 + sqr(HdotX / ax) + sqr(HdotY / ay));
+ float PDF = sigma2 / (sigma2 + sqr(HdotX / ax) + sqr(HdotY / ay));
PDF *= dot(Haf, Haf) / (4.71238898038 * sqr(dot(Haf, L)) * ax*ay * sigma * sqr(range));
-
+
rgba.rgb = Gterm(HdotL, sigma) * lightSpecular * PDF * max(NdotL, 0.0);
}
if ( ( mode == scatter_transmit ) || ( mode == scatter_reflect_transmit ) )
@@ -99,12 +99,12 @@ vec4 kggxGlossyBSDF( in mat3 tanFrame, in vec3 L, in vec3 V, in vec3 lightSpecul
}
vec4 kggxGlossyDefaultMtl( in vec3 normal, in vec3 tangent, in vec3 L, in vec3 V, in vec3 lightSpecular,
- in vec3 materialSpecular, in float roughU, in float roughV )
+ in vec3 materialSpecular, in float roughU, in float roughV )
{
vec3 bitan = normalize(cross(normal, tangent));
mat3 tanFrame = mat3( normalize(cross( bitan, normal) ), bitan, normal );
return vec4(materialSpecular, 1.0) * kggxGlossyBSDF( tanFrame, L, V, lightSpecular, 1.5, roughU, roughV, scatter_reflect );
-}
+}
// To be exact, this is not the Ward lobe as Ward originally described (there are a few flaws in
// the original paper, which had spawned half a dozen corrective measures as papers of their own).
@@ -119,25 +119,25 @@ vec4 wardGlossyBSDF( in mat3 tanFrame, in vec3 L, in vec3 V, in vec3 lightSpecul
// specular
float ax = clamp(roughnessU, 0.0001, 1.0);
float ay = clamp(roughnessV, 0.0001, 1.0);
-
+
float NdotL = dot(tanFrame[2], L);
float HdotL = clamp(dot(H, L), 0.0, 1.0);
-
-// if (0.0f < NdotL)
+
+// if (0.0f < NdotL)
// {
vec3 Haf = L + V;
-
+
float HdotN = clamp( dot(H, tanFrame[2]), 0.0001, 1.0 );
float HdotX = clamp( abs(dot(H, tanFrame[0])), 0.0001, 1.0 );
float HdotY = clamp( abs(dot(H, tanFrame[1])), 0.0001, 1.0 );
-
+
if ( ( mode == scatter_reflect ) || ( mode == scatter_reflect_transmit ) )
{
float exponent = -(sqr(HdotX/ax) + sqr(HdotY/ay));
exponent /= sqr(HdotN);
float PDF = exp(exponent) / (4.0 * 3.1415926535 * ax * ay);
PDF *= 4.0 * dot(Haf, Haf) / sqr(sqr(dot(Haf,tanFrame[2])));
-
+
rgba.rgb = Gterm(HdotL, sqrt(ax * ay)) * lightSpecular * PDF * max(NdotL, 0.0);
}
if ( ( mode == scatter_transmit ) || ( mode == scatter_reflect_transmit ) )
@@ -149,7 +149,7 @@ vec4 wardGlossyBSDF( in mat3 tanFrame, in vec3 L, in vec3 V, in vec3 lightSpecul
}
vec4 wardGlossyDefaultMtl( in vec3 normal, in vec3 tangent, in vec3 L, in vec3 V, in vec3 lightSpecular,
- in vec3 materialSpecular, in float roughU, in float roughV )
+ in vec3 materialSpecular, in float roughU, in float roughV )
{
vec3 bitan = normalize(cross(normal, tangent));
mat3 tanFrame = mat3( normalize(cross( bitan, normal) ), bitan, normal );
diff --git a/src/Runtime/res/effectlib/refraction.glsllib b/src/Runtime/res/effectlib/refraction.glsllib
index 271ca44f..f961c50e 100644
--- a/src/Runtime/res/effectlib/refraction.glsllib
+++ b/src/Runtime/res/effectlib/refraction.glsllib
@@ -42,11 +42,11 @@ vec3 refraction( in sampler2D sampler, in float materialIOR )
vec2 newUV = vec2(gl_FragCoord.xy/texSize);
if ( xdir > ydir)
{
- newUV = ( viewDir.x > 0.0) ? newUV + displace.xy : newUV - displace.xy;
+ newUV = ( viewDir.x > 0.0) ? newUV + displace.xy : newUV - displace.xy;
}
else
{
- newUV = ( viewDir.y > 0.0) ? newUV - displace.xy : newUV + displace.xy;
+ newUV = ( viewDir.y > 0.0) ? newUV - displace.xy : newUV + displace.xy;
}
vec3 refractColor = texture( sampler, newUV ).rgb;
@@ -72,15 +72,15 @@ vec3 refractBlur( in sampler2D sampler, in vec3 viewDir, in float materialIOR, i
for (int y = -sz; y <= sz; ++y)
{
- for (int x = -sz; x <= sz; ++x)
- {
- float wt = float(x*x + y*y) / (blurWidth * 0.5);
- wt = exp2(-wt);
- //refractColor += wt * textureOffset( sampler, newUV, ivec2(x, y) ).rgb;
- vec2 uvOfs = vec2(x, y) * texSize;
- refractColor += wt * texture( sampler, newUV+uvOfs).rgb;
- wtsum += wt;
- }
+ for (int x = -sz; x <= sz; ++x)
+ {
+ float wt = float(x*x + y*y) / (blurWidth * 0.5);
+ wt = exp2(-wt);
+ //refractColor += wt * textureOffset( sampler, newUV, ivec2(x, y) ).rgb;
+ vec2 uvOfs = vec2(x, y) * texSize;
+ refractColor += wt * texture( sampler, newUV+uvOfs).rgb;
+ wtsum += wt;
+ }
}
return refractColor / wtsum;
diff --git a/src/Runtime/res/effectlib/sampleArea.glsllib b/src/Runtime/res/effectlib/sampleArea.glsllib
index d5c2b728..70c7ae0d 100644
--- a/src/Runtime/res/effectlib/sampleArea.glsllib
+++ b/src/Runtime/res/effectlib/sampleArea.glsllib
@@ -59,50 +59,50 @@ float getUVHitBounds( in vec3 pos, in mat3 lightFrame, in vec3 lightPos, in floa
{
float d0 = dot( lightPos, lightFrame[2] );
float d1 = dot( pos, lightFrame[2] );
-
+
// If the point is behind the light, it can't be illuminated.
if (d0 < d1)
{
UVmin = vec2( -1.0, -1.0 );
UVmax = vec2( -1.0, -1.0 );
- return 0.0;
+ return 0.0;
}
// Compute where all the rays of the light beam hit the light plane
float t[4];
vec3 v[4];
-
+
v[0] = V0; v[1] = V1; v[2] = V2; v[3] = V3;
t[0] = (d0 - d1) / dot(V0, lightFrame[2]);
t[1] = (d0 - d1) / dot(V1, lightFrame[2]);
t[2] = (d0 - d1) / dot(V2, lightFrame[2]);
t[3] = (d0 - d1) / dot(V3, lightFrame[2]);
-
+
UVmin = vec2(1e6, 1e6);
UVmax = vec2(-1e6, -1e6);
-
+
// If any of them are "negative" relative to the ray direction
- // We don't want to consider them.
+ // We don't want to consider them.
bool weight[4];
float wtsum = 0.0;
weight[0] = (t[0] > 0.0);
weight[1] = (t[1] > 0.0);
weight[2] = (t[2] > 0.0);
weight[3] = (t[3] > 0.0);
-
+
width *= dot(lightFrame[0], lightFrame[0]);
height *= dot(lightFrame[1], lightFrame[1]);
-
+
for (int i = 0; i < 4; ++i)
{
vec3 curPos = pos + v[i] * t[i];
curPos -= lightPos;
vec2 curUV = vec2( dot(curPos, lightFrame[0]) / width, dot(curPos, lightFrame[1]) / height ) + vec2(0.5);
-
+
UVmin = min(UVmin, curUV); UVmax = max(UVmax, curUV);
wtsum += weight[i] ? 0.25 : 0.0;
}
-
+
return wtsum;
}
@@ -112,50 +112,50 @@ vec4 sampleAreaGlossy( in mat3 tanFrame, in vec3 pos, in int lightIdx, in vec3 v
float sigmaU = clamp( 0.5 * roughU, 0.005, 0.5 );
float sigmaV = clamp( 0.5 * roughV, 0.005, 0.5 );
vec2 UVset[5];
-
+
mat3 lightFrame = mat3( arealights[lightIdx].right.xyz, arealights[lightIdx].up.xyz, arealights[lightIdx].direction.xyz );
-
+
float thetaI = acos( dot(viewDir, lightFrame[2]) );
vec2 minMaxThetaH = vec2( (thetaI - 1.5707) * 0.5,
- (thetaI + 1.5707) * 0.5 );
+ (thetaI + 1.5707) * 0.5 );
vec4 sinCosThetaH = vec4( abs(sin(minMaxThetaH)), abs(cos(minMaxThetaH)) );
// First thing we do is compute a small-scale version of the ray hit for a very tiny roughness
// then we scale that up based on the _actual_ roughness.
- float wt = computeMicroHit( pos, tanFrame, arealights[lightIdx].position.xyz, lightFrame,
+ float wt = computeMicroHit( pos, tanFrame, arealights[lightIdx].position.xyz, lightFrame,
arealights[lightIdx].right.w, arealights[lightIdx].up.w, viewDir, UVset );
UVset[0] -= UVset[4]; UVset[1] -= UVset[4];
UVset[2] -= UVset[4]; UVset[3] -= UVset[4];
-
+
UVset[0] *= mix(1.0, sinCosThetaH.y / 0.005, sigmaU); UVset[1] *= mix(1.0, sinCosThetaH.x / 0.005, sigmaU);
UVset[2] *= mix(1.0, sinCosThetaH.y / 0.005, sigmaV); UVset[3] *= mix(1.0, sinCosThetaH.x / 0.005, sigmaV);
UVset[0] += UVset[4]; UVset[1] += UVset[4];
UVset[2] += UVset[4]; UVset[3] += UVset[4];
-
+
vec2 UVmin = UVset[4], UVmax = UVset[4];
vec2 cminUV, cmaxUV;
UVmin = min(UVmin, UVset[0]); UVmax = max(UVmax, UVset[0]);
UVmin = min(UVmin, UVset[1]); UVmax = max(UVmax, UVset[1]);
UVmin = min(UVmin, UVset[2]); UVmax = max(UVmax, UVset[2]);
UVmin = min(UVmin, UVset[3]); UVmax = max(UVmax, UVset[3]);
-
+
cminUV = clamp( UVmin, vec2(0.0), vec2(1.0) );
cmaxUV = clamp( UVmax, vec2(0.0), vec2(1.0) );
-
+
vec2 hitScale = (cmaxUV - cminUV);
vec2 fullScale = (UVmax - UVmin);
float intensity = ( hitScale.x * hitScale.y ) / max( fullScale.x * fullScale.y, 0.0001 );
- return vec4( wt * intensity );
+ return vec4( wt * intensity );
}
vec4 sampleAreaDiffuse( in mat3 tanFrame, in vec3 pos, in int lightIdx )
{
float intensity = 0.0;
vec3 finalDir;
- intensity = calculateDiffuseAreaOld( -arealights[lightIdx].direction.xyz, arealights[lightIdx].position.xyz,
- arealights[lightIdx].up, arealights[lightIdx].right, pos, finalDir );
+ intensity = calculateDiffuseAreaOld( -arealights[lightIdx].direction.xyz, arealights[lightIdx].position.xyz,
+ arealights[lightIdx].up, arealights[lightIdx].right, pos, finalDir );
intensity *= clamp( dot(finalDir, tanFrame[2]), 0.0, 1.0 );
return vec4( intensity );
}
@@ -164,7 +164,7 @@ vec4 sampleAreaDiffuseTransmissive( in mat3 tanFrame, in vec3 pos, in int lightI
{
float intensity = 0.0;
vec3 finalDir;
- intensity = calculateDiffuseAreaOld( -arealights[lightIdx].direction.xyz, arealights[lightIdx].position.xyz,
+ intensity = calculateDiffuseAreaOld( -arealights[lightIdx].direction.xyz, arealights[lightIdx].position.xyz,
arealights[lightIdx].up, arealights[lightIdx].right, pos, finalDir );
intensity *= clamp( dot(finalDir, -tanFrame[2]), 0.0, 1.0 );
diff --git a/src/Runtime/res/effectlib/sampleLight.glsllib b/src/Runtime/res/effectlib/sampleLight.glsllib
index 62fc8b33..3218cdf5 100644
--- a/src/Runtime/res/effectlib/sampleLight.glsllib
+++ b/src/Runtime/res/effectlib/sampleLight.glsllib
@@ -107,13 +107,13 @@ void sampleLight(in LightSource light,
float dist = length(wi);
wi = wi / dist; // == normalize(wi);
att = 1.0f / (light.constantAttenuation + (light.linearAttenuation + light.quadraticAttenuation * dist) * dist);
- /*
+ /*
if (light.spotCutoff < 180.0f) // spot light
{
float spot = max(0.0f, dot(wi, -light.direction.xyz));
att *= (spot >= cos(light.spotCutoff * PI / 180.0f)) ? pow(spot, light.spotExponent) : 0.0f;
}
- */
+ */
#if QT3DS_ENABLE_SSM
if ( light.shadowIdx >= 0 )
att *= sampleCubemap( shadowCubes[light.shadowIdx], light.shadowControls, light.shadowView, light.position.xyz, pos, vec2(1.0, light.shadowControls.z) );
diff --git a/src/Runtime/res/effectlib/sampleProbe.glsllib b/src/Runtime/res/effectlib/sampleProbe.glsllib
index 53da5aaa..43024ec3 100644
--- a/src/Runtime/res/effectlib/sampleProbe.glsllib
+++ b/src/Runtime/res/effectlib/sampleProbe.glsllib
@@ -34,7 +34,7 @@
uniform sampler2D light_probe;
uniform vec4 light_probe_props;
uniform vec4 light_probe_rotation;
-uniform vec4 light_probe_offset; // light_probe_offset.w = number of mipmaps
+uniform vec4 light_probe_offset; // light_probe_offset.w = number of mipmaps
#if QT3DS_ENABLE_LIGHT_PROBE_2
uniform sampler2D light_probe2;
@@ -56,7 +56,7 @@ mat3 orthoNormalize( in mat3 tanFrame )
outMat[0] = normalize( cross( tanFrame[1], tanFrame[2] ) );
outMat[1] = normalize( cross( tanFrame[2], outMat[0] ) );
outMat[2] = tanFrame[2];
-
+
return outMat;
}
@@ -69,7 +69,7 @@ mat3 tangentFrame( vec3 N, vec3 p )
// are not ones with intrinsic UVs, so we can't really go there.
// vec2 duv1 = dFdx( uv );
// vec2 duv2 = dFdy( uv );
-
+
// solve the linear system
vec3 dp2perp = cross( dp2, N );
vec3 dp1perp = cross( N, dp1 );
@@ -95,7 +95,7 @@ vec2 transformSample( vec2 origUV, vec4 probeRot, vec2 probeOfs )
vec2 getProbeSampleUV( vec3 smpDir, vec4 probeRot, vec2 probeOfs )
{
vec2 smpUV;
-
+
#if QT3DS_ENABLE_IBL_FOV
smpUV.x = (2.0 * atan(-smpDir.z, smpDir.x) + 3.14159265358 ) / light_probe_opts.x;
smpUV.y = (2.0 * atan(-smpDir.z, smpDir.y) + 3.14159265358 ) / light_probe_opts.x;
@@ -104,7 +104,7 @@ vec2 getProbeSampleUV( vec3 smpDir, vec4 probeRot, vec2 probeOfs )
smpUV.y = 1.0 - (acos(smpDir.y) / 1.57079632679);
#endif
smpUV = transformSample( smpUV.xy * 0.5, probeRot, probeOfs ) + vec2(0.5, 0.5);
-
+
return smpUV;
}
@@ -112,13 +112,13 @@ vec4 getTopLayerSample( vec3 inDir, float lodShift, vec3 lodOffsets )
{
#if QT3DS_ENABLE_LIGHT_PROBE_2
if ( light_probe2_props.w < 0.5 )
- return vec4(0.0, 0.0, 0.0, 0.0);
-
+ return vec4(0.0, 0.0, 0.0, 0.0);
+
vec2 smpUV = getProbeSampleUV( inDir, vec4(1.0, 0.0, 0.0, 1.0), light_probe_props.xy );
smpUV.x -= 0.5;
smpUV.x *= light_probe2_props.x;
smpUV.x += light_probe2_props.y;
-
+
vec4 retVal = 0.4 * textureLod( light_probe2, smpUV , lodShift );
retVal += 0.2 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.x );
retVal += 0.3 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.y );
@@ -136,30 +136,30 @@ vec3 getProbeSample( vec3 smpDir, float lodShift, vec3 normal )
}
vec3 getProbeWeightedSample( vec3 smpDir, float lodShift, float roughness, vec3 normal )
-{
+{
// This gives us a weighted sum that approximates the total filter support
// of the full-blown convolution.
vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
float wt = 1.0;
-
+
#if QT3DS_ENABLE_IBL_FOV
wt = min(wt, smoothstep(roughness * -0.25, roughness * 0.25, smpUV.x));
wt = min(wt, smoothstep(roughness * -0.25, roughness * 0.25, smpUV.y));
wt = min(wt, 1.0 - smoothstep(1.0 - roughness*0.25, 1.0 + roughness*0.25, smpUV.x));
wt = min(wt, 1.0 - smoothstep(1.0 - roughness*0.25, 1.0 + roughness*0.25, smpUV.y));
#endif
-
+
vec3 lodOffsets;
- lodOffsets.x = mix(-2.0, -0.70710678, roughness);
+ lodOffsets.x = mix(-2.0, -0.70710678, roughness);
lodOffsets.y = min( 2.0 * smoothstep(0.0, 0.1, roughness), 2.0 - 1.29289 * smoothstep(0.1, 1.0, roughness) );
lodOffsets.z = min( 6.0 * smoothstep(0.0, 0.1, roughness), 6.0 - 4.585786 * smoothstep(0.1, 1.0, roughness) );
-
+
ivec2 iSize = textureSize(light_probe, 0);
vec3 ddx = dFdx( smpDir ) * float(iSize.x);
vec3 ddy = dFdy( smpDir ) * float(iSize.y);
// vec2 ddxUV = dFdx( smpUV ) * float(iSize.x);
// vec2 ddyUV = dFdy( smpUV ) * float(iSize.y);
-
+
vec2 deriv;
deriv.x = max( dot(ddx, ddx), dot(ddy, ddy) );
// deriv.y = max( dot(ddxUV, ddxUV), dot(ddyUV, ddyUV) );
@@ -171,14 +171,14 @@ vec3 getProbeWeightedSample( vec3 smpDir, float lodShift, float roughness, vec3
float maxLod = log2( max(float(iSize.x), float(iSize.y)) );
minLod = clamp( minLod / maxLod, 0.0, 1.0 );
minLod *= minLod * maxLod;
-
- lodShift = max( lodShift, minLod );
-
+
+ lodShift = max( lodShift, minLod );
+
vec3 retVal = 0.4 * textureLod( light_probe, smpUV , lodShift ).xyz;
retVal += 0.2 * textureLod( light_probe, smpUV , max(minLod, lodShift+lodOffsets.x) ).xyz;
retVal += 0.3 * textureLod( light_probe, smpUV , lodShift+lodOffsets.y ).xyz;
retVal += 0.1 * textureLod( light_probe, smpUV , lodShift+lodOffsets.z ).xyz;
-
+
#if QT3DS_ENABLE_LIGHT_PROBE_2
vec4 topSmp = getTopLayerSample( smpDir, lodShift, lodOffsets );
vec3 tempVal = mix( retVal, topSmp.xyz, topSmp.w );
@@ -189,9 +189,9 @@ vec3 getProbeWeightedSample( vec3 smpDir, float lodShift, float roughness, vec3
float ctr = 0.5 + 0.5 * light_probe_props.z;
float vertWt = smoothstep(ctr-roughness*0.25, ctr+roughness*0.25, smpUV.y);
float wtScaled = mix(1.0, vertWt, light_probe_props.z + 1.0);
- retVal *= wtScaled;
+ retVal *= wtScaled;
}
-
+
return retVal * wt;
}
@@ -199,9 +199,9 @@ vec3 getProbeAnisoSample( vec3 smpDir, float roughU, float roughV, mat3 tanFrame
{
float minRough = min(roughU, roughV);
float maxRough = max(roughU, roughV);
-
+
float lodMin = log2( (minRough*3.0 + maxRough)*0.25 ) + (light_probe_offset.w - 2.0);
-
+
float ratio = clamp( maxRough / minRough, 1.01, 27.0);
vec2 texSize = vec2( textureSize( light_probe, int(floor( lodMin )) ) );
texSize = mix( texSize, texSize * 0.5, fract(lodMin) );
@@ -209,31 +209,31 @@ vec3 getProbeAnisoSample( vec3 smpDir, float roughU, float roughV, mat3 tanFrame
// Boundary of 1.0..9.0 is just to keep the number of samples to within a
// reasonable number of samples in the filter. Similarly, with the clamping
// of the ratio to a max of 27.0 is just to prevent the step size in the filter
- // to be no bigger than 3 texels (beyond which, there are some artifacts at high
+ // to be no bigger than 3 texels (beyond which, there are some artifacts at high
// roughness, aka low texture res).
float stepFig = clamp(floor( ratio ), 1.0, 9.0);
-
+
// numSteps is half the number of samples we need to take, which makes it
// the number of steps to take on each side.
int numSteps = int( floor(stepFig * 0.5) );
-
+
vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
vec4 result = vec4(0.0);
-
+
vec3 smpDirOfs = (maxRough == roughU) ? 0.01 * tanFrame[0] : 0.01 * tanFrame[1];
vec2 stepPos = getProbeSampleUV(normalize(smpDir + smpDirOfs), light_probe_rotation, light_probe_offset.xy);
vec2 stepNeg = getProbeSampleUV(normalize(smpDir - smpDirOfs), light_probe_rotation, light_probe_offset.xy);
stepPos -= smpUV; stepNeg -= smpUV;
stepPos *= texSize; stepNeg *= texSize;
-
+
// This ensures that we step along a size that makes sense even if one of the two
// sammpling directions wraps around the edges of the IBL texture.
smpDirOfs /= min( length(stepPos), length(stepNeg) );
smpDirOfs *= ratio / stepFig;
-
+
float sigma = mix(0.0, 2.0, ratio / 27.0);
sigma *= sigma;
-
+
float wt = (1.0 / (ratio - 1.0)) + 1.0;
result.xyz += wt * getProbeWeightedSample( smpDir, lodMin, minRough, tanFrame[2] );
result.w += wt;
@@ -264,7 +264,7 @@ vec4 sampleDiffuse( mat3 tanFrame )
// gives us this LOD... Technically, "x" pixels depends on what the original
// texture resolution was, which is why we use light_probe_offset.w, which holds
// the number of mip levels the texture has.
-
+
return vec4( light_probe_props.w * getProbeWeightedSample( tanFrame[2], light_probe_offset.w - 2.65149613, 1.0, tanFrame[2] ), 1.0 );
// }
@@ -294,11 +294,11 @@ vec4 sampleDiffuse( mat3 tanFrame )
kernel[26] = 0.84375; kernel[27] = 0.28175;
kernel[28] = 0.71875; kernel[29] = 0.46875;
kernel[30] = 0.96875; kernel[31] = 0.015625;
-
+
float phiShift = noise1d(gl_FragCoord.xy) - 0.5;
-
+
vec3 ret = vec3(0, 0, 0);
-
+
int ct = 24;
float step = 25.0;
@@ -309,23 +309,23 @@ vec4 sampleDiffuse( mat3 tanFrame )
// the sampled directions.
for( int i = 0; i < ct; ++i )
{
- vec3 localDir;
- float phi = 6.28318530718 * (kernel[i] + phiShift);
- float cosTheta = sqrt( float(i+1) / step);
- localDir.z = sqrt(1.0 - cosTheta*cosTheta);
- localDir.x = cos(phi) * cosTheta;
- localDir.y = sin(phi) * cosTheta;
- vec3 smpDir = tanFrame[0]*localDir.x + tanFrame[1]*localDir.y + tanFrame[2]*localDir.z;
-
-
+ vec3 localDir;
+ float phi = 6.28318530718 * (kernel[i] + phiShift);
+ float cosTheta = sqrt( float(i+1) / step);
+ localDir.z = sqrt(1.0 - cosTheta*cosTheta);
+ localDir.x = cos(phi) * cosTheta;
+ localDir.y = sin(phi) * cosTheta;
+ vec3 smpDir = tanFrame[0]*localDir.x + tanFrame[1]*localDir.y + tanFrame[2]*localDir.z;
+
+
float lodShift = light_probe_offset.w - 2 + log2( 3.1415926535 / (localDir.z * step) );
vec3 smpColor = getProbeSample( smpDir, lodShift, tanFrame[2] );
-
+
// The assumption here is that the BSDF and the sampling PDF are identical
// so they cancel out and therefore, we don't need to include it here.
ret += smpColor;
}
-
+
ret *= aoFactor / 24.0;
return ret;
*/
@@ -334,7 +334,7 @@ vec4 sampleDiffuse( mat3 tanFrame )
vec4 sampleDiffuseCustomMaterial( vec3 normal, vec3 worldPos, float aoFactor )
{
- mat3 tanFrame = tangentFrame( normal, worldPos );
+ mat3 tanFrame = tangentFrame( normal, worldPos );
return sampleDiffuse( tanFrame );
}
@@ -359,18 +359,18 @@ vec4 sampleGlossyAniso( mat3 tanFrame, vec3 viewDir, float roughU, float roughV
// Compute the Geometric occlusion/self-shadowing term
float NdotL = clamp( dot( smpDir, tanFrame[2] ), 0.0, 0.999995);
- float k = sigma * 0.31830988618; // roughness / pi
+ float k = sigma * 0.31830988618; // roughness / pi
float Gl = clamp( (NdotL / (NdotL*(1.0-k) + k) + (1.0 - k*k)) * 0.5, 0.0, 1.0 );
-
+
vec3 outColor;
-
+
outColor = getProbeAnisoSample( smpDir, sigmaU, sigmaV, tanFrame );
-
+
return vec4( light_probe_props.w * Gl * outColor, 1.0 );
// }
// PKC -- the code below is for full-blown IBL, which we'll skip for now
-
+
/*
float step = clamp( ceil(32.0 * sqrt(max(sigmaU, sigmaV))), 4.0, 32.0 );
int actualCt = int(step);
@@ -401,56 +401,56 @@ vec4 sampleGlossyAniso( mat3 tanFrame, vec3 viewDir, float roughU, float roughV
kernel[30] = 0.96875; kernel[31] = 0.015625;
float thetaI = acos( dot(viewDir, tanFrame[2]) );
-
+
// NOTE : The model I'm using here is actually based on the KGGX model used in
// physGlossyBSDF. This is my own variation on the original GGX which uses something
// closer to a pure Cauchy distribution in tangent space, but also supports anisotropy.
for (int i = 0; i < actualCt; ++i)
{
vec3 localDir;
-
+
float phi = 6.28318530718 * (kernel[i] + phiShift);
float u = float(i + 1) / (step + 1.0);
float rU = cos(phi) * sigmaU;
float rV = sin(phi) * sigmaV;
float sigma = sqrt(rU * rU + rV * rV);
-
+
float boundA = atan( ((thetaI - 1.57079632679) * 0.5) / sigma );
float boundB = atan( ((thetaI + 1.57079632679) * 0.5) / sigma );
float t = (1.0 - u) * boundA + u * boundB;
float thetaH = tan( t ) * sigma;
-
+
float cosThetaH = cos( thetaH );
float sinThetaH = sin( thetaH );
localDir.z = cosThetaH;
localDir.y = sin(phi) * sinThetaH;
localDir.x = cos(phi) * sinThetaH;
-
+
vec3 halfDir = tanFrame[0]*localDir.x + tanFrame[1]*localDir.y + tanFrame[2]*localDir.z;
halfDir = normalize(halfDir);
vec3 smpDir = reflect( -viewDir, halfDir );
-
+
vec2 scaledXY = localDir.xy / vec2(sigmaU, sigmaV);
float PDF = (sigmaU*sigmaV) / (sigmaU*sigmaV + dot(scaledXY, scaledXY));
- vec3 Haf = smpDir + viewDir; // We need the unnormalized half vecter as well as the normalized one
+ vec3 Haf = smpDir + viewDir; // We need the unnormalized half vecter as well as the normalized one
float HdotL = dot(halfDir, smpDir);
// normalize the PDF to compute the filter support
// This gives us the ideal miplevel at which to sample the texture map.
PDF *= dot(Haf, Haf) / (4.0 * dot(Haf, smpDir) * HdotL * sigmaU*sigmaV * (boundB-boundA)*(boundB-boundA));
-
+
// Again assuming that the pdf and BSDF are equivalent -- that's not generally valid,
// but it saves a lot of ALU cycles.
float lodShift = log2( 512.0 * sigma / PDF );
-
- float k = sigma * 0.31830988618; // roughness / pi
+
+ float k = sigma * 0.31830988618; // roughness / pi
float Gl = clamp( (HdotL / (HdotL*(1.0-k) + k) + (1.0 - k*k)) * 0.5, 0.0, 1.0 );
-
+
vec3 smpColor = Gl * getProbeSample( smpDir, lodShift, tanFrame[2] );
ret += smpColor;
}
ret /= float(actualCt);
return vec4(ret, 1.0);
-*/
+*/
}
vec4 sampleGlossy( mat3 tanFrame, vec3 viewDir, float roughness )
@@ -460,7 +460,7 @@ vec4 sampleGlossy( mat3 tanFrame, vec3 viewDir, float roughness )
vec4 sampleGlossyCustomMaterial( vec3 normal, vec3 worldPos, vec3 viewDir, float roughness )
{
- mat3 tanFrame = tangentFrame( normal, worldPos );
+ mat3 tanFrame = tangentFrame( normal, worldPos );
return sampleGlossy( tanFrame, viewDir, roughness );
}
diff --git a/src/Runtime/res/effectlib/screenSpaceAO.glsllib b/src/Runtime/res/effectlib/screenSpaceAO.glsllib
index bb6cbbe6..54204a1f 100644
--- a/src/Runtime/res/effectlib/screenSpaceAO.glsllib
+++ b/src/Runtime/res/effectlib/screenSpaceAO.glsllib
@@ -39,7 +39,7 @@ float hashRot(vec2 pos)
// Basically an odd-even hash.
float px = 2.0 * fract(floor(pos.x) * 0.5);
float py = fract(floor(pos.y) * 0.5);
-
+
return px + py;
}
@@ -52,7 +52,7 @@ vec3 getViewSpacePos( sampler2D depthSampler, vec2 camProps, vec2 UV, vec4 UvToE
{
float sampleDepth = getDepthValue( texture(depthSampler, UV), camProps );
sampleDepth = depthValueToLinearDistance( sampleDepth, camProps );
-
+
vec2 scaledUV = (UV * UvToEye.xy) + UvToEye.zw;
return vec3(scaledUV * sampleDepth, sampleDepth);
}
@@ -62,7 +62,7 @@ vec2 computeDir( vec2 baseDir, int v )
float ang = 3.1415926535 * hashRot( gl_FragCoord.xy ) + float(v - 1);
vec2 vX = vec2(cos(ang), sin(ang));
vec2 vY = vec2(-sin(ang), cos(ang));
-
+
return vec2( dot(baseDir, vX), dot(baseDir, vY) );
}
@@ -71,23 +71,23 @@ vec2 offsetDir( vec2 baseDir, int v )
float ang = float(v - 1);
vec2 vX = vec2(cos(ang), sin(ang));
vec2 vY = vec2(-sin(ang), cos(ang));
-
+
return vec2( dot(baseDir, vX), dot(baseDir, vY) );
}
float SSambientOcclusion(sampler2D depthSampler, vec3 viewNorm, vec4 aoParams, vec4 aoParams2, vec2 camProps, vec4 aoScreen, vec4 UvToEye)
{
float ret = 0.0;
-
+
vec2 centerUV = gl_FragCoord.xy * aoScreen.zw;
vec3 viewPos = getViewSpacePos( depthSampler, camProps, centerUV, UvToEye );
viewPos += viewNorm * aoParams.w;
-
+
float screenRadius = aoParams.y * aoScreen.y / viewPos.z;
if (screenRadius < 1.0) { return 1.0; }
vec3 kernel[9];
-
+
// The X and Y are the 2d direction, while the Z is the height of the sphere at that point.
// In essence, it normalizes the 3d vector, but we're really interested in the 2D offset.
kernel[0] = vec3(-0.1376476, 0.2842022, 0.948832);
@@ -99,52 +99,52 @@ float SSambientOcclusion(sampler2D depthSampler, vec3 viewNorm, vec4 aoParams, v
kernel[6] = vec3(0.7343006, 0.3774331, 0.5642);
kernel[7] = vec3(0.1408805, -0.88915, 0.4353);
kernel[8] = vec3(-0.6642616, -0.543601, 0.5130);
-
+
int radLevels = int(floor(aoParams2.x));
float radStep = 1.0 / aoParams2.x;
-
+
for (int j = 1; j <= radLevels; ++j)
{
for (int i = 0; i < 9; ++i)
{
float curRange = aoParams.y * radStep * float(j);
float curRadius = curRange * kernel[i].z;
-
+
vec3 smpDir;
smpDir.xy = computeDir(kernel[i].xy, j) * aoParams2.y + (1.0 - aoParams2.y) * offsetDir(kernel[i].xy, j);
smpDir.z = kernel[i].z;
smpDir *= curRange;
-
+
vec2 smpUV = centerUV.xy + smpDir.xy * aoScreen.zw;
-
+
// First method is based on Horizon-Based AO
vec3 samplePos = getViewSpacePos( depthSampler, camProps, smpUV, UvToEye );
vec3 smpVec = samplePos - viewPos;
-
+
float lenRad = dot(smpVec, smpVec);
smpVec = normalize(smpVec);
float lenDot = dot(smpVec, viewNorm);
- lenRad /= aoParams.y*aoParams.y;
+ lenRad /= aoParams.y*aoParams.y;
float falloff = smoothstep(8.0, 0.0, (lenRad - 1.0) * 0.125);
float occl = 1.0 - clamp(lenDot * falloff, 0.0, 1.0);
-
+
ret += occl * occl;
}
}
-
+
ret = (ret) / (9.0 * float(radLevels));
-
+
// Blend between soft and hard based on softness param
// NOTE : the 0.72974 is actually an gamma-inverted 0.5 (assuming gamma 2.2)
// Would not need this if we linearized color instead.
float hardCut = (1.0 - aoParams.z) * 0.72974;
ret = smoothstep(0.0, 1.0, (ret - hardCut) / (1.0 - hardCut));
-
+
// Blend between full and no occlusion based on strength param
ret = aoParams.x * ret + (1.0 - aoParams.x);
-
- return ret;
+
+ return ret;
}
#endif
diff --git a/src/Runtime/res/effectlib/screenSpaceDO.glsllib b/src/Runtime/res/effectlib/screenSpaceDO.glsllib
index 2a4a6080..2ccc69fc 100644
--- a/src/Runtime/res/effectlib/screenSpaceDO.glsllib
+++ b/src/Runtime/res/effectlib/screenSpaceDO.glsllib
@@ -37,7 +37,7 @@ vec3 getViewSpacePos( sampler2D depthSampler, vec2 camProps, vec2 UV, vec4 UvToE
{
float sampleDepth = getDepthValue( texture(depthSampler, UV), camProps );
sampleDepth = depthValueToLinearDistance( sampleDepth, camProps );
-
+
vec2 scaledUV = (UV * UvToEye.xy) + UvToEye.zw;
return vec3(scaledUV * sampleDepth, sampleDepth);
}
@@ -46,15 +46,15 @@ float shadowOcclusion(sampler2D depthSampler, vec3 lightDir, vec3 worldPos, mat4
{
vec3 viewPos = getViewSpacePos( depthSampler, camProps, ( gl_FragCoord.xy * aoScreen.zw ), UvToEye );
float depth = viewPos.z;
-
+
// Get the screen-space UV
vec2 centerUV = gl_FragCoord.xy * aoScreen.zw;
-
+
float screenDist = shadowParams.y * 3.1415926535 * aoScreen.y / viewPos.z;
if (screenDist < 1.0) { return 1.0; }
-
+
vec3 viewL = normalize( (viewMat * vec4(lightDir, 0)).xyz );
-
+
float steps = min( screenDist, 20.0 );
int maxCt = int(steps);
float step = 3.1415926535 * shadowParams.y / float(maxCt);
@@ -64,30 +64,30 @@ float shadowOcclusion(sampler2D depthSampler, vec3 lightDir, vec3 worldPos, mat4
{
vec3 ray = lightDir * step * float(i);
vec3 samplePos = worldPos - ray;
-
+
vec4 smpUV = viewProj * vec4(samplePos, 1.0);
smpUV /= smpUV.w;
smpUV.xy = (smpUV.xy + 1.0) * 0.5;
-
+
vec3 testPos = getViewSpacePos( depthSampler, camProps, smpUV.xy, UvToEye );
testPos.z += shadowParams.w;
vec3 testVec = normalize(viewPos - testPos);
testVec -= viewL;
float isBehind = clamp( testVec.z, 0.0, 1.0 );
- float diff = (testPos.z - depth) / shadowParams.y;
+ float diff = (testPos.z - depth) / shadowParams.y;
ret -= isBehind * (1.0 / (1.0 + diff * diff));
}
-
+
ret /= float(maxCt); // divide by number of samples;
// Blend between soft and hard based on softness param
// NOTE : the 0.72974 is actually an gamma-inverted 0.5 (assuming gamma 2.2)
// Would not need this if we linearized color instead.
float hardCut = (ret <= 0.72974) ? 0.0 : 1.0;
ret = shadowParams.z * ret + (1.0 - shadowParams.z) * hardCut;
-
+
// Blend between full and no occlusion based on strength param
ret = shadowParams.x * ret + (1.0 - shadowParams.x);
-
+
return ret;
}
@@ -96,7 +96,7 @@ float shadowOcclusion(sampler2D depthSampler, vec3 lightDir, vec3 worldPos, mat4
float glossyOcclusionBasis(sampler2D depthSampler, mat3 tanFrame, vec3 worldPos, mat4 viewProj, vec3 viewDir, vec4 shadowParams, vec2 camProps, float roughness)
{
float ret = 16.0;
-
+
float kernel[16];
kernel[0] = 0.5; kernel[1] = 0.25;
kernel[2] = 0.75; kernel[3] = 0.125;
@@ -114,30 +114,30 @@ float glossyOcclusionBasis(sampler2D depthSampler, mat3 tanFrame, vec3 worldPos,
ivec2 iCoords = ivec2( gl_FragCoord.xy );
float depth = getDepthValue( texelFetch(depthSampler, iCoords, 0) );
depth = depthValueToLinearDistance( depth, camProps );
-
+
for( int i = 0; i < 16; ++i )
{
- vec3 localDir;
+ vec3 localDir;
float phi = 6.28318530718 * (kernel[i] + phiShift);
float cosTheta = sqrt( float(i+1) / 33.0);
localDir.z = sqrt(1.0 - cosTheta*cosTheta) * normFac;
localDir.x = cos(phi) * cosTheta;
localDir.y = sin(phi) * cosTheta;
-
+
localDir = normalize(localDir);
-
+
vec3 halfDir = tanFrame[0]*localDir.x + tanFrame[1]*localDir.y + tanFrame[2]*localDir.z;
vec3 ray = reflect( -viewDir, halfDir ) * shadowParams.x;
-
+
vec4 samplePos = vec4( worldPos + ray, 1.0 );
-
+
vec4 sampleProj = viewProj * samplePos;
sampleProj /= sampleProj.w;
sampleProj.xy = (sampleProj.xy + 1.0) * 0.5;
float sampleDepth = getDepthValue( texture(depthSampler, sampleProj.xy) );
sampleDepth = depthValueToLinearDistance( sampleDepth, camProps );
-
+
// Occlusion is applied based on a Cauchy distribution filter
// But with a "dead zone" for the very close samples. By subtracting it from 16,
// which represents no occlusion (16/16 = 1), we let nearby occluders have a
@@ -147,9 +147,9 @@ float glossyOcclusionBasis(sampler2D depthSampler, mat3 tanFrame, vec3 worldPos,
float occlDist = 4.0 * max(depth - sampleDepth - shadowParams.y, 0.0) / shadowParams.x;
float occlFactor = 1.0 / ( 1.0 + occlDist*occlDist*0.04 );
occlFactor -= 1.0 / ( 1.0 + occlDist*occlDist*4.0 );
- ret -= min(2.0 * occlFactor, 1.0);
+ ret -= min(2.0 * occlFactor, 1.0);
}
-
+
ret /= 16.0; // divide by number of samples;
return ret;
}
diff --git a/src/Runtime/res/effectlib/shadowMapping.glsllib b/src/Runtime/res/effectlib/shadowMapping.glsllib
index 666590e3..df351f9a 100644
--- a/src/Runtime/res/effectlib/shadowMapping.glsllib
+++ b/src/Runtime/res/effectlib/shadowMapping.glsllib
@@ -37,21 +37,21 @@ float sampleParaboloid( in sampler2D shadowMap, in vec4 shadowControls, in mat4
{
vec4 projCoord = shadowMatrix * vec4( worldPos, 1.0 );
vec3 smpCoord = projCoord.xyz / projCoord.w;
-
- float ptDepth = depthValueToLinearDistance( 1.0 - smpCoord.z, cameraProps );
+
+ float ptDepth = depthValueToLinearDistance( 1.0 - smpCoord.z, cameraProps );
ptDepth = (ptDepth - cameraProps.x) / (cameraProps.y - cameraProps.x);
- smpCoord = normalize( smpCoord.xyz );
+ smpCoord = normalize( smpCoord.xyz );
smpCoord.xy /= -( smpCoord.z + 1.0 );
smpCoord.xy = vec2(1.0) - smpCoord.xy;
smpCoord.xy *= 0.5;
-
+
smpUV = smpCoord.xy; // This is just for debug purposes to ensure what the sampled UV cooord is.
-
+
float sampleDepth = texture( shadowMap, smpCoord.xy ).x + shadowControls.x;
sampleDepth *= sampleDepth;
ptDepth *= ptDepth;
- float shadowFac = min(1.0, exp(shadowControls.y * sampleDepth * sampleDepth) / exp(shadowControls.y * ptDepth * ptDepth));
-
+ float shadowFac = min(1.0, exp(shadowControls.y * sampleDepth * sampleDepth) / exp(shadowControls.y * ptDepth * ptDepth));
+
smpUV.xy *= shadowFac;
return shadowFac;
}
@@ -63,10 +63,10 @@ float sampleCubemap( in samplerCube shadowCube, in vec4 shadowControls, in mat4
vec4 viewCoord = shadowViewMat * vec4( viewDir.xyz, 0.0 );
viewCoord.xyz /= ptDepth;
ptDepth = clamp((ptDepth - 1.0) / (cameraProps.y - 1.0), 0.0, 1.0);
-
- float smpDepth = texture( shadowCube, viewDir.xyz ).x + shadowControls.x;
-
- float shadowFac = min(1.0, exp(shadowControls.y * smpDepth) / exp(shadowControls.y * ptDepth));
+
+ float smpDepth = texture( shadowCube, viewDir.xyz ).x + shadowControls.x;
+
+ float shadowFac = min(1.0, exp(shadowControls.y * smpDepth) / exp(shadowControls.y * ptDepth));
return shadowFac;
}
@@ -76,31 +76,31 @@ float sampleOrthographic( in sampler2D shadowMap, in vec4 shadowControls, in mat
vec3 smpCoord = projCoord.xyz / projCoord.w;
float sampleDepth = texture( shadowMap, smpCoord.xy ).x + shadowControls.x;
-
+
return min(1.0, exp(shadowControls.y * sampleDepth) / exp(shadowControls.y * smpCoord.z));
}
struct ParaboloidMapResult
{
- vec4 m_Position;
- vec4 m_WorldPos;
+ vec4 m_Position;
+ vec4 m_WorldPos;
};
ParaboloidMapResult VertexParaboloidDepth(vec3 pos, mat4 inMVP)
{
- vec4 glPos = inMVP * vec4( pos, 1.0 );
- glPos /= glPos.w;
- glPos.xyz = normalize( glPos.xyz );
- vec4 world_pos;
- world_pos.w = glPos.z;
- glPos.xy /= glPos.z + 1.0;
- world_pos.xyz = pos.xyz;
-
- ParaboloidMapResult retval;
- retval.m_Position = glPos;
- retval.m_WorldPos = world_pos;
- return retval;
+ vec4 glPos = inMVP * vec4( pos, 1.0 );
+ glPos /= glPos.w;
+ glPos.xyz = normalize( glPos.xyz );
+ vec4 world_pos;
+ world_pos.w = glPos.z;
+ glPos.xy /= glPos.z + 1.0;
+ world_pos.xyz = pos.xyz;
+
+ ParaboloidMapResult retval;
+ retval.m_Position = glPos;
+ retval.m_WorldPos = world_pos;
+ return retval;
}
#endif \ No newline at end of file
diff --git a/src/Runtime/res/effectlib/shadowMappingFragment.glsllib b/src/Runtime/res/effectlib/shadowMappingFragment.glsllib
index 514d00e5..660d736a 100644
--- a/src/Runtime/res/effectlib/shadowMappingFragment.glsllib
+++ b/src/Runtime/res/effectlib/shadowMappingFragment.glsllib
@@ -1,10 +1,10 @@
#include "depthpass.glsllib"
float FragmentParaboloidDepth( vec4 inWorldPos, mat4 inMVP, vec2 inCameraProperties )
{
- if (inWorldPos.w < 0.0)
- discard;
- vec4 projVec = inMVP * vec4( inWorldPos.xyz, 1.0 );
- projVec /= projVec.w;
- projVec.z = depthValueToLinearDistance( 1.0 - projVec.z, inCameraProperties );
- return (projVec.z - inCameraProperties.x) / (inCameraProperties.y - inCameraProperties.x);
+ if (inWorldPos.w < 0.0)
+ discard;
+ vec4 projVec = inMVP * vec4( inWorldPos.xyz, 1.0 );
+ projVec /= projVec.w;
+ projVec.z = depthValueToLinearDistance( 1.0 - projVec.z, inCameraProperties );
+ return (projVec.z - inCameraProperties.x) / (inCameraProperties.y - inCameraProperties.x);
}
diff --git a/src/Runtime/res/effectlib/simpleGlossyBSDF.glsllib b/src/Runtime/res/effectlib/simpleGlossyBSDF.glsllib
index 5b463e74..31a9ac50 100644
--- a/src/Runtime/res/effectlib/simpleGlossyBSDF.glsllib
+++ b/src/Runtime/res/effectlib/simpleGlossyBSDF.glsllib
@@ -81,7 +81,7 @@ vec4 simpleGlossyBSDFEnvironment( in mat3 tanFrame, in vec3 viewDir, in float ro
// RNM radiosity normal maps
vec4 glossyRNM( in vec3 N, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ )
{
- // we use a fixed basis like Half Life
+ // we use a fixed basis like Half Life
vec3 B0 = vec3( -0.40825, 0.70711, 0.57735);
vec3 B1 = vec3( -0.40825, -0.70711, 0.57735);
vec3 B2 = vec3( 0.8165, 0.0, 0.57735);
@@ -92,8 +92,8 @@ vec4 glossyRNM( in vec3 N, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ )
dp.z = clamp( dot ( N , B2 ), 0.0, 1.0);
float sum = 1.0 / dot( dp, vec3(1.0, 1.0, 1.0) );
- vec3 diffuseLight = dp.x * rnmX + dp.y * rnmY + dp.z * rnmZ;
- //vec3 diffuseLight = N.x * rnmX + N.y * rnmY + N.z * rnmZ;
+ vec3 diffuseLight = dp.x * rnmX + dp.y * rnmY + dp.z * rnmZ;
+ //vec3 diffuseLight = N.x * rnmX + N.y * rnmY + N.z * rnmZ;
return (vec4(diffuseLight, 1.0) * sum);
}
diff --git a/src/Runtime/res/effectlib/spotEdf.glsllib b/src/Runtime/res/effectlib/spotEdf.glsllib
index defa641d..663bd8f0 100644
--- a/src/Runtime/res/effectlib/spotEdf.glsllib
+++ b/src/Runtime/res/effectlib/spotEdf.glsllib
@@ -34,7 +34,7 @@ float spotEdf( float exponent )
float dist = length(viewDir);
vec3 spotDir = viewDir / dist;
-
+
float spot = max(0.0f, dot(spotDir, normal));
att = pow(spot, exponent);
diff --git a/src/Runtime/res/effectlib/tessellationLinear.glsllib b/src/Runtime/res/effectlib/tessellationLinear.glsllib
index 99035145..f854cc15 100644
--- a/src/Runtime/res/effectlib/tessellationLinear.glsllib
+++ b/src/Runtime/res/effectlib/tessellationLinear.glsllib
@@ -44,59 +44,59 @@ uniform float disableCulling;
float isBackFace()
{
- vec3 faceNormal = normalize( cross( ctWorldPos[2] - ctWorldPos[0], ctWorldPos[1] - ctWorldPos[0] ) );
+ vec3 faceNormal = normalize( cross( ctWorldPos[2] - ctWorldPos[0], ctWorldPos[1] - ctWorldPos[0] ) );
- vec3 ncd = normalize( ctWorldPos[0] - camera_position );
+ vec3 ncd = normalize( ctWorldPos[0] - camera_position );
- return sign( dot(faceNormal, ncd) );
+ return sign( dot(faceNormal, ncd) );
}
float adaptiveCameraFactor( in float minTess, in float maxTess )
{
- float distanceValue0 = distance( camera_position, ctWorldPos[0] );
- float distanceValue1 = distance( camera_position, ctWorldPos[1] );
- float distanceValue2 = distance( camera_position, ctWorldPos[2] );
+ float distanceValue0 = distance( camera_position, ctWorldPos[0] );
+ float distanceValue1 = distance( camera_position, ctWorldPos[1] );
+ float distanceValue2 = distance( camera_position, ctWorldPos[2] );
- float range = distanceRange[1] - distanceRange[0];
+ float range = distanceRange[1] - distanceRange[0];
- vec3 edgeDistance;
- edgeDistance[0] = ((distanceValue1 + distanceValue2) / 2.0) / range;
- edgeDistance[1] = ((distanceValue2 + distanceValue0) / 2.0) / range;
- edgeDistance[2] = ((distanceValue0 + distanceValue1) / 2.0) / range;
+ vec3 edgeDistance;
+ edgeDistance[0] = ((distanceValue1 + distanceValue2) / 2.0) / range;
+ edgeDistance[1] = ((distanceValue2 + distanceValue0) / 2.0) / range;
+ edgeDistance[2] = ((distanceValue0 + distanceValue1) / 2.0) / range;
- edgeDistance = clamp( edgeDistance, vec3(0.0), vec3(1.0) );
+ edgeDistance = clamp( edgeDistance, vec3(0.0), vec3(1.0) );
- //float af = mix( minTess, maxTess, 1.0 - edgeDistance[gl_InvocationID] );
- float af = 1.0 - edgeDistance[gl_InvocationID];
- af = clamp( af*af*maxTess , minTess, maxTess );
+ //float af = mix( minTess, maxTess, 1.0 - edgeDistance[gl_InvocationID] );
+ float af = 1.0 - edgeDistance[gl_InvocationID];
+ af = clamp( af*af*maxTess , minTess, maxTess );
- return af;
+ return af;
}
-void tessShader ( in float tessEdge, in float tessInner )
+void tessShader ( in float tessEdge, in float tessInner )
{
- float bf = isBackFace();
- bf = max(disableCulling, bf);
+ float bf = isBackFace();
+ bf = max(disableCulling, bf);
- // adapative tessellation factor
- float af = adaptiveCameraFactor( tessInner, tessEdge );
+ // adapative tessellation factor
+ float af = adaptiveCameraFactor( tessInner, tessEdge );
- // Calculate the tessellation levels
- gl_TessLevelInner[0] = af * bf;
- gl_TessLevelOuter[gl_InvocationID] = af * bf;
+ // Calculate the tessellation levels
+ gl_TessLevelInner[0] = af * bf;
+ gl_TessLevelOuter[gl_InvocationID] = af * bf;
}
#endif
#if TESSELLATION_EVALUATION_SHADER
layout (triangles, equal_spacing, ccw) in;
-vec4 tessShader ( )
+vec4 tessShader ( )
{
- vec4 p0 = gl_TessCoord.x * gl_in[0].gl_Position;
- vec4 p1 = gl_TessCoord.y * gl_in[1].gl_Position;
- vec4 p2 = gl_TessCoord.z * gl_in[2].gl_Position;
- vec4 pos = p0 + p1 + p2;
- return pos;
+ vec4 p0 = gl_TessCoord.x * gl_in[0].gl_Position;
+ vec4 p1 = gl_TessCoord.y * gl_in[1].gl_Position;
+ vec4 p2 = gl_TessCoord.z * gl_in[2].gl_Position;
+ vec4 pos = p0 + p1 + p2;
+ return pos;
}
#endif
diff --git a/src/Runtime/res/effectlib/tessellationLinearCM.glsllib b/src/Runtime/res/effectlib/tessellationLinearCM.glsllib
index cd3b1645..d2bb90af 100644
--- a/src/Runtime/res/effectlib/tessellationLinearCM.glsllib
+++ b/src/Runtime/res/effectlib/tessellationLinearCM.glsllib
@@ -71,31 +71,31 @@ varying vec3 varWorldPosTC[];
void main() {
#if QT3DS_ENABLE_WORLD_POSITION
- ctWorldPos[0] = varWorldPos[0];
- ctWorldPos[1] = varWorldPos[1];
- ctWorldPos[2] = varWorldPos[2];
+ ctWorldPos[0] = varWorldPos[0];
+ ctWorldPos[1] = varWorldPos[1];
+ ctWorldPos[2] = varWorldPos[2];
#endif
- gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
- tessShader( tessLevelOuter, tessLevelInner);
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+ tessShader( tessLevelOuter, tessLevelInner);
- varObjPosTC[gl_InvocationID] = varObjPos[gl_InvocationID];
- varNormalTC[gl_InvocationID] = varNormal[gl_InvocationID];
+ varObjPosTC[gl_InvocationID] = varObjPos[gl_InvocationID];
+ varNormalTC[gl_InvocationID] = varNormal[gl_InvocationID];
#if QT3DS_ENABLE_UV0
- varTexCoord0TC[gl_InvocationID] = varTexCoord0[gl_InvocationID];
+ varTexCoord0TC[gl_InvocationID] = varTexCoord0[gl_InvocationID];
#endif
#if QT3DS_ENABLE_TEXTAN
- varTangentTC[gl_InvocationID] = varTangent[gl_InvocationID];
- varObjTangentTC[gl_InvocationID] = varObjTangent[gl_InvocationID];
+ varTangentTC[gl_InvocationID] = varTangent[gl_InvocationID];
+ varObjTangentTC[gl_InvocationID] = varObjTangent[gl_InvocationID];
#endif
#if QT3DS_ENABLE_BINORMAL
- varBinormalTC[gl_InvocationID] = varBinormal[gl_InvocationID];
- varObjBinormalTC[gl_InvocationID] = varObjBinormal[gl_InvocationID];
+ varBinormalTC[gl_InvocationID] = varBinormal[gl_InvocationID];
+ varObjBinormalTC[gl_InvocationID] = varObjBinormal[gl_InvocationID];
#endif
#if QT3DS_ENABLE_WORLD_POSITION
- varWorldPosTC[gl_InvocationID] = varWorldPos[gl_InvocationID];
-#endif
+ varWorldPosTC[gl_InvocationID] = varWorldPos[gl_InvocationID];
+#endif
}
#endif
@@ -143,29 +143,29 @@ varying vec3 VARYING_NAME(varWorldPos);
#endif
void main() {
- vec4 pos = tessShader( );
+ vec4 pos = tessShader( );
- gl_Position = model_view_projection_matrix * pos;
+ gl_Position = model_view_projection_matrix * pos;
- VARYING_NAME(varObjPos) = gl_TessCoord.x * varObjPosTC[0] + gl_TessCoord.y * varObjPosTC[1] + gl_TessCoord.z * varObjPosTC[2];
- VARYING_NAME(varNormal) = gl_TessCoord.x * varNormalTC[0] + gl_TessCoord.y * varNormalTC[1] + gl_TessCoord.z * varNormalTC[2];
+ VARYING_NAME(varObjPos) = gl_TessCoord.x * varObjPosTC[0] + gl_TessCoord.y * varObjPosTC[1] + gl_TessCoord.z * varObjPosTC[2];
+ VARYING_NAME(varNormal) = gl_TessCoord.x * varNormalTC[0] + gl_TessCoord.y * varNormalTC[1] + gl_TessCoord.z * varNormalTC[2];
#if QT3DS_ENABLE_UV0
- VARYING_NAME(varTexCoord0) = gl_TessCoord.x * varTexCoord0TC[0] + gl_TessCoord.y * varTexCoord0TC[1] + gl_TessCoord.z * varTexCoord0TC[2];
-#endif
+ VARYING_NAME(varTexCoord0) = gl_TessCoord.x * varTexCoord0TC[0] + gl_TessCoord.y * varTexCoord0TC[1] + gl_TessCoord.z * varTexCoord0TC[2];
+#endif
#if QT3DS_ENABLE_TEXTAN
- VARYING_NAME(varTangent) = gl_TessCoord.x * varTangentTC[0] + gl_TessCoord.y * varTangentTC[1] + gl_TessCoord.z * varTangentTC[2];
- VARYING_NAME(varObjTangent) = gl_TessCoord.x * varObjTangentTC[0] + gl_TessCoord.y * varObjTangentTC[1] + gl_TessCoord.z * varObjTangentTC[2];
+ VARYING_NAME(varTangent) = gl_TessCoord.x * varTangentTC[0] + gl_TessCoord.y * varTangentTC[1] + gl_TessCoord.z * varTangentTC[2];
+ VARYING_NAME(varObjTangent) = gl_TessCoord.x * varObjTangentTC[0] + gl_TessCoord.y * varObjTangentTC[1] + gl_TessCoord.z * varObjTangentTC[2];
#endif
#if QT3DS_ENABLE_BINORMAL
- VARYING_NAME(varBinormal) = gl_TessCoord.x * varBinormalTC[0] + gl_TessCoord.y * varBinormalTC[1] + gl_TessCoord.z * varBinormalTC[2];
- VARYING_NAME(varObjBinormal) = gl_TessCoord.x * varObjBinormalTC[0] + gl_TessCoord.y * varObjBinormalTC[1] + gl_TessCoord.z * varObjBinormalTC[2];
+ VARYING_NAME(varBinormal) = gl_TessCoord.x * varBinormalTC[0] + gl_TessCoord.y * varBinormalTC[1] + gl_TessCoord.z * varBinormalTC[2];
+ VARYING_NAME(varObjBinormal) = gl_TessCoord.x * varObjBinormalTC[0] + gl_TessCoord.y * varObjBinormalTC[1] + gl_TessCoord.z * varObjBinormalTC[2];
#endif
#if QT3DS_ENABLE_WORLD_POSITION
- VARYING_NAME(varWorldPos) = gl_TessCoord.x * varWorldPosTC[0] + gl_TessCoord.y * varWorldPosTC[1] + gl_TessCoord.z * varWorldPosTC[2];
+ VARYING_NAME(varWorldPos) = gl_TessCoord.x * varWorldPosTC[0] + gl_TessCoord.y * varWorldPosTC[1] + gl_TessCoord.z * varWorldPosTC[2];
#endif
- VARYING_NAME(varNormal) = normalize(normal_matrix * VARYING_NAME(varNormal));
+ VARYING_NAME(varNormal) = normalize(normal_matrix * VARYING_NAME(varNormal));
}
#endif
diff --git a/src/Runtime/res/effectlib/tessellationNPatch.glsllib b/src/Runtime/res/effectlib/tessellationNPatch.glsllib
index a483440c..62ec2635 100644
--- a/src/Runtime/res/effectlib/tessellationNPatch.glsllib
+++ b/src/Runtime/res/effectlib/tessellationNPatch.glsllib
@@ -31,21 +31,21 @@
#ifndef TESSELLATION_NPATCH_GLSLLIB
#define TESSELLATION_NPATCH_GLSLLIB
-struct NPatchTessPatch
+struct NPatchTessPatch
{
- float b210;
- float b120;
- float b021;
- float b012;
- float b102;
- float b201;
- float b111;
- float n110;
- float n011;
- float n101;
- float t110;
- float t011;
- float t101;
+ float b210;
+ float b120;
+ float b021;
+ float b012;
+ float b102;
+ float b201;
+ float b111;
+ float n110;
+ float n011;
+ float n101;
+ float t110;
+ float t011;
+ float t101;
};
#if TESSELLATION_CONTROL_SHADER
@@ -64,118 +64,118 @@ uniform float disableCulling;
float isBackFace()
{
- vec3 faceNormal = normalize( cross( ctWorldPos[2] - ctWorldPos[0], ctWorldPos[1] - ctWorldPos[0] ) );
+ vec3 faceNormal = normalize( cross( ctWorldPos[2] - ctWorldPos[0], ctWorldPos[1] - ctWorldPos[0] ) );
- vec3 ncd = normalize( ctWorldPos[0] - camera_position );
+ vec3 ncd = normalize( ctWorldPos[0] - camera_position );
- return sign( 0.2 + dot(faceNormal, ncd) ); // 0.2 is a conservative offset to account for curved surfaces
+ return sign( 0.2 + dot(faceNormal, ncd) ); // 0.2 is a conservative offset to account for curved surfaces
}
float adaptiveCameraFactor( in float minTess, in float maxTess )
{
- float distanceValue0 = distance( camera_position, ctWorldPos[0] );
- float distanceValue1 = distance( camera_position, ctWorldPos[1] );
- float distanceValue2 = distance( camera_position, ctWorldPos[2] );
+ float distanceValue0 = distance( camera_position, ctWorldPos[0] );
+ float distanceValue1 = distance( camera_position, ctWorldPos[1] );
+ float distanceValue2 = distance( camera_position, ctWorldPos[2] );
- float range = distanceRange[1] - distanceRange[0];
+ float range = distanceRange[1] - distanceRange[0];
- vec3 edgeDistance;
- edgeDistance[0] = ((distanceValue1 + distanceValue2) / 2.0) / range;
- edgeDistance[1] = ((distanceValue2 + distanceValue0) / 2.0) / range;
- edgeDistance[2] = ((distanceValue0 + distanceValue1) / 2.0) / range;
+ vec3 edgeDistance;
+ edgeDistance[0] = ((distanceValue1 + distanceValue2) / 2.0) / range;
+ edgeDistance[1] = ((distanceValue2 + distanceValue0) / 2.0) / range;
+ edgeDistance[2] = ((distanceValue0 + distanceValue1) / 2.0) / range;
- edgeDistance = clamp( edgeDistance, vec3(0.0), vec3(1.0) );
+ edgeDistance = clamp( edgeDistance, vec3(0.0), vec3(1.0) );
- //float af = mix( minTess, maxTess, 1.0 - edgeDistance[gl_InvocationID] );
- float af = 1.0 - edgeDistance[gl_InvocationID];
- af = clamp( af*af*maxTess , minTess, maxTess );
+ //float af = mix( minTess, maxTess, 1.0 - edgeDistance[gl_InvocationID] );
+ float af = 1.0 - edgeDistance[gl_InvocationID];
+ af = clamp( af*af*maxTess , minTess, maxTess );
- return af;
+ return af;
}
float adaptiveFeatureFactor( in float minTess, in float maxTess )
{
- vec3 adaptValue;
- adaptValue[0] = clamp( dot(ctNorm[1], ctNorm[2]), -1.0, 1.0 );
- adaptValue[1] = clamp( dot(ctNorm[2], ctNorm[0]), -1.0, 1.0 );
- adaptValue[2] = clamp( dot(ctNorm[0], ctNorm[1]), -1.0, 1.0 );
+ vec3 adaptValue;
+ adaptValue[0] = clamp( dot(ctNorm[1], ctNorm[2]), -1.0, 1.0 );
+ adaptValue[1] = clamp( dot(ctNorm[2], ctNorm[0]), -1.0, 1.0 );
+ adaptValue[2] = clamp( dot(ctNorm[0], ctNorm[1]), -1.0, 1.0 );
- //float af = min( adaptValue[0], min(adaptValue[1], adaptValue[2]) );
- // map [-1, +1] range to [0, 1] range
- float af = (adaptValue[gl_InvocationID] + 1.0) / 2.0;
+ //float af = min( adaptValue[0], min(adaptValue[1], adaptValue[2]) );
+ // map [-1, +1] range to [0, 1] range
+ float af = (adaptValue[gl_InvocationID] + 1.0) / 2.0;
- af = mix( minTess, maxTess, 1.0 - af );
+ af = mix( minTess, maxTess, 1.0 - af );
- return af;
+ return af;
}
float getwij(int i, int j)
{
- return dot(gl_in[j].gl_Position.xyz - gl_in[i].gl_Position.xyz, ctNorm[i]);
+ return dot(gl_in[j].gl_Position.xyz - gl_in[i].gl_Position.xyz, ctNorm[i]);
}
float getvij(int i, int j)
{
- vec3 pji = gl_in[j].gl_Position.xyz - gl_in[i].gl_Position.xyz;
- vec3 nij = ctNorm[i] + ctNorm[j];
+ vec3 pji = gl_in[j].gl_Position.xyz - gl_in[i].gl_Position.xyz;
+ vec3 nij = ctNorm[i] + ctNorm[j];
- return 2.0*dot(pji, nij)/dot(pji, pji);
+ return 2.0*dot(pji, nij)/dot(pji, pji);
}
-void tessShader ( in float tessEdge, in float tessInner )
+void tessShader ( in float tessEdge, in float tessInner )
{
- // setup control points
- // notations and formulas see http://alex.vlachos.com/graphics/CurvedPNTriangles.pdf
- // note we compute separate x,y,z component for each invocation
- float b300 = gl_in[0].gl_Position[gl_InvocationID];
- float b030 = gl_in[1].gl_Position[gl_InvocationID];
- float b003 = gl_in[2].gl_Position[gl_InvocationID];
- float n200 = ctNorm[0][gl_InvocationID];
- float n020 = ctNorm[1][gl_InvocationID];
- float n002 = ctNorm[2][gl_InvocationID];
- float t200 = ctTangent[0][gl_InvocationID];
- float t020 = ctTangent[1][gl_InvocationID];
- float t002 = ctTangent[2][gl_InvocationID];
-
- // compute tangent control points
- tcTessPatch[gl_InvocationID].b210 = (2.0*b300 + b030 - getwij(0,1)*n200)/3.0;
- tcTessPatch[gl_InvocationID].b120 = (2.0*b030 + b300 - getwij(1,0)*n020)/3.0;
- tcTessPatch[gl_InvocationID].b021 = (2.0*b030 + b003 - getwij(1,2)*n020)/3.0;
- tcTessPatch[gl_InvocationID].b012 = (2.0*b003 + b030 - getwij(2,1)*n002)/3.0;
- tcTessPatch[gl_InvocationID].b102 = (2.0*b003 + b300 - getwij(2,0)*n002)/3.0;
- tcTessPatch[gl_InvocationID].b201 = (2.0*b300 + b003 - getwij(0,2)*n200)/3.0;
- // compute center control point
- float E = ( tcTessPatch[gl_InvocationID].b210
- + tcTessPatch[gl_InvocationID].b120
- + tcTessPatch[gl_InvocationID].b021
- + tcTessPatch[gl_InvocationID].b012
- + tcTessPatch[gl_InvocationID].b102
- + tcTessPatch[gl_InvocationID].b201 ) / 6.0;
-
- float V = ( b300 + b030 + b003 ) / 3.0;
- tcTessPatch[gl_InvocationID].b111 = E + (E-V)*0.5;
-
- // compute normals
- tcTessPatch[gl_InvocationID].n110 = n200 + n020 - getvij(0,1) * (b030 - b300);
- tcTessPatch[gl_InvocationID].n011 = n020 + n002 - getvij(1,2) * (b003 - b030);
- tcTessPatch[gl_InvocationID].n101 = n002 + n200 - getvij(2,0) * (b300 - b003);
- // compute tangents
- tcTessPatch[gl_InvocationID].t110 = t200 + t020 - getvij(0,1) * (b030 - b300);
- tcTessPatch[gl_InvocationID].t011 = t020 + t002 - getvij(1,2) * (b003 - b030);
- tcTessPatch[gl_InvocationID].t101 = t002 + t200 - getvij(2,0) * (b300 - b003);
-
- // compute backface
- float bf = isBackFace();
- bf = max(disableCulling, bf);
-
- // adapative tessellation factor regarding features
- float af = adaptiveFeatureFactor( tessInner, tessEdge );
-
- //float cf = adaptiveCameraFactor( tessInner, tessEdge );
-
- // Calculate the tessellation levels
- gl_TessLevelInner[0] = af * bf;
- gl_TessLevelOuter[gl_InvocationID] = af * bf;
+ // setup control points
+ // notations and formulas see http://alex.vlachos.com/graphics/CurvedPNTriangles.pdf
+ // note we compute separate x,y,z component for each invocation
+ float b300 = gl_in[0].gl_Position[gl_InvocationID];
+ float b030 = gl_in[1].gl_Position[gl_InvocationID];
+ float b003 = gl_in[2].gl_Position[gl_InvocationID];
+ float n200 = ctNorm[0][gl_InvocationID];
+ float n020 = ctNorm[1][gl_InvocationID];
+ float n002 = ctNorm[2][gl_InvocationID];
+ float t200 = ctTangent[0][gl_InvocationID];
+ float t020 = ctTangent[1][gl_InvocationID];
+ float t002 = ctTangent[2][gl_InvocationID];
+
+ // compute tangent control points
+ tcTessPatch[gl_InvocationID].b210 = (2.0*b300 + b030 - getwij(0,1)*n200)/3.0;
+ tcTessPatch[gl_InvocationID].b120 = (2.0*b030 + b300 - getwij(1,0)*n020)/3.0;
+ tcTessPatch[gl_InvocationID].b021 = (2.0*b030 + b003 - getwij(1,2)*n020)/3.0;
+ tcTessPatch[gl_InvocationID].b012 = (2.0*b003 + b030 - getwij(2,1)*n002)/3.0;
+ tcTessPatch[gl_InvocationID].b102 = (2.0*b003 + b300 - getwij(2,0)*n002)/3.0;
+ tcTessPatch[gl_InvocationID].b201 = (2.0*b300 + b003 - getwij(0,2)*n200)/3.0;
+ // compute center control point
+ float E = ( tcTessPatch[gl_InvocationID].b210
+ + tcTessPatch[gl_InvocationID].b120
+ + tcTessPatch[gl_InvocationID].b021
+ + tcTessPatch[gl_InvocationID].b012
+ + tcTessPatch[gl_InvocationID].b102
+ + tcTessPatch[gl_InvocationID].b201 ) / 6.0;
+
+ float V = ( b300 + b030 + b003 ) / 3.0;
+ tcTessPatch[gl_InvocationID].b111 = E + (E-V)*0.5;
+
+ // compute normals
+ tcTessPatch[gl_InvocationID].n110 = n200 + n020 - getvij(0,1) * (b030 - b300);
+ tcTessPatch[gl_InvocationID].n011 = n020 + n002 - getvij(1,2) * (b003 - b030);
+ tcTessPatch[gl_InvocationID].n101 = n002 + n200 - getvij(2,0) * (b300 - b003);
+ // compute tangents
+ tcTessPatch[gl_InvocationID].t110 = t200 + t020 - getvij(0,1) * (b030 - b300);
+ tcTessPatch[gl_InvocationID].t011 = t020 + t002 - getvij(1,2) * (b003 - b030);
+ tcTessPatch[gl_InvocationID].t101 = t002 + t200 - getvij(2,0) * (b300 - b003);
+
+ // compute backface
+ float bf = isBackFace();
+ bf = max(disableCulling, bf);
+
+ // adapative tessellation factor regarding features
+ float af = adaptiveFeatureFactor( tessInner, tessEdge );
+
+ //float cf = adaptiveCameraFactor( tessInner, tessEdge );
+
+ // Calculate the tessellation levels
+ gl_TessLevelInner[0] = af * bf;
+ gl_TessLevelOuter[gl_InvocationID] = af * bf;
}
#endif
@@ -194,95 +194,95 @@ vec3 teBinormal;
bool doLinear(int i, int j)
{
- /*
- vec3 edgeji = gl_in[j].gl_Position.xyz - gl_in[i].gl_Position.xyz;
+ /*
+ vec3 edgeji = gl_in[j].gl_Position.xyz - gl_in[i].gl_Position.xyz;
- float di = sign( dot( ctNorm[i], edgeji ) );
- float dj = sign( dot( ctNorm[j], -edgeji ) );
+ float di = sign( dot( ctNorm[i], edgeji ) );
+ float dj = sign( dot( ctNorm[j], -edgeji ) );
- if ( di != dj )
- return false;
- else
- return true;*/
+ if ( di != dj )
+ return false;
+ else
+ return true;*/
- // Always do linear normal interpolation for now
- // Seems to produce always good results unless we would produce
- // a s-shaped triangle.
- return true;
+ // Always do linear normal interpolation for now
+ // Seems to produce always good results unless we would produce
+ // a s-shaped triangle.
+ return true;
}
-vec4 tessShader ( )
+vec4 tessShader ( )
{
- // pre compute square tesselation coord
- vec3 tessSquared = gl_TessCoord * gl_TessCoord;
- vec3 tessCubed = tessSquared * gl_TessCoord;
-
- // combine control points
- vec3 b210 = vec3(tcTessPatch[0].b210, tcTessPatch[1].b210, tcTessPatch[2].b210);
- vec3 b120 = vec3(tcTessPatch[0].b120, tcTessPatch[1].b120, tcTessPatch[2].b120);
- vec3 b021 = vec3(tcTessPatch[0].b021, tcTessPatch[1].b021, tcTessPatch[2].b021);
- vec3 b012 = vec3(tcTessPatch[0].b012, tcTessPatch[1].b012, tcTessPatch[2].b012);
- vec3 b102 = vec3(tcTessPatch[0].b102, tcTessPatch[1].b102, tcTessPatch[2].b102);
- vec3 b201 = vec3(tcTessPatch[0].b201, tcTessPatch[1].b201, tcTessPatch[2].b201);
- vec3 b111 = vec3(tcTessPatch[0].b111, tcTessPatch[1].b111, tcTessPatch[2].b111);
-
- // combine control normals
- vec3 n110 = vec3(tcTessPatch[0].n110, tcTessPatch[1].n110, tcTessPatch[2].n110);
- vec3 n011 = vec3(tcTessPatch[0].n011, tcTessPatch[1].n011, tcTessPatch[2].n011);
- vec3 n101 = vec3(tcTessPatch[0].n101, tcTessPatch[1].n101, tcTessPatch[2].n101);
-
- // combine control tangents
- vec3 t110 = vec3(tcTessPatch[0].t110, tcTessPatch[1].t110, tcTessPatch[2].t110);
- vec3 t011 = vec3(tcTessPatch[0].t011, tcTessPatch[1].t011, tcTessPatch[2].t011);
- vec3 t101 = vec3(tcTessPatch[0].t101, tcTessPatch[1].t101, tcTessPatch[2].t101);
-
- // NPatch normal
- if ( doLinear( 0, 1 ) == true )
- {
- // linear normal
- teNorm = ctNorm[0] * gl_TessCoord[2]
- + ctNorm[1] * gl_TessCoord[0]
- + ctNorm[2] * gl_TessCoord[1];
- // NPatch tangent
- teTangent = ctTangent[0] * gl_TessCoord[2]
- + ctTangent[1] * gl_TessCoord[0]
- + ctTangent[2] * gl_TessCoord[1];
- }
- else
- {
- // quadratic normal
- teNorm = ctNorm[0] * tessSquared[2]
- + ctNorm[1] * tessSquared[0]
- + ctNorm[2] * tessSquared[1]
- + n110*gl_TessCoord[2] * gl_TessCoord[0]
- + n011*gl_TessCoord[0] * gl_TessCoord[1]
- + n101*gl_TessCoord[2] * gl_TessCoord[1];
-
- // NPatch tangent
- teTangent = ctTangent[0] * tessSquared[2]
- + ctTangent[1] * tessSquared[0]
- + ctTangent[2] * tessSquared[1]
- + t110*gl_TessCoord[2] * gl_TessCoord[0]
- + t011*gl_TessCoord[0] * gl_TessCoord[1]
- + t101*gl_TessCoord[2] * gl_TessCoord[1];
- }
-
- // NPatch binormal
- teBinormal = cross( teNorm, teTangent );
-
- // npatch interpolated position
- vec3 finalPos = gl_in[0].gl_Position.xyz * tessCubed[2]
- + gl_in[1].gl_Position.xyz * tessCubed[0]
- + gl_in[2].gl_Position.xyz * tessCubed[1]
- + b210 * 3.0 * tessSquared[2] * gl_TessCoord[0]
- + b120 * 3.0 * tessSquared[0] * gl_TessCoord[2]
- + b201 * 3.0 * tessSquared[2] * gl_TessCoord[1]
- + b021 * 3.0 * tessSquared[0] * gl_TessCoord[1]
- + b102 * 3.0 * tessSquared[1] * gl_TessCoord[2]
- + b012 * 3.0 * tessSquared[1] * gl_TessCoord[0]
- + b111 * 6.0 * gl_TessCoord[0] * gl_TessCoord[1] * gl_TessCoord[2];
-
- return vec4( finalPos, 1.0 );
+ // pre compute square tesselation coord
+ vec3 tessSquared = gl_TessCoord * gl_TessCoord;
+ vec3 tessCubed = tessSquared * gl_TessCoord;
+
+ // combine control points
+ vec3 b210 = vec3(tcTessPatch[0].b210, tcTessPatch[1].b210, tcTessPatch[2].b210);
+ vec3 b120 = vec3(tcTessPatch[0].b120, tcTessPatch[1].b120, tcTessPatch[2].b120);
+ vec3 b021 = vec3(tcTessPatch[0].b021, tcTessPatch[1].b021, tcTessPatch[2].b021);
+ vec3 b012 = vec3(tcTessPatch[0].b012, tcTessPatch[1].b012, tcTessPatch[2].b012);
+ vec3 b102 = vec3(tcTessPatch[0].b102, tcTessPatch[1].b102, tcTessPatch[2].b102);
+ vec3 b201 = vec3(tcTessPatch[0].b201, tcTessPatch[1].b201, tcTessPatch[2].b201);
+ vec3 b111 = vec3(tcTessPatch[0].b111, tcTessPatch[1].b111, tcTessPatch[2].b111);
+
+ // combine control normals
+ vec3 n110 = vec3(tcTessPatch[0].n110, tcTessPatch[1].n110, tcTessPatch[2].n110);
+ vec3 n011 = vec3(tcTessPatch[0].n011, tcTessPatch[1].n011, tcTessPatch[2].n011);
+ vec3 n101 = vec3(tcTessPatch[0].n101, tcTessPatch[1].n101, tcTessPatch[2].n101);
+
+ // combine control tangents
+ vec3 t110 = vec3(tcTessPatch[0].t110, tcTessPatch[1].t110, tcTessPatch[2].t110);
+ vec3 t011 = vec3(tcTessPatch[0].t011, tcTessPatch[1].t011, tcTessPatch[2].t011);
+ vec3 t101 = vec3(tcTessPatch[0].t101, tcTessPatch[1].t101, tcTessPatch[2].t101);
+
+ // NPatch normal
+ if ( doLinear( 0, 1 ) == true )
+ {
+ // linear normal
+ teNorm = ctNorm[0] * gl_TessCoord[2]
+ + ctNorm[1] * gl_TessCoord[0]
+ + ctNorm[2] * gl_TessCoord[1];
+ // NPatch tangent
+ teTangent = ctTangent[0] * gl_TessCoord[2]
+ + ctTangent[1] * gl_TessCoord[0]
+ + ctTangent[2] * gl_TessCoord[1];
+ }
+ else
+ {
+ // quadratic normal
+ teNorm = ctNorm[0] * tessSquared[2]
+ + ctNorm[1] * tessSquared[0]
+ + ctNorm[2] * tessSquared[1]
+ + n110*gl_TessCoord[2] * gl_TessCoord[0]
+ + n011*gl_TessCoord[0] * gl_TessCoord[1]
+ + n101*gl_TessCoord[2] * gl_TessCoord[1];
+
+ // NPatch tangent
+ teTangent = ctTangent[0] * tessSquared[2]
+ + ctTangent[1] * tessSquared[0]
+ + ctTangent[2] * tessSquared[1]
+ + t110*gl_TessCoord[2] * gl_TessCoord[0]
+ + t011*gl_TessCoord[0] * gl_TessCoord[1]
+ + t101*gl_TessCoord[2] * gl_TessCoord[1];
+ }
+
+ // NPatch binormal
+ teBinormal = cross( teNorm, teTangent );
+
+ // npatch interpolated position
+ vec3 finalPos = gl_in[0].gl_Position.xyz * tessCubed[2]
+ + gl_in[1].gl_Position.xyz * tessCubed[0]
+ + gl_in[2].gl_Position.xyz * tessCubed[1]
+ + b210 * 3.0 * tessSquared[2] * gl_TessCoord[0]
+ + b120 * 3.0 * tessSquared[0] * gl_TessCoord[2]
+ + b201 * 3.0 * tessSquared[2] * gl_TessCoord[1]
+ + b021 * 3.0 * tessSquared[0] * gl_TessCoord[1]
+ + b102 * 3.0 * tessSquared[1] * gl_TessCoord[2]
+ + b012 * 3.0 * tessSquared[1] * gl_TessCoord[0]
+ + b111 * 6.0 * gl_TessCoord[0] * gl_TessCoord[1] * gl_TessCoord[2];
+
+ return vec4( finalPos, 1.0 );
}
#endif
diff --git a/src/Runtime/res/effectlib/tessellationNPatchCM.glsllib b/src/Runtime/res/effectlib/tessellationNPatchCM.glsllib
index 0047d6ec..4616b583 100644
--- a/src/Runtime/res/effectlib/tessellationNPatchCM.glsllib
+++ b/src/Runtime/res/effectlib/tessellationNPatchCM.glsllib
@@ -72,40 +72,40 @@ varying vec3 varWorldPosTC[];
void main() {
- ctNorm[0] = varNormal[0];
- ctNorm[1] = varNormal[1];
- ctNorm[2] = varNormal[2];
+ ctNorm[0] = varNormal[0];
+ ctNorm[1] = varNormal[1];
+ ctNorm[2] = varNormal[2];
#if QT3DS_ENABLE_TEXTAN
- ctTangent[0] = varObjTangent[0];
- ctTangent[1] = varObjTangent[1];
- ctTangent[2] = varObjTangent[2];
+ ctTangent[0] = varObjTangent[0];
+ ctTangent[1] = varObjTangent[1];
+ ctTangent[2] = varObjTangent[2];
#endif
#if QT3DS_ENABLE_WORLD_POSITION
- ctWorldPos[0] = varWorldPos[0];
- ctWorldPos[1] = varWorldPos[1];
- ctWorldPos[2] = varWorldPos[2];
+ ctWorldPos[0] = varWorldPos[0];
+ ctWorldPos[1] = varWorldPos[1];
+ ctWorldPos[2] = varWorldPos[2];
#endif
- gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
- tessShader( tessLevelOuter, tessLevelInner);
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+ tessShader( tessLevelOuter, tessLevelInner);
- varObjPosTC[gl_InvocationID] = varObjPos[gl_InvocationID];
- varNormalTC[gl_InvocationID] = varNormal[gl_InvocationID];
+ varObjPosTC[gl_InvocationID] = varObjPos[gl_InvocationID];
+ varNormalTC[gl_InvocationID] = varNormal[gl_InvocationID];
#if QT3DS_ENABLE_UV0
- varTexCoord0TC[gl_InvocationID] = varTexCoord0[gl_InvocationID];
+ varTexCoord0TC[gl_InvocationID] = varTexCoord0[gl_InvocationID];
#endif
#if QT3DS_ENABLE_TEXTAN
- varTangentTC[gl_InvocationID] = varTangent[gl_InvocationID];
- varObjTangentTC[gl_InvocationID] = varObjTangent[gl_InvocationID];
+ varTangentTC[gl_InvocationID] = varTangent[gl_InvocationID];
+ varObjTangentTC[gl_InvocationID] = varObjTangent[gl_InvocationID];
#endif
#if QT3DS_ENABLE_BINORMAL
- varBinormalTC[gl_InvocationID] = varBinormal[gl_InvocationID];
- varObjBinormalTC[gl_InvocationID] = varObjBinormal[gl_InvocationID];
+ varBinormalTC[gl_InvocationID] = varBinormal[gl_InvocationID];
+ varObjBinormalTC[gl_InvocationID] = varObjBinormal[gl_InvocationID];
#endif
#if QT3DS_ENABLE_WORLD_POSITION
- varWorldPosTC[gl_InvocationID] = varWorldPos[gl_InvocationID];
-#endif
+ varWorldPosTC[gl_InvocationID] = varWorldPos[gl_InvocationID];
+#endif
}
#endif
@@ -154,37 +154,37 @@ varying vec3 VARYING_NAME(varWorldPos);
void main() {
- ctNorm[0] = varNormalTC[0];
- ctNorm[1] = varNormalTC[1];
- ctNorm[2] = varNormalTC[2];
+ ctNorm[0] = varNormalTC[0];
+ ctNorm[1] = varNormalTC[1];
+ ctNorm[2] = varNormalTC[2];
#if QT3DS_ENABLE_TEXTAN
- ctTangent[0] = varObjTangentTC[0];
- ctTangent[1] = varObjTangentTC[1];
- ctTangent[2] = varObjTangentTC[2];
+ ctTangent[0] = varObjTangentTC[0];
+ ctTangent[1] = varObjTangentTC[1];
+ ctTangent[2] = varObjTangentTC[2];
#endif
- vec4 pos = tessShader( );
+ vec4 pos = tessShader( );
- gl_Position = model_view_projection_matrix * pos;
+ gl_Position = model_view_projection_matrix * pos;
- VARYING_NAME(varObjPos) = gl_TessCoord.z * varObjPosTC[0] + gl_TessCoord.x * varObjPosTC[1] + gl_TessCoord.y * varObjPosTC[2];
+ VARYING_NAME(varObjPos) = gl_TessCoord.z * varObjPosTC[0] + gl_TessCoord.x * varObjPosTC[1] + gl_TessCoord.y * varObjPosTC[2];
#if QT3DS_ENABLE_UV0
- VARYING_NAME(varTexCoord0) = gl_TessCoord.z * varTexCoord0TC[0] + gl_TessCoord.x * varTexCoord0TC[1] + gl_TessCoord.y * varTexCoord0TC[2];
-#endif
+ VARYING_NAME(varTexCoord0) = gl_TessCoord.z * varTexCoord0TC[0] + gl_TessCoord.x * varTexCoord0TC[1] + gl_TessCoord.y * varTexCoord0TC[2];
+#endif
#if QT3DS_ENABLE_WORLD_POSITION
- VARYING_NAME(varWorldPos) = gl_TessCoord.z * varWorldPosTC[0] + gl_TessCoord.x * varWorldPosTC[1] + gl_TessCoord.y * varWorldPosTC[2];
+ VARYING_NAME(varWorldPos) = gl_TessCoord.z * varWorldPosTC[0] + gl_TessCoord.x * varWorldPosTC[1] + gl_TessCoord.y * varWorldPosTC[2];
#endif
- VARYING_NAME(varNormal) = normalize(normal_matrix * teNorm);
+ VARYING_NAME(varNormal) = normalize(normal_matrix * teNorm);
#if QT3DS_ENABLE_TEXTAN
- VARYING_NAME(varTangent) = normalize(normal_matrix * teTangent);
- VARYING_NAME(varObjTangent) = gl_TessCoord.z * varObjTangentTC[0] + gl_TessCoord.x * varObjTangentTC[1] + gl_TessCoord.y * varObjTangentTC[2];
+ VARYING_NAME(varTangent) = normalize(normal_matrix * teTangent);
+ VARYING_NAME(varObjTangent) = gl_TessCoord.z * varObjTangentTC[0] + gl_TessCoord.x * varObjTangentTC[1] + gl_TessCoord.y * varObjTangentTC[2];
#endif
#if QT3DS_ENABLE_BINORMAL
- VARYING_NAME(varBinormal) = normalize(normal_matrix * teBinormal);
- VARYING_NAME(varObjBinormal) = gl_TessCoord.z * varObjBinormalTC[0] + gl_TessCoord.x * varObjBinormalTC[1] + gl_TessCoord.y * varObjBinormalTC[2];
+ VARYING_NAME(varBinormal) = normalize(normal_matrix * teBinormal);
+ VARYING_NAME(varObjBinormal) = gl_TessCoord.z * varObjBinormalTC[0] + gl_TessCoord.x * varObjBinormalTC[1] + gl_TessCoord.y * varObjBinormalTC[2];
#endif
}
diff --git a/src/Runtime/res/effectlib/tessellationPath.glsllib b/src/Runtime/res/effectlib/tessellationPath.glsllib
index 82d68fab..17b87b08 100644
--- a/src/Runtime/res/effectlib/tessellationPath.glsllib
+++ b/src/Runtime/res/effectlib/tessellationPath.glsllib
@@ -35,15 +35,15 @@
#if TESSELLATION_CONTROL_SHADER
layout (vertices = 5) out;
-void tessShader ( in float edgeTessAmount, float innerTessAmount )
+void tessShader ( in float edgeTessAmount, float innerTessAmount )
{
- gl_TessLevelOuter[0] = innerTessAmount;
- gl_TessLevelOuter[1] = edgeTessAmount;
- gl_TessLevelOuter[2] = innerTessAmount;
- gl_TessLevelOuter[3] = edgeTessAmount;
+ gl_TessLevelOuter[0] = innerTessAmount;
+ gl_TessLevelOuter[1] = edgeTessAmount;
+ gl_TessLevelOuter[2] = innerTessAmount;
+ gl_TessLevelOuter[3] = edgeTessAmount;
- gl_TessLevelInner[0] = edgeTessAmount / 2.0;
- gl_TessLevelInner[1] = innerTessAmount;
+ gl_TessLevelInner[0] = edgeTessAmount / 2.0;
+ gl_TessLevelInner[1] = innerTessAmount;
}
#endif
@@ -53,22 +53,22 @@ layout (quads, equal_spacing, cw) in;
vec2 getTangent(vec2 p0, vec2 p1, vec2 p2, vec2 p3, float t)
{
- // derivative
- float dbt0 = -3.0 * (1.0 - t) * (1.0 - t);
- float dbt1 = 3.0 * (1.0 - t) * (1.0 - 3.0 * t);
- float dbt2 = 3.0 * t * (2.0 - 3.0 * t);
- float dbt3 = 3.0 * t * t;
-
- // tangent on curve
- return normalize( dbt0 * p0 + dbt1 * p1 + dbt2 * p2 + dbt3 * p3 );
+ // derivative
+ float dbt0 = -3.0 * (1.0 - t) * (1.0 - t);
+ float dbt1 = 3.0 * (1.0 - t) * (1.0 - 3.0 * t);
+ float dbt2 = 3.0 * t * (2.0 - 3.0 * t);
+ float dbt3 = 3.0 * t * t;
+
+ // tangent on curve
+ return normalize( dbt0 * p0 + dbt1 * p1 + dbt2 * p2 + dbt3 * p3 );
}
//An exact cross product would involve normalizing dx,dy. Since
//this algorithm needs merely the sign, normalization is not necessary.
float roughCrossProd( vec2 prev, vec2 point, vec2 next )
{
- vec2 inDxDy = point - prev;
- vec2 outDxDy = next - point;
- return inDxDy.x * outDxDy.y - inDxDy.y * outDxDy.x;
+ vec2 inDxDy = point - prev;
+ vec2 outDxDy = next - point;
+ return inDxDy.x * outDxDy.y - inDxDy.y * outDxDy.x;
}
//The incoming corss product tells us both if we should do a seam merge
@@ -76,12 +76,12 @@ float roughCrossProd( vec2 prev, vec2 point, vec2 next )
//anchor point is at .5 gl_TessCoord.y space.
vec3 computeAdjoiningFactors( float cross, vec2 adjoining, vec2 point, float tessY )
{
- vec3 retval = vec3( 0.0, 0.0, 0.0 );
- float multiplier = cross < 0.0 ? 1.0 : -1.0;
- float weight = abs(cross) > 0.001 ? multiplier * ( ( tessY - .5 )/ .5 ) : 0.0;
- retval.z = weight > 0.0 ? 1.0 : 0.0;
- retval.xy = mix( point, adjoining, weight );
- return retval;
+ vec3 retval = vec3( 0.0, 0.0, 0.0 );
+ float multiplier = cross < 0.0 ? 1.0 : -1.0;
+ float weight = abs(cross) > 0.001 ? multiplier * ( ( tessY - .5 )/ .5 ) : 0.0;
+ retval.z = weight > 0.0 ? 1.0 : 0.0;
+ retval.xy = mix( point, adjoining, weight );
+ return retval;
}
#define NO_TAPER 0
@@ -91,9 +91,9 @@ vec3 computeAdjoiningFactors( float cross, vec2 adjoining, vec2 point, float tes
//Tapering is done by interpolating the path width somewhat cleverly.
float getTaperResult( float inIncomingValue, float inBeginValue, float inEndValue, vec2 taperData, uint inMode )
{
- float mixInfo = mix( taperData.x, taperData.y, gl_TessCoord.x );
- float theValueMixer = inMode == BEGIN_TAPER ? inBeginValue : inEndValue;
- return mix( theValueMixer, inIncomingValue, mixInfo );
+ float mixInfo = mix( taperData.x, taperData.y, gl_TessCoord.x );
+ float theValueMixer = inMode == BEGIN_TAPER ? inBeginValue : inEndValue;
+ return mix( theValueMixer, inIncomingValue, mixInfo );
}
uniform vec2 beginTaperInfo;
@@ -101,81 +101,81 @@ uniform vec2 endTaperInfo;
struct STessShaderResult
{
- vec3 m_Position;
- vec2 m_TexCoord;
- vec2 m_Tangent;
- vec2 m_Binormal;
- float m_Opacity;
+ vec3 m_Position;
+ vec2 m_TexCoord;
+ vec2 m_Tangent;
+ vec2 m_Binormal;
+ float m_Opacity;
};
-STessShaderResult tessShader ( float inPathWidth )
+STessShaderResult tessShader ( float inPathWidth )
{
- vec2 p1 = gl_in[0].gl_Position.xy;
- vec2 c1 = gl_in[0].gl_Position.zw; //c1
- vec2 c2 = gl_in[1].gl_Position.xy; //c2
- vec2 p2 = gl_in[1].gl_Position.zw;
- vec4 taperData = gl_in[3].gl_Position;
- vec2 udata = gl_in[4].gl_Position.xy;
-
- //Adjust width for taper if necessary.
- inPathWidth = taperData.z > 0.0 ? getTaperResult( inPathWidth, beginTaperInfo.x, endTaperInfo.x, taperData.xy, uint(taperData.z) ) : inPathWidth;
-
- float adjoiningWeight = 0.0;
- vec2 adjoining = vec2( 0.0, 0.0 );
- if ( gl_TessCoord.x == floor(gl_TessCoord.x) ) // gl_TessCord.x either 0.0 or 1.0
- {
- vec2 point, cross1, cross2;
- if ( gl_TessCoord.x == 0.0 )
- {
- adjoining = gl_in[2].gl_Position.xy;
- point = p1;
- cross1 = adjoining;
- cross2 = c1;
- }
- else // gl_TessCoord.x == 1.0
- {
- adjoining = gl_in[2].gl_Position.zw;
- point = p2;
- cross1 = c2;
- cross2 = adjoining;
- }
- float cross = roughCrossProd( cross1, point, cross2 );
- vec3 adjoiningFactors = computeAdjoiningFactors( cross, adjoining, point, gl_TessCoord.y );
- adjoining = adjoiningFactors.xy;
- adjoiningWeight = adjoiningFactors.z;
- }
-
- float v = gl_TessCoord.x;
- // cubic basis function calculated from v.
- float bv0 = (1.0 - v) * (1.0 - v) * (1.0 - v);
- float bv1 = 3.0 * v * (1.0 - v) * (1.0 - v);
- float bv2 = 3.0 * v * v * (1.0 - v);
- float bv3 = v * v * v;
-
- //u ranges from 0 - 1. What we want is to
- //have u range from -1,1.
- float u = 2.0 * ( gl_TessCoord.y - .5 );
-
- vec2 tangent = getTangent( p1, c1, c2, p2, v );
- vec2 normal = vec2( tangent.y, -tangent.x );
-
- vec2 offset = normal * inPathWidth * u;
-
- vec2 pointOnPath = bv0*p1 + bv1*c1 + bv2*c2 + bv3*p2;
-
- vec2 finalPosXY = offset + pointOnPath;
-
- STessShaderResult retval;
- retval.m_Position = vec3( mix( finalPosXY, adjoining, adjoiningWeight), 0.0 );
- retval.m_Opacity = taperData.z > 0.0 ? getTaperResult( 1.0, beginTaperInfo.y, endTaperInfo.y, taperData.xy, uint(taperData.z) ) : 1.0;
-
- // cubic interpolation of the texture coords
- retval.m_TexCoord.x = mix( udata.x, udata.y, v );
- retval.m_TexCoord.y = gl_TessCoord.y;
- retval.m_Tangent = tangent;
- retval.m_Binormal = normal;
-
- return retval;
+ vec2 p1 = gl_in[0].gl_Position.xy;
+ vec2 c1 = gl_in[0].gl_Position.zw; //c1
+ vec2 c2 = gl_in[1].gl_Position.xy; //c2
+ vec2 p2 = gl_in[1].gl_Position.zw;
+ vec4 taperData = gl_in[3].gl_Position;
+ vec2 udata = gl_in[4].gl_Position.xy;
+
+ //Adjust width for taper if necessary.
+ inPathWidth = taperData.z > 0.0 ? getTaperResult( inPathWidth, beginTaperInfo.x, endTaperInfo.x, taperData.xy, uint(taperData.z) ) : inPathWidth;
+
+ float adjoiningWeight = 0.0;
+ vec2 adjoining = vec2( 0.0, 0.0 );
+ if ( gl_TessCoord.x == floor(gl_TessCoord.x) ) // gl_TessCord.x either 0.0 or 1.0
+ {
+ vec2 point, cross1, cross2;
+ if ( gl_TessCoord.x == 0.0 )
+ {
+ adjoining = gl_in[2].gl_Position.xy;
+ point = p1;
+ cross1 = adjoining;
+ cross2 = c1;
+ }
+ else // gl_TessCoord.x == 1.0
+ {
+ adjoining = gl_in[2].gl_Position.zw;
+ point = p2;
+ cross1 = c2;
+ cross2 = adjoining;
+ }
+ float cross = roughCrossProd( cross1, point, cross2 );
+ vec3 adjoiningFactors = computeAdjoiningFactors( cross, adjoining, point, gl_TessCoord.y );
+ adjoining = adjoiningFactors.xy;
+ adjoiningWeight = adjoiningFactors.z;
+ }
+
+ float v = gl_TessCoord.x;
+ // cubic basis function calculated from v.
+ float bv0 = (1.0 - v) * (1.0 - v) * (1.0 - v);
+ float bv1 = 3.0 * v * (1.0 - v) * (1.0 - v);
+ float bv2 = 3.0 * v * v * (1.0 - v);
+ float bv3 = v * v * v;
+
+ //u ranges from 0 - 1. What we want is to
+ //have u range from -1,1.
+ float u = 2.0 * ( gl_TessCoord.y - .5 );
+
+ vec2 tangent = getTangent( p1, c1, c2, p2, v );
+ vec2 normal = vec2( tangent.y, -tangent.x );
+
+ vec2 offset = normal * inPathWidth * u;
+
+ vec2 pointOnPath = bv0*p1 + bv1*c1 + bv2*c2 + bv3*p2;
+
+ vec2 finalPosXY = offset + pointOnPath;
+
+ STessShaderResult retval;
+ retval.m_Position = vec3( mix( finalPosXY, adjoining, adjoiningWeight), 0.0 );
+ retval.m_Opacity = taperData.z > 0.0 ? getTaperResult( 1.0, beginTaperInfo.y, endTaperInfo.y, taperData.xy, uint(taperData.z) ) : 1.0;
+
+ // cubic interpolation of the texture coords
+ retval.m_TexCoord.x = mix( udata.x, udata.y, v );
+ retval.m_TexCoord.y = gl_TessCoord.y;
+ retval.m_Tangent = tangent;
+ retval.m_Binormal = normal;
+
+ return retval;
}
#endif
diff --git a/src/Runtime/res/effectlib/tessellationPhong.glsllib b/src/Runtime/res/effectlib/tessellationPhong.glsllib
index a70eda4e..98a683dc 100644
--- a/src/Runtime/res/effectlib/tessellationPhong.glsllib
+++ b/src/Runtime/res/effectlib/tessellationPhong.glsllib
@@ -31,11 +31,11 @@
#ifndef TESSELLATION_PHONG_GLSLLIB
#define TESSELLATION_PHONG_GLSLLIB
-struct PhongTessPatch
+struct PhongTessPatch
{
- float projIJ;
- float projJK;
- float projIK;
+ float projIJ;
+ float projJK;
+ float projIK;
};
#if TESSELLATION_CONTROL_SHADER
@@ -53,78 +53,78 @@ uniform float disableCulling;
float isBackFace()
{
- vec3 faceNormal = normalize( cross( ctWorldPos[2] - ctWorldPos[0], ctWorldPos[1] - ctWorldPos[0] ) );
+ vec3 faceNormal = normalize( cross( ctWorldPos[2] - ctWorldPos[0], ctWorldPos[1] - ctWorldPos[0] ) );
- vec3 ncd = normalize( ctWorldPos[0] - camera_position );
+ vec3 ncd = normalize( ctWorldPos[0] - camera_position );
- return sign( 0.2 + dot(faceNormal, ncd) ); // 0.2 is a conservative offset to account for curved surfaces
+ return sign( 0.2 + dot(faceNormal, ncd) ); // 0.2 is a conservative offset to account for curved surfaces
}
float adaptiveCameraFactor( in float minTess, in float maxTess )
{
- float distanceValue0 = distance( camera_position, ctWorldPos[0] );
- float distanceValue1 = distance( camera_position, ctWorldPos[1] );
- float distanceValue2 = distance( camera_position, ctWorldPos[2] );
+ float distanceValue0 = distance( camera_position, ctWorldPos[0] );
+ float distanceValue1 = distance( camera_position, ctWorldPos[1] );
+ float distanceValue2 = distance( camera_position, ctWorldPos[2] );
- float range = distanceRange[1] - distanceRange[0];
+ float range = distanceRange[1] - distanceRange[0];
- vec3 edgeDistance;
- edgeDistance[0] = ((distanceValue1 + distanceValue2) / 2.0) / range;
- edgeDistance[1] = ((distanceValue2 + distanceValue0) / 2.0) / range;
- edgeDistance[2] = ((distanceValue0 + distanceValue1) / 2.0) / range;
+ vec3 edgeDistance;
+ edgeDistance[0] = ((distanceValue1 + distanceValue2) / 2.0) / range;
+ edgeDistance[1] = ((distanceValue2 + distanceValue0) / 2.0) / range;
+ edgeDistance[2] = ((distanceValue0 + distanceValue1) / 2.0) / range;
- edgeDistance = clamp( edgeDistance, vec3(0.0), vec3(1.0) );
+ edgeDistance = clamp( edgeDistance, vec3(0.0), vec3(1.0) );
- //float af = mix( minTess, maxTess, 1.0 - edgeDistance[gl_InvocationID] );
- float af = 1.0 - edgeDistance[gl_InvocationID];
- af = clamp( af*af*maxTess , minTess, maxTess );
+ //float af = mix( minTess, maxTess, 1.0 - edgeDistance[gl_InvocationID] );
+ float af = 1.0 - edgeDistance[gl_InvocationID];
+ af = clamp( af*af*maxTess , minTess, maxTess );
- return af;
+ return af;
}
float adaptiveFeatureFactor( in float minTess, in float maxTess )
{
- vec3 adaptValue;
- adaptValue[0] = clamp( dot(ctNorm[1], ctNorm[2]), -1.0, 1.0 );
- adaptValue[1] = clamp( dot(ctNorm[2], ctNorm[0]), -1.0, 1.0 );
- adaptValue[2] = clamp( dot(ctNorm[0], ctNorm[1]), -1.0, 1.0 );
+ vec3 adaptValue;
+ adaptValue[0] = clamp( dot(ctNorm[1], ctNorm[2]), -1.0, 1.0 );
+ adaptValue[1] = clamp( dot(ctNorm[2], ctNorm[0]), -1.0, 1.0 );
+ adaptValue[2] = clamp( dot(ctNorm[0], ctNorm[1]), -1.0, 1.0 );
- //float af = min( adaptValue[0], min(adaptValue[1], adaptValue[2]) );
- // map [-1, +1] range to [0, 1] range
- float af = (adaptValue[gl_InvocationID] + 1.0) / 2.0;
+ //float af = min( adaptValue[0], min(adaptValue[1], adaptValue[2]) );
+ // map [-1, +1] range to [0, 1] range
+ float af = (adaptValue[gl_InvocationID] + 1.0) / 2.0;
- af = mix( minTess, maxTess, 1.0 - af );
+ af = mix( minTess, maxTess, 1.0 - af );
- return af;
+ return af;
}
float mapToTangentPlane(int i, vec3 q)
{
- vec3 q_minus_p = q - gl_in[i].gl_Position.xyz;
- return q[gl_InvocationID] - dot(q_minus_p, ctNorm[i]) * ctNorm[i][gl_InvocationID];
+ vec3 q_minus_p = q - gl_in[i].gl_Position.xyz;
+ return q[gl_InvocationID] - dot(q_minus_p, ctNorm[i]) * ctNorm[i][gl_InvocationID];
}
-void tessShader ( in float tessEdge, in float tessInner )
+void tessShader ( in float tessEdge, in float tessInner )
{
- // compute projections separate for each xyz component
- tcTessPatch[gl_InvocationID].projIJ = mapToTangentPlane(0, gl_in[1].gl_Position.xyz) + mapToTangentPlane(1, gl_in[0].gl_Position.xyz);
- tcTessPatch[gl_InvocationID].projJK = mapToTangentPlane(1, gl_in[2].gl_Position.xyz) + mapToTangentPlane(2, gl_in[1].gl_Position.xyz);
- tcTessPatch[gl_InvocationID].projIK = mapToTangentPlane(2, gl_in[0].gl_Position.xyz) + mapToTangentPlane(0, gl_in[2].gl_Position.xyz);
-
- // compute backface
- float bf = isBackFace();
- bf = max(disableCulling, bf);
- // adapative tessellation factor regarding features
- float af = adaptiveFeatureFactor( tessInner, tessEdge );
- // adapative tessellation factor regarding camera
- //float cf = adaptiveFeatureFactor( tessInner, tessEdge );
-
- // the camera tess factor is the limit
- //af = min(af, cf);
-
- // Calculate the tessellation levels
- gl_TessLevelInner[0] = af * bf;
- gl_TessLevelOuter[gl_InvocationID] = af * bf;
+ // compute projections separate for each xyz component
+ tcTessPatch[gl_InvocationID].projIJ = mapToTangentPlane(0, gl_in[1].gl_Position.xyz) + mapToTangentPlane(1, gl_in[0].gl_Position.xyz);
+ tcTessPatch[gl_InvocationID].projJK = mapToTangentPlane(1, gl_in[2].gl_Position.xyz) + mapToTangentPlane(2, gl_in[1].gl_Position.xyz);
+ tcTessPatch[gl_InvocationID].projIK = mapToTangentPlane(2, gl_in[0].gl_Position.xyz) + mapToTangentPlane(0, gl_in[2].gl_Position.xyz);
+
+ // compute backface
+ float bf = isBackFace();
+ bf = max(disableCulling, bf);
+ // adapative tessellation factor regarding features
+ float af = adaptiveFeatureFactor( tessInner, tessEdge );
+ // adapative tessellation factor regarding camera
+ //float cf = adaptiveFeatureFactor( tessInner, tessEdge );
+
+ // the camera tess factor is the limit
+ //af = min(af, cf);
+
+ // Calculate the tessellation levels
+ gl_TessLevelInner[0] = af * bf;
+ gl_TessLevelOuter[gl_InvocationID] = af * bf;
}
#endif
@@ -136,33 +136,33 @@ layout(location = 15) in PhongTessPatch tcTessPatch[];
uniform float phongBlend;
-vec4 tessShader ( )
+vec4 tessShader ( )
{
- // pre compute square tesselation coord
- vec3 tessSquared = gl_TessCoord * gl_TessCoord;
-
- // barycentric linear position
- vec3 linearPos = gl_TessCoord.x * gl_in[0].gl_Position.xyz
- + gl_TessCoord.y * gl_in[1].gl_Position.xyz
- + gl_TessCoord.z * gl_in[2].gl_Position.xyz;
-
- // projective terms
- vec3 projJI = vec3(tcTessPatch[0].projIJ, tcTessPatch[1].projIJ, tcTessPatch[2].projIJ);
- vec3 projKJ = vec3(tcTessPatch[0].projJK, tcTessPatch[1].projJK, tcTessPatch[2].projJK);
- vec3 projIK = vec3(tcTessPatch[0].projIK, tcTessPatch[1].projIK, tcTessPatch[2].projIK);
-
- // phong interpolated position
- vec3 phongPos = tessSquared.x * gl_in[0].gl_Position.xyz
- + tessSquared.y * gl_in[1].gl_Position.xyz
- + tessSquared.z * gl_in[2].gl_Position.xyz
- + gl_TessCoord.x * gl_TessCoord.y * projJI
- + gl_TessCoord.y * gl_TessCoord.z * projKJ
- + gl_TessCoord.z * gl_TessCoord.x * projIK;
-
- // final blend between linear and phong interpolation
- vec3 finalPos = (1.0-phongBlend)*linearPos + phongBlend*phongPos;
-
- return vec4( finalPos, 1.0 );
+ // pre compute square tesselation coord
+ vec3 tessSquared = gl_TessCoord * gl_TessCoord;
+
+ // barycentric linear position
+ vec3 linearPos = gl_TessCoord.x * gl_in[0].gl_Position.xyz
+ + gl_TessCoord.y * gl_in[1].gl_Position.xyz
+ + gl_TessCoord.z * gl_in[2].gl_Position.xyz;
+
+ // projective terms
+ vec3 projJI = vec3(tcTessPatch[0].projIJ, tcTessPatch[1].projIJ, tcTessPatch[2].projIJ);
+ vec3 projKJ = vec3(tcTessPatch[0].projJK, tcTessPatch[1].projJK, tcTessPatch[2].projJK);
+ vec3 projIK = vec3(tcTessPatch[0].projIK, tcTessPatch[1].projIK, tcTessPatch[2].projIK);
+
+ // phong interpolated position
+ vec3 phongPos = tessSquared.x * gl_in[0].gl_Position.xyz
+ + tessSquared.y * gl_in[1].gl_Position.xyz
+ + tessSquared.z * gl_in[2].gl_Position.xyz
+ + gl_TessCoord.x * gl_TessCoord.y * projJI
+ + gl_TessCoord.y * gl_TessCoord.z * projKJ
+ + gl_TessCoord.z * gl_TessCoord.x * projIK;
+
+ // final blend between linear and phong interpolation
+ vec3 finalPos = (1.0-phongBlend)*linearPos + phongBlend*phongPos;
+
+ return vec4( finalPos, 1.0 );
}
#endif
diff --git a/src/Runtime/res/effectlib/tessellationPhongCM.glsllib b/src/Runtime/res/effectlib/tessellationPhongCM.glsllib
index fdbdbc23..1374a633 100644
--- a/src/Runtime/res/effectlib/tessellationPhongCM.glsllib
+++ b/src/Runtime/res/effectlib/tessellationPhongCM.glsllib
@@ -73,34 +73,34 @@ varying vec3 varWorldPosTC[];
void main() {
#if QT3DS_ENABLE_WORLD_POSITION
- ctWorldPos[0] = varWorldPos[0];
- ctWorldPos[1] = varWorldPos[1];
- ctWorldPos[2] = varWorldPos[2];
+ ctWorldPos[0] = varWorldPos[0];
+ ctWorldPos[1] = varWorldPos[1];
+ ctWorldPos[2] = varWorldPos[2];
#endif
- ctNorm[0] = varNormal[0];
- ctNorm[1] = varNormal[1];
- ctNorm[2] = varNormal[2];
+ ctNorm[0] = varNormal[0];
+ ctNorm[1] = varNormal[1];
+ ctNorm[2] = varNormal[2];
- gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
- tessShader( tessLevelOuter, tessLevelInner);
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+ tessShader( tessLevelOuter, tessLevelInner);
- varObjPosTC[gl_InvocationID] = varObjPos[gl_InvocationID];
- varNormalTC[gl_InvocationID] = varNormal[gl_InvocationID];
+ varObjPosTC[gl_InvocationID] = varObjPos[gl_InvocationID];
+ varNormalTC[gl_InvocationID] = varNormal[gl_InvocationID];
#if QT3DS_ENABLE_UV0
- varTexCoord0TC[gl_InvocationID] = varTexCoord0[gl_InvocationID];
+ varTexCoord0TC[gl_InvocationID] = varTexCoord0[gl_InvocationID];
#endif
#if QT3DS_ENABLE_TEXTAN
- varTangentTC[gl_InvocationID] = varTangent[gl_InvocationID];
- varObjTangentTC[gl_InvocationID] = varObjTangent[gl_InvocationID];
+ varTangentTC[gl_InvocationID] = varTangent[gl_InvocationID];
+ varObjTangentTC[gl_InvocationID] = varObjTangent[gl_InvocationID];
#endif
#if QT3DS_ENABLE_BINORMAL
- varBinormalTC[gl_InvocationID] = varBinormal[gl_InvocationID];
- varObjBinormalTC[gl_InvocationID] = varObjBinormal[gl_InvocationID];
+ varBinormalTC[gl_InvocationID] = varBinormal[gl_InvocationID];
+ varObjBinormalTC[gl_InvocationID] = varObjBinormal[gl_InvocationID];
#endif
#if QT3DS_ENABLE_WORLD_POSITION
- varWorldPosTC[gl_InvocationID] = varWorldPos[gl_InvocationID];
-#endif
+ varWorldPosTC[gl_InvocationID] = varWorldPos[gl_InvocationID];
+#endif
}
#endif
@@ -148,29 +148,29 @@ varying vec3 VARYING_NAME(varWorldPos);
#endif
void main() {
- vec4 pos = tessShader( );
+ vec4 pos = tessShader( );
- gl_Position = model_view_projection_matrix * pos;
+ gl_Position = model_view_projection_matrix * pos;
- VARYING_NAME(varObjPos) = gl_TessCoord.x * varObjPosTC[0] + gl_TessCoord.y * varObjPosTC[1] + gl_TessCoord.z * varObjPosTC[2];
- VARYING_NAME(varNormal) = gl_TessCoord.x * varNormalTC[0] + gl_TessCoord.y * varNormalTC[1] + gl_TessCoord.z * varNormalTC[2];
+ VARYING_NAME(varObjPos) = gl_TessCoord.x * varObjPosTC[0] + gl_TessCoord.y * varObjPosTC[1] + gl_TessCoord.z * varObjPosTC[2];
+ VARYING_NAME(varNormal) = gl_TessCoord.x * varNormalTC[0] + gl_TessCoord.y * varNormalTC[1] + gl_TessCoord.z * varNormalTC[2];
#if QT3DS_ENABLE_UV0
- VARYING_NAME(varTexCoord0) = gl_TessCoord.x * varTexCoord0TC[0] + gl_TessCoord.y * varTexCoord0TC[1] + gl_TessCoord.z * varTexCoord0TC[2];
-#endif
+ VARYING_NAME(varTexCoord0) = gl_TessCoord.x * varTexCoord0TC[0] + gl_TessCoord.y * varTexCoord0TC[1] + gl_TessCoord.z * varTexCoord0TC[2];
+#endif
#if QT3DS_ENABLE_TEXTAN
- VARYING_NAME(varTangent) = gl_TessCoord.x * varTangentTC[0] + gl_TessCoord.y * varTangentTC[1] + gl_TessCoord.z * varTangentTC[2];
- VARYING_NAME(varObjTangent) = gl_TessCoord.x * varObjTangentTC[0] + gl_TessCoord.y * varObjTangentTC[1] + gl_TessCoord.z * varObjTangentTC[2];
+ VARYING_NAME(varTangent) = gl_TessCoord.x * varTangentTC[0] + gl_TessCoord.y * varTangentTC[1] + gl_TessCoord.z * varTangentTC[2];
+ VARYING_NAME(varObjTangent) = gl_TessCoord.x * varObjTangentTC[0] + gl_TessCoord.y * varObjTangentTC[1] + gl_TessCoord.z * varObjTangentTC[2];
#endif
#if QT3DS_ENABLE_BINORMAL
- VARYING_NAME(varBinormal) = gl_TessCoord.x * varBinormalTC[0] + gl_TessCoord.y * varBinormalTC[1] + gl_TessCoord.z * varBinormalTC[2];
- VARYING_NAME(varObjBinormal) = gl_TessCoord.x * varObjBinormalTC[0] + gl_TessCoord.y * varObjBinormalTC[1] + gl_TessCoord.z * varObjBinormalTC[2];
+ VARYING_NAME(varBinormal) = gl_TessCoord.x * varBinormalTC[0] + gl_TessCoord.y * varBinormalTC[1] + gl_TessCoord.z * varBinormalTC[2];
+ VARYING_NAME(varObjBinormal) = gl_TessCoord.x * varObjBinormalTC[0] + gl_TessCoord.y * varObjBinormalTC[1] + gl_TessCoord.z * varObjBinormalTC[2];
#endif
#if QT3DS_ENABLE_WORLD_POSITION
- VARYING_NAME(varWorldPos) = gl_TessCoord.x * varWorldPosTC[0] + gl_TessCoord.y * varWorldPosTC[1] + gl_TessCoord.z * varWorldPosTC[2];
+ VARYING_NAME(varWorldPos) = gl_TessCoord.x * varWorldPosTC[0] + gl_TessCoord.y * varWorldPosTC[1] + gl_TessCoord.z * varWorldPosTC[2];
#endif
- VARYING_NAME(varNormal) = normalize(normal_matrix * VARYING_NAME(varNormal));
+ VARYING_NAME(varNormal) = normalize(normal_matrix * VARYING_NAME(varNormal));
}
#endif
diff --git a/src/Runtime/res/effectlib/vertexFragmentBase.glsllib b/src/Runtime/res/effectlib/vertexFragmentBase.glsllib
index 6da8a701..add11bbc 100644
--- a/src/Runtime/res/effectlib/vertexFragmentBase.glsllib
+++ b/src/Runtime/res/effectlib/vertexFragmentBase.glsllib
@@ -49,7 +49,7 @@ void initializeBaseFragmentVariables()
{
normal = normalize( varNormal );
surfNormal = normalize( varNormal );
-
+
texCoord0 = vec3( varTexCoord0.xy, 1.0 );
tangent = normalize( varTangent );
@@ -58,4 +58,4 @@ void initializeBaseFragmentVariables()
viewDir = normalize( camera_position - varWorldPos );
}
-#endif \ No newline at end of file
+#endif