DynamicLightSecondary?
by Stefan Lundmark · in Torque Game Engine Advanced · 07/04/2008 (6:37 am) · 7 replies
What does DynamicLightSecondary do? I'm playing around with CustomMaterials so they receive the same bumpmapping light as procedural ones, and I'm curious if DynamicLightSecondary is infact that feature, since it is disabled in CustomMaterial, and if so it makes sense that it doesn't work.
Edit: Actually, taking a procedurally created texture and using it as a Custom Shader works fine apart from the bumpmaps, which are rendered, but not together with dynamic lights so there's no sense of depth in it.
Edit: Actually, taking a procedurally created texture and using it as a Custom Shader works fine apart from the bumpmaps, which are rendered, but not together with dynamic lights so there's no sense of depth in it.
#2
Thanks. My issue was something else entirely (terrain normals not being passed correctly to the vertex shader) which affected the dot calculation between normal and lightVec.
07/06/2008 (9:06 pm)
Guess it was quite obvious by the name. :) I just wanted to make sure.Thanks. My issue was something else entirely (terrain normals not being passed correctly to the vertex shader) which affected the dot calculation between normal and lightVec.
#3
07/07/2008 (11:30 am)
Ahh yeah, I ran into that a while ago working on some other terrain shaders. Since the default terrain shaders don't use normal info, I guess that bug was never found. ;/
#4
I got the Terrains to recognize normals now, only thing left is tangent and binormal. From what I've read, that's the easy part but I've not been able to nail it yet. ConstructorShape and Interior has helper functions to calculate those, but they are dependant on indices which I've also yet to figure out.
In any case, thanks again. :)
07/10/2008 (4:52 am)
Thanks Brian, got me working in the correct direction.I got the Terrains to recognize normals now, only thing left is tangent and binormal. From what I've read, that's the easy part but I've not been able to nail it yet. ConstructorShape and Interior has helper functions to calculate those, but they are dependant on indices which I've also yet to figure out.
In any case, thanks again. :)
#5
Usually, in most shaders I've seen in TGEA, you multiply lightVec with tangent-space in the vertex shader before you pass it on to the pixel shader. Then the regular stuff:
Now, I commented out the multiplication from the vertex shader. (Shown below)
And now suddenly the normal maps render on the terrain perfectly. How can this happen? I was under the impression, and have been told, that you need tangent-space to get normal mapping working, unless you're doing object-space normal mapping, or something like that.
Is there an explaination for this, and why is it working without tangent-space?
07/13/2008 (5:47 am)
Brian, if you're still around I'd love to hear a comment about the following:Usually, in most shaders I've seen in TGEA, you multiply lightVec with tangent-space in the vertex shader before you pass it on to the pixel shader. Then the regular stuff:
float4 bumpNormal = tex2D(bumpMap, IN.texCoord); float4 bumpDot = saturate( dot(bumpNormal.xyz * 2.0 - 1.0, normalize (IN.lightVec)));
Now, I commented out the multiplication from the vertex shader. (Shown below)
//OUT.lightVec.xyz = mul(objToTangentSpace, OUT.lightVec);
And now suddenly the normal maps render on the terrain perfectly. How can this happen? I was under the impression, and have been told, that you need tangent-space to get normal mapping working, unless you're doing object-space normal mapping, or something like that.
Is there an explaination for this, and why is it working without tangent-space?
#6
1. The objToTangentSpace matrix may not be right, which is why you don't get bumps when you actually use the matrix to multiple object->tangetspace. I know you have to be careful about how the matrix is constructed, or you'll end up with it flipped and pointing the wrong way.
2. When you got rid of the multiply it's in object space. The terrain polys are mostly oriented close to what object space is anyways, so it looks like its working. (Which hey, this is all fake stuff anyways, so if that works for your project, you've eliminated a matrix vector multiply in your vertex shader!). But I would guess that if you created some cliffs or something, the shading may not look right there.
3. Another possibility is that the light vec shader constant is incorrect, since a lot of the shader setup has been skipped during terrain rendering, maybe you're getting leftover stuff from a previous ::setupPass call. I'd make sure that the shader constants you're using are explicitly set in the terrrender::renderblock method.
These are just wild guesses in the dark, and are probably wrong. But hopefully they help you somehow. ;)
07/14/2008 (3:03 pm)
Without really seeing it, I would guess that:1. The objToTangentSpace matrix may not be right, which is why you don't get bumps when you actually use the matrix to multiple object->tangetspace. I know you have to be careful about how the matrix is constructed, or you'll end up with it flipped and pointing the wrong way.
2. When you got rid of the multiply it's in object space. The terrain polys are mostly oriented close to what object space is anyways, so it looks like its working. (Which hey, this is all fake stuff anyways, so if that works for your project, you've eliminated a matrix vector multiply in your vertex shader!). But I would guess that if you created some cliffs or something, the shading may not look right there.
3. Another possibility is that the light vec shader constant is incorrect, since a lot of the shader setup has been skipped during terrain rendering, maybe you're getting leftover stuff from a previous ::setupPass call. I'd make sure that the shader constants you're using are explicitly set in the terrrender::renderblock method.
These are just wild guesses in the dark, and are probably wrong. But hopefully they help you somehow. ;)
#7
07/17/2008 (5:16 am)
They sure did! Thanks :)
Torque Owner Brian Richardson
DynamicLightSecondary is a feature that allows two lights to be shaded during a light pass instead of one. Lights have to meet certain conditions in order to be combined. So in this case, that shouldn't affect you.