Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/grid_frag.glsl
- This file was moved from source/blender/draw/modes/shaders/object_grid_frag.glsl.
| /* Infinite grid | /* Infinite grid | ||||
| * Author: Clément Foucault */ | * Author: Clément Foucault */ | ||||
| /* We use the normalized local position to avoid precision | /* We use the normalized local position to avoid precision | ||||
| * loss during interpolation. */ | * loss during interpolation. */ | ||||
| in vec3 local_pos; | in vec3 local_pos; | ||||
| out vec4 FragColor; | out vec4 FragColor; | ||||
| uniform vec3 planeAxes; | uniform vec3 planeAxes; | ||||
| uniform vec3 screenVecs[2]; | |||||
| uniform float gridDistance; | uniform float gridDistance; | ||||
| uniform float meshSize; | uniform float meshSize; | ||||
| uniform float lineKernel = 0.0; | uniform float lineKernel = 0.0; | ||||
| uniform sampler2D depthBuffer; | uniform sampler2D depthBuffer; | ||||
| #define cameraPos (ViewMatrixInverse[3].xyz) | #define cameraPos (ViewMatrixInverse[3].xyz) | ||||
| uniform int gridFlag; | uniform int gridFlag; | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | if ((gridFlag & PLANE_XY) != 0) { | ||||
| angle *= angle; | angle *= angle; | ||||
| fade *= 1.0 - angle * angle; | fade *= 1.0 - angle * angle; | ||||
| } | } | ||||
| } | } | ||||
| if ((gridFlag & GRID) != 0) { | if ((gridFlag & GRID) != 0) { | ||||
| /* Using `max(dot(dFdxPos, screenVecs[0]), dot(dFdyPos, screenVecs[1]))` | /* Using `max(dot(dFdxPos, screenVecs[0]), dot(dFdyPos, screenVecs[1]))` | ||||
| * would be more accurate, but not really necessary. */ | * would be more accurate, but not really necessary. */ | ||||
| float grid_res = dot(dFdxPos, screenVecs[0]); | float grid_res = dot(dFdxPos, screenVecs[0].xyz); | ||||
| /* The gride begins to appear when it comprises 4 pixels */ | /* The gride begins to appear when it comprises 4 pixels */ | ||||
| grid_res *= 4; | grid_res *= 4; | ||||
| /* from biggest to smallest */ | /* from biggest to smallest */ | ||||
| vec4 scale; | vec4 scale; | ||||
| #if 0 | #if 0 | ||||
| int step_id = 0; | int step_id = 0; | ||||
| ▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines | |||||