Reflection by geometry of vehicle?

Im trying to apply a nice reflection to my vehicle but the reflection seems to be getting stretched by the polies of the model.So if i have a low poly model that is kinda messy then the reflection is real weird and not uniform.If i have a very high poly model with polies that flow through the hole model the reflection is ok.

Im not using any special reflection shader just the one that comes built in with unity.

I just want the reflection to kinda lay across the model and ignore the polies or vertexes of the model.The reflection should go across the vehicle depending on its shape and geometry.

If im wrong please tell me but my reflections are just really stretched out on flat surfaces.

Sounds like you are using the mirror shader instead of a real cubemap based reflection, is that possible?

Possibly

Here is the script im using to achieve real time cube maps

// Attach this script to an object that uses a Reflective shader.
// Realtime reflective cubemaps!

@script ExecuteInEditMode

var cubemapSize = 128;
var oneFacePerFrame = false;
private var cam : Camera;
private var rtex : RenderTexture;

function Start () {
    // render all six faces at startup
    UpdateCubemap( 63 );
}

function LateUpdate () {
    if (oneFacePerFrame) {
        var faceToRender = Time.frameCount % 6;
        var faceMask = 1 << faceToRender;
        UpdateCubemap (faceMask);
    } else {
        UpdateCubemap (63); // all six faces
    }
}

function UpdateCubemap (faceMask : int) {
    if (!cam) {
        var go = new GameObject ("CubemapCamera", Camera);
        go.hideFlags = HideFlags.HideAndDontSave;
        go.transform.position = transform.position;
        go.transform.rotation = Quaternion.identity;
        cam = go.camera;
        cam.farClipPlane = 100; // don't render very far into cubemap
        cam.enabled = false;
    }
    
    if (!rtex) {    
        rtex = new RenderTexture (cubemapSize, cubemapSize, 16);
        rtex.isPowerOfTwo = true;
        rtex.isCubemap = true;
        rtex.hideFlags = HideFlags.HideAndDontSave;
        renderer.sharedMaterial.SetTexture ("_Cube", rtex);
    }
    
    cam.transform.position = transform.position;
    cam.RenderToCubemap (rtex, faceMask);
}

function OnDisable () {
    DestroyImmediate (cam);
    DestroyImmediate (rtex);
}

thats a cubemap based reflection so it technically should work.

perhaps you expect a reflection thats more accurate than what cubemap offers? (cubemap is rendered from 1 point onto the 6 sides of the cube that surround it and then projected inward onto your model)

Also ensure that the model is not over the edge large cause it will become less accurate the larger the model becomes (the texture is still the same cube).

but just to be sure: what share are you using on the material?

I think that pictures would clarify the situation. Show us the low and high poly versions of the model using the shader, and point out the difference.

Im using the reflective/specular.

The image attached helps explain how the reflection changes its look when meeting certain lines or polies on the model.

The other image explains that a cylinder with no segments going horizontal to the cylinder makes the reflection stretch out a lot


I fail to see a problem aside of the one area there on the truck at the right side which might be related to the normals in that area

What you see otherwise is how its meant to look, how a center point project looks on objects and always will. (in reality it would look like this too)

the refleciton / the point on the cubemap thats used for a pixel on the object depends on the normal at that position, so for the cylinder you basically cover a range of 180 degree thats mapped on that small area and correspondingly they get pushed together on the horizontal axis like this if you use that much data but so little radial distance (you are mapping 128 pixels onto what you see there, vertical as horizontal) so you get a visual “compression”

I see what you mean. What do the normals on those models look like?

Im not real sure what you mean by normals.I think the image attached is what your looking for right?Do you want it taken from the model program?

I mean the vertex normals for the mesh. If you are importing them, then the modelling program will probably show them to you. If you’re generating them on import, you’d have to visualize them with a shader.

To test whether it’s odd normals, though, try changing the import settings to generate normals with a smoothing angle of 0, and compare that to what it looks like with a smoothing angle of 180.

Hmm im not sure i follow.I modeled it in 3ds max and i export to .fbx.What should i do.Anything i need to do inside 3ds max?

Try giving it a plain flat normal map (or hard-code float3(0.5,0.5,1) .

That’ll force it to calculate the normal per-pixel rather than per-vertex. You might get a cleaner reflection that way.

The tangent-space basis is still calculated per-vertex. With a flat normal map you’re basically throwing out a bunch of data and recovering the interpolated vertex normal from that basis. In other words, you’re wasting a lot of time to get the same result as no normal map.

Daniel Brauer could you explain a little better what you want me to do so you can see the vertex normals?

Normals are direction vectors stored in your mesh, one for each vertex. They are used by shaders to determine the direction a surface faces for the purposes of lighting and reflection. You can leave their generation to your modelling package, or you can have Unity generate them on import. Here is the section of the manual (look at the “Normals Tangents” section) that explains how to do that.

Ok gotcha.Ok the first image is the normals set to 0 and the second is the normals set to 180.


Ok, there’s your answer: you need better vertex normals from Max, or you can try to play with Unity’s import settings until you get a result you like.

I think with a setting of 40 or something it should look ok. But it would be best if you made your own smoothing groups.

Ok.I have a smooth modifier applied to the model in 3ds max.It gives it all a nice smooth look in 3ds max.What is your suggestions to help it out in 3ds max?

Ah, ok. I’ve had that fix stuff with awkward engines in the past, that defaulted specular lighting back to per-vertex if there was no normal map, and adding even flat a normal map forced it to render the normals per-pixel (as the per-vertex interpolation got a little wobbly) and look considerably smoother.

I figured this might give a similar effect.