Shining Meshes

Started by
13 comments, last by Medo Mex 10 years, 9 months ago
I noticed in some modern games that all the meshes are shining.
I'm not talking about specular light here, but the entire mesh is shining which make it look much more realistic, how do I get this effect?
Advertisement

Like the environment is reflected on polished metal? Maybe you are looking for environmental mapping.

Do you mean meshes which seem to be emitting light by themselves instead of reflecting light from light sources?

You can achieve this with emissive materials, which are materials which have an emissive color or texture which gets added to the lighting results of the geometry.

Note that emissive materials in general don't affect surrounding geometry though as they're not actual light sources

I gets all your texture budgets!

I just took a screenshot of something similiar.

I want to achieve this shininess:

[attachment=17218:sh.png]

Yeah, those are done with environment maps, like Tispe said

This technique is achieved by calculating a reflection vector for your surface point and using it to sample relfections from a cube map.

I gets all your texture budgets!

Looks like there is also bloom (best seen on the rims), so might even be hdr lightning.

@Radikalizm: Any samples/tutorials? I want to do exactly the same effect...

float3 cubeTexCoord = reflect(-toCamera, normal);
float3 reflectedColor = texCUBE( cubeSamp, cubeTexCoord );

@belfegor: I'm new to this... How do I generate the cube texture?

At start use pre-existing cube texture and practice with that.

If you must, to match the surrounding scene you must have dynamic cube, which means you must render your scene multiple times, possibly in lower resolution for better performance, something like this (chopped code from my old project):


D3DXCreateRenderToEnvMap(device, CUBEMAP_RESOLUTION, 1, format, TRUE, D3DFMT_D16, &RenderToEnvMap);
D3DXCreateCubeTexture(device, CUBEMAP_RESOLUTION, 1, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &CubeMapTexture);
...
void RenderSceneIntoEnvMap(D3DXVECTOR3 camPosition)
{
    // 90 degree fov to get a seamless environment map texture
    D3DXMATRIX cubeProj;
    D3DXMatrixPerspectiveFovLH( &cubeProj, D3DX_PI * 0.5f, 1.0f, 1.0f, 1000.0f );

    RenderToEnvMap->BeginCube(CubeMapTexture);

    for(UINT i = 0; i < 6; i++)
    {
        RenderToEnvMap->Face((D3DCUBEMAP_FACES)i, 0 );
        D3DXMATRIX cubeFaceView = getCubeMapViewMatrix((D3DCUBEMAP_FACES)i, camPosition);
        D3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0 );
        RenderScene(&cubeFaceView, &cubeProj);
    }

    RenderToEnvMap->End(0);
}
...
 
D3DXMATRIX getCubeMapViewMatrix(DWORD dwFace, D3DXVECTOR3 camPosition)
{
    D3DXVECTOR3 lookDir;
    D3DXVECTOR3 upDir;

    switch( dwFace )
    {
    case D3DCUBEMAP_FACE_POSITIVE_X:
        lookDir = D3DXVECTOR3( 1.0f, 0.0f, 0.0f ) + camPosition;
        upDir   = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
        break;
    case D3DCUBEMAP_FACE_NEGATIVE_X:
        lookDir = D3DXVECTOR3(-1.0f, 0.0f, 0.0f ) + camPosition;
        upDir   = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
        break;
    case D3DCUBEMAP_FACE_POSITIVE_Y:
        lookDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) + camPosition;
        upDir   = D3DXVECTOR3( 0.0f, 0.0f,-1.0f );
        break;
    case D3DCUBEMAP_FACE_NEGATIVE_Y:
        lookDir = D3DXVECTOR3( 0.0f,-1.0f, 0.0f ) + camPosition;
        upDir   = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
        break;
    case D3DCUBEMAP_FACE_POSITIVE_Z:
        lookDir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f ) + camPosition;
        upDir   = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
        break;
    case D3DCUBEMAP_FACE_NEGATIVE_Z:
        lookDir = D3DXVECTOR3( 0.0f, 0.0f,-1.0f ) + camPosition;
        upDir   = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
        break;
    }

    D3DXMATRIX cubeFaceView;
    D3DXMatrixLookAtLH( &cubeFaceView, &camPosition, &lookDir, &upDir );
    return cubeFaceView;
}

Or use some other method to render your environment like "dual paraboloid" but then that is not cube texture.

This topic is closed to new replies.

Advertisement