Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

GLSL and your own defined functions

This topic is 4841 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

I don't see lerp() as a function in GLSL like HLSL? I coded up my own version and works fine in render monkey but in my engine it fails?
vec3 lerp(vec4 a, vec4 b, float s)
{
    return vec3(a + (b - a) * s);       
}

thats the function ahead of void main(void) do I have to pass in these functions as somekind of variable on the client side? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hi,
You can put that code in your method that compile and link your shader to see if there is an error message (which is writen in a file), and us what it is :


GLint infologLength = 0;
GLint charsWritten = 0;
GLchar *infoLog;

glGetObjectParameterivARB(ph, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength);

if (infologLength > 0)
{
cout<<"shader "<<infologLength<<endl ;
infoLog = (char *)malloc(infologLength);
glGetInfoLogARB(ph, infologLength, &charsWritten, infoLog);
ofstream oFile3("infoLogFile.txt");
oFile3<<infoLog ;
free(infoLog);
}

Share this post


Link to post
Share on other sites
Quote:
Original post by phantom
and are you sure that mix() wont do the job?

That's so bizarre. Why did they call it "mix" instead of "lerp"?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Sneftel
That's so bizarre. Why did they call it "mix" instead of "lerp"?


mix() is also used by the renderman api.
glsl has quite a lot in common with above mentioned api
actually I like it, but your mileage may vary :)


Share this post


Link to post
Share on other sites
Seb sorry I am getting an error on the glGetInfoLogARB saying it doesn't take 4 parameters, so I am giving up. Ok, I am using mix(). So when you code your own functions their isn't anything special I need to do then?

Thanks all

Share this post


Link to post
Share on other sites
I'd heard that it owed a lot to Renderman, but I'd never used that system. I wonder why they chose "mix" for Renderman, though... was it an attempt to make the terminology less "mathy"?

Share this post


Link to post
Share on other sites
i'm guessing because if you supply it with two colours it will 'mix' between them [smile]

Mars, afaik you dont have todo anything special, just make sure the compiler knows how to call the function like you'd do in C or C++.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Sneftel
I'd heard that it owed a lot to Renderman, but I'd never used that system. I wonder why they chose "mix" for Renderman, though... was it an attempt to make the terminology less "mathy"?


Renderman mix function actually looks like this (surprise! :p)

color mix(color,color,float)

maybe they chose mix instead of lerp, because "mixing colors"
sounds more natural than "lerping colors"

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!