Grid lines and floor files

For developmental things relating to the graphics of the game.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

z-man wrote:
Jonathan wrote:Now we're talking about the dual texture floor:
- Why did you make the lines in one dimension brighter than in the other? (I know why it happens, but why did you do it?)
As n54 said, I did not make the textures myself. In the non-moviepack version, the gridlines have the same intensity ( I hope ).
I was talking about the non-moviepack textures. Final gridline color = gridline+background of other texture so because the background intensity is different the gridlines have different intensity.
- How about multitexturing the floor? (as an option) What are we going to do with the alpha channel?
You mean the multitexturing extension of opengl? Yep. That's the way I'd do it today. Back when the code was written, multitexturing would not have given additional speed in most situations and I was too lazy to lear and use it.
Multitexturing is easy, but often explained poorly. The GL spec and the redbook (note that you can download the texturing chapter) helped me finally understand it. Most online tutorials (not just for GL) are crap.
n54 wrote: The way it is it's two transparent layers on top of each other, something which makes getting exact colors/color tones a kind of nightmare
Why? The two textures are just blended additively, and the color of the second texture gets multiplied by its alpha value.
The first is also multiplied by its alpha, but the old framebuffer contents are multiplied by 1 - alpha.
I don't really know why its not using standard alpha blending,
The floor mirror would be messed up.
ˌɑrməˈɡɛˌtrɑn
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Indeed. All true. You're getting dangerously close to getting asked to take over the rendering code :)
User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

Yes some time in the future it might be nice if Jonathan and Philippe could team up on the rendering code. Philippeqc hasn't posted in a while but he was reading up on the opengl documentation (is there both a red book and a blue book?).

Me I'm just planning on getting to learn blender well at some point in the future (it won't be soon, nothing is ever "soon" for me lol). Which brings up a question: does opengl or sdl have (m)any standard filetypes for models/meshes? If they do maybe we should use one of them?

On the color problem with the alpha layering in dual textured floor, I'll share my experiences, and the solution I've finally found :D

The examples below are used with moviepack_floor_red/green/blue values of 0.5.

Current method one:
Make floor_a.png with the highest ten pixels white (FFFFFF) and the rest red (FF0000).
Make floor_b.png with the leftmost ten pixels white (FFFFFF) and the rest red (FF0000).
Result:
Grid line intersections = FFFFFF (intersection of the white parts of both floor_a and _b).
Grid lines assuming 50% opacity in the rendering of the layers and moviepack_floor rgb values of 0.5 = (FFFFFF/2)+(FF0000/2) = 777777+770000 = FF7777 i.e. a pale red.
Grid tiles = FF0000 (intersection of the red parts of both floor_a and _b).

Current method two:
Make floor_a.png as above.
Make floor_b.png with the leftmost ten pixels white and the rest 100% transparent.
Result:
Grid line intersections = FFFFFF.
Grid lines created from _a = FFFFFF as the 100% transparent part of _b doesn't affect them.
Grid lines created from _b = FF7777 as above because the red part of _a affects them.
Grid tiles = as above.

Note that this method will create lines with differing "brightness" and might be what you were thinking of Johnatan. Keep in mind the lines might also look like they have different brightness depending on the direction you're travelling: lines parallel to the direction will seem brighter than those crossing it for optical reasons (depending on speed) and this is entirely correct.

Current method three:
Make floor_a.png with the top ten pixels white and the rest 100% transparent.
Make floor_b.png with the leftmost ten pixels white and the rest 100% transparent.
Result:
Grid line intersections = FFFFFF.
Grid lines = 777777 because each layer is 50% opaque and the base value of the grid is pure black 000000.
Grid tiles = 000000 (base colour).

Note that if you try to use moviepack_floor_red/green/blue you will only change the values applied to the grid lines and not the base color in this situation.

If we change moviepack_floor_red/green/blue to 1 we will in method three above get a pure black floor with pure white lines (so this is indeed possible).

In method two above we get pure white lines with lighter red tiles than the texture red.

In method one above we get the same as with method two.

So one gets to choose if one wants pure gridlines or the correct (in relation to texture color) floor color, or neither :D you can't have both in a simple way.

The solution:
What possible workarounds are there? The solution if you go for both pure gridlines and correct floor color using method one or two above with moviepack_floor_red/green/blue of 1 is to try to preempt the problem with the floor color by making texture floor color darker than it should be. For both floor_a.png and floor_b.png add a 50% transparent layer with a pure black fill over the red parts only. This seems to work correctly for me I've tested it with wall textures which have the correct color and the modified floor textures gave the same color tone to the unshaded walls.
Attachments
The workaround floor textures get indentical colors to both the pure white part and the light brown of the unshaded wall.
The workaround floor textures get indentical colors to both the pure white part and the light brown of the unshaded wall.
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

n54 wrote:Yes some time in the future it might be nice if Jonathan and Philippe could team up on the rendering code. Philippeqc hasn't posted in a while but he was reading up on the opengl documentation (is there both a red book and a blue book?).
He posted here that he'll be busy with his studies plus a job, so I suppose he'll be out for a while.
does opengl or sdl have (m)any standard filetypes for models/meshes? If they do maybe we should use one of them?
OpenGL does not define any file format, and SDL itself does not know anything about 3d. Most 3d formats are quite trivial to load, especially text based ones like VRML. Trivial in comparison to texture files, I mean. So supporting any number of popular formats is just a question of energy and time.
Do you know what file formats milkshape 3d can export? It would be logical to choose one that is both supported by milkshape and blender. Based on the fact that those are the affordable modelers I know, I assume they are the most popular by the egocentric principle. :)
User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

I'm not familiar with Milkshape 3d so I don't know...

As for blender I'm a bit unsure which format/export would be the best to use. I kinda like the idea of keeping it open source, i.e. that the file format is an open source format but I have no idea which would be the leading/most supported os 3d mesh/texturing format for our use. I suspect .blend-files might be too heavy but I'm not that knowledgeable about it yet and afaik there's been some format/use changes to blender formats fairly recently (since my last attempt at climbing the learning curve that is lol).
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

I learn fast, but I don't yet have much experience with C++ and OpenGL.

FF/2=7F.8 (hex)
255/2=127.5 (decimal)
ˌɑrməˈɡɛˌtrɑn
User avatar
n54
MVP
Posts: 1587
Joined: Sun Dec 21, 2003 12:40 pm

Post by n54 »

Jonathan wrote:I learn fast, but I don't yet have much experience with C++ and OpenGL.

FF/2=7F.8 (hex)
255/2=127.5 (decimal)
Ooops thank you, I wasn't thinking in "pairs" :oops: of course it would be 7F7F7Fh (I added the h on there because I wonder if this is international hex notation or just norwegian? At uni they used to add a small h, o, d or b depending). Remember to count the zero as first value (so it's 7F and 127, both are half of 256 values in total including 0 and up to and including 255) ;)

I'm going to test out dual texturing of no-grid floor textures later today (1024x1024 "fake bumpmap" concrete) and see if there's any quality difference between singel and dual with those.

Edit:
Dual texturing of no-grid floor textures did not work according to plan of course since floor_a/b.png get stretched. Silly me :) It's not a problem or anything like that, I was just curious.
Post Reply