Author Topic: Oblivion bubble ship  (Read 22746 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #15 on: September 07, 2018, 02:08:55 pm »
Almost all of the model exterior that required AO has been occluded successfully. :D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Oblivion bubble ship
« Reply #16 on: September 07, 2018, 04:23:59 pm »
Quote
Almost all of the model exterior that required AO has been occluded successfully.
The problem is that the real model is build from composit material, rather than metallic.
It looks more like the white body of a glider plane.

Here is another build with a bunch of changes…
« Last Edit: September 07, 2018, 11:14:46 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #17 on: September 08, 2018, 09:57:59 am »
That's because we're working with per-material constant Ns. The big idea behind material metalness/roughness (that's the PBR way of rendering things) is per-pixel variable Ns that's hardcoded in its own map_Ns.

I'm currently looking into this technique closely and I think I'll soon be able to come up with a shader that can handle PBR models without having to rework/adapt their texture maps first.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Oblivion bubble ship
« Reply #18 on: September 08, 2018, 10:04:27 am »
In the last build, i think i have removed all the watermarks from the bubble_body/engine texture set, however if you could inspect them closely just to make sure they have been all cleaned up, 4 eyes being better than 2...
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #19 on: September 08, 2018, 10:35:13 am »
That's a very nice-looking "moonlit" rendition of the model. :)

(I can't see any offending watermarks in the texture color/alpha channels.)

Yet the model should be AO mapped. I can't enjoy bare renders now that I have an almost complete set of map_Ka textures. I'm appending them below in the zip for you to use too. You can derive their respective meshes in the MTL file from the texture names.

Note that to be able to see AO, the material needs to go through the normalmap branch of PPL. To this end, the AO-ed materials should have either their own normal map or utilize the neutral_bump.png dummy explicitly. Note also that my current ObjReader renders AO much more vividly than yours because yours uses it predominantly in the ambient material+light component while mine shares it equally between the material+light ambient and diffuse components.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Oblivion bubble ship
« Reply #20 on: September 08, 2018, 11:52:19 am »
Quote
That's a very nice-looking "moonlit" rendition of the model.
Yes, the rendition must match closely the ambient lighting of the wallpapr being used.

Did you notice the new red light animation, the new rotor rotate effect, the new rotule and legs texturing, and the reworked jet propulsion.

Now i have to figure what to change with the legs to have a real flying version  :-\

Thanks for the new occ textures, they have been added to the material file !

« Last Edit: September 08, 2018, 12:04:01 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #21 on: September 08, 2018, 03:39:57 pm »
Yes, I've noticed all the mods and I appreciate them, especially the jets and red lights. They are a killer! :)

Now i have to figure what to change with the legs to have a real flying version  :-\

Professionally, the rotule+legs assy should be rigged with a triped skeleton so that the legs could be posed using rotation gizmos. 8)

But since we aren't seeking the easy ways (hehe), we should obviously split the front legs into two distinct meshes. The back leg should be lifted a little in parallel with the fuselage, and the front legs, rotated backwards on both sides of, and parallel to, the back leg. (see the picture below)

I think this will also need some adjustments to the rotule_ext and rotule_lisere meshes.

Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Oblivion bubble ship
« Reply #22 on: September 08, 2018, 07:22:30 pm »
Here is what i came with, for the flying version...
« Last Edit: September 08, 2018, 07:59:37 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #23 on: September 08, 2018, 09:09:08 pm »
Looks cool! :D
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Oblivion bubble ship
« Reply #24 on: September 09, 2018, 02:02:00 pm »
I couldn't use the .stl pilot, because it is a scanned model, and the mesh quality is too low  :-\
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #25 on: September 09, 2018, 02:59:49 pm »
Don't even try to, because the only pilot that ever flew the Oblivion bubble ship was Tom Cruise in one or another of his clone reincarnations. ;)

Unless we're able to find Tom's textured body or head model let the bubble cockpit remain unmanned.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Oblivion bubble ship
« Reply #26 on: September 10, 2018, 08:10:05 pm »
Skytower platform...
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #27 on: September 10, 2018, 08:28:53 pm »
OMG! :o

This is terrific! Is it just the round platform without the passageway/living cubicle?

Tell you what: I'll send you the shader that renders AO like my ObjReader does, and I would like to try and generate the real AO map for the platform in Blender (when you're done with the model) so that you won't need the pseudo-shadow mesh at all...
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
Re: Oblivion bubble ship
« Reply #28 on: September 10, 2018, 08:39:15 pm »
Quote
Is it just the round platform without the passageway/living cubicle?
Yes, just the single platform for the purpose of self centering of the view port.

And then, no more need to have a pilot within the cockpit ;)
« Last Edit: September 10, 2018, 08:46:57 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Oblivion bubble ship
« Reply #29 on: September 10, 2018, 09:06:16 pm »
Awesome!!! 8)

Here's the "new" normalfrag_shader code; use it instead of your current "reference" ObjReader shader in the Mobj_LoadShader() proc:

Code: [Select]
        const char* normfrag_shader =
        "#define BUMP_NORMAL     0\n"
        "#define BUMP_PARALLAX   1\n"
        "#define BUMP_STEEP      2\n"
        "#define BUMP_SELFSHADOW 3\n"

        "//#define SPEC_INTENSITY_POINT       4.3 // Point light\n"
        "//#define SPEC_INTENSITY_DIRECTIONAL 1.5 // Directional light\n"
        "//#define SPECULAR_FACTOR            1.75\n"
        "//#define SPECULAR_ALPHA             0.1\n"
        "//#define SPEC_FACTOR_NO_SPEC_MAP    0.6\n"
        "//#define ENV_ALPHA_FACTOR           0.3\n"
        "//#define GLOW_MAP_INTENSITY         1.5\n"
        "//#define AMBIENT_LIGHT_BOOST        1.0\n"

        "uniform sampler2D sBasemap;   // colorMap\n"
        "uniform sampler2D sNormalmap; // normalMap\n"
        "uniform sampler2D sSpecmap;   // specularMap\n"
        "uniform sampler2D sShadowmap; // shadowMap\n"
        "uniform sampler2D sHeightmap; // heightMap\n"
        "uniform float materialAlpha;\n"
        "uniform int nLights;\n"
        "uniform int nLightFlags;\n"
        "uniform int nBumpMode;\n"
        "uniform vec3 viewDir;\n"

        "varying vec4 position;\n"
        "varying vec3 lNormal;\n"
        "varying mat3 tbnMatrix; // to calc tangents for sNormalmap\n"

        "void main() {\n"
            "vec2 newUV;\n"
            "vec2 texCoord = gl_TexCoord[0].xy;\n"
            "vec3 eyeDir = vec3(normalize(-position).xyz); // Camera is at (0,0,0) in ModelView space\n"

            "if (nBumpMode == BUMP_STEEP) {\n;"

                "vec3 eDir = normalize(eyeDir); \n"
                "vec2 vParallaxDirection = normalize(-eyeDir.xy);\n"

                "// The length of this vector determines the furthest amount of displacement\n"
                "float fLength         = length(eDir);\n"
                "float fParallaxLength = sqrt(fLength * fLength - eDir.z * eDir.z ) / eDir.z;\n"

                "// Compute the actual reverse parallax displacement vector\n"
                "vec2 vParallaxOffsetTS = -vParallaxDirection * fParallaxLength;\n"

                "// Need to scale the amount of displacement to account for different height ranges\n"
                "// in height maps. This is controlled by a designer-editable parameter\n"
                "float parallaxScale = 0.3; // can be a uniform\n"
                "vParallaxOffsetTS  *= parallaxScale;\n"

                "float nMinSamples      = 6.0;\n"
                "float nMaxSamples      = 1000.0 * parallaxScale;\n"
                "float nNumSamples      = mix(nMinSamples, nMaxSamples, 1.0 - eDir.z);\n"
                "float fStepSize        = 1.0 / nNumSamples;\n"
                "float fCurrHeight      = 0.0;\n"
                "float fPrevHeight      = 1.0;\n"
                "float fNextHeight      = 0.0;\n"
                "float nStepIndex       = 0.0;\n"
                "vec2 vTexOffsetPerStep = fStepSize * vParallaxOffsetTS;\n"
                "vec2 vTexCurrentOffset = texCoord;\n"
                "float  fCurrentBound   = 1.0;\n"
                "float  fParallaxAmount = 0.0;\n"

                "while (nStepIndex < nNumSamples && fCurrHeight <= fCurrentBound) {\n"
                    "vTexCurrentOffset -= vTexOffsetPerStep;\n"
                    "fPrevHeight = fCurrHeight;\n"
                    "fCurrHeight = texture2D( sHeightmap, vTexCurrentOffset).r;\n"
                    "fCurrentBound -= fStepSize;\n"
                    "nStepIndex += 1.0;\n"
                "}\n"

                "vec2 pt1 = vec2( fCurrentBound, fCurrHeight );\n"
                "vec2 pt2 = vec2( fCurrentBound + fStepSize, fPrevHeight );\n"
                "float fDelta2 = pt2.x - pt2.y;\n"
                "float fDelta1 = pt1.x - pt1.y;\n"
                "float fDenominator = fDelta2 - fDelta1;\n"
                "fParallaxAmount = (pt1.x * fDelta2 - pt2.x * fDelta1 ) / fDenominator;\n"

                "vec2 vParallaxOffset = vParallaxOffsetTS * (1.0 - fParallaxAmount);\n"
                "newUV = texCoord - vParallaxOffset;\n"

            "} else if (nBumpMode == BUMP_PARALLAX) {\n"
                "float scale = 0.04;\n"
                "float bias = -0.025;\n"

                "vec3 h = normalize(tbnMatrix * eyeDir);\n"
                "float height = texture2D(sHeightmap, texCoord).r;\n"
                "height = height * scale + bias;\n"
                "newUV = texCoord + (height * vec2(h.x * h.z, h.y * h.z));\n"
                "//if (newUV.x > 1.0 || newUV.y > 1.0 || newUV.x < 0.0 || newUV.y < 0.0) discard; // ML: doesn't work for tiled tex coords w/o one more texture scale uniform\n"
            "} else {\n// if (nBumpMode == BUMP_NORMAL) {\n"
                "newUV = texCoord;\n"
            "}\n"

            "vec4 lightDiffuse  = vec4(0.0, 0.0, 0.0, 1.0);\n"
            "vec4 lightAmbient  = vec4(0.0, 0.0, 0.0, 1.0);\n"
            "vec4 lightSpecular = vec4(0.0, 0.0, 0.0, 1.0);\n"
            "vec4 lightAmbientDiffuse = vec4(0.0, 0.0, 0.0, 1.0);\n"

            "vec3 normal = texture2D(sNormalmap, newUV.st).rgb * 2.0 - 1.0;\n"
            "normal = normalize(tbnMatrix * normal);\n"
            "vec3 lightDir;\n"

            "lightAmbient = gl_FrontMaterial.emission + (gl_LightModel.ambient * gl_FrontMaterial.ambient);\n"

            "int lightFlags = nLightFlags;\n"
            "#pragma optionNV unroll all\n"
            "for (int i = 0; i < nLights; ++i, lightFlags >>= 1) { // MAX_LIGHTS\n"
                "if ((lightFlags & 1) == 0) continue; // ML: inspect individual on/off bitfield flags\n"
                "float specularIntensity = 1.0;\n"
                "float attenuation = 1.0;\n"
                "vec4 lpos = gl_LightSource[i].position; // ML: speed up access\n"

                "// Attenuation and light direction\n"
                "if (i != 0 && lpos.w == 1.0) {\n"
                    "// Positional light source\n"
                    "float dist = distance(lpos.xyz, position.xyz);\n"
                    "float spotEffect = 1.0;\n"
                    "attenuation = spotEffect / (gl_LightSource[i].constantAttenuation + (gl_LightSource[i].linearAttenuation * dist) + (gl_LightSource[i].quadraticAttenuation * dist * dist));\n"
                    "lightDir = normalize(lpos.xyz - position.xyz);\n"
                    "specularIntensity = 4.3; // Point light, SPEC_INTENSITY_POINT\n"
                "} else {\n"
                    "// Directional light source\n"
                    "lightDir = normalize(lpos.xyz);\n"
                    "specularIntensity = 1.5; // Directional light, SPEC_INTENSITY_DIRECTIONAL\n"
                "}\n"

                "// Ambient and Diffuse\n"
                "lightAmbient += (gl_FrontLightProduct[i].ambient * attenuation);\n"
                "lightDiffuse += ((gl_FrontLightProduct[i].diffuse * max(dot(normal, lightDir), 0.0)) * attenuation);\n"

                "// Specular\n"
                "float NdotHV = clamp(dot(normal, normalize(eyeDir + lightDir)), 0.0, 1.0);\n"
                "lightSpecular += ((gl_FrontLightProduct[i].specular * pow(max(0.0, NdotHV), gl_FrontMaterial.shininess)) * attenuation) * specularIntensity;\n"
            "}\n"

            "// Occlusion\n"
            "vec3 depth = texture2D(sShadowmap, newUV).rgb;\n"
            "lightAmbientDiffuse = lightAmbient + lightDiffuse;\n"
            "lightAmbientDiffuse.rgb *= depth;\n" // MLL 09-05-2018: make AO affect diffuse lighting
            "//lightAmbientDiffuse.rgb *= texture2D(sLightmap, texCoord2).rgb;\n"

            "// Base color\n"
            "vec4 baseColor = texture2D(sBasemap, newUV);\n"
            "vec4 fragmentColor;\n"
            "fragmentColor.rgb = baseColor.rgb * max(lightAmbientDiffuse.rgb /* * 1.0*/, gl_LightModel.ambient.rgb - 0.425); // ML: redundant AMBIENT_LIGHT_BOOST removed\n"
            "fragmentColor.a = baseColor.a * materialAlpha; // !!! ML: !!!\n"

            "// Spec color\n"
            "fragmentColor.rgb += lightSpecular.rgb * (texture2D(sSpecmap, newUV).rgb * depth * 1.75); // SPECULAR_FACTOR\n"
            "fragmentColor.a += (dot(lightSpecular.a, lightSpecular.a) * 0.1); // SPECULAR_ALPHA\n"

            "gl_FragColor = fragmentColor * 2.0;\n" // MLL 09-05-2018: allow 100% overbrightening
        "}";

It has two major fixes:

1. It renders AO in both ambient and diffuse channels; and

2. It allows our current "stray light" control to overbrighten normal-mapped materials in the scene up to 100%. So, the former 100% full-bright is now exactly at the control's mid-position, and drawing the thumb fully upwards now yields genuine +100% overbrightness. I am sick and tired of using illegal 2.0 2.0 2.0's in the color channels whenever I need extra brightness/shininess in our materials.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)