Draw shadow on terrain
Draw shadow on terrain
Hi
Im doing an aircraft game and what some simple shadow on the terrain (to easier see distance when flying close to the ground). I know there are built in shadows, but i use a custom shader for the terrain which i havent done myself so built-in shadows doesnt work right?
Im fine with a dark filled circle as shadow, i dont need real shadows that turn/roll with the actual plane (if its easier to do).
Any ideas?
Thanks
Erik
Im doing an aircraft game and what some simple shadow on the terrain (to easier see distance when flying close to the ground). I know there are built in shadows, but i use a custom shader for the terrain which i havent done myself so built-in shadows doesnt work right?
Im fine with a dark filled circle as shadow, i dont need real shadows that turn/roll with the actual plane (if its easier to do).
Any ideas?
Thanks
Erik
Re: Draw shadow on terrain
Afaik Irrlicht's shadows are independent from the shader. Have you tried it?
Re: Draw shadow on terrain
Fake shadows can be done very easily in software: create a sphere, give it a transparent black texture, then scale and move it as needed.
Re: Draw shadow on terrain
I will make my own shadows since i need to control position and size myself.
I started experimenting but im a little lost. Is this a good start? It is transparent but brightens everything (obviously) Do i need to create a material or can i just set it to "black"? Preferably it should not be totally opaque (the circular shadow (black color) on the terrain i mean)
I started experimenting but im a little lost. Is this a good start? It is transparent but brightens everything (obviously) Do i need to create a material or can i just set it to "black"? Preferably it should not be totally opaque (the circular shadow (black color) on the terrain i mean)
Code: Select all
scene::ISceneNode * sphere = gfx.smgr->addSphereSceneNode(50,20,0,-1,vect3d(1000,200,1000));
sphere->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
Re: Draw shadow on terrain
Don't use TRANSPARENT_ADD_COLOR. Maybe TRANSPARENT_VERTEX_ALPHA will work if you don't use a material, but remember to use alpha with the vertex colours (black).
Re: Draw shadow on terrain
Like so? This does not work, its just a solid black. But what do you mean with "use alpha with the vertex colours"? The image file does have an alpha channel.
But even if the texture/material would work, wouldnt the sphere be visible when looking from the side? Halv of the sphere will be sticking out of the ground like a hill... (right now thats how it looks)
Code: Select all
scene::ISceneNode * sphere = gfx.smgr->addSphereSceneNode(50,20,0,-1,vect3d(1000,200,1000));
sphere->setMaterialTexture(0, gfx.driver->getTexture("gfx/particles/cloud2.png"));
sphere->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
Re: Draw shadow on terrain
You said "Do i need to create a material or can i just set it to "black"?" so I assumed you were not using a material.
Anyway, does your image file have an alpha channel? If it does, you can use TRANSPARENT_ALPHA_CHANNEL.
Anyway, does your image file have an alpha channel? If it does, you can use TRANSPARENT_ALPHA_CHANNEL.
Re: Draw shadow on terrain
Yes this makes it transparent (if i reduce opacity in photoshop) but concerning my other question: it is still "a hill" sticking up from the terrain (half the sphere). How do i use this as a shadow? Only useful when looking at it from an exact topdown angle... Did i misunderstand something?
Re: Draw shadow on terrain
No, that's it. But I thought you were in an aircraft? It now appears you are on the ground looking at the shadow of an aircraft?
Re: Draw shadow on terrain
Well its an aircraft game yes, but its not a topdown 2D view so i cannot draw spheres and expect them to look like circles all the time. There is a chase-camera (third-person cam) like freelancer or darkstar one or similar games.
But i learned how TRANSPARENT_ALPHA_CHANNEL worked:)
So back to real shadows then:
Are there cheaper built-in shadows than the stencil buffer ones from tutorial 8? I use large open maps with lots of units. Maybe i can just enable shadows for some objects and gain myself to some performance? I might have several "suns" to light the scene properly, can i choose to only cast shadows from some light or is it automatically every light in the scene if i use shadows?
Thanks for all your help!
Erik
But i learned how TRANSPARENT_ALPHA_CHANNEL worked:)
So back to real shadows then:
Are there cheaper built-in shadows than the stencil buffer ones from tutorial 8? I use large open maps with lots of units. Maybe i can just enable shadows for some objects and gain myself to some performance? I might have several "suns" to light the scene properly, can i choose to only cast shadows from some light or is it automatically every light in the scene if i use shadows?
Thanks for all your help!
Erik