Jump to content

  • Log In with Google      Sign In   
  • Create Account


JohnnyCode

Member Since 10 Mar 2008
Offline Last Active Today, 12:15 PM
*----

Posts I've Made

In Topic: Problems with Normal Mapping

18 April 2014 - 07:24 PM

What means that your solution is not corrupt, as you may have been thinking. Just make an order in your production system in first place!


In Topic: Problems with Normal Mapping

18 April 2014 - 09:08 AM

seeing this, your normal texture seems to contain negative z for that spot (a z <0.5  in texture) though in texture you posted it does not seem so.

 

Let me aware you that many normal map generating software does not produce z component with relation to -1,1 scale- due to compressing efficiency accuracy and the fact negative z component is realy not desired for a texture space normal, but x and y are. You can also compute z component youself after having -1,1 x and y components- such as z=sqrt(1.0-x*x+y*y) - what is even more effective than normalizing the sampled normal and allowing you to have 2 normal maps in one texture.


In Topic: Is there a way to break out of an if statement without "hacking the code...

17 April 2014 - 04:01 PM

 

I would usually set the boolean flag to false right after execution has been done once because I just want the code to execute once.

I do not see though why would execution return before the if again, is it in a cycle?

 

In case you do not wish the code to continue inside the if upon some condidtion, nested if is what I would do.

 

In case the if is in a cycle and you wish it to run only once- you should move it out of cycle primarily if you can.

 

In case the execution once wish to run it , once not, keep condition altering as you do.

 

Anyway, it is always a very particular problem, and one has always many ways to rethink what he is performing and how.

 

Without criticizing the very concrete code of yours, we cannot give you a definite advice on this.


In Topic: Problems with Normal Mapping

17 April 2014 - 08:40 AM

 

vec2 screenPos = gl_FragCoord.xy;
    screenPos.x /= resolution.x;
    screenPos.y /= resolution.y;    
    screenPos
= screenPos * 2 - 1; // Convert to NDC

In case gl_FragCoord is not in projection space (NDC) after vertex function, this is just ok, but consider that.

 

 

vec4 lightScreenPos = pointLightInfo[2*index]; // Pre-transformed to NDC
        vec3 lightVector = vec3(lightScreenPos.xy - screenPos.xy, lightScreenPos.z);    
        lightVector
.x *= resolution.x / resolution.y;

if the comment is true, you should keep light vector in NDC and not scale it to screen aspect, since the normal direction is in NDC=texture space right?

 

But those things do not seem as the couse to me though. What seems as possible couse to me is this

 

 

normalMap.g = -normalMap.g; // Our normal map program produces an inverted y axis.
    
    normalMap
= normalMap * 2 - 1; // Normalize to [-1, 1]

try switching those two lines - first make normal -1,1 and then switch sign of g component. You could also try to dot the light vector with a constant (0,0,1) vector to see if it is purely the sampled normal problem.

 

 


In Topic: Anyone know of large open code repository?

15 April 2014 - 06:34 PM

sourceforge.net hosts code base of projects such as FireBirdSQL f.e., why not go there?


PARTNERS