Jump to content
  • Advertisement
Sign in to follow this  
Tasaq

GLSL shader problems

This topic is 2520 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, so i need to make my shader working on my tutors laptop for tests(quadro fx 3800m), it works fine on my laptop, my friends also had no problems, but on his i have black areas sad.png here's the code:

vec4 gra()
{
float dist;
float diflvl=0.0, speclvl=0.0, NdL;
vec4 ReturnedColor=vec4(0.0, 0.0, 0.0, 1.0);
vec3 lp, halfv;
vec4 ambient=vec4(0.001, 0.001, 0.001, 1.0);//*gl_FrontMaterial.ambient;
vec4 diffuse=vec4(0.6, 0.6, 0.6, 1.0)*gl_FrontMaterial.diffuse;
vec4 specular=vec4(0.5, 0.5, 0.5, 1.0)*gl_FrontMaterial.specular;
for(int i=0; i<LightNumber; ++i)
{
lp=vec3((LightPosition)-View);
lp=normalize(lp);
dist=distance(LightPosition, View);
halfv=reflect(lp, Normal);
diflvl=clamp(dot(lp, normalize(Normal)),0.0,1.0);
speclvl=pow(dot(normalize(View.xyz), normalize(halfv.xyz)), 40.0);
speclvl=clamp(speclvl, 0.0, 1.0);
if(dist > LightParams.x-0.5)
{
diflvl*=0.05;
if(dist < LightParams.x)
{
diflvl=clamp(dot(lp, normalize(Normal)),0.0,1.0)*(LightParams.x-dist)/0.5;
speclvl=clamp(speclvl, 0.0, (LightParams.x-dist)/0.5);
}
}
if(dist > LightParams.x)
{
//amblvl*=0.1;
speclvl=0.0;
}
diflvl+=LightUnafected;
ReturnedColor+=ambient+diffuse*diflvl+specular*speclvl*glossValue;
}
// texturki

ReturnedColor.rgb *= texColor.rgb;
ReturnedColor.a=alphaValue;

return ReturnedColor;
}

Assuming that texture doesn't have perfect black areas, as far as I can see there is no way this code could return vec of only 0.0 ..... but it does and I can't work it out why :\ When i forced the dist to 999.0 black areas were gone, but so were lights... If I could work on that notebook for test I could simply try to make it work or rewrite it. Oh and btw I have gt540m, I tested it on gt330m and vaio with ati 4xxx(don't remember well, but it was high-end). Also i tried it on my stationary pc with 3870x2, it worked perfectly until I reinstalled windows, then the same thing happened.(If you are curious why i can't write on stationary pc... it kinda got damaged both motherboard and ram so i have bsod few minutes after start up). Any ideas why this happens?

Share this post


Link to post
Share on other sites
Advertisement
Rendering black faces is often an indication, that your shader does not compile. Try to output the compilation messages as debug output to get an idea of what went wrong.

Share this post


Link to post
Share on other sites

Rendering black faces is often an indication, that your shader does not compile. Try to output the compilation messages as debug output to get an idea of what went wrong.

It compiled, and it didn't render black faces but rather black areas, like half moons. I solved it today when i had a chance of trying to do something on that laptop again, and all i did was changing speclvl from 0.0 to 0.000001 in the last if. I don't get why, but it works :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!