Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: qazwsx on January 05, 2011, 02:06:25 pm

Title: ALPHA: NPR-rendering in Freespace
Post by: qazwsx on January 05, 2011, 02:06:25 pm
After playing around yesterday with GLSL for the first time,  I decided to have a look at the main-f.sdr shader, with a few simple adjustments, an almost cartoon-like effect can be achieved:
(http://i260.photobucket.com/albums/ii19/omega_angelfire/NPR%20in%20FSO/celshade3.png)
(http://i260.photobucket.com/albums/ii19/omega_angelfire/NPR%20in%20FSO/celshade2.png)
(http://i260.photobucket.com/albums/ii19/omega_angelfire/NPR%20in%20FSO/celshade.png)

And one without ambient lighting, to show the full extent of the effect:
(http://i260.photobucket.com/albums/ii19/omega_angelfire/NPR%20in%20FSO/index2.png)
Model from Earth Defense

Mod to enable this shading style is attached, instructions included in readme.

http://www.mediafire.com/?j3cwolhwhju99ry
Title: Re: ALPHA: NPR-rendering in Freespace
Post by: redsniper on January 05, 2011, 02:11:15 pm
Eh... er... I mean... I'm not sure how that looks that much different from normal FS. Maybe I'm just blind. It's most apparent on the Herc I guess. Is there any way you could crank the effect up higher maybe?
Title: Re: ALPHA: NPR-rendering in Freespace
Post by: qazwsx on January 05, 2011, 03:16:01 pm
Two options, turn down ambient light and modify line 107 of main-f.sdr:

Code: [Select]
lightDiffuse += (gl_FrontLightProduct[i].diffuse * smoothstep(-0.05, 0.05, (dot(normal, lightDir))) * attenuation);
By changing the smoothstep values -0.05 and 0.05 so that they are closer together, i.e. -0.01 and 0.01 respectively, you can increase the sharpness of the terminator.

EDIT: Attachment has changed version, just needs to be renamed as a .sdr file as as I'm not able to upload them.

[attachment deleted by admin]
Title: Re: ALPHA: NPR-rendering in Freespace
Post by: Droid803 on January 05, 2011, 09:22:55 pm
Wait, what's that last fighter?
Something ED-exclusive?
Title: Re: ALPHA: NPR-rendering in Freespace
Post by: qazwsx on January 06, 2011, 02:14:21 am
Yeah, I needed a smooth, rounded model to show the quick change in shading even across gently curving surfaces,  and it was the first one I had at hand, the GTC Sphere and GTD Torus were out of action.

One of the reasons that the effect is hard to see is that I'm just using it over the mediaVPs, it works best with smooth models, with weak normal maps so the change-over isn't distorted too much.