SradKiller

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

107 Neutral

About SradKiller

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. do you have a sample with source code?
  2. Many shaders GLSL in scenes

      Did not work  :( Remained only the first
  3. Many shaders GLSL in scenes

      Hi Missionctrl, thank you for your reply. Yes, i'm calling glUseProgram() in applyLight and drawTerrain (Pseudocode) void applyLight(float, float, float, float){ glUseProgram(.......) .......... } ............ void drawTerrain(){ glUseProgram(.....) ................ } then... i need draw the the same model twice ? this is slow or compromise the performance ? Or the result is only one model drawn ?   Wow, very nice this tutorial, but the light and terrain is a example for "multi shader". I would like to use separate shader for light, SSAO, glow, terrain...and others
  4. Many shaders GLSL in scenes

      Hi Missionctrl, thank you for your reply. Yes, i'm calling glUseProgram() in applyLight and drawTerrain (Pseudocode) void applyLight(float, float, float, float){ glUseProgram(.......) .......... } ............ void drawTerrain(){ glUseProgram(.....) ................ } then... i need draw the the same model twice ? this is slow or compromise the performance ? Or the result is only one model drawn ?
  5. Hello guys. I'm studying GLSL and had a question to apply more than one program. Example, i have 2 GLSL: Texture (Code 1): Vertex: varying vec2 coord; void main(void) { coord = gl_Vertex.xy; gl_Position = ftransform(); //gl_ProjectionMatrix * (gl_ModelViewMatrix * gl_Vertex); } Frag: uniform sampler2D text1; varying vec2 coord; void main(void) { vec4 color = texture2D(text1, coord); gl_FragColor = color; } And i have the GLSL to light (Code 2): Vertex: varying vec3 normal; varying vec4 pos; varying vec4 rawpos; void main() { normal = gl_NormalMatrix * gl_Normal; gl_Position = ftransform(); pos = gl_ModelViewMatrix * gl_Vertex; rawpos = gl_Vertex; gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; } Frag: varying vec3 normal; varying vec4 pos; void main() { vec4 color = vec4(1,0,0,1); vec4 matspec = vec4(1,1,0,1); float shininess = 512; vec4 lightspec = vec4(10,10,10,10); vec4 lpos = vec4(1,-5,9,1); vec4 s = -normalize(-lpos); vec3 light = s.xyz; vec3 n = normalize(normal); vec3 r = -reflect(light, n); r = normalize(r); vec3 v = -pos.xyz; v = normalize(v); vec4 diffuse = color * max(0.0, dot(n, s.xyz)) * color; vec4 specular; if (shininess != 0.0) { specular = lightspec * matspec * pow(max(0.0, dot(r, v)), shininess); } else { specular = vec4(0.0, 0.0, 0.0, 0.0); } gl_FragColor = diffuse + specular; } All work correctly. But when I try to apply both, only the last one is applied to the scene. I wanted to know how I can put the two together without having to do just one file (.Frag and .Vert). Because I would like to leave the lights more dynamic, for example (pseudocode): //ApplyLight uses the program GLSL to Light (Vide code 2) //applyLight(PositionX, PositionY, PositionZ, Atenuation); applyLight(1.0f, 2.0f, 0.0f, 4.0f); applyLight(3.6f, 4.5f, 2.0f, 5.0f); applyLight(2.0f, 1.0f, 1.1f, 3.6f); applyLight(0.0f, 2.0f, 4.0f, 4.5f); //Draw Terrain use the Code 1 and draw a .obj file drawTerrain(); How could I do that? Apply more than one program to an object / scene. Could someone explain me? Regardless of language, I'm using both android ES and C ++.   Thank you