|
- //There seems to be a texture coordinate error...
- "varying vec3 vLocalVertex;\n"
- "varying vec4 TextureCoord0;\n"
- "void main()\n"
- "{\n"
- " vLocalVertex = gl_Vertex;\n"
- " TextureCoord0 = gl_TextureMatrix[0] * gl_MultiTexCoord0;\n"
- " gl_Position = ftransform();\n"
- "}\n"
- "\n"
- ,
- "uniform sampler2D default_map;\n"
- "varying vec4 TextureCoord0;\n"
- "varying vec3 vLocalVertex;\n"
- "uniform float hdrExposure;\n"
- "uniform float hdrGamma;\n"
- "vec3 decodeRGBE(vec4 rgba) \n"
- "{ \n"
- " float f = pow(2.0, rgba.a * 255.0 - (128.0 + 8.0)); \n"
- " return rgba.rgb * 255.0 * f; \n"
- "} \n"
- "vec3 toneMapHDR(vec3 rgb) \n"
- "{ \n"
- " return pow(rgb * 1.0, 1.0 / vec3(2.2));\n"
- "} \n"
- "vec4 textureSphere(sampler2D texture,vec3 n) \n"
- "{ \n"
- " const float PI = 3.14159;\n"
- " float yaw = acos(n.y) / PI;\n"
- " float pitch = (atan(n.x, n.z) + PI) / (2.0 * PI);\n"
- " return texture2D(texture, vec2(pitch, yaw));\n"
- "} \n"
- "void main()\n"
- "{\n"
- " vec3 normal = normalize(vLocalVertex.xyz);\n"
- " vec3 c = toneMapHDR(decodeRGBE(textureSphere(default_map, normal)));\n"
- " gl_FragColor = vec4(c, 1.0);\n"
- "}\n"
- "\n"
复制代码 |
|