Skip to main content
gamedev.net
🔒 Locked

lightmaps anyone?

Started by bartiss 1 reply 450+ views
Original Post
bartiss
bartiss
Hi, I'm trying to implement a lightmap rendering. Unit now my lighting was baked into a texture (not very reasonable, is it ;-) ). What I need is a render of a triangle list using one diffuse color texture and other color lightmap texture (with alpha) in a single pass. I know it might work using double rendering with different textures and alphablending, but I'm sure there's a much better solution. Can anybody tell me what are the right RenderStates and TextureStages settings to achieve it? Thanks in advance Bartiss
CodeImp
CodeImp
Here is some states you might want to try. This uses a normal color texture on the first stage and the lightmap texture on the second stage. Modulates the vertex colors with the standard texture colors, then modulates it with the lightmap. Uses the alpha channel of the standard color texture. Assuming d3dd is a valid Direct3D Device.

// Alpha blendingd3dr.AlphaBlendEnable = true;d3dr.SourceBlend = Blend.SourceAlpha;d3dr.DestinationBlend = Blend.InvSourceAlpha;d3dr.BlendOperation = BlendOperation.Add;// First color stage// Here we modulate the vertex colors with the standard textured3dd.TextureState[0].ColorOperation = TextureOperation.Modulate;d3dd.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;d3dd.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;d3dd.TextureState[0].ResultArgument = TextureArgument.Current;// Second color stage// Here we modulate the result of previous stage with the lightmap textured3dd.TextureState[1].ColorOperation = TextureOperation.Modulate;d3dd.TextureState[1].ColorArgument1 = TextureArgument.TextureColor;d3dd.TextureState[1].ColorArgument2 = TextureArgument.Current;d3dd.TextureState[1].ResultArgument = TextureArgument.Current;// No more further stagesd3dd.TextureState[2].ColorOperation = TextureOperation.Disable;// First alpha stage// Take the alpha channel from the standard texture as resultd3dd.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;d3dd.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;// No further stagesd3dd.TextureState[1].AlphaOperation = TextureOperation.Disable;
Kind regards,
Pascal van der Heiden

CodeImp - My trademark and website
bartiss
bartiss
Thanks and sorry for posting this at all :) There are lots of tutorials on the net considering this (quite common I must admit) issue.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.