OpenGL ES 2.0. GLSL - cannot use two sampled colors at the same time in fragment shader -
I do not even know how to describe this problem, so I will explain with the code. I have a piece shider that does parallax mapping and light computations. I have been able to detect the problem for texture and / or light count samples, so I will only post the code to keep it for a while:
// sample map vec3 albedo = texture2D (U_albedo_texture_1, p_texc) .rgb; Vec3 ao = texture2D (u_ambientocclusion_texture, v_texcoord) .rgb-0.5; // ambient blocking vec3 normal T = texture 2d (u_normalmap_texture, p_texc) .rgb * 2.0 - 1.0; // tangent space normal vec4 normal w = vc4 (general (tbn * normal t) .xyz, 1.0); // World Space General vec3 color = VC3 (0.0); Vec3 environment = textured cube (u_cubemap_texture, -normalW.xyz) .rgb; // Find ambient light with cubemap color = environment = ao; Float d = length (light_ vector); Float atin = 1.0 / dot (light_ettenitation, vc3 (1.0, d, d * d)); // Mathematical attenuation of Point Light // Expand the word float ndotl = max (dot (normal .x, light_ vector), 0.0); Color + = aten * ndotl * light_diffuse.rgb * albedo; // Speakular Term Float HD = Max (0.0, dot (half-vector, normal W. xz)); Color + = Atten * ((Shiniz + 8.0) / 8.0 * 3.1416) * Light_spiqualer RGB * P_X * POW (HDTin, Shinness); Gl_FragColor = vec4 (color.rgb, 1.0); I am working on this code in other shaders, but here in parallax mapping shader, it just leaves the pixels and I do not understand why why instead of showing the object It only leaves pixels and the object is not visible at all. No Wrong or Dirty Color, Nothing
I have been able to find this problem in albedo and ambient sample colors. Both of them are being sampled correctly if I print
gl_FragColor = vec4 (ambient .rgb, 1.0); or
gl_FragColor = vec4 (encode. RGB, 1.0); They both appear properly, but if I try to do something with both colors, the pixels are out. None of the following is done:
gl_FragColor = vec4 (environment + albedo, 1.0); Gl_FragColor = vec4 (environment * Albedo, 1.0); Gl_FragColor = vec4 (ambient, r., G, environment.b, 1.0); The environment has been sampled with 2D textures from the cube map and albedo. I have surroundings and general mapping and other samples for those work and they also work in the form of a combination of ambient or albedo. So Ambient + AO works and B2 + AO works.
So, this is my problem and I do not know what the reason for it is. Like I said, I have the same code in another embossed and it does one thing.
worth mentioning, it runs on PowerWat emulator for OpenGL ES 2.0. And GPU is an NVIDIA GT220. Inadequate stuff like other errors in my code, and if necessary, I will post the full piece shader code. Sorry for the long post: P
Resolved Wow, could not believe the reason was so stupid, but I remember it completely Done Basically, I forgot to load cubemap for that particular model and it was not sent to shader. Yet, how the hell had some sample in the first place? I mean, it was working separately, what was the sample unit sample? Have a Qurem in the Cash from the previous processing?
Still, how did this hell do something in the first place?
Generally when my shaders do not produce the desired results, but are feeling 'normal' in an angry way, it is because the shader compilation has abandoned it (I have made an error Somewhere built-in) and 'fixed pipeline instead' shider ...
Comments
Post a Comment