Super Mario Galaxy-esqe rim lighting with blitz3d!

Community Forums/Graphic Chat/Super Mario Galaxy-esqe rim lighting with blitz3d!

Cubed Inc.(Posted 2011) [#1]
sup guys
I've been trying recently to create rim lighting with blitz3d thats decently similair to the rim lighting in the mario galaxy games.
I somewhat pulled off a convincing effect using only 2 parented directional lights (originally 4) for the rimming,one for the center lighting and playing around with the ambient light. I call it "fake velvet wrapping" (named after the velvet shader which was used in the smg games)

http://imageshack.us/photo/my-images/546/blitzcc2011092720564532.png/
-without FVW

http://imageshack.us/photo/my-images/9/blitzcc2011092720565114.png/
-with FVW

It's got alot of problems though.
The rim light is pretty dim and not was noticable as I was hoping for it to be and the lighting looks quite ugly on actual maps and levels.

For a brighter more defined rim outline it is possible to add two more parental lights on top of the original rim lights, but since blitz3d can only support 8 rendered lights at once, it's seems like kind of a waste of the precious effect.

I just wanted to show that it is sort of possible to pull off with blitz3d. It's the best I can do at the moment.

Last edited 2011

Last edited 2011

Last edited 2011

Last edited 2011

Last edited 2011

Last edited 2011


Gabriel(Posted 2011) [#2]
Before I start, I'll admit that I don't know much about rim lighting from a technical standpoint so there might be more going on than I see,

That said, could you not fake rim lighting by applying a sphere map (basically a black texture with a blurry white circle (hollow) almost as big as the texture) and set that to additive blending?


Cubed Inc.(Posted 2011) [#3]
Actually you can, but using real lights to fake it would save alot of time. Also, the mario model used has several textures split up from several images, so I wasnt able to do your idea properly. You would also have to apply the spheremap to EVERY object, so it would prove somewhat less conventient. I might try out your idea though.


Gabriel(Posted 2011) [#4]
Yep, these are valid points. I was thinking mostly in terms of it being a cheaper effect than using the lights, and perhaps being a stronger effect than you've managed to achieve so far. It would need to be on all materials of all meshes, and you'd have to create the spheremap, so I can certainly see that your technique has advantages.


RifRaf(Posted 2011) [#5]
Rim lighting can be done well if you have fast extension lib for Blitz3D, using a rim light cube map and aligning it to a light source(doesnt have to be a light, any entity to give angle of application)

you can then apply that to any object you wish to have rim lighting. This wont suffer any weird angle artifacts like the sphere map approach.

its not hard to apply a texture to all materials just make your own application routine and have it do all the work, it can pass through the entity and its children performing and checks or special case stuff you want it to do. After its applied once thats it.. no real time lighting to take up gpu time or waste any of your 7 dx lights.

When you use the Function call of the FastExt lib to align the cubemap to an orientation its updated on every entity that has it applied you dont have to reapply or anything like that. I once used it on all my Mesh particles without any speed hit whatsoever and were talking 1500 particles seen at once all with rimlighting.

ApplyRimlight(entity,rimtexture,texturechannel=6)

This application style is exactly what I do for all my special fx textures that can be applied in game.


I don't use rimlighting in Tiny Tanks anymore but I haven't updated my tutorial video yet so you will can see it there on the TT website still.

edit : fastext also lets you use blend modes such as addsigned, and addsmooth which help with this effect too

Last edited 2011


Matty(Posted 2011) [#6]
I just see a Mario character...what should the rim lighting look like? Or is it a good thing that I don't notice the effect?


Kryzon(Posted 2011) [#7]
I agree it is a bit dim. Is there any way to increase the contrast?
Have you also played with negatively-colored lights (i.e: -50,-50,-50 to give some nice darkening effects)?

what should the rim lighting look like?

It is a coloring factor based on the Dot product of the eye-vector with a pixel's normal vector (this when properly done in shader code, that is).

Shader Designer screenshot (anything orange is rim-color):



Matty(Posted 2011) [#8]
Thanks Kryzon - I can see how it should work now, basically the orange areas are where the pixel's normal vector is roughly approaching perpendicular to the eye vector...

Edit - a bit like this:

Graphics3D 512,512,0,2
camera=CreateCamera()
mesh=LoadMesh("teapot.x")
EntityFX mesh,1+2

MoveEntity camera,0,0,-3

For s=1 To CountSurfaces(mesh)
	surf=GetSurface(mesh,s)
	For v=0 To CountVertices(surf)-1
		VertexColor surf,v,0,0,0
	Next 
Next


Repeat
TurnEntity mesh,.1,.2,.3

For s=1 To CountSurfaces(mesh)
	surf=GetSurface(mesh,s)
	For v=0 To CountVertices(surf)-1
		TFormNormal VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),mesh,camera
		VertexColor surf,v,127.0 + 127.0 * TFormedZ(),127.0 + 127.0 * TFormedZ(),127.0 + 127.0 * TFormedZ()
	Next 
Next


RenderWorld
Flip

Until KeyDown(1)
End


Last edited 2011

Last edited 2011


Kryzon(Posted 2011) [#9]
Precisely! :)

EDIT: I just noticed how you're using the TFormedZ() part of the vector. It's representing '-1' when the normal points towards the camera, and '+1' when the normal points away from it.

Last edited 2011


Matty(Posted 2011) [#10]
Yes, but something to remember is that when its pointing away from the camera usually that vertex won't be visible.