1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Like RaceDepartment on Facebook.

Dof script for 3dsmax

Discussion in 'Racer' started by ammods, Nov 18, 2010.

  1. Dof script for 3dsmax?

    i know there's one out there, but it uses the old shader style, is there anyone out there, who can update it, for the newer version of the shaders..or am i wasting my time asking for such a thing


    hope someone can come to the table on this

    sorry i meant to add the ???

    as im looking for a new format to edit for, and this is about all there is at present
     
  2. Exactly what are you asking for? A DOF exporter or importer for 3DS Max?

    For exporting DOF from Max, I suggest my DOF exporter plugin.
     
  3. To use that exporter for a car body for example, you'll have to connect all your objects into the one that is defined in a car.

    Ie, body.dof will need to be a single object in 3ds max for it to work right, using sub-materials...

    Is that right Some1?


    I find your tool totally invaluable for tracks now! Great work Some1!

    Dave
     
  4. Yes and no, since Racer supports generics, you can export more than one dof for a car, but then you need to use the generics in the car.ini to set the other parts. But in the simple case, yes, you collapse all your models to one object and then export as body.dof for example.

    Hehe, at first, I read unvaluable... :D
     
  5. sorry i meant exporter, as the one you've created still uses the old shader system, what i'm after is an update

    also i'm interested in hearing from someone who makes tracks for racer, as i'm thinking about switching to racer, from my current format, my mods are very australia, ie bathurst, gold coast aka surfers paradise and such

    cheers all.
     
  6. KS95

    KS95
    RACER Moderator

    You mean Racer's shaders? The exporter has no effect on cg/non cg.
     
  7. this is where i get lost, i can export a car for racer, but soon as i do, i get befuddled with the shaders part, as the game i'm editing for now, has all that built in, all we do is convert the cars and put them ingame, and your done, with racer it's more indepth,

    so if someone could explain to me a dummies guide if you will to shaders then i can get started,
     
  8. ammods,
    Try www.racer.nl documentation page for info on shaders and look at other content, cars/tracks, to see how they are done.
     
  9. Stereo

    Stereo
    Premium Member

    The basics of shaders:
    - it's a text description of the material
    - uses the object's material names
    - assigns textures, lighting, reflections, etc.
    Generally this will correspond to the same stuff used in other programs - it's just more easy to edit since it's in a separate text file (car.shd, track.shd, car_nocg.shd etc.)

    The easiest way to go into more detail is with an example.
    Code:
    vf_reflect_window
    {
      vertex_shader
      {
        file=dyn_standard_reflect_window_v.cg
      }
      fragment_shader
      {
        file=dyn_standard_reflect_window_f.cg
      }
    }
    
    shader_glass~vf_reflect_window
    {
      ;sort_offset=1
      reflect=0.6
      layer0
      {
        map=glass.tga
        blendfunc=blend
        ;blendfunc=one src_alpha
      }
      layer1
      {
        map=$trackenvmap
      }
    }
    This is the shader code used for the Lamborghini Murcielago's windows.
    Most obvious is the bracket structure - this is used to create a hierarchy of information. When Racer looks for data, it uses this hierarchy to locate it. Also referred to by periods in documentation (name.thing=value) to write in-line.
    Code:
    name # name of the section
    { # start the section
      things... # information in that section
    } # end the section
    I'll go through it again, with notes after each bit to indicate what it does.
    Code:
    vf_reflect_window # named section for repeated use later
    {
      vertex # this is being applied at the vertices of the mesh
    _shader  # and is referring to a shader
      {
        file= # the only information needed is the filename
        dyn_standard_reflect_window_v.cg # this is in data/renderer/shaders/, look there for alternatives
      }
      fragment_shader # this is applied on a per-pixel basis.  Distinction's not that important unless you need to edit them.
      {
        file=dyn_standard_reflect_window_f.cg # same location, most shaders have _v and _f with the same name
      }
    } # end of the vf_reflect_window
    
    shader_ # all material sections are prefixed with shader_
    glass # the name of the material in question
    ~ # the tilde links up another section
    vf_reflect_window # any values in vf_reflect_shadow get copied into this structure for use.  Since the shaders tend to be repeated, it's easier to write them once at the top of the file and refer to them like this for each material using the same type of material (no reflections, reflections, glass, etc.)
    {
      ;sort_offset=1 # lines starting with a semicolon are commented out
      reflect=0.6 # strength of reflections - higher is more.  This and other parameters can appear directly in the shader
      layer0 # first texture layer
      {
        map=glass.tga # again a file reference, this time in the car folder
        blendfunc=blend # transparent materials need a blendfunc to decide how to render - blend is most common
        ;blendfunc=one src_alpha
      }
      layer1 # next texture layer
      {
        map=$trackenvmap # this time instead of a file reference, it refers to a special texture - Racer's reflection map
      }
    }
    dyn_standard_reflect_window_v/f.cg expects certain values to be in the shader - either you provide them or defaults are used. It also expects a certain texture order, in this case, 0) texture, 1) reflection. Other shaders will use the layers for different purposes. Generally layer0 is a texture map, and others are indicated by the filename - standard_reflect will want a reflection map after the main texture, while standard_bump_reflect will want the main texture, a bumpmap, and then the reflection map provided.

    Main reference for cg shaders is at http://www.racer.nl/reference/gpushader.htm. You can skip down to the Shader Library section if you just want to use the defaults.
     
  10. I guess, if 0.9 final comes out, it would be possible to add a shader editor to the DOF exporter, so the user shouldn't have to do more than just specify the supershader for a material, the textures and some other parametes and be done... hmm...
     
  11. thanks @ stereo,
    @ some1, that would be a good idea, if something like that could be done, as it would make life alot easier, i'd guess

    i'll look into the info given here, and go from there
     
  12. Ruud

    Ruud
    RACER Developer

    That's what rFactor does with their Max plugin; define materials specific to rFactor, with parameters and all that. We're not planning such a plugin ourselves though, so perhaps basing something on the existing plugin might help. I think it should be a C++ .dlu or something, for Max materials. Hm.
     
  13. One drawback rFactor plugins have, as far as I remember, is that if you change a material, you need to export all the objects that use that material... or was it, that you needed to export the object that changed the material...

    Anyway, somehow, I feel that having car.shd helps to decouple the generic 3d asset from the game specific stuff. So you don't need to make the car model in max just for Racer, but it is a generic model, and you just use DOF exporter to export the models and later match the materials to the shaders in car.shd.

    Ruud, a long time ago, I asked, if it was possible to have a common shaders definition file somewhere in data/renderer, so that when creating car.sh or track.shd, one wouldn't need to define the vertex and fragment shaders explicitly, but just use the ones globaly defined.

    For example:
    in data/renderer/commonshaders.ini:

    Code:
    vf_standard
    {
       vertex_shader
       {
          file = ...
       }
       fragment_shader
       {
          file = ...
       }
    }
    
    and in some data/cars/mycar/car.shd:

    Code:
    
    shader_somematerial~vf_standard
    {
       layer0
       {
          ....
       }
    }
    
    Of course, the user could still specify custom shaders in the shd file, but this way a lot of common shader code could be refactored away from the content shader files...
     
  14. Even if we could have an #include at the beginning of the file it might make things nicer?
     

  15. something along those lines would be good, even if the current exporter is updated to use the latest car.shd would be more for what i'm aiming for, just a thought, i dont think i'd start editing full time for racer until 0.9, as i dont want to have to redo everything over..
     
  16. That makes some good sense, especially since all the generic shaders we reference are named nicely. It makes sense to have them referenced with those same names.

    It'd certainly help generate some consistency, so everyone calls a standard material "standard" etc...

    Would make it easier for people to read shaders that others have made and give them a head start when reading any other shader.


    That said, I also like to sometimes define my own shaders but this still allows that anyway. Longer term, it's nice to help people out by making this stuff more obvious, but it's also useful to understand how it works for any content developer in my view.
    If you can learn how to model or texture, learning the relatively simple bits you need to, to use shaders, isn't that tough at all. I think it's essential to obtaining the best results from your work.
    As always, those who are stuck can ask here... I'm sure no one here wouldn't help someone who had some stunning work that just needed some shader file developing a bit :D

    Hmmmm

    Dave
     
  17. everyone i really do appreciate your feedback and helping me to make a decision regarding racer, some say racer is crap, but i'm a very open minded person and willing to give anything a go once, here is a screen, of what i'd be putting into racer, you must understand i'm australian and whatever i bring in, will more than likely be australian...

    http://img25.imageshack.us/img25/1651/scrshot0001a.jpg this is a v8supercar
    http://img560.imageshack.us/img560/2749/wr2pc2010111013564480.jpg norm beechey's monaro,

    of course there is alot more than this, plus there is tracks and such that i have in my posession as well, basically i'm ready to move onto a new format, and you guys explaining everything to me in "laymans" terms certainly makes things alot easer to understand
    cheers
     
  18. We won't hold that against you.
    Some of the best of us are lol I'm from Sydney, lived in Adelaide for a few years too
     
  19. i wont hold that against you lol, i'm from West aussie, best part lol..i wont tell you where i was originally from you'll make the 2 headed, and inbred jokes) which just makes me want t o tear you a new one...but anyways back on topic, just installed the dof exporter, so im gonna start investigating
     
  20. Brisbane guy here.
    You're from tassie then I take it? Some nice roads there.