Optimizing Fire Effect

Started by
10 comments, last by Phillip Schuster 24 years, 5 months ago
Hi all !!

I am currently developing my own 3DEngine and I use procedural textures. One of these textures uses that simple fire-effect. I think all of you know that. The texture is 8Bit (so Palettized). My question is:

How can optimize the routine below ??? It's more a less a Blur-Filter. Is it worth to do it in assembler or can you think of other optimisations ??

code:
void C8BitTexture::Fire(int blurval){	long x,y;	int color = 0;	for (y=1;y		for (x=1;x			color = 0;			color += (int)GetByte((y*width)+x);			color += (int)GetByte(((y-1)*width)+x);			color += (int)GetByte((y*width)+x+1);			color += (int)GetByte(((y+1)*width)+x);			color += (int)GetByte((y*width)+x-1);			//If we divide by 5 and do not set color to 0 it gives a very 			//interesting effect			color = color / blurval;						if (color > palette.numColors) color = palette.numColors;						SetPixel(x,y-1,color);		}	}}

Phillip

[This message has been edited by Phillip Schuster (edited November 08, 1999).]

[This message has been edited by Phillip Schuster (edited November 08, 1999).]

[This message has been edited by Phillip Schuster (edited November 08, 1999).]

Phillip Schuster
Advertisement
When I say C++ is hard to optimize, I don't mean from a progammers perspective, I mean from the compilers perspective.

As a programmer, you know a lot about the code you write (for example the possible domain of variables, certain special cases that never occur etc.), because of all the sh*t you can do in C++ (e.g. pointer arithmetics) the compiler can't make ANY assumptions as to what the programmer inteded with a piece of code, but have to go by the book - producing code with a large, frequently unnecesarry, overhead.

In most cases this is completely irrelevant, but for tight loops where each statement is executed millions of times each frame, every cycle counts.

Java beeing a much more strict language is a lot easier to auto-optimize.

/Niels

<b>/NJ</b>

This topic is closed to new replies.

Advertisement