Cogl.DepthState.prototype.set_range
function set_range(near_val: Number(gfloat), far_val: Number(gfloat)): void { // Gjs wrapper for cogl_depth_state_set_range() }
Sets the range to map depth values in normalized device coordinates to before writing out to a depth buffer.
After your geometry has be transformed, clipped and had perspective division applied placing it in normalized device coordinates all depth values between the near and far z clipping planes are in the range -1 to 1. Before writing any depth value to the depth buffer though the value is mapped into the range [0, 1].
With this function you can change the range which depth values are mapped too although the range must still lye within the range [0, 1].
If your driver does not support this feature (for example you are using GLES 1 drivers) then if you don't use the default range values you will get an error reported when calling cogl_pipeline_set_depth_state (). You can check ahead of time for the Cogl.FeatureID.ogl_feature_id_depth_range feature with Cogl.has_feature to know if this function will succeed.
By default normalized device coordinate depth values are mapped to the full range of depth buffer values, [0, 1].
NB: this won't directly affect the state of the GPU. You have to then set the state on a Cogl.Pipeline using Cogl.Pipeline.prototype.set_depth_state.
Since 2.0
- near_val
The near component of the desired depth range which will be clamped to the range [0, 1]
- far_val
The far component of the desired depth range which will be clamped to the range [0, 1]