Home Technical Talk

Stylistic CGFX Shader

1
polycounter lvl 18
Offline / Send Message
kodde polycounter lvl 18
Hey guys,

I'm preparing for a Shader course I'm going to hold and I wanted to make a showcase video to inspire the students for a stylistic shader project assignment.

Thought I'd share my results with you.

[ame]http://www.youtube.com/watch?v=r-2YRozCGME&hd=1[/ame]

Please do give me some feedback. I'm still open for modifying this. If anyone wants to play around with it I can make the project available.

Replies

  • zxcman
    Options
    Offline / Send Message
    zxcman polycounter lvl 10
    PLEASE MAKE THIS SHADER WORKING WITH MAXS!!!11!!11
  • felipefrango
    Options
    Offline / Send Message
    felipefrango polycounter lvl 9
    Looks awesome, I'd love to see this working in Max as well. :p
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    There's really nothing that should be Maya specific about it, and if there is I can try the "3D Studio Max" export preset from Mental Mill.

    I'll share the project for you guys tomorrow when I'm at work. Don't have the files here.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Wish I was in your course Kodde :) Looking good.
  • chronic
    Options
    Offline / Send Message
    chronic polycounter lvl 10
    it would be cool to see some experimentation with computational methods (instead of relying on texture). there are some good examples from renderman.
    google search result:
    http://www.cs.unc.edu/~feasel/classes/238/238hw4.html
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    haiddasalami> I'd welcome you if there was a way. Have been contemplating on doing some Mental Mill tutorials. But I doubt that many would find them useful as Mental Mill does not seems that widespread. It's not something every enthusiast has in their arsenal of software.

    chronic> That seems mighty fancy. I'm going to look into it a bit. Seems like a good way to go if you know exactly what type of crosshatch you want. Do you figure this is less performance requiring? First thing that struck me was "this sounds expensive". But I have only breezed through it.

    The nice part about having it a texture as it is now is your end user artist can play around with whatever tileable pattern they like.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Alright here's two exported versions, one CGFX for Maya and one FX for Max. I have not been able to confirm if the Max version works. I exported with the 3D Studio Max preset from Mental Mill. There's also some crosshatches and two ramps included if you want to try them out. The hatches aren't all perfectly tiling.

    Download link

    One important thing to set up correctly is the UV set for the hatch texture. It uses a different UV set than the base texture. Texcoord0 is for the base texture and texcoord3 is for the hatch texture. You probably need to manually change the texcoord3 parameter when loading the shader.

    My Mental Mill had crashed yesterday so I had to redo a few features, also included normal map support and two additional directional lights in this version.

    Please let me know if this works in Max. Also, please do share any cool results you might get out of this :)


    Also tried three new crosshatch patterns.
    newHatches.jpg

    One idea I have is to use several different hatch patterns for different levels of luminosity.
  • Neox
    Options
    Offline / Send Message
    Neox veteran polycounter
    now mix them hatching by the amount of blackness in the shading ^^

    so it gets hatched on light shading, crosshatched on darker values and very tight crosshatched on the very dark parts! very nice work man :)
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Neox wrote: »
    now mix them hatching by the amount of blackness in the shading ^^

    so it gets hatched on light shading, crosshatched on darker values and very tight crosshatched on the very dark parts! very nice work man :)

    Working on it as we speak!
    If I implement this, will you try it for me in Max? ;)
    Want to know if the Mental Mill export works well with Max.
  • Neox
    Options
    Offline / Send Message
    Neox veteran polycounter
    when i'm at home i can definitely do it, hm menta mill, does that mean you could even render it? that'd be great ^^
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    multiHatch.jpg

    This would probably look better with hand drawn hatches. Right now it's just my test textures. Unfortunately does not have flexibility to set your own amount of hatches. You don't have to use all three levels/hatches though.

    Download Link

    This version retains same functionality as the first one if you don't want to use multiple hatches.


    neox> Would be nice if you could render this(suppose you mean offline render?). I think it should be possible. But I'm not sure how. I can save as .xmsl files or export to .cgfx/.fx. I think Mental Mill is supposed to save to a native format for 3DSMax. Does max load .xmsl files?
  • cw
    Options
    Offline / Send Message
    cw polycounter lvl 17
    Looks really nice, I wonder if somehow screen space normal could be used to warp the hatching to follow the form a bit. Maybe too fiddly. hmm.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    cw> My initial idea was to get the feel of a 2D comic in that the crosshatch would not wrap around the form, it would always be planar aligned with the camera. That's also what I'm doing at the moment through a planar projection in Maya. Feeding the camera values to the projection and thereby making the hatch follow the camera.

    You could just use a regular static UV set for this, but you would have problems with seams. Is this the look you mean? Or some hybrid between a planar projection following the camera but being a bit bent?
  • cw
    Options
    Offline / Send Message
    cw polycounter lvl 17
    Yeah I was trying to think of a cunning way not to use the uvs of the model as is because of any pixel density problems or seam problems. I shall stop criticising now! :D
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    cw wrote: »
    Yeah I was trying to think of a cunning way not to use the uvs of the model as is because of any pixel density problems or seam problems. I shall stop criticising now! :D

    Sorry if I came of sounding defensive about the matter. Please do share ideas and suggestions. I still have your idea in the back of my head, not sure how what to do with it yet.

    :)
  • cw
    Options
    Offline / Send Message
    cw polycounter lvl 17
    No I didn't take it that way, honestly, I just have a habit of never being satisfied with awesome things, and thinking of twiddles and tweaks. It's so ingrained in my nature these days. :D
  • Neox
    Options
    Offline / Send Message
    Neox veteran polycounter
    bloody hell the warp placement ramp is the missing piece i needed for getting it to work in unreal back when i tried doing this effect for airborn! so simple so great, haha
  • zxcman
    Options
    Offline / Send Message
    zxcman polycounter lvl 10
    dude! this is awesome!
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    zxman> Thanks!
    Did you or anyone else for that matter the Max version a try? Does it work well? All the parameters and slots show up properly and function well?

    I'm a Maya user and don't really have access to 3DSMAX, curious to know if Mental Mill easily exports to Max as well. Would be nice to publish for a broader mass.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Hi kodde, your shader looks awesome!..I give it a try in Max 2010 and here is the screen grab of the material editor parameter...

    cgfxmax.jpg

    First of all, some of the text got crop off by the texture slot..probably you can shorten the name/ text by removing the "msl_Sketchy_1_" on the text, leaving only the the "base/ ramp/ etc". I don't know how it suppose to looks like in Maya, so I can't really tell is there any missing part on the parameter or not.

    Second, it seems like put the shade on the highlighted area (probably my fault not putting the correct map on correct slot though)..

    cgfxmaxtest.jpg

    *Model download from the internet.
    Based on the list position top to bottom..

    msl_Sketchy_1_bas ............. [ robbie.tga ] ---> base texture
    msl_Sketchy_1_ram ............. [ ramp05.png ]
    msl_Sketchy_1_ram ............. [ rampSketch05.png ]
    msl_Sketchy_1_nor ............. [ skethDanny.004.png ]
    msl_Sketchy_1_dar ............. [ hatchDark01.png ]
    msl_Sketchy_1_med ............. [ hatchMedium01.png ]
    msl_Sketchy_1_ligh ............. [ hatchLight01.png ]

    The rest of the setting is still the default..
    And owh, it's a mirrored UV..the right one you notice the seam in the middle.
    Looking forward for more updates on this! :)

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel>
    Thank you for trying it out.
    There's one parameter missing in your screenshot there which shows up in Maya, which is called "invertY". What it does is pretty much turn the ramp textures upside down if you check it. I think that's why you would need to enable judging by your screenshot. The reason for the parameter not showing is probably because it doesn't have any UI code.

    The reason for the long names comes from Mental Mill's naming conventions. That's what I dislike the most about working in that program, it doesn't give you any clean and working UI code when exporting to Max/Maya. I'll add a new version asap which should fix these issues. Should just be some tweaking in a text editor.


    Concering the mirrored UV. Did you use the texcoord3 UV set slot with a new UV set for the hatch? Do you have any slots called "texcoord0", "texcoord1", "texcoord2" and "texcoord3" in your material editor? You need to make a secondary UV set for the purpose of the hatch and link that to the texcoord3 slot. This enables you to eliminate any potential seams and also make a dynamic UV projection that follows the camera like I have in my example video (I suppose this is possible in Max as well).
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    This download has an updated version for Max which should have a better UI with proper names and the invertY attribute showing up properly. That is unless I forgot some semi colon or something alike when editing it in Notepad++ :)

    Download link (Maya 002 and Max 003 versions)
  • chronic
    Options
    Offline / Send Message
    chronic polycounter lvl 10
    Thread HIJACK

    I did a quick and dirty conversion of the renderman shader from my previous post - here is that in Maya. not gonna take this further, no free time for it - but those interested should also check out the Nvidia Shader Library, there are similar shader examples.

    crosshatch_crazy.jpg

    Edit: Im not gonna share this cgfx shader cause its just a pure copy of someone else's work - doesn't feel right, but it functions as a 'proof of concept'.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    The new 003 version is much organize UI there kodde :)
    Here it is if you haven't saw it before..

    cgfxmax003.jpg

    Btw, the invertY checkbox is named wrongly, it said "Hatch Pattern Tiling", same like the parameter above it..heheh..

    Another thing I notice is that when I apply my normal map to my character, the face orientation/ normal is flipped and I have to purposely flip the normal of all the face in order for it to show the texture (I know it's not a mesh error because when I check it suing Max's xView "face orientation" feature it highlighting all the polys, means all polys flipped)

    Is there anything that I should prepare before using your shader to display the hatch pattern?..because I still can't get a result like in your video..and..erm..I'm not sure I quite understand about the "texcoord UV set slot" or "secondary UV set" that you mention in your previous reply..Hope some other Max user can confirm about it working properly in Max or not.

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Chronic> That's pretty neat.

    Revel> Thanks for trying the new version.
    Hard to get everything right when I can't debug it myself :)
    Fixing the UI text is easy. Concering the normal map, did you try to set Normal Map Multiplier to a negative value? Did that solve the issue?

    Have you worked with multiple UV sets/channels in max? This is what you need to do. Create a new UV set/channel with a planar map (following camera if you want it fancy). Then you need to use the materials set/channel slot called "texcoord3" and set it to use your newly created set/channel. I don't know how to do this in Max. Maybe someone else can help?

    Thanks
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    The Normal Map Multiplier can go down only until 0.0, cannot have negative value.

    Multiple UV set what I think of right now is separating it using MaterialIDs and combine it with Multi/Sub-Object material type, but this will separate the UVs (for example 1 texture for head, another for body) and I don't think this is what you mean. Sorry, but I'm not that expert in Max and yeah a more expert Max user should help you developing this shader even further. I can see a lot of potential use of this sketch shader of yours! :)

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel> Oh that's right. The minimum of 0 is set by the UI code in the .fx file. You cannot manually type in a negative number? We have this in Maya, quite useful sometimes. I can just invert this function for the max shader if it turns out that a negative value would do the trick.

    Material ID's sounds like different shaders for different polygon faces, and like you said this is not what I referring to.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    DUDE IT WORKS!..lol, sorry I just too happy right now :)

    Ehrm, ok so I try google about "multiple UV set" topic for Max and didn't really get a clear explanation. But I did found some topic about changing the mapping channel, so what I have to do in Max just apply another Unwrap UVW Modifier and change the Map Channel setting to 4, it looks like you hard-coded it to work into that channel, correct?.. (notice you said about texcoord0-3 and use the 3 instead, but in Max there is no map channel 0, it start from 1 so use the 4 instead of 3)..

    Here it is in Max, using my Pandaboi character~

    pandaboisketch.jpg

    Can I request some changing in the order of the map parameter in the material editor?..so instead of hatch dark-medium-light, can you make it hatch light-medium-dark?...it make more sense to me.

    Also the naming of the light parameter instead of "msl_light0_direction", "msl_light1_direction", "msl_light2_direction" for the light position, you can make it "Light 1", "Light 2", "Light 3" (less auto-naming programming stuff). The "Invert Y" like I mention earlier, and about the model flipped normal when I applied the shader to my model.

    Owh, almost forgot, in Max I can't type negative value into the Normal Map Multiplier. The one that I used on the picture above is Multiplier by 2.

    *you can refer what I'm saying to the screen grab of the Max UI that I posted before.
    Other than that, it's awesome!:)

    EDIT:
    One more thing I notice about your shader, it doesn't play nice with omni light. It only light the model based on the viewport that I created it (for example; in top viewport I create an omni light, and it only light the model from the top even though I change the position of the light, this error also applied to front/ left/ etc..) but for spot light and directional light, it works as expected.

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Hey Revel,

    Glad you liked it and got the map channel figured out. In Maya texcoord0, 1 & 2 are all used by defaul for UV/Binormal/Tagent. That's why it seemed normal to increment and use the next texcoord which is 3. In Max's .fx file it seems to differ, I can try putting it in channel 2 instead.

    So just making sure here, the normal map on your panda is inverted right?

    So to summarize:
    -Rename "InvertY" properly
    -Invert normal map functionality (right?)
    -Rename light slots to proper names
    -Re order dark-medium-light to light-medium-dark
    -Switch so R is for Light, G is for Medium and B is for Dark. Makes more sense in that order.


    Concering the omni light it doesn't work since there's no point or spot lights added to the shader? I can add some but it makes the shader more sluggish the more lights there are, also clutters the UI which is just one long list of attributes. What lights and how many do you think it useful to have?
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Hmm..I'm not really sure about tho change it to use the channel 2, I'm not using channel 2 yet because simply I just don't know how to utilize multiple UV channel in Max, but I read in AREA forum they said usually using the map channel 2 for dirt map or something. I guess for now (and for save) just leave it to what it is right now, but just don't forget to write it in your final Max release's readme file, until some more expert people comment/asking for change :)

    Yes, on the screen grab the Panda was inverted normal. And everything on the summary seems cool.

    About the light, when I put an omni light from the top viewport, the source of light only from the top even though I move the light to the bottom of the mesh, also if I put from the front viewport the light source is only from the front and cannot be moved following the omni light. But if I use spot/ directional light, when I move the light it self, the light source is following the light as expected.

    Owh, I think what you referring to point light is called omni light in Max (the light which don't have any direction and cast ray evenly to every direction), with that said does your shader work with point light in Maya?..because in Max it works only with the type of light which have a light direction (spot and directional light).

    If you still confuse with my words tomorrow I try to explain it using pics if you want.

    I think 3 lights is enough, can't trade the more option that we have in the shader for more lights support with the Max lagging like hell..heheh..

    Btw, thanks for the support on this shader's Max compatibility..I'll be jealous if you only make it for Maya user.. :)

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel> Realtime shaders like this one have lights coded in the shader code. There are only directional lights in this shader. You might be able to link a omni light in max, but that won't change the matter. I'm guessing you have managed to link the omni light to define the shaders directional lights direction.

    If you want a working point/omni light in the shader I will have to add those first. You can't just change them around like you might in Max/Maya.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Ah I see...sorry for my lacks of understanding about coding...I only code using flash action scripting...well, just to move ball from 1 place to another lol.

    Now that's explain why when I put omni light I only see a permanent light source position, because when I put it let say in top viewport there is no way to changing the direction of the light because such a feature doesn't exist in omni light parameter. Now, I guess since this is not the official release yet, you can try to add the omni light support in the shader and I try to look into it in Max whether going to cause lagging or not.

    Can you make it based on the light position instead of light direction? And I see why you making the parameter of the light in your shader by "light direction" instead of "light position" is for a reason. Xoliul using "light position" in his shader so it support both directional and omni light type, maybe you can apply that to your shader too? Does that sounds easy fix for you?..Cus I have no idea how you gonna do that..again, sorry for my lacks of understanding in coding. Thanks!

    _Revel
  • karera
    Options
    Offline / Send Message
    karera polygon
    Amazing work Kostas :) love your shaders /Lilja
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Hey thanks Alexander :)
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Yes!some one bring this thread back up...so any update kodde? :)
    But ya I notice you're working on your other KoddeShader v2.0, looks nice and seems like everyone love it too...hehehh

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel> Yeah I know I missed out on the planned updates here. Got caught up with working on the KoddeShader v2.0 as you mentioned.

    I'll try to fix the issues I spoke of earlier for a max version. Most of them are cosmetic changes so it shouldn't take forever.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel>
    I finally found a few spare minutes at the end of the day at work to fix these issues... hopefully. I still can't debug myself to be sure. Will you try this version?

    sketchShader_Maya02_Max05.rar

    These are the issues that should be solved:
    -Rename "InvertY" properly
    -Invert normal map functionality
    -Rename light slots to proper names
    -Re order dark-medium-light to light-medium-dark
    -Switch so R is for Light, G is for Medium and B is for Dark. Makes more sense in that order.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Hi kodde, thanks for the update! but unfortunately the object's normal still need to be flipped in order for it to show the object correctly.

    Btw, I'm not too sure with what you said about "invert normal map functionality" because it seems like the previous version is looks better. Sorry if I'm explaining it wrongly but the one that flipped is not the map of the normal map but the object normal it self, as if you manually select all faces and press the "flip" button to flip the faces inside out.

    About the UI naming it looks perfect now :)

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel> Ok I see.
    So the normal map functionality was correct before? But your geometry normals were inverted? And you are sure this is not an error on your end? This behavior is consistent on all models you try on?

    Good to hear that the UI is better now.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Yes, I've tried on 2 of my models, both showing the object's normal was inside out when the shader display correctly. And what makes me really sure is when I turn on the xView function on detecting face normal, it highlighting every faces when the shader looks ok, which mean when the shader ok all the faces face the opposite direction.

    About the normal map behavior between this release and the previous release I'll try to post up some images later to show you the difference.

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel wrote: »
    Yes, I've tried on 2 of my models, both showing the object's normal was inside out when the shader display correctly. And what makes me really sure is when I turn on the xView function on detecting face normal, it highlighting every faces when the shader looks ok, which mean when the shader ok all the faces face the opposite direction.

    About the normal map behavior between this release and the previous release I'll try to post up some images later to show you the difference.

    _Revel

    I don't doubt the normal map functionality is screwed now. I intentionally flipped it as I was previously under the impression it was inverted using the shader in Max.

    So I need to reverse the geometry normals and restore normal map functionality as previous version. Correct?
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Yes..Dude, you're a genius! I can only able to imagine how things work but you can make it real!.. lol :)

    Just to help you visualize my steps to set it up correctly in Max;
    1. load a DirectX Shader type and apply your sketch shader
    2. plug in all the necessary maps
    3. apply unwrap UVW modifier and set a map channel 4 then collapse stack
    4. apply the shader to the model
    5. select all faces in sub-object mode and hit the Flip button (to correct the inside out looking object)

    Here is an image to show you what I mean..

    flippedv.jpg

    On the left is when the object didn't have sketch shader on it, the right is a same model with sketch shader on it. As you can see the one without shader looks inside out, but the one with sketch shader looks good. Hope it helps!

    Looking forward for the next release~

    _Revel
  • yiannisk
    Options
    Offline / Send Message
    yiannisk polycounter lvl 7
    very cool stuff you got here! cheers!
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    Revel> Try this version. Normal Map functionality as well as culling order has been changes. sketchShader_Maya02_Max06.rar

    yiannisk> Thanks :)
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Oh gosh...I'm super confuse now...but one thing I notice from v05 and v06 the light-med-dark naming is correct but the slot kinda messed up.

    map name.................[the actual map]
    light...........................[dark area]
    medium......................[light area]
    dark...........................[medium area]

    And v06 normal map kinda same with v05 but only when I set the multiplier by 0...multiplier by 1 showing no normal map, and by 2 showing the reverse of multiplier 0.

    Another thing I notice all the shader since v03, v05, v06 react negative to the light source direction (facing light source become dark and vise versa). In v03 and v05, if I Flip the object's normal it react ok with the light direction but without any spec (this is why I thought it make the object's normal flipped previously) but different case with v06, it still react negative to the light source direction but when I Flip the face..well, its flipped (looks like the image on the left of my previous post).

    kodde, did you have any test object that you familiar with to test this shader?..I'll try it in Max and if possible tell me what test did you usually do and I'll post the result for you to have a look and judge what change to make.

    Sorry, but if you think this is just take to much time and you can't debug it yourself and want to stop the conversion to Max shader, I can't do much about it, cus I feel it looks more complicated than I thought at first.

    _Revel
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 18
    The 06 should have re-arranged light-mediun-dark area placement, I covered this in the list of things I intended to fix earlier.

    I don't think this is going anywhere. I cannot debug it and as I try to fix things it seems to get worse or not work according to what I'm hearing. I think I'll leave it at this. The 03 version seemed to have all functionality working, just cosmetic tweaks.

    So you can still use it with max if you want, you just have to live with the cosmetic/ui quirks.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Yeah, I just hope you can find a copy of Max to try the shader yourself. Until that time, good luck with your Maya shader :poly121:

    _Revel
  • airbrush
    Options
    Offline / Send Message
    airbrush polycounter lvl 13
    Hi,

    I tried the lastest version in max 2010, I placed 3 omni lights in my scene and set them respectively in the shader but it seems to have no effect on the look of the shader...moving the lights around has no effect on it.
  • ReeverRayne
    Options
    Offline / Send Message
    Sorry i am a tad slow....is there any instruction on how to load and use it? i am very confuse....sorry ....
  • pfellner
    Options
    Offline / Send Message
    @ReeverRayne, you need to have the Cgfx Shader Plugin installed and activated, then in the Hypershade window, create a Cgfx Shader and point it towards the Stylistic file. I have yet to get it to render and can't find instructions either. It may not work with Maya 2013.
1
Sign In or Register to comment.