Normals - which way?

Discussion in 'Car Modding' started by Johannes Rojola, Sep 15, 2012.

  1. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    I noticed a issue, or I am not sure if it is a issue.

    [​IMG]

    I get completely different cubic reflection depending on which way my normals in the mesh are. In this picture left side of the suspension is original mesh, and in the right side is the same mesh but with flipped normals. Material is the same. Issue is that I have always had hard time to get chrome materials to look good, they look washed out grey most of the time (like the example in left). With flipped normals the reflection effect is much better, albeit it requires texture adjustments for better end result.

    Sure, the one in the right is done "wrong", it is completely black in Max, hence inverted. But still, this bothers me, what is going on and what should I do? It would be a lot easier with flipped normals for sure...
     
  2. MaXyM

    MaXyM Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,774
    Likes Received:
    29
    Firstly - it is correct, that reflection is dependent on normals. It is how it should work and how does.
    Chrome effect (mirror-like) depends on math performed by shader. It's possible you will achieve it just by using pitch black texture. it would explain why inverted normals gives you what you want.

    BTW KSzczech shaders for rf1 (SRPL Shader Pack) work this way - mirror/chrome effect you may get only with black diffuse. With brighter colours it is less reflective (like glossy coated etc).

    Note also that chrome/mirror needs very sharp light reflection, which is not possible to achieve with current 3dmax plugins (limited maximum value to: 100 while for chrome it should be something like 10 000)
     
    1 person likes this.
  3. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    Normals should always point outside. Period :)

    What you're experiencing is fresnel equation going bananas because your normals are reversed. In such situation, fresnel equation will always produce maximum reflectivity.

    You have two fresnel parameters called "fresnel min" and "fresnel max". First describes reflectivity of material when looking straight at it, second describes reflectivity of material when looking parallelly to it's surface.

    So if you want material with low reflectivity you set both fresnel min and fresnel max to low values. If you want material with high reflectivity you set both fresnel min and fresnel max to high values.
    If you want material with reflectivity varying depending on viewing angle you set fresnel min and max to proper range and set fresnel exponent to desired linearity (value of 1.0) or non-linearity (higher values).

    Here are 3 examples:

    [​IMG]

    First sphere has fresnel min and max set to 0,1 - so it's a material with low reflectivity.
    Second sphere has them set to 0,9 - so it's a highly reflective material.
    Third sphere has fresnel min set to 0,05 and fresnel max set to 1,0. That's why it's less reflective at center and more reflective near edges.



    When you reverse your normals, fresnel equations will always think you're looking at the object at extreme angles and will output "fresnel max" as object's reflectivity. It should never be done this way - you should leave proper normal vectors for lighting and just set "fresnel min" and "fresnel max" properly.
     
    Last edited by a moderator: Oct 10, 2012
    2 people like this.
  4. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    Thanks, it seems I have to get back to my fresnel settings. Also nice to know why inverted normals look how they do. Challenge is that I need to have proper chrome but also normal body paint incorporated into a same texture. It gets really troublesome trying to find the balance with fresnel settings and alpha channel.
     
  5. MaXyM

    MaXyM Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,774
    Likes Received:
    29
    I think problem is not related to texture at all. But for sure you have to define two different materials: for chrome and for the rest of livery.
    It's because alpha doesn't control Fresnel parameters (which are different for chrome and the rest) but controls only amount of reflection (it's final effect multiplier only).
     
  6. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    How can one parameter (alpha) control 3 parameters (fresnel) ? :)

    For separate materials you need separate materials and that's it. It's not like you're going to create fresnel parameters for chrome and then just weaken it for plastic or wood.

    And besides - fresnel is the reflectivity. I think you got it a little mixed up :)
     
  7. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    I know, but problem is that with my cars you never know which parts are chrome and which painted, and which even rust or leather. Even I don't know, because there is so many ways how you can paint custom cars.

    So go figure :D
     
  8. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    Yeah, but rF2 doesn't support that kind of freedom. I don't think any game does, although modern games would be capable of it.

    It's all down to level at which material parameters are selected. If CPU selects materials before rendering part of geometry (like in rF2) you will be stuck with the same set of parameters for that geometry.
    If all materials are passed to pixel shader and selection is done there - you get much more freedom, but it creates some limitations on artist as to texture sizes and formats.
     
    Last edited by a moderator: Sep 18, 2012
  9. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    Yes there are limitations for sure, and most certainly with number of textures and their sizes. With single car spec-mod you would have much more freedom, as most of the textures would be shared with all cars. However, our mod there will be dozens of different cars featuring everything from rusted metal to gold. I think, I've gotten close enough with all the requirements, but nothing is at the level what I would wish for really... lots of compromises.
     
  10. MaXyM

    MaXyM Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,774
    Likes Received:
    29
    Do you mean that in case of your mod, skinner should have freedom to select material used to build a part of car?
    if so, only way is to provide such parts as upgrades. Then any upgrade is different material, even if using the same texture (skin one or extra one - doesn't matter)

    Don't know a serious reason why you have to agree with this constraint.
     
  11. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    It is not constrain if you have 20 similar cars on the track. Just common sense to use shared textures for better perfomance.

    I once planned using upgrades for various material parts, but it just bloats the texture and material space too much. Also makes it less fun for player to custom paint these parts, as everything is shattered in numerous different texture files.
     
  12. MaXyM

    MaXyM Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,774
    Likes Received:
    29
    But it is you who wants to reproduce various materials ;) You cannot make various materials using one set of properties. Just simple as KSzczech wrote: For separate materials you need separate materials and that's it.

    Huge amount of various materials costs higher number of various textures, memory usage etc. You can do nothing with it.

    Finally we are talking about special materials. chrome, gold or rusted metal. i see no reason to give user possibility to paint anything on it (I quess suspension, window frames etc). Give users skinning possibility for coated livery only. There are always compromises. For sure there is no possibility to allow user to change material properties just by making a skin.
     
    Last edited by a moderator: Sep 18, 2012
  13. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    I think you got totally mixed up, MaXyM ;)

    1. Having materials switched based on skin painter's preferences is only possible if game engine has material selection at pixel shader level and that would cause additional restrictions on texturing
    2. If multiple cars use the same material, then textures are shared in video memory
    3. Creating a mod with lot's of unique cars will require using lots of unique materials and therefore it's less optimal

    So #2 is not a constraint of any kind. It's an optimization actually. An optimization that you loose when you start creating unique materials.

    You allready know that, but it seems like you completely misunderstood previous posts.
     
  14. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    Yeah my original challenge was and pretty much is how I can make best out of pile of compromises. That meaning that I need to try to control both chrome and regular paint from single texture with alpha. I think I have already gotten the best out of it and that's fine. Now if you want full chrome car, that's okay. Also if you want fully rusted car, it will do as well. Or anything between. Sure basic knowledge of alpha editing is required...

    With some other modding project I would do it differently, like for single car mod etc which would not be intended to be customized by player.

    If getting back to the original post, I first thought that my normals were actually flipped somehow because all the insides of chrome parts where shiny as I intended. I didn't know fresnel does have a circus inside the meshes :D Now that I know this, it is easier for me to try to make the material look good as possible and not keep thinking about normals.
     
  15. MaXyM

    MaXyM Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,774
    Likes Received:
    29
    @KSzczech, I understand whole problem very well.
    - The author wants to create a lot of cars with different materials
    - Author want to give driver a possibility to customize appearance (change material, painting)

    Those are goals to achieve. Unfortunately it cannot be done without sacrifice performance a bit, because as you said, it is impossible to use single material to represent materials with different fresnel reflections. So to me sticking with idea of single material is just a constraint which must be released to achieve goals.
    Of course, author may want to sacrifice quality and create some unrealistic materials - but that is another story not mentioned about.


    In that case you cannot get both chrome and paint. It is probably something between depending on fresnel settings (since both materials require completely different ones). But if you are satisfied with the result then ok.
     
    Last edited by a moderator: Sep 18, 2012
  16. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    I'm not saying you don't understand the problem. I'm saying you misunderstood previous posts :) You did call sharing textures a constraint :)

    EDIT:
    Nope, you still don't understand :) If two cars use the same texture (brake discs for example) it will be loaded only once to video memory - that's what we were talking about - it was clearily mentioned it's about single-car mods, not mod Johannes is working on.
     
    Last edited by a moderator: Sep 18, 2012
  17. MaXyM

    MaXyM Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,774
    Likes Received:
    29
    Yes, because it is, from the goal point of view.
    OK, it might be not, if one single texture contains textures for more materials at once.
     
  18. Johannes Rojola

    Johannes Rojola Registered

    Joined:
    Sep 8, 2011
    Messages:
    1,038
    Likes Received:
    38
    The pure chrome material in itself is not that good either that I feel like I am missing something very important. Believe me, I try to make such material all the time :D Even ISI 60's formula cars use baked/faked chrome textures in their exhaust pipes or similar parts. I know it is not realistic, but when shaders are what they are (rF2 is not Crysis) often times just fake textures do the job.
     
  19. K Szczech

    K Szczech Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,720
    Likes Received:
    45
    For pure chrome I would go for black diffuse texture, as MaXyM mentioned before. You don't want object's color added to reflection - you just want pure reflection.
    Check those 3 spheres I posted before - they use black diffuse texture.

    There's still an issue with realtime cubemaps though. Objects are rendered to cubemap without shadows and that leads to situation when contents of reflection are way different than surroundings of a car.
    It's visible on your screenshot - axle reflects bright road while actual road is in car's shadow.

    This work against the very idea of realtime reflections, because if contents of cubemap are that much different than surroundings, then you may aswell use static cubemap.

    As user - I think I'd rather have this axle with no reflections at all than "glowing" like this in shadow.


    Another limitation, and this is actually true for all games - there are no self-reflections in games. So car's axle doesn't reflect car's floor, but sky instead. You need to artificially limit reflectivity of materials that are surrounded by other parts of a car.
    It's best done by a texture. It should be specular map, but specular maps have no effect on cubemaps in rF2 so our only option is using alpha channel of texture to make reflections less apparent.
     
    Last edited by a moderator: Sep 18, 2012
  20. Tuttle

    Tuttle Technical Art Director - Env Lead

    Joined:
    Feb 14, 2012
    Messages:
    2,480
    Likes Received:
    775
    Yeah, but the result is more like a pure mirror than a chrome metal...I'm fighting with my rims to get a stuff like this but without faking a bit the texture it looks awful...:

    [​IMG]

    If you have any suggestion I really appreciate it....:)
     

Share This Page