Jump to content

Need help with Light mixing in custom shader


Pryme8
 Share

Recommended Posts

So I feel dumb... I have tried a bunch of different mixing methods and I still cant get the look I was expecting.

I have a fixed light and a camera light:

vec3 vLightPosition = vec3(0., 100., 2.);    
vec3 pLightPosition = cameraPosition;
vec3 baseColor = texture2D(textureSampler, vUV).rgb;
vec3 shadowColor = vec3(0.1, 0.1, 0.15);
vec3 lightColor = vec3(0.3, 0.6, 0.8);

vec3 vNormalW = normalize(vNormal);    
vec3 viewDirectionW = normalize(cameraPosition - vPositionW);
vec3 lightVectorW = normalize(vLightPosition - vPositionW);
    
vec3 plightVectorW = normalize(pLightPosition - vPositionW);

float ndl = max(0., dot(vNormalW, lightVectorW));
float pndl = max(0., dot(vNormalW, plightVectorW));

vec3 angleW = normalize(viewDirectionW + lightVectorW);
vec3 pangleW = normalize(viewDirectionW + plightVectorW);

    //float specComp = max(0., dot(vNormalW, pangleW));
    //specComp = pow(specComp, max(1., 64.)) * 0.5;    

float lf = (pndl*PLIGHT_INTENS);
    
vec3 color = mix(shadowColor, baseColor+(lightColor*lf), max(ndl, lf));

  /* baseColor = mix(shadowColor, baseColor, ndl+lf); 
    vec3 color = mix(baseColor, lightColor, lf);


Effectively the vLight is a fixed point light or a hemi light, the pLight is the miners/camera light.

I need to basically have the two lights effect each other, this math might actually by right and I am just being weird... 

Need any kind of input.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...