shader code structure question (3 posts)

  • Profile picture of mcbeth mcbeth19p said 2 months, 4 weeks ago:

    I have added a a second ramp texture to a copy of lightblow(has rim lighting) and made some other adjustment that produce a workable toon effect the “problem” is that subtle charges to the calculations in that second ramp produces different but interesting results, thus far I have 8 of them all produced by using different combinations of *,+,= and other subtle tweaks to two lines of code. I kinda trying to figure out the least cumbersome way to having the different variants of the effect available without having to physically change the code every time or something crazy Like 8 “ifdef”s for one texture, I can post the code later when I get home but it is not that different from the color ramp already in these lighting shaders apart from a custom float operating on light x and y

  • Profile picture of mifth mifth132p said 2 months, 4 weeks ago:

    Don’t understand what you want. I did the lightblow. Can you make your question more clear.

  • Profile picture of mcbeth mcbeth19p said 2 months, 4 weeks ago:

    let me see how I can explain this
    I have added a second ramp to the shader
    see below

      vec2 light = computeLighting(vPosition, normal, vViewDir.xyz, lightDir.xyz) * spotFallOff;
    	   vec3 normalizedLight_ViewDirection = normalize(vViewDir.xyz+lightDir.xyz);
    	   float NDotL2 = max(0.0, dot(normal, normalizedLight_ViewDirection));
    
    	   #ifdef COLORRAMP2
               light.x *= texture2D(m_ColorRamp2, vec2(light.x+NDotL2, 0.0)).r;
               light.y *= texture2D(m_ColorRamp2, vec2(light.y+NDotL2, 0.0)).r;
           #endif	

    ramp2 can also be calculated as

    different variants to play with
    	defaultpreferred
    	//looks nice without *
    	light.x *= texture2D(m_ColorRamp2, vec2(light.x+NDotL2, 0.0)).r;
            light.y *= texture2D(m_ColorRamp2, vec2(light.y+NDotL2, 0.0)).r;
    
    	other variants
    	//looks nice with *= and +=
    	light.x = texture2D(m_ColorRamp2, vec2(light.x*+NDotL2, 0.0)).r;
            light.y = texture2D(m_ColorRamp2, vec2(light.y*+NDotL2, 0.0)).r;
    
            light.x = texture2D(m_ColorRamp2, vec2(light.x*NDotL2, 0.0)).r;
            light.y = texture2D(m_ColorRamp2, vec2(light.y*NDotL2, 0.0)).r; 

    these produce different looks example

    http://i.imgur.com/9keHx.jpg
    http://i.imgur.com/0kwJ6.jpg
    http://i.imgur.com/lyGqQ.jpg
    http://i.imgur.com/I2wxo.jpg

    some are negligibly similar so I wont probably use all but I am trying to figure out the best way to use the different looks available without having to alter the shader every time which would make having different “looks” on individual models difficult

    hope I’m more clear now