opengl - GLSL calculating color vector from multiple lights -
I am using my own self This is my piece program:
# version Vec4 vertexPosition in 330; Normal in Vec3 surface; Coordination in Vec2 texture; Vec3 normal in the eye; Out vec4 output color; Uniform Sampler 2D Texture_Defuse; Uniform Bull Specular; Uniform float shinness; Structure Light {vec4 status; Vec4 ambient collar; Vec4 diffuseColor; Vec4 specularColor; }; Uniform Light Light [8]; Zero main () {outputColor = texture2D (texture_diffuse, textureCoordinate); {Vec3 lightDirection = normalize (Lights [L] .position.xyz - vertexPosition.xyz) for (Int L = 0; L & L; 8; L ++); Float diffilite intensity = maximum (0, dot (surface normal, light direction)); OutputColor.rgb + = lights [l] .ambientColor.rgb * Lights [l] .ambientColor.a; OutputColor.rgb + = Illumination [l] .diffusecolor.rgb * Lights [l] .diffusecolor.a * diffuseLightIntensity; If (specular) {vec3 reflection direction = normal (reflect (light direction, surface normal)); Float Specular = Max (0.0, Dot (IVEE Normal, Reflection Direction)); If (diffuseLightIntensity! = 0) {vec3 specularColorOut = pow (specular, shininess) * lights [l] .specularColor.rgb; OutputColor.rgb + = specularColorOut * lights [l] .specularColor.a; }}}} The problem is now that when I have 2 light sources, then the ambient color vec4 (0.2f, 0.2f, 0.2f, 1.0f) will have ambient color on the vec4 (0.4f, 0.4f, 0.4f, 1.0f) because I add it to the output caller variable. How can I calculate a single environment and a single diffuse color variation for many lights, so I will get a realistic result? Here's a fun fact: ambient lightness, diffuse or spicular color in the real world They do not emit a color period (well, if you want to be technical, emit light emissions of many ), but in individual photons " Ambient "properties, they have different wavelengths). Whatever you are doing is copying, which has copied crap about OpenGL's ambient light color. Stop copying someone else's code and make it correct The color of each light is that you use that color to spread the light of the object and Speculular contributions are used to calculate. this is the matter.
The ambient view has an asset, it is not intended to represent any particular light: the light visible from the second object in the view, which is in the form of a normal total has been taken. You do not have ambient "light"; There is only one ambient word, and it should be implemented once.
Comments
Post a Comment