- Home /
 
               Question by 
               miketucker · Nov 05, 2011 at 01:28 PM · 
                shaderglsles2.0  
              
 
              Hatching Shader?
Does anyone know how to make a cross hatched shader like this one? http://learningwebgl.com/lessons/example04/teapot-simple-crosshatch.html
There is an attached GLSL shader but after trying to add it into Unity i get warnings about graphics card..
VERTEX SHADER:
   attribute vec3 aVertexPosition;
     attribute vec3 aVertexNormal;
     uniform mat4 uMVMatrix;
     uniform mat4 uPMatrix;
     uniform mat4 uNMatrix;
     varying vec4 vTransformedNormal;
     varying vec4 vPosition;
     void main(void) {
         vPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
         gl_Position = uPMatrix * vPosition;
         vTransformedNormal = uNMatrix * vec4(aVertexNormal, 1.0);
     }
FRAGMENT SHADER:
 #ifdef GL_ES
     precision highp float;
     #endif
     varying vec4 vTransformedNormal;
     varying vec4 vPosition;
     uniform float uMaterialShininess;
     uniform vec3 uAmbientColor;
     uniform vec3 uPointLightingLocation;
     uniform vec3 uPointLightingSpecularColor;
     uniform vec3 uPointLightingDiffuseColor;
     uniform sampler2D uSampler;
     void main(void) {
         vec3 lightWeighting;
         vec3 lightDirection = normalize(uPointLightingLocation - vPosition.xyz);
         vec3 normal = normalize(vTransformedNormal.xyz);
         float specularLightWeighting = 0.0;
         vec3 eyeDirection = normalize(-vPosition.xyz);
         vec3 reflectionDirection = reflect(-lightDirection, normal);
         specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);
         float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
         lightWeighting = uAmbientColor
             + uPointLightingSpecularColor * specularLightWeighting
             + uPointLightingDiffuseColor * diffuseLightWeighting;
         gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
         if (length(lightWeighting) < 1.00) {
             if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {
                 gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
             }
         }
         if (length(lightWeighting) < 0.75) {
             if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {
                 gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
             }
         }
         if (length(lightWeighting) < 0.50) {
             if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {
                 gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
             }
         }
         if (length(lightWeighting) < 0.3465) {
             if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {
                 gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
             }
         }
     }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
ES2.0 Diffuse Shader? 0 Answers
converting HLSL to GLSL. 0 Answers
Shader error: Shader program of type 'vp' already exists at line .... 1 Answer
iPhone: Use of undeclared identifier '_patchFragColor' 1 Answer
GLSL error 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                