Jump to content

  • Log In with Google      Sign In   
  • Create Account


[FFP] Lighting for terrain so dull (dark)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 greenpig83   Members   -  Reputation: 323

Like
0Likes
Like

Posted 22 May 2013 - 08:53 PM

Hi,

    I'm working with an tile based terrain. The terrain is display in an isometric view. I try to limit myself to FFP because I want to target low system computers. The problem is that I tried so many light direction, the world light is so dull. The maximum bright (the surface face the light ? ) is the current texture color. Every other surface look darker. I think the surface that direct the light should get brighter than it's normal texture color! How can I achieve it with old FFP ?
I want to achieve the flat terrain surface should get lit 100% (normal texture color). the slope face the light should get brighter, the other slopes should get darker!

sc3_zps386ada13.png

(same normal for 1 Triangle)

 

sc4_zps228f11e0.png

(Each vertex have its own Normal -  the edge look smooth, but the lighting even darker!)

 

Original Texture : 

15030_zps7e49cc20.png


Edited by greenpig83, 22 May 2013 - 09:01 PM.


Sponsor:

#2 Steve_Segreto   Crossbones+   -  Reputation: 1468

Like
1Likes
Like

Posted 23 May 2013 - 12:25 AM

Nice screenshots!

 

Have you tried adding an ambient factor to each pixel's color?

 

Another thing to try is SRGB correct rendering (gamma correct). http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/



#3 Tom KQT   Members   -  Reputation: 1502

Like
0Likes
Like

Posted 23 May 2013 - 01:08 AM

I haven't worked with the FFP for a while, so I did a quick test now and it seems that the FFP lighting will never (*) produce enough light for the surface to get brighter than its normal texture color at 100 % intensity. It's quite weird, but even if you combine full while (0xFFFFFFFF) ambient color with as many directional lights shining at the surface from the same direction as you want, you will never get anything brighter than the original texture color. Also emissive color of the material doesn't help.

Maybe there are some combinations in SetTextureStageState that would change it, but I honestly don't know.

 

If you don't manage to get the desired look by playing with ambient and diffuse colors, you will probably have to use shaders. I don't think that would be such a problem with low-end computers. Well, yea, you would increase your HW requirements to GCs supporting shaders.

 

 

(*) The only exception seems to be specular colors, those (of course) get added "on top" of the diffuse and ambient lighting. But I don't think specular would work in your case (ortho view, directional lights, flat terrain).


Edited by Tom KQT, 23 May 2013 - 01:08 AM.


#4 Steve_Segreto   Crossbones+   -  Reputation: 1468

Like
0Likes
Like

Posted 23 May 2013 - 01:13 AM

It's quite weird, but even if you combine full while (0xFFFFFFFF) ambient color with as many directional lights shining at the surface from the same direction as you want, you will never get anything brighter than the original texture color.

 

That's because the operation is a modulation, which is just a multiply. So multiply original color by 1 and you get the original color, anything less and you get a darker color. if you use an additive operation instead, you can exceed the original color, but not exceed 1.0f.

 

If you want to go beyond that you can look at high dynamic range lighting and/or SRGB correction.



#5 C0lumbo   Crossbones+   -  Reputation: 2115

Like
1Likes
Like

Posted 23 May 2013 - 01:15 AM

Your problem is that you can never achieve an output colour brighter than the original texture with your current setup.

 

The solution is colour doubling/quadrupling. Look into using D3DTOP_MODULATE2X and D3DTOP_MODULATE4X and halfing/quartering the light brightness to compensate.



#6 greenpig83   Members   -  Reputation: 323

Like
0Likes
Like

Posted 23 May 2013 - 01:19 AM

Yeah I tried to mess with the Lighting setting, Material setting... ambient,emission,specular... It does make it lighter, but never supass the texture real color.
It seem the only solution is to use Multi Texture, using ColorOp = Modulate2x or 4x. It does make thing brighter, how ever it require a lightMap.

This guy seem to solve my problem in his way. Not perfect but I think acceptable : http://age.hys.cz/viewtopic.php?f=5&t=2

15_2D_elevation_small.png

 

In his post, it seems he does use a lightMap, then modulate the slope surface with it : 

elevation_matrix.png

I tries to use his but it not very easy. Cause I'm not sure this is his real lightMap or just a demo, the gray value is not the same in all edge. because we only apply the lightMap to the sloped surface, flat surface surround it is intact. so that the Border must have the same gray value! Although this look quite right, the black region mean the surface need darkening, the white region mean it should be brighter. The gray mean we keep it as normal texture color! Still very headache.

 

The reason I want to use FFP, because this is just a 2D project using DirectX3D. Also I does use vertex,lighting, multiTexture. Still wonder if 5 year old laptop with integrated card support multi texture 3 stage :(


Edited by greenpig83, 23 May 2013 - 01:24 AM.


#7 C0lumbo   Crossbones+   -  Reputation: 2115

Like
2Likes
Like

Posted 23 May 2013 - 01:26 AM

Use D3DTOP_MODULATE2X/D3DTOP_MODULATE4X on the texture stage state that combines your dynamic lighting result with your texture result to get the overbrightening effect that you want.

 

The feature does not require your lighting to come from a texture (light map) like you state in your last post.
 



#8 Tom KQT   Members   -  Reputation: 1502

Like
0Likes
Like

Posted 23 May 2013 - 01:28 AM

It's quite weird, but even if you combine full while (0xFFFFFFFF) ambient color with as many directional lights shining at the surface from the same direction as you want, you will never get anything brighter than the original texture color.

 

That's because the operation is a modulation, which is just a multiply. So multiply original color by 1 and you get the original color, anything less and you get a darker color. if you use an additive operation instead, you can exceed the original color, but not exceed 1.0f.

 

If you want to go beyond that you can look at high dynamic range lighting and/or SRGB correction.

Modulation between diffuse color of the light and diffuse color of the material, similarly for ambient etc. Yes, that will never go above 1.

But then the lights are summed together (Ambient Light + Diffuse Light + Specular Light + Emissive Light) and there really must be addition, because with modulation you would get complete black look for any material without emissive color, which is not how it really works. And also - what about multiple lights? Their results also cannot be modulated, they must be added together.

It just seems that FFP is adding the lights together, while never going above 1 (clipping the result to 1). So if one light was enough to get to 1, then all other light sources have no effect.


Edited by Tom KQT, 23 May 2013 - 01:29 AM.


#9 kauna   Crossbones+   -  Reputation: 2156

Like
1Likes
Like

Posted 23 May 2013 - 06:29 AM

Just a little reality check when you say that you want to limit yourself to FFP because you want to target "low-end" machines. 

 

Direct3D 9.0 was released year 2002 ... that's over 10 years now. It supports shader model 3.0 already.

Direct3D 8.1 was released year 2001 and it supports some shader level already and it doesn't work on anything older than Windows XP.

 

http://store.steampowered.com/hwsurvey/

 

Above is the Steam hardware survey. People using hardware with DX8 level GPU (some or none shader support) and below presents 0.41% of the Steam gamers. On the other hand 98.54% of the people using Steam have access to SM3.0 level hardware. 

 

Cheers!



#10 apatriarca   Crossbones+   -  Reputation: 1601

Like
0Likes
Like

Posted 23 May 2013 - 09:02 AM

To add to what kauna said, this is the Unity web player statistics (which is thus probably targeted to more causal gamers than Stem). Less than 3% of players use GPUs without shader support.



#11 VladR   Members   -  Reputation: 722

Like
2Likes
Like

Posted 23 May 2013 - 09:49 AM

You seem to want to get a high-contrast lighting. It is entirely possible to achieve using just FFP.

 

This is one of the best attempts of mine from the old days of DX 8 to achieve this goal:

I had:

- Shadows (prebaked in lightmap)

- Regular Diffuse + Ambient light

- High-intensity highlights for triangles under certain angle

- Material map blended with procedurally generated texture map

ScreenShotJune003.jpg

 

ScreenShotJune004.jpg

 

Obviously, I don't remember the exact combination of the TSS after all these years, but I remember very clearly that I had to use MULTIPLY_2X AND MULTIPLY_4X to achieve this, in combination with one of those states that let you specify if you want to saturate the result or clamp it.

 

Of course, if you already have a lot of (1.0f,1.0f,1.0f) colors in your base texture map, that is not going to get you anywhere, since no matter how you mulitply the 1.0f, you will still get 1.0f at most.
 

 

Thus, the trick is to make the majority of the scene darker, so that only certain parts get brighter - in my case, I wanted to achieve the dynamic light with the time-of-day feature, thus the terrain was dynamically lighted throughout whole day with varied direction of the light.

 

It is a lot of tweaking, though. You need to be able to dynamically, at run-time, change the intensity of Directional and Ambient RGB, either through key shortcuts or some UI.

 

It does take few hrs to come with the final look, but it is totally worth it.

 

 

To summarize, you need:

- A profile system where you keep good combinations in a code so that you don't have to spend half an hour to figure the best combination you had working 5 minutes ago. Copy/paste the combination into a separate codepath as soon as it looks good enough ( so that later you can choose between the best ones).

- Screenshot system, where you grab screens and compare different combinations of all parameters (texture, diff, ambient, TSS ColorOp)

- Base terrain texture in at least 6 different levels of Brightness / Contrast : Texture_10, Texture_30, Texture_50, Texture_65, Texture_80, Texture_100 (that you can switch between at runtime upon a keypress). I can change the texture by pressing 'T' at runtime and can see right away which brightness is best this way right away

- TSS ColorOp change upon a keypress (from ALL possible ones - see DX Docs)

 

When you have the system above, then all it takes is just few keypresses and you can come up with some pretty nice combinations.

 


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#12 greenpig83   Members   -  Reputation: 323

Like
0Likes
Like

Posted 25 May 2013 - 08:56 AM

Yeah, I think I found the way for my problem. Generate a prebake LightMap (need a tesselation and generate light intensity at each point in the surface), because there are no changing in light direction, so the lightmap is used for all the game render time. Use modulate2x for the LightMap make it look brighter as expected.

 

About the Shader limit issue. I havent made a wide investigation, but I remember some game require: Pixel Shader 2.0 .  And it seems a lot of Computer/Laptop with integrated cards fail to start it. Example "League of Legend" (There are more like this, I saw some ). Though I'm not a master (more like a newbie) with Shader, so I'm not quite sure a normal lighting like my game may need what kind of Pixel shader :  1.0 ? what about Vertex Shader. In a ps file, there always, go throught VS then PS. Of couse if shader work for my case, I will try it because it seem alot more simple than prepare a prebake light. because there need to be quite a lot of it (slopes above have different light than one at base level). 



#13 C0lumbo   Crossbones+   -  Reputation: 2115

Like
0Likes
Like

Posted 25 May 2013 - 09:54 AM

Yeah, I think I found the way for my problem. Generate a prebake LightMap (need a tesselation and generate light intensity at each point in the surface), because there are no changing in light direction, so the lightmap is used for all the game render time. Use modulate2x for the LightMap make it look brighter as expected.

 

If you actually want to use a lightmap, then that's obviously fine, but there is absolutely no need to switch from using dynamic vertex lighting to light maps just in order to enable the modulate2x brightening effect. You can enable the modulate2x (or 4x) on the texture stage state which combines the lighting output with the diffuse texture.

 

Sorry to keep repeating myself in this thread, but for some reason you've concluded that modulate2x only works when combining textures, but that's wrong. You can achieve the effect you want with your existing dynamic lighting. Of course, there's plenty of good reasons for using light maps, but it sounds like you're making the choice for the wrong reasons in this particular situation.



#14 apatriarca   Crossbones+   -  Reputation: 1601

Like
0Likes
Like

Posted 26 May 2013 - 07:34 AM

About the Shader limit issue. I havent made a wide investigation, but I remember some game require: Pixel Shader 2.0 .  And it seems a lot of Computer/Laptop with integrated cards fail to start it. Example "League of Legend" (There are more like this, I saw some ). Though I'm not a master (more like a newbie) with Shader, so I'm not quite sure a normal lighting like my game may need what kind of Pixel shader :  1.0 ? what about Vertex Shader. In a ps file, there always, go throught VS then PS. Of couse if shader work for my case, I will try it because it seem alot more simple than prepare a prebake light. because there need to be quite a lot of it (slopes above have different light than one at base level). 

 

There always be someone which will not be able to play your game. Integrated cards used to suck, but they all support shaders now. My two years old netbook has support for the DirectX 11 API for example. OpenGL ES 2 is now the standard API used in the mobile world and supports shaders. WebGL have similar requirements. Unity* and other engines do not support the fixed pipeline anymore. If you really want to play something new, you should now probably buy a computer with shader support. Learning to write shaders is also a lot more useful than learning to work with the fixed pipeline.

 

* The current version still support it actually, but they recently decided to drop it in the next version.



#15 VladR   Members   -  Reputation: 722

Like
1Likes
Like

Posted 29 May 2013 - 11:53 AM

It used to be - about 7-10 yrs ago - that you could say that if your computer cannot run the game, you are probably not a target market.

 

These days, when even cheapest of laptops ship with SM 2.0 cards, the only PCs you can find that can't run SM 2.0 are the ones that are kept as second/third computer at home - which means that in that household is still at least 1 computer able to run it.

 

 

I do, however, understand, your unwillingness to learn the shaders. They are not really that straightforward and debugging them is, by default, PITA - especially compared to FFP.

 

Long-term, you can't avoid shaders, really.


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS