OpenGL ES2.0 finier coloring tool usage details, opengles2.0

Source: Internet
Author: User

OpenGL ES2.0 finier coloring tool usage details, opengles2.0

Vertex shader:

uniform mat4 uMVPMatrix; uniform mat4 uMMatrix; uniform vec3 uCamera;attribute vec3 aPosition;  attribute vec3 aNormal;    varying vec3 eyeVary;varying vec3 newNormalVary;void main()  {   gl_Position = uMVPMatrix * vec4(aPosition,1);     vec3 normalTarget=aPosition+aNormal;  vec3 newNormal=(uMMatrix*vec4(normalTarget,1)).xyz-(uMMatrix*vec4(aPosition,1)).xyz;  newNormal=normalize(newNormal);    newNormalVary=newNormal;    vec3 eye = normalize(uCamera-(uMMatrix*vec4(aPosition,1)).xyz);  eyeVary=eye;} 
Fragment coloring tool:
precision mediump float;uniform samplerCube sTexture;varying vec3 eyeVary;varying vec3 newNormalVary;vec4 zfs(   in float zsl){    vec3 vTextureCoord;  vec4 finalColorZS;  vec4 finalColorFS;  vec4 finalColor;    const float maxH=0.7;  const float minH=0.2;  float sizeH=maxH-minH;  float testValue=abs(dot(eyeVary,newNormalVary));  if(testValue>maxH)  {     vTextureCoord=refract(-eyeVary,newNormalVary,zsl);     finalColor=textureCube(sTexture, vTextureCoord);    }  else if(testValue<=maxH&&testValue>=minH) {     vTextureCoord=reflect(-eyeVary,newNormalVary);     finalColorFS=textureCube(sTexture, vTextureCoord);       vTextureCoord=refract(-eyeVary,newNormalVary,zsl);     finalColorZS=textureCube(sTexture, vTextureCoord);       float ratio=(testValue-minH)/sizeH;     finalColor=finalColorZS*ratio+(1.0-ratio)*finalColorFS;  }  else   {     vTextureCoord=reflect(-eyeVary,newNormalVary);     finalColor=textureCube(sTexture, vTextureCoord);    }    return finalColor;}void main(){   vec4 finalColor=vec4(0.0,0.0,0.0,0.0);   finalColor.r=zfs(0.97).r;     finalColor.g=zfs(0.955).g;     finalColor.b=zfs(0.94).b;     gl_FragColor=finalColor;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.