Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/shaders/common_smaa_lib.glsl
| Show First 20 Lines • Show All 730 Lines • ▼ Show 20 Lines | # endif | ||||
| float Ltop = dot(SMAASamplePoint(colorTex, offset[0].zw).rgba, weights); | float Ltop = dot(SMAASamplePoint(colorTex, offset[0].zw).rgba, weights); | ||||
| // We do the usual threshold: | // We do the usual threshold: | ||||
| float4 delta; | float4 delta; | ||||
| delta.xy = abs(L - float2(Lleft, Ltop)); | delta.xy = abs(L - float2(Lleft, Ltop)); | ||||
| float2 edges = step(threshold, delta.xy); | float2 edges = step(threshold, delta.xy); | ||||
| # ifndef SMAA_NO_DISCARD | # ifndef SMAA_NO_DISCARD | ||||
| # ifdef GPU_FRAGMENT_SHADER | |||||
| // Then discard if there is no edge: | // Then discard if there is no edge: | ||||
| if (dot(edges, float2(1.0, 1.0)) == 0.0) | if (dot(edges, float2(1.0, 1.0)) == 0.0) | ||||
| discard; | discard; | ||||
| # endif | # endif | ||||
| # endif | |||||
| // Calculate right and bottom deltas: | // Calculate right and bottom deltas: | ||||
| float Lright = dot(SMAASamplePoint(colorTex, offset[1].xy).rgba, weights); | float Lright = dot(SMAASamplePoint(colorTex, offset[1].xy).rgba, weights); | ||||
| float Lbottom = dot(SMAASamplePoint(colorTex, offset[1].zw).rgba, weights); | float Lbottom = dot(SMAASamplePoint(colorTex, offset[1].zw).rgba, weights); | ||||
| delta.zw = abs(L - float2(Lright, Lbottom)); | delta.zw = abs(L - float2(Lright, Lbottom)); | ||||
| // Calculate the maximum delta in the direct neighborhood: | // Calculate the maximum delta in the direct neighborhood: | ||||
| float2 maxDelta = max(delta.xy, delta.zw); | float2 maxDelta = max(delta.xy, delta.zw); | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | # endif | ||||
| float3 Ctop = SMAASamplePoint(colorTex, offset[0].zw).rgb; | float3 Ctop = SMAASamplePoint(colorTex, offset[0].zw).rgb; | ||||
| t = abs(C - Ctop); | t = abs(C - Ctop); | ||||
| delta.y = max(max(t.r, t.g), t.b); | delta.y = max(max(t.r, t.g), t.b); | ||||
| // We do the usual threshold: | // We do the usual threshold: | ||||
| float2 edges = step(threshold, delta.xy); | float2 edges = step(threshold, delta.xy); | ||||
| # ifndef SMAA_NO_DISCARD | # ifndef SMAA_NO_DISCARD | ||||
| # ifdef GPU_FRAGMENT_SHADER | |||||
| // Then discard if there is no edge: | // Then discard if there is no edge: | ||||
| if (dot(edges, float2(1.0, 1.0)) == 0.0) | if (dot(edges, float2(1.0, 1.0)) == 0.0) | ||||
| discard; | discard; | ||||
| # endif | # endif | ||||
| # endif | |||||
| // Calculate right and bottom deltas: | // Calculate right and bottom deltas: | ||||
| float3 Cright = SMAASamplePoint(colorTex, offset[1].xy).rgb; | float3 Cright = SMAASamplePoint(colorTex, offset[1].xy).rgb; | ||||
| t = abs(C - Cright); | t = abs(C - Cright); | ||||
| delta.z = max(max(t.r, t.g), t.b); | delta.z = max(max(t.r, t.g), t.b); | ||||
| float3 Cbottom = SMAASamplePoint(colorTex, offset[1].zw).rgb; | float3 Cbottom = SMAASamplePoint(colorTex, offset[1].zw).rgb; | ||||
| t = abs(C - Cbottom); | t = abs(C - Cbottom); | ||||
| Show All 27 Lines | |||||
| * Depth Edge Detection | * Depth Edge Detection | ||||
| */ | */ | ||||
| float2 SMAADepthEdgeDetectionPS(float2 texcoord, float4 offset[3], SMAATexture2D(depthTex)) | float2 SMAADepthEdgeDetectionPS(float2 texcoord, float4 offset[3], SMAATexture2D(depthTex)) | ||||
| { | { | ||||
| float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(depthTex)); | float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(depthTex)); | ||||
| float2 delta = abs(neighbours.xx - float2(neighbours.y, neighbours.z)); | float2 delta = abs(neighbours.xx - float2(neighbours.y, neighbours.z)); | ||||
| float2 edges = step(SMAA_DEPTH_THRESHOLD, delta); | float2 edges = step(SMAA_DEPTH_THRESHOLD, delta); | ||||
| # ifdef GPU_FRAGMENT_SHADER | |||||
| if (dot(edges, float2(1.0, 1.0)) == 0.0) | if (dot(edges, float2(1.0, 1.0)) == 0.0) | ||||
| discard; | discard; | ||||
| # endif | |||||
| return edges; | return edges; | ||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| // Diagonal Search Functions | // Diagonal Search Functions | ||||
| # if !defined(SMAA_DISABLE_DIAG_DETECTION) | # if !defined(SMAA_DISABLE_DIAG_DETECTION) | ||||
| ▲ Show 20 Lines • Show All 585 Lines • Show Last 20 Lines | |||||