Parallax and dynamic lights (and shadows)

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Parallax and dynamic lights (and shadows)

Post by Mikenoworth »

So I acheived parallax mapping today, of course using basics, to implement it into my project is *sigh* much much more work. But there [edit] is an issue! [/edit]

Each pass I set the lights position to the camera's position. (not using the parent/child method):

[edit] Parallax mapped nodes (ISceneNodes, of course) do not get properly lit by the light. [/edit]

Screenies anyone? 8)

Image

And another angle..

Image

As you can see, I've got the light maxxed out with a big raidus, and it's a point light. [edit] My other educated guess about the parallax mapping is it doesn't take PROPER influence from the lights .. um .. light. [/edit]

Any help here would be super awesome terrific #1 go!!
Last edited by Mikenoworth on Wed Aug 09, 2006 6:13 pm, edited 1 time in total.
Stout Beer
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

any information about your system, driver, and the scene (model format etc.)?
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

My card is a Radeon 9600, the scene _was_ rendered in OpenGL. All the models are .x format, created in Belnder, and resaved by mview.exe.

I also do something like this for my scenes on rendering:

Code: Select all

cscene::preRender()
{
  scenemgr->beginScene(stuff);
}

cscene::postRender()
{
  scenemgr->endScene();
}

// then in a derivec class..

(cscene derived class)::Render()
{
  preRender();

  .. other code (like moving the light)

 postRender()

{
I just noticed I was using OpenGL. I switched it to Direct3D 9 and, it's lit better, no extreme-dark anywhere on the models, but it is still comparably darker, ie looks like screenshot 2 but from all angles, the light is working, it's just not as bright as it should be. [edit] 8) [/edit]

One more tidbit, for some reason Irrlicht no longer prints any log info to the console (or the editors output window) after the constructor for my scene class has completed execution. Code for that is insignificant, but here she be anyway! (This is for the base class)

Code: Select all

#include "StdAfx.h"

#include ".\cscene.h"
#include ".\cnewton.h"
#include ".\caudio.h"
#include ".\cmaterials.h"
#include ".\cnodes.h"
#include ".\canimatedtextures.h"
#include ".\ccolormaterials.h"

// Constructor - attributes can be null. folder is the relative path to this
// scenes static code folder. ex. "scenes/test/"
CScene::CScene( irr::core::stringc name, irr::core::stringc folder, IrrlichtDevice *device, _scene_attributes *attributes ) 	
{		
	m_Name = name;	
	m_Device = device;	
	m_Video	= m_Device->getVideoDriver();
	m_SceneManager = m_Device->getSceneManager();
	m_GUI = m_Device->getGUIEnvironment();	
	m_Skin = m_GUI->getSkin();

	// Validate m_Device
	if( !m_Device )
	{		
		printf("IRRLICHT_DEVICE_INVALID\n");
		return;
	}
	
	// Set default values for all appropriate members.
	setDefaults();	

	// Set the 3d environment attributes
	if(attributes) 
		SetAttributes( attributes );
	else
		printf("Using default _scene_attributes\n");
	
	// ..
	m_Attributes.EventCallback = new CEventCallback();

	// Setup the event receiver, if possible.
	if(m_Attributes.EventCallback)		
		m_Device->setEventReceiver( m_Attributes.EventCallback );
	else
		printf("using no event callback. (no input will be checked)\n");

	// Set fog parameters for the scene
	m_Video->setFog(	m_Attributes.FogColor, 
						m_Attributes.USE_LINEAR_FOG, 
						m_Attributes.FOG_START, 
						m_Attributes.FOG_END, 
						m_Attributes.FOG_DENSITY, 
						m_Attributes.USE_PIXEL_FOG, 
						m_Attributes.USE_RANGE_FOG
					);

	// Set the ambient light color for the scene
	m_Video->setAmbientLight( m_Attributes.AmbientLightColor );

	// Create Font object
	m_Font = new CGFont( m_GUI );	
Where m_Font = new CGFont( m_GUI ); is where the last log is displayed, telling me the font (Irrlicht font, not my own) was created. After that no more info is ever given from Irrlicht.

Here's the rest of the constructor..

Code: Select all

	m_Camera = m_SceneManager->addCameraSceneNode(0);

	// The newton object does not need to load anything, depends on no other
	// object and is used by m_Materials & m_Nodes we should init it first.
	m_Newton = new CNewton( m_Device );
	
	// Color materials also has no dependancies other than Irrlicht.
	m_ColorMaterials = new CColorMaterials( m_Video, folder + "colormaterials.sc" );

	// Everything else loads a static code file to create themselves.
	// m_Nodes must be created lastly becuase it uses the other objects
	// to construct itself, therefore they must be valid or the game
	// will crash.
	m_Audio = new CAudio();	
	m_Audio->Load( folder + "audio.sc" );		
	m_Materials = new CMaterials( m_Newton, m_Audio, folder + "materials.sc" );		
	m_AnimatedTextures = new CAnimatedTextures( m_Device, folder + "textures.sc" );
	m_Nodes = new CNodes( this, folder + m_Name + ".sc" );
}
There is another problem that may be related to some of this, but I doubt it, the fps camera input does not work either, yes input receiver was enabled for it, (fpscam->enableinput something or other(true) ).

That initially stopped working when I implemented my cscene class, and at the same time as Irrlicht began to stop logging info.
Last edited by Mikenoworth on Wed Aug 09, 2006 6:15 pm, edited 1 time in total.
Stout Beer
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The shadows are still lost in translation.
Maybe I should assume that you already know this...

If you are moving the light to be at the same position as the camera for every render, you'll never see any shadows. Shadow is what you see when light is blocked by something. From the position of the light, you would only see the blocking object and the receiving object. That blocking object would obscure the area that is in shadow. In the places that you would expect to see shadow you would just see the part of the object that is blocking the light.

This is the basis for most shadow mapping techniques.
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

:oops: D'oh!!

:lol: :lol: :lol: :lol:

Oh man :lol: I threw common sense out the window so bad on that one. :lol: :lol:

8) Okay.. Time to ninja-edit my post. :twisted:
Stout Beer
kburkhart84
Posts: 277
Joined: Thu Dec 15, 2005 6:11 pm

Post by kburkhart84 »

I saw in your post that the input for the FPS camera stopped working. You may have the problem I had, which is easily fixed. If you are using DirectInput, you need to make sure that the flags for your device are non-exclusive instead of exclusive. I don't remember which function it is in, but you have to put either exclusive or non-exclusive as one of the flags. With exclusive mode, only DInput has access to the input device, which means Irrlicht won't, which is a reason why the FPS camera wouldn't work.

Also, I am (hopefully temporarily) on a RADEON 9200, and my OpenGL support doesn't have support for GLSL, so Irrlicht can't do the per-pixel lighting in OpenGL, but for DX9 it can. Your card isn't too far ahead of mine and it may be the same type of issue. I'm not sure what changed between 9200 and 9600 and that may be it as well.
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

I use Irrlicht directly for input.
Stout Beer
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

eh... btw... i have a GeForce FX5200... an I try to use Parallax mapping in OpenGL, but it shows up almost exactly as bump mapping...actually , only the mapping coordinates change a little.... does the fx5200 not have parallax mapping support for ogl?

by the way, where can I find Microsoft Visual C++ Toolkit 2003?

It seems that it has been replaced by VC++ Express on the microsoft site... and I need the compiler for the code::blocks IDE. I don't like using GCC compiler in Irrlicht because it hasn't any support for Direct3D 8/9...

A link anyone?
TheC
Posts: 93
Joined: Fri May 05, 2006 7:50 am

Post by TheC »

I was never able to find it after they removed it, no mirrors or anything.

I just lived with VC++
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

hellbound, you can use the compiler that comes with vc++ express in code::blocks. Make sure you use a current nightly build and not C::B 1.0RC2.
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

i know that i can use the compiler that comes with vc express 2005, but it's really buggy...
that's why i need msvc tk 03... it's impossible to find...
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

Buggy? Why is it buggy?
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

it sometimes fails to compile even the most precise snippet of code... it's a bug...
Post Reply