whysee

Members
  • Content count

    10
  • Joined

  • Last visited

Community Reputation

127 Neutral

About whysee

  • Rank
    Member
  1. I all I'm back in shader since ten years ... so I looking for a starting code to make a sort of wipe effect in 2D: I think its a classical effect but i can't find any example I need to make cursor as a moving shape on the screen that make appear a texture behind. If the cursor move again over the same path it reveals another texture behind. Every time the shape pass over a texture it reveals another texture behind it . etc. Is someone can give me a snipet as a starting point, I'm going in many direction but still stuck Thanks a lot
  2. Hi all maybe it's a stupid question but im stuck: what i wanna do is making a lookup in a cube map that simulate a spotlight like in http://www.ronfrazier.net/apparition/index.html the lookup is made by a vector from the vertex to the light. color = textureCube(EnvMap, light2Dir); it works well but my map is centered so the light seems to come from the center of the scene also i need to move it for each spotlight how can i move this cube map to the position of the light ? thanx for your help
  3. hi all i've made glsl shader that cast two spotlights on a scene. it's work really good but when i get closer the framerate drops down what the explanation of this phenomena ? i think the decreasing of perf come from the number of fragment effectively processed to do the lighting but what are the tricks to get good perf on very close views is someone has an example of indexed map ligthing in glsl maybe its faster ? thanks [Edited by - whysee on October 28, 2005 11:24:38 AM]
  4. Quote:Original post by eviltwigflipper Quote:Original post by whysee but i want a do i by a GLSL shader im a newbie in this scope Theres like no advantages in doing it in a shader, your better off using glBlend, and it will probley be faster. yes it's faster but my point is to do some per pixel shading. i have many spotlights casting their beam on flat surfaces like cubes, so per vertex don't fit
  5. ok so here is the new frag I control my light[0] parameters for each pass corresponding to each "real" light in my application void main() { vec4 diffuse1,ambient1; vec3 n,halfV; float NdotL,NdotHV; vec4 color = ambientGlobal; vec4 color2= vec4(0.0,0.0,0.0,1.0);// = ambientGlobal; float att,spotEffect; float dist1 = length(lightDir1); /* Compute the diffuse, ambient and globalAmbient terms */ diffuse1 = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse; ambient1 = gl_FrontMaterial.ambient * gl_LightSource[0].ambient; /* a fragment shader can't write a verying variable, hence we need a new variable to store the normalized interpolated normal */ n = normalize(normal); /* compute the dot product between normal and ldir */ NdotL = max(dot(n,normalize(lightDir1)),0.0); if (NdotL > 0.0) { spotEffect = dot(normalize(gl_LightSource[0].spotDirection), normalize(-lightDir1)); if (spotEffect > gl_LightSource[0].spotCosCutoff) { spotEffect = pow(spotEffect, gl_LightSource[0].spotExponent); att = spotEffect / (gl_LightSource[0].constantAttenuation + gl_LightSource[0].linearAttenuation * dist1 + gl_LightSource[0].quadraticAttenuation * dist1 * dist1); color += att * (diffuse1 * NdotL + ambient1); halfV = normalize(halfVector1); NdotHV = max(dot(n,halfV),0.0); color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(NdotHV,gl_FrontMaterial.shininess); } } gl_FragColor = color; } in my app : something like : for nb lights setGLLightPos(glLightNum, pos); swapBuffer(); do you think it's a good way to do such a thing BTW you said that conditonnals block are in concern for shader perf do you have any pointer or more advices on the subject do you think a sort of cubemap lighting can be more efficient. I lack of knowledge in this topic
  6. but i want a do i by a GLSL shader im a newbie in this scope so i don't know how to do a multi-light shader here is what i begin the problem is that is very ugly i just have duplicated the two process for the two spotlight how could i do for any number of ligths void main() { vec4 diffuse1,ambient1; vec4 diffuse2,ambient2; vec3 n,halfV; float NdotL,NdotHV; vec4 color = ambientGlobal; vec4 color2= vec4(0.0,0.0,0.0,1.0);// = ambientGlobal; float att,spotEffect; float dist1 = length(lightDir1); float dist2 = length(lightDir2); /* Compute the diffuse, ambient and globalAmbient terms */ diffuse1 = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse; ambient1 = gl_FrontMaterial.ambient * gl_LightSource[0].ambient; diffuse2 = gl_FrontMaterial.diffuse * gl_LightSource[1].diffuse; ambient2 = gl_FrontMaterial.ambient * gl_LightSource[1].ambient; /* a fragment shader can't write a verying variable, hence we need a new variable to store the normalized interpolated normal */ n = normalize(normal); /* compute the dot product between normal and ldir */ NdotL = max(dot(n,normalize(lightDir1)),0.0); if (NdotL > 0.0) { spotEffect = dot(normalize(gl_LightSource[0].spotDirection), normalize(-lightDir1)); if (spotEffect > gl_LightSource[0].spotCosCutoff) { spotEffect = pow(spotEffect, gl_LightSource[0].spotExponent); att = spotEffect / (gl_LightSource[0].constantAttenuation + gl_LightSource[0].linearAttenuation * dist1 + gl_LightSource[0].quadraticAttenuation * dist1 * dist1); color += att * (diffuse1 * NdotL + ambient1); halfV = normalize(halfVector1); NdotHV = max(dot(n,halfV),0.0); color += att * gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(NdotHV,gl_FrontMaterial.shininess); } } ///* NdotL = max(dot(n,normalize(lightDir2)),0.0); if (NdotL > 0.0) { spotEffect = dot(normalize(gl_LightSource[1].spotDirection), normalize(-lightDir2)); if (spotEffect > gl_LightSource[1].spotCosCutoff) { spotEffect = pow(spotEffect, gl_LightSource[1].spotExponent); att = spotEffect / (gl_LightSource[1].constantAttenuation + gl_LightSource[1].linearAttenuation * dist2 + gl_LightSource[1].quadraticAttenuation * dist2 * dist2); color2 += att * (diffuse2 * NdotL + ambient2); halfV = normalize(halfVector2); NdotHV = max(dot(n,halfV),0.0); color2 += att * gl_FrontMaterial.specular * gl_LightSource[1].specular * pow(NdotHV,gl_FrontMaterial.shininess); } } //*/ gl_FragColor = color2+ color; } my problem is also in term of performance one more light decrease famerate a lot please need help or any pointers on multi light shader
  7. hi all I'm looking for a method to create multiple dynamic spotligths i've tryed to write a fragment program using an opengl ligth it's cool but what can i do if i want more lights do i duplicates values and calculation ? so try two spotlights and the performance decrease dramatically I've heard about other techniques still using glsl is someone can give me some example of multi spotlights rendering that works ? tanx
  8. thanks for your answer I'm wondering if something like Cg SDK or an other one working on linux can help writing vertex program, if someone has set up a good environment for that. Or if there a way to write GLSL code to be converted in ARBvp/fp1.0 I have read some spec on ARBvp assembly so I think i could understand something but my was on a good tutorial on how to make complex shader, passing parameters adding projective texture blending and so on .. I'm new to this post and maybe this question is an other topic for graphic theory ?
  9. hi all, I'm currently writing an online game where each player has a spotlight after testing many technique to get lighting and shadows for multiple lights I found it's more extensible to write it out as a shader but ... it seem difficult for me to find a good starting point : my app ONLY support ARBvp1.0 and ARBfp1.0 Where I can find a good tutorial on how to write such files ? I need advices for a good way to write it Do I need SDK if exists where I can test my effects ? I'm on linux with a GeForce3