Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Trying to make "lineThickness" values behave like pixel units.

  • Loading branch information...
commit 5a674c6a84ca630eb6b66c9c27b67df8328e70e7 1 parent 529a495
@emackey emackey authored
View
8 Apps/Sandcastle/gallery/Volumes.html
@@ -157,8 +157,8 @@
var lineThicknessXSlider = new HorizontalSlider({
value : adjustableGridMaterials[0].uniforms.lineThickness.x,
- minimum : 0.0,
- maximum : 1.1,
+ minimum : 0.5,
+ maximum : 10.0,
intermediateChanges : true,
style : "width:150px;",
onChange : function(value) {
@@ -172,8 +172,8 @@
var lineThicknessYSlider = new HorizontalSlider({
value : adjustableGridMaterials[0].uniforms.lineThickness.y,
- minimum : 0.0,
- maximum : 1.1,
+ minimum : 0.5,
+ maximum : 10.0,
intermediateChanges : true,
style : "width:150px;",
onChange : function(value) {
View
6 Source/Scene/Material.js
@@ -209,7 +209,7 @@ define([
* <li><code>gridColor</code>: rgba color object for the grid's lines.</li>
* <li><code>holeAlpha</code>: Alpha value for the holes between grid lines.</li>
* <li><code>lineCount</code>: Object with x and y values specifying the number of columns and rows respectively.</li>
- * <li><code>lineThickness</code>: Object with x and y values specifying the thickness of grid lines in the range 0.0 to 1.0.</li>
+ * <li><code>lineThickness</code>: Object with x and y values specifying the thickness of grid lines (in pixels where available).</li>
* </ul>
* <li>Stripe</li>
* <ul>
@@ -1070,8 +1070,8 @@ define([
uniforms : {
gridColor : new Color(0.0, 1.0, 0.0, 1.0),
holeAlpha : 0.4,
- lineCount : new Cartesian2(8.0, 8.0),
- lineThickness : new Cartesian2(0.1, 0.1)
+ lineCount : new Cartesian2(5.0, 5.0),
+ lineThickness : new Cartesian2(1.0, 1.0)
},
source : GridMaterial
});
View
11 Source/Shaders/Materials/GridMaterial.glsl
@@ -21,20 +21,21 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
float value;
#ifdef GL_OES_standard_derivatives
// Fuzz Factor - Controls blurriness between lines and holes
- const float fuzz = 0.1;
+ const float fuzz = 1.0;
+ vec2 thickness = lineThickness - 1.0;
// From "3D Engine Design for Virtual Globes" by Cozzi and Ring, Listing 4.13.
vec2 dx = abs(dFdx(st));
vec2 dy = abs(dFdy(st));
- vec2 dF = vec2(max(dx.s, dy.s), max(dx.t, dy.t)) * lineCount * 10.0;
+ vec2 dF = vec2(max(dx.s, dy.s), max(dx.t, dy.t)) * lineCount;
value = min(
- smoothstep(dF.s * lineThickness.s, dF.s * (fuzz + lineThickness.s), scaledWidth),
- smoothstep(dF.t * lineThickness.t, dF.t * (fuzz + lineThickness.t), scaledHeight));
+ smoothstep(dF.s * thickness.s, dF.s * (fuzz + thickness.s), scaledWidth),
+ smoothstep(dF.t * thickness.t, dF.t * (fuzz + thickness.t), scaledHeight));
#else
// Fuzz Factor - Controls blurriness between lines and holes
const float fuzz = 0.05;
- vec2 range = 0.5 - (lineThickness * 0.5);
+ vec2 range = 0.5 - (lineThickness * 0.05);
value = min(
1.0 - smoothstep(range.s, range.s + fuzz, scaledWidth),
1.0 - smoothstep(range.t, range.t + fuzz, scaledHeight));
Please sign in to comment.
Something went wrong with that request. Please try again.