• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Vlion

Fussy Fog. :-(

6 posts in this topic

I am not getting the fog to work. Whats happening is all my objects are colored the color of the intended fog. The fog is not showing. :-| This code is taken from a simplistic solar system model, btw.
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#pragma comment( linker, "/entry:\"mainCRTStartup\"" )  // set the entry point to be main()


#define SCRNX 600
#define SCRNY 600

bool fscrn;
float eyex, eyey, eyez;
float px, py, pz;
float tx,ty,tz;
float ex,ey;
float time;


//Slow, unoptimized...oh well.
void DrawEllipse()
{
	glColor3ub(255,255,255);
	float x,y,z,t;
	for(t = 0.0; t <= 360; t += 1)
	{
		x = 5*sin(t);
		y = 4*cos(t);
		z = 0;
		glBegin(GL_POINTS);
		{
			glVertex3f(x,y,z);
		}
		glEnd();
	}
}
void DrawSphere(float x,float y, float z, float r)
{
	glPushMatrix();
	{
		glTranslatef(x,y,z);
		glutSolidSphere(r,16,16);
	}
	glPopMatrix();
}
//Location in space of the orbit point, and radius of orbit.
void DrawMoon(float x, float y, float z, float r)
{
	
	glPushMatrix();
	{
		
		glTranslatef(x,y,z);	//Translate to the Earth posiiton
		
		x = r*sin(time*10);		//Rotate co-ords			
		y = r*cos(time*10);
		z = sin(time);

		glTranslatef(x,y,z);	//Translate to the rotate position

		glutSolidSphere(.5,16,16);

	}		
	glPopMatrix();
}


void Render()
{
	float pos[] = {0,0,0,1};
	float color[] = {1,1,0,1};
	float amb[] = {1,1,1,1};
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	glPushMatrix();
	{
		glTranslatef(tx,ty,tz);
		gluLookAt(eyex,eyey,eyez,px,py,pz,0,1,0);
		glPushMatrix();
		{
			glDisable(GL_LIGHTING);
			glColor4ub(255,255,0,255);
			DrawSphere(0,0,0,1);

			glEnable(GL_LIGHTING);

			glLightfv(GL_LIGHT0, GL_AMBIENT, amb);	
			
			glLightfv(GL_LIGHT0, GL_DIFFUSE, color);
			glLightfv(GL_LIGHT0, GL_POSITION, pos);
			
			glColor3f(0,1,0);

			DrawSphere(ex,ey,0,1);
			DrawMoon(ex,ey,0,2);
			
			
		}
		glPopMatrix();
		
		
		//The axes
		glPushMatrix();
		{
			glBegin(GL_LINES);
			{
				
				//X axis
				glColor3ub(255,0,0);		
				glVertex3f(100,0,0);
				glVertex3f(-100,0,0);
				
				//Y axis
				glColor3ub(0,255,0);
				glVertex3f(0,100,0);
				glVertex3f(0,-100,0);
				
				//Z axis
				glColor3ub(0,0,255);
				glVertex3f(0,0,100);
				glVertex3f(0,0,-100);
				
				DrawEllipse();
				
			}
			glEnd();
			
			
		}
		glPopMatrix();
		
	}
	glPopMatrix();
	
	glFlush();
	glutSwapBuffers();
	
}

int Init(int argc,char **argv)
{
	eyex = eyey = 0;
	eyez = 10;
	
	px = py = pz = 0;
	
	tx = ty = tz = 0;
	ex = ey = time = 0;
	float fogcolor[] = {1,1,0,1};
	
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowSize(SCRNX,SCRNX);
	glutInitWindowPosition(0,0);
	glutInit(&argc,argv);
	
	glutCreateWindow("Star model");
	
	glClearColor(0,0,0,0);
	glViewport(0,0,SCRNX,SCRNX);
	glMatrixMode(GL_PROJECTION);
	
	glLoadIdentity();
	gluPerspective(60.0f, SCRNX/SCRNX, 1.0, 1000.0f);
	glShadeModel(GL_SMOOTH);
	
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
	
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	
	glFrontFace(GL_CW);
	glCullFace(GL_FRONT);

GLuint	fogMode[]= { GL_EXP, GL_EXP2, GL_LINEAR };	// Storage For Three Types Of Fog
GLuint	fogfilter = 0;								// Which Fog Mode To Use 
GLfloat	fogColor[4] = {0.5f,0.5f,0.5f,1.0f};		// Fog Color

	glFogi(GL_FOG_MODE, fogMode[fogfilter]);			// Fog Mode
	glFogfv(GL_FOG_COLOR, fogColor);					// Set Fog Color
	glFogf(GL_FOG_DENSITY, 0.35f);						// How Dense Will The Fog Be
	glHint(GL_FOG_HINT, GL_DONT_CARE);					// Fog Hint Value
	glFogf(GL_FOG_START, 1.0f);							// Fog Start Depth
	glFogf(GL_FOG_END, 5.0f);							// Fog End Depth
	glEnable(GL_FOG);
	

	return 0;
}
void Main()
{
	ex = 5*sin(time);
	ey = 4*cos(time);
	time += 0.01;
	
	Render();
};

void Mouse(int,int,int,int);
void Special(int,int,int);
void Key(unsigned char,int,int);

int main(int argc,char **argv)
{
	Init(argc,argv);
	glutDisplayFunc(Render);
	
	glutIdleFunc(Main);
	
	glutMouseFunc(Mouse);
	glutKeyboardFunc(Key);
	glutSpecialFunc(Special);
	
	
	glutMainLoop();
	return 0;
}

 
I came, I saw, I got programmers block. ~V''''lion
0

Share this post


Link to post
Share on other sites
You are not seeing the fog, problably because you are clearing the screen with a color tha is diference of the fog color. So you have to do the clear colo like the fog color...

So...if you put your fog this...

GLfloat fogColor[4] = {0.5f,0.5f,0.5f,1.0f};

you have to do this...

glClearColor(0.5f,0.5f,0.5f,1.0f);

I hope that is waht you want
0

Share this post


Link to post
Share on other sites
I dont get it....
My models not emerging from fog...its just totally colored the color the fog color is.
v''lion

I came, I saw, I got programmers block.
~V''''lion
0

Share this post


Link to post
Share on other sites
The way that I understand OpenGL fogging to work is that the fog color is applied to pixels as they are rendered based on their distance from the viewer. You mention your objects as being completely fog colored. This is likely because they are pretty far from the camera. Does this fog color fade away as the camera nears the object? The reason the rest of space is not fogged is because that you aren''t rendering anything there, so there are no pixels to fog. I can''t think of an easy way to do fog in a space environment, unless you set the fog color to black. I hope that this has helped.


Feel free to email me.
0

Share this post


Link to post
Share on other sites
Try making the fog start further back - remeber GL is right-handed, so you could try setting the start to -3.0f and the end to sommat like -8.0f.

DeathWish
0

Share this post


Link to post
Share on other sites
Yeah. I figured out what was happening.
Its like Lord Karnus said- only the pixels on the objects are getting fogged- its up to me to deal wityh the other stuff.
Which is really interesting.
In Homeworld and HW:Cataclysm, they evidently have a fog that bypasses certain objects. Ships/and other ingame models are fogged t the background color, and the background shows perfectly. I`m pretty sure the background is a textures sphere.
Hm.
Anyways, thanx.
~V''lion
0

Share this post


Link to post
Share on other sites
Hey, i think the fog density is 1.0f as default. So make the fog depth function, and change it to a lower number.
0

Share this post


Link to post
Share on other sites