# PhillipClark

Member

13

119 Neutral

• Rank
Member

2. ## PhillipClark

Elizabeth Bailey and I just ordered an N64 with 7 games, ZOMG time to enjoy old times.
3. ## Parentheses in HLSL cause light attenuation function to not work correctly?

Wow, those posts are way over my head inpus.pos is in world space (transformed in vertex shader), but the light_vector is just raw input, no transformations. Is that correct? Here are the lighting equations I'm using, from the book "Mathematics for 3D Game Programming and Computer Graphics": [eqn]\mathcal{K}_{diffuse} = \mathcal{DA} + \mathcal{D}(\sum_{i=1}^{n}\mathcal{C}_{i}max(\mathbf{N}\bigodot\mathbf{L}_{i},0))[/eqn] D = diffuse reflection color A = ambient intensity (should this be a float or a float3?) C = light attenuation * light_color N = surface normal L = normalized light vector [eqn]\mathcal{K}_{specular} = \mathcal{S}(\sum_{i=1}^{n}\mathcal{C}_{i}max( \mathbf{R} \bigodot \mathbf{V}_{i}, 0 )^m ( \mathbf{N} \bigodot \mathbf{L} > 0 ) )[/eqn] S = specular reflection color C = light attenuation * light_color R = 2*( N dot L )*N - L V = camera vector m = specular exponent N = surface normal L = normalized light vector Here is the dropbox link to the model: https://www.dropbox....pl6jls/kit2.obj
4. ## Parentheses in HLSL cause light attenuation function to not work correctly?

So my light color, which is currently ( 1.0f, 1.0f, 1.0f ), needs to be something like ( 100.0f, 100.0f, 100.0f )? I tried this but it is still the same result. I am apparently missing some of the logic here. I'm not sure what you are talking about dividing by PI. I haven't seen any diffuse/specular calculations that use PI, unless you're talking about the actual physical model, not the real time phong model. I guess I should have specified Also my light position is at ( 5, 5, -5 ) so it's not a crazy distance away or anything. I have it coded so that I can move the light around so I should be able to move it close enough. I got the 3d model a while ago so I have no clue where it is online but I can upload it somewhere for you (no texture, just v/vn obj file). What's a good free upload place? Update: I can only get it to light the object if make the equation attenuation = 1.0f / ( d*d*0.00000075 ) or making the light color something ridiculous like ( 999999, 9999999, 99999999 ) but that's kind of silly, there has to be a better way right? Also, using that, I can't get the light to completely "fall off" no matter how far I move it away from the object.