[osg-users] Why is it that no matter what The model material properties value reset the are Always invalid?
Mirro Xu
mirro187 at gmail.com
Sat Nov 2 04:36:23 PDT 2019
mirro wrote:
> Hi,
>
> //There seems to be a texture coordinate error...
>
>
> Code:
>
> _eftManager->getPassStateSet(pid)->setAttributeAndModes(loadProgram(
> "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"
> ), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
>
>
>
>
> Thank you!
>
> Cheers,
> Mirro
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76870#76870
More information about the osg-users
mailing list