Fetze Mini JLI'ler
Anmeldedatum: 23.11.2008 Beiträge: 16
Medaillen: Keine
|
Verfasst am: 08.02.2009, 22:30 Titel: System.EntryPointNotFoundException.. nur im Releasemode > |
|
|
Heyho.
Langsam komme ich mir ein wenig blöd dabei vor, aber ich habe mal wieder eine Frage zu einem Bug, der nur im Releasemode auftritt. Ich scheine sowas anzuziehen. >.>
Wie dem auch sei: Im Debugmodus läuft alles bestens, im Releasemode gibts eine System.EntryPointNotFoundException für opengl32.dll durch den .Net Wrapper Tao.OpenGL mit der Funktion glActiveTexture. Ich vermute mal, dass das völlig willkürlich ist, da der Bug bei gleicher Modulimplementation (Tao.OpenGL ist eine seperate .dll) nur in einem von mehreren Programmen auftritt.
Mal ganz allgemein: Woher kann sowas kommen? Bei Dingen wie stack overflow, NullreferenceException etc. liegt ja noch die Erklärung nicht initialisierter Variablen nahe (die ja im Debugmodus mit null initialisiert werden), aber eine EntryPointNotFoundException sollte doch an sich unabhängig von Debug oder Release sein? Oder verbirgt sich da mehr dahinter?
Falls jemand nen Blick auf den Code werfen will, den gibts hier (freue mich aber auch über allgemeine Denkanstöße!):
Program.cs
Code: |
using System;
using System.Collections.Generic;
using System.Text;
using Fetze.Module;
using Fetze.Utility;
using Fetze.Module.ZweiDeXT.Shader;
using Clr = Fetze.Utility.Color;
namespace ZweiDe_Application
{
class Program
{
private static int screenNum = 0;
private static FrameCounter frameCount;
private static ZweiDe.Texture[] texDiffuse = new ZweiDe.Texture[3];
private static ZweiDe.Texture[] texNormal = new ZweiDe.Texture[3];
private static ZweiDe.TextHelper[] hlpText = new ZweiDe.TextHelper[2];
private static Light.Source[] lights = new Light.Source[4];
private static Point<int> mousePos;
private static int numLights = 4;
static void Main(string[] args)
{
ZweiDe.CompiledKey = new ZweiDe.ZweiDeVerifier(ZweiDeKey.ZweiDeKey.VerifyKey);
ZweiDe.Init
(
640,
480,
32,
true,
0
);
Console.WriteLine(ZweiDe.VERSION);
texDiffuse[0] = ZweiDe.Texture.Load("scene_diff.png");
texNormal[0] = ZweiDe.Texture.Load("scene_norm.png");
texDiffuse[1] = ZweiDe.Texture.Load("wall_diff.png");
texNormal[1] = ZweiDe.Texture.Load("wall_norm.png");
texDiffuse[2] = ZweiDe.Texture.Load("char_diff.png");
texNormal[2] = ZweiDe.Texture.Load("char_norm.png");
texDiffuse[1].SetHandle(0.0f, texDiffuse[1].Height);
texNormal[1].SetHandle(0.0f, texNormal[1].Height);
texDiffuse[2].SetHandle(0.0f, texDiffuse[2].Height);
texNormal[2].SetHandle(0.0f, texNormal[2].Height);
Light.AmbientIntensity = 0.1f;
SetAmbientByIntensity();
new Light.Reciever(texNormal[0], 0, 0, false);
new Light.Reciever(texNormal[1], 375, 180, true);
new Light.Reciever(texNormal[2], 400, 200, true);
new Light.Reciever(texNormal[1], 200, 250, true);
new Light.Reciever(texNormal[2], 100, 275, true);
lights[0] = new Light.Source();
lights[0].SetRange(150.0f);
lights[0].SetColor(255, 255, 255);
lights[1] = new Light.Source();
lights[1].SetRange(250.0f);
lights[1].SetColor(255, 0, 0);
lights[2] = new Light.Source();
lights[2].SetRange(200.0f);
lights[2].SetColor(0, 255, 0);
lights[3] = new Light.Source();
lights[3].SetRange(150.0f);
lights[3].SetColor(0, 128, 255);
lights[3].SetIntensity(2.0f);
hlpText[0] = new ZweiDe.TextHelper();
hlpText[0].MinPrerenderDelay = 100.0f;
hlpText[1] = new ZweiDe.TextHelper(
"q//w/tChange number of lights (0 - 4)/n" +
"a//s/tChange ambient light/n" +
"y//x/tChange light intensities/n" +
"r/tEnable // Disable HDR/n" +
"F12/tTake a screenshot");
frameCount = new FrameCounter(ZweiDe.MainTimer());
do
{
ZweiDe.GetMousePos(out mousePos.x, out mousePos.y);
Draw();
ZweiDe.SetBlend(ZweiDe.BlendMode.Alpha);
ZweiDe.SetColor(0, 0, 0, 128);
ZweiDe.DrawRect(0, 0,
Math.Max(hlpText[0].Width, hlpText[1].Width) + 20,
50 + hlpText[1].Height + 10);
ZweiDe.SetColor(255, 255, 255, 196);
hlpText[0].Draw(10, 10);
hlpText[1].Draw(10, 50);
ZweiDe.SetColor(255, 255, 255, 255);
if (ZweiDe.KeyHitFrame(ZweiDe.KeyID.F12))
{
string fileName = String.Format("screenshot{0}.png", screenNum);
if (System.IO.File.Exists(fileName))
System.IO.File.Delete(fileName);
ZweiDe.Texture.GetFromRC(0, 0, ZweiDe.WindowSize.x, ZweiDe.WindowSize.y).ToPixmap().SaveToFile(fileName);
screenNum++;
}
if (ZweiDe.KeyHitFrame(ZweiDe.KeyID.Q) &&
numLights > 0)
{
lights[numLights - 1].Disabled = true;
numLights--;
}
if (ZweiDe.KeyHitFrame(ZweiDe.KeyID.W) &&
numLights < 4)
{
numLights++;
lights[numLights - 1].Disabled = false;
}
if (ZweiDe.KeyDown(ZweiDe.KeyID.A))
{
Light.AmbientIntensity -= (float)frameCount.TimeDelta * 0.01f;
Light.AmbientIntensity = Math.Max(0.0f, Light.AmbientIntensity);
SetAmbientByIntensity();
}
if (ZweiDe.KeyDown(ZweiDe.KeyID.S))
{
Light.AmbientIntensity += (float)frameCount.TimeDelta * 0.01f;
SetAmbientByIntensity();
}
if (ZweiDe.KeyDown(ZweiDe.KeyID.Y))
{
lights[0].SetIntensity(lights[0].Intensity - (float)frameCount.TimeDelta * 0.01f);
lights[1].SetIntensity(lights[1].Intensity - (float)frameCount.TimeDelta * 0.01f);
lights[2].SetIntensity(lights[2].Intensity - (float)frameCount.TimeDelta * 0.01f);
lights[3].SetIntensity(lights[3].Intensity - (float)frameCount.TimeDelta * 0.01f);
}
if (ZweiDe.KeyDown(ZweiDe.KeyID.X))
{
lights[0].SetIntensity(lights[0].Intensity + (float)frameCount.TimeDelta * 0.01f);
lights[1].SetIntensity(lights[1].Intensity + (float)frameCount.TimeDelta * 0.01f);
lights[2].SetIntensity(lights[2].Intensity + (float)frameCount.TimeDelta * 0.01f);
lights[3].SetIntensity(lights[3].Intensity + (float)frameCount.TimeDelta * 0.01f);
}
if (ZweiDe.KeyHitFrame(ZweiDe.KeyID.R))
{
Light.HDREnabled = !Light.HDREnabled;
}
ZweiDe.Flip();
frameCount.Update(ZweiDe.MainTimer());
hlpText[0].SetText(
String.Format("{0}/tFPS/n", frameCount.Fps) +
String.Format("{0:F}/tms", frameCount.MsPerFrame));
ZweiDe.UpdateKeys();
}
while
(
!ZweiDe.KeyDown(ZweiDe.KeyID.Escape) &&
(ZweiDe.GetWindowParam(ZweiDe.WindowParam.Opened) != 0)
);
if (ZweiDe.Initialized)
ZweiDe.Terminate();
}
static void Draw()
{
lights[0].SetPosition(
mousePos.x + 0.5f,
mousePos.y,
32.0f + (float)Math.Sin(ZweiDe.MainTimer()) * 32.0f);
lights[1].SetPosition(
-lights[1].Range + (ZweiDe.WindowSize.x + lights[1].Range * 2) * (float)((ZweiDe.MainTimer() / 10.0d) % 1.0d),
300,
32);
lights[2].SetPosition(
300.0f + (float)Math.Sin(ZweiDe.MainTimer() / 3.0d) * 150.0f,
-lights[2].Range + (ZweiDe.WindowSize.y + lights[2].Range * 2) * (float)((ZweiDe.MainTimer() / 10.0d) % 1.0d),
32);
lights[3].SetPosition(
(ZweiDe.WindowSize.x / 2) + (float)Math.Sin(ZweiDe.MainTimer()) * 150.0f,
(ZweiDe.WindowSize.y / 2) - (float)Math.Cos(ZweiDe.MainTimer()) * 150.0f,
32.0f + (float)Math.Sin(ZweiDe.MainTimer()) * 16.0f);
Light.UpdateLightmap(0, 0);
ZweiDe.Cls();
ZweiDe.SetBlend(ZweiDe.BlendMode.Alpha);
ZweiDe.DrawTexture(
texDiffuse[0],
0,
0);
ZweiDe.DrawTexture(
texDiffuse[1],
375,
180);
ZweiDe.DrawTexture(
texDiffuse[2],
400,
200);
ZweiDe.DrawTexture(
texDiffuse[1],
200,
250);
ZweiDe.DrawTexture(
texDiffuse[2],
100,
275);
Light.ApplyLightmap();
ZweiDe.SetColor(0, 255, 0);
ZweiDe.DrawRect(mousePos.x, mousePos.y, 2, 2);
ZweiDe.SetColor(255, 0, 0);
ZweiDe.DrawRect(
mousePos.x,
mousePos.y - (32.0f + (float)Math.Sin(ZweiDe.MainTimer()) * 32.0f),
2, 2);
ZweiDe.SetColor(255, 255, 255);
}
static void SetAmbientByIntensity()
{
Clr.RGBAf clrTemp = new Clr.RGBAf();
clrTemp.a = 1.0f;
clrTemp.r =
Func.InterpolateLinear(
Light.AmbientIntensity, new float[] {
0.0f, 0.0f,
0.5f, 0.95f,
1.5f, 1.0f
});
clrTemp.g =
Func.InterpolateLinear(
Light.AmbientIntensity, new float[] {
0.0f, 0.0f,
0.5f, 0.85f,
1.5f, 1.0f
});
clrTemp.b =
Func.InterpolateLinear(
Light.AmbientIntensity, new float[] {
0.0f, 1.0f,
0.5f, 0.4f,
1.5f, 1.0f
});
Light.AmbientLight = clrTemp.ToRGBA();
}
}
}
|
Light.cs
Code: |
using System;
using System.Collections.Generic;
using System.Text;
using Fetze.Module;
using Fetze.Utility;
using Fetze.Module.ZweiDeXT.Shader;
using Clr = Fetze.Utility.Color;
namespace ZweiDe_Application
{
public sealed class Light
{
private static List<Reciever> recievers = new List<Reciever>();
private static List<Reciever> recieversH = new List<Reciever>();
private static List<Reciever> recieversV = new List<Reciever>();
private static List<Source> lights = new List<Source>();
private static ZweiDe.Texture lightMap = null;
private static ZweiDe.Texture whiteTex = null;
private static Clr.RGBA ambient = new Clr.RGBA(128, 128, 128, 255);
private static float ambientIntensity = 1.0f;
private static bool hdrEnabled = true;
private static bool normEnabled = true;
public static Clr.RGBA AmbientLight
{
get { return Light.ambient; }
set { Light.ambient = value; }
}
public static float AmbientIntensity
{
get { return Light.ambientIntensity; }
set { Light.ambientIntensity = value; }
}
public static bool HDREnabled
{
get { return Light.hdrEnabled; }
set
{
if (Light.hdrEnabled != value)
{
Light.hdrEnabled = value;
Light.lightMap = null;
}
}
}
public static bool NormalMapsEnabled
{
get { return Light.normEnabled; }
set { Light.normEnabled = value; }
}
public static ZweiDe.Texture Lightmap
{
get { return Light.lightMap; }
}
#region Default lightmap shader
private static Shader.Program shLightmapDefault = new Shader.Program(
new Shader.Vertex[] { Shader.Vertex.Load( new string[] {
"uniform vec3 lightPos;",
"varying vec3 lightVec;",
"void main()",
"{",
"\tlightVec = lightPos - gl_Vertex.xyz;",
"\tgl_Position = ftransform();",
"\tgl_TexCoord[0] = gl_MultiTexCoord0;",
"\tgl_FrontColor = gl_Color;",
"}"} )
},
new Shader.Fragment[] { Shader.Fragment.Load( new string[] {
"uniform sampler2D normal;",
"uniform float lightRange;",
"varying vec3 lightVec;",
"void main()",
"{",
"\tvec4 texClr = texture2D(normal, gl_TexCoord[0].st);",
"\tfloat distCoeff = 1.0 - clamp(length(lightVec) / lightRange, 0.0, 1.0);",
"\tfloat lightVal = ",
"\tdot(2.0 * (texClr.xyz - 0.5), normalize(lightVec)) *",
"\tdistCoeff * distCoeff;",
"\tgl_FragColor = vec4(gl_Color.xyz * lightVal, texClr.w);",
"}"} )
});
private static Shader.Program shLightmapConv = new Shader.Program(
new Shader.Vertex[0],
new Shader.Fragment[] { Shader.Fragment.Load( new string[] {
"uniform sampler2D tex;",
"uniform float mult;",
"uniform float bias;",
"void main()",
"{",
"\tgl_FragColor = gl_Color * (texture2D(tex, gl_TexCoord[0].st) + bias) * mult;",
"}"} )
});
#endregion
public sealed class Reciever
{
private bool vertical = false;
private ZweiDe.Texture normalTex = null;
private Vector2D pos = new Vector2D();
public bool IsVertical
{
get { return this.vertical; }
}
public ZweiDe.Texture NormalmapTex
{
get { return this.normalTex; }
}
public Vector2D Pos
{
get { return this.pos; }
}
public Reciever(ZweiDe.Texture normTex, double xPos, double yPos, bool vertical)
{
this.vertical = vertical;
this.pos = new Vector2D(xPos, yPos);
this.normalTex = normTex;
Light.recievers.Add(this);
if (vertical)
Light.recieversV.Add(this);
else
Light.recieversH.Add(this);
}
public void Dispose()
{
Light.recievers.Remove(this);
if (this.vertical)
Light.recieversV.Remove(this);
else
Light.recieversH.Remove(this);
this.normalTex = null;
}
public void SetPosition(double x, double y)
{
this.pos.x = x;
this.pos.y = y;
}
public void SetNormalmapTex(ZweiDe.Texture tex)
{
this.normalTex = tex;
}
internal void Draw(
float xOffset, float yOffset, float minX, float minY, float maxX, float maxY)
{
Point<float> posTemp;
posTemp.x = (float)this.pos.x - this.normalTex.Handle.x - xOffset;
posTemp.y = (float)this.pos.y - this.normalTex.Handle.y - yOffset;
Rect<float> texCoord;
texCoord.x = Math.Max(0.0f, minX - posTemp.x);
texCoord.y = Math.Max(0.0f, minY - posTemp.y);
texCoord.w = this.normalTex.Width - Math.Max(0.0f, posTemp.x + this.normalTex.Width - maxX) - texCoord.x;
texCoord.h = this.normalTex.Height - Math.Max(0.0f, posTemp.y + this.normalTex.Height - maxY) - texCoord.y;
ZweiDe.DrawTexturePart(
this.normalTex,
Math.Max(posTemp.x, minX),
Math.Max(posTemp.y, minY),
texCoord.x,
texCoord.y,
texCoord.w,
texCoord.h);
}
}
public sealed class Source
{
private bool disabled = false;
private Vector3D pos = new Vector3D();
private float range = 250.0f;
private float intensity = 1.0f;
private Clr.RGBA clr = new Clr.RGBA(255, 255, 255, 255);
private Shader.Program shLightmap = Light.shLightmapDefault;
internal ZweiDe.Texture texTemp = null;
public Vector3D Pos
{
get { return this.pos; }
}
public float Range
{
get { return this.range; }
}
public float FlatRange
{
get { return (float)Math.Sqrt(this.range * this.range - this.pos.z * this.pos.z); }
}
public float Intensity
{
get { return this.intensity; }
}
public Clr.RGBA Color
{
get { return this.clr; }
}
public Shader.Program LightmapShader
{
get { return this.shLightmap; }
}
public bool Disabled
{
get { return this.disabled; }
set { this.disabled = value; }
}
static Source()
{
Light.shLightmapDefault.Compile();
Light.shLightmapConv.Compile();
}
public Source(double x, double y, double z)
{
this.pos = new Vector3D(x, y, z);
this.UpdateTempTex();
Light.lights.Add(this);
}
public Source() : this(0, 0, 0) {}
public void Dispose()
{
Light.lights.Remove(this);
this.shLightmap = null;
}
private void UpdateTempTex()
{
if (this.texTemp == null)
{
this.texTemp = ZweiDe.Texture.Create(ZweiDe.WindowSize.x, ZweiDe.WindowSize.y);
this.texTemp.CreateRenderBuffer(ZweiDe.Texture.TexFlag.None);
int width = (int)Math.Ceiling(this.range * 2.0f);
int height = ZweiDe.WindowSize.y;
int oglWidth;
int oglHeight;
int maxSize = ZweiDe.Texture.GetMaxSize();
if (width < 1) width = 1;
if (height < 1) height = 1;
if (width > maxSize) width = maxSize;
if (height > maxSize) height = maxSize;
if (this.texTemp != null) { oglWidth = this.texTemp.OglWidth; oglHeight = this.texTemp.OglHeight; }
else { oglWidth = 0; oglHeight = 0; }
if (this.texTemp == null ||
width > oglWidth)
{
if (this.texTemp != null)
{
this.texTemp.Dispose();
this.texTemp = null;
}
this.texTemp = ZweiDe.Texture.Create(width, height);
this.texTemp.CreateRenderBuffer(ZweiDe.Texture.TexFlag.None);
}
else
{
this.texTemp.ForceBoundaries(width, height, (float)width / (float)oglWidth, (float)height / (float)oglHeight);
}
}
}
public void SetPosition(double x, double y, double z)
{
this.pos.x = x;
this.pos.y = y;
this.pos.z = z;
}
public void SetRange(float range)
{
if (this.range != range)
{
this.range = range;
this.UpdateTempTex();
}
}
public void SetIntensity(float intensity)
{
this.intensity = intensity;
}
public void SetColor(byte r, byte g, byte b)
{
this.clr.r = r;
this.clr.g = g;
this.clr.b = b;
}
public void SetShader(Shader.Program shader)
{
this.shLightmap = shader;
}
internal Rect<int> UpdateLmTex(float xOffset, float yOffset)
{
if (this.disabled) return new Rect<int>(0, 0, -1, -1);
Rect<int> litArea = new Rect<int>(ZweiDe.WindowSize.x, ZweiDe.WindowSize.y, 0, 0);
ZweiDe.BlendMode blendB4 = ZweiDe.DrawBlend;
Clr.RGBA clrB4 = ZweiDe.DrawColor;
Shader.Program shB4 = Shader.Program.CurrentBound;
if (shB4 != this.shLightmap) Shader.Program.Bind(this.shLightmap);
this.texTemp.BindRenderBuffer();
ZweiDe.Cls();
xOffset += (float)Math.Round(this.pos.x - this.range);
ZweiDe.SetBlend(ZweiDe.BlendMode.Alpha);
ZweiDe.SetColor(this.clr.r, this.clr.g, this.clr.b, this.clr.a);
Shader.Program.SetUniform("lightRange", this.range);
Rect<float> minmax;
int drawCount;
float hRangeTemp = this.FlatRange;
if (this.pos.z < this.range &&
this.pos.z >= 0.0f)
{
Shader.Program.SetUniform("lightPos",
(float)this.pos.x - xOffset,
(float)this.pos.y - yOffset,
(float)this.pos.z);
minmax = new Rect<float>(
Math.Max(0.0f, (float)this.pos.x - xOffset - hRangeTemp),
Math.Max(0.0f, (float)this.pos.y - yOffset - hRangeTemp),
Math.Min(ZweiDe.WindowSize.x, (float)this.pos.x - xOffset + hRangeTemp),
Math.Min(ZweiDe.WindowSize.y, (float)this.pos.y - yOffset + hRangeTemp));
// Render horizontal recievers
drawCount = 0;
for (int i = 0; i < Light.recieversH.Count; i++)
{
if (Light.recieversH[i].Pos.x - Light.recieversH[i].NormalmapTex.Handle.x - xOffset > minmax.w) continue;
if (Light.recieversH[i].Pos.y - Light.recieversH[i].NormalmapTex.Handle.y - yOffset > minmax.h) continue;
if (Light.recieversH[i].Pos.x - Light.recieversH[i].NormalmapTex.Handle.x - xOffset + Light.recieversH[i].NormalmapTex.Width < minmax.x) continue;
if (Light.recieversH[i].Pos.y - Light.recieversH[i].NormalmapTex.Handle.y - yOffset + Light.recieversH[i].NormalmapTex.Height < minmax.y) continue;
Light.recieversH[i].Draw(
xOffset, yOffset,
minmax.x, minmax.y, minmax.w, minmax.h);
drawCount++;
}
if (drawCount > 0)
{
litArea.x = Math.Min(litArea.x, (int)minmax.x);
litArea.y = Math.Min(litArea.y, (int)minmax.y);
litArea.w = Math.Max(litArea.w, (int)minmax.w);
litArea.h = Math.Max(litArea.h, (int)minmax.h);
}
}
// Render vertical recievers with individual lightPos
minmax = new Rect<float>(
Math.Max(0.0f, (float)this.pos.x - xOffset - hRangeTemp),
Math.Max(0.0f, (float)this.pos.y - yOffset - this.range),
Math.Min(ZweiDe.WindowSize.x, (float)this.pos.x - xOffset + hRangeTemp),
Math.Min(ZweiDe.WindowSize.y, (float)this.pos.y - yOffset + this.range));
drawCount = 0;
for (int i = 0; i < Light.recieversV.Count; i++)
{
if (Light.recieversV[i].Pos.x - Light.recieversV[i].NormalmapTex.Handle.x - xOffset > minmax.w) continue;
if (Light.recieversV[i].Pos.y - Light.recieversV[i].NormalmapTex.Handle.y - yOffset > minmax.h) continue;
if (Light.recieversV[i].Pos.x - Light.recieversV[i].NormalmapTex.Handle.x - xOffset + Light.recieversV[i].NormalmapTex.Width < minmax.x) continue;
if (Light.recieversV[i].Pos.y - Light.recieversV[i].NormalmapTex.Handle.y - yOffset + Light.recieversV[i].NormalmapTex.Height < minmax.y) continue;
Shader.Program.SetUniform("lightPos",
(float)this.pos.x - xOffset,
(float)-this.pos.z - yOffset + (float)Light.recieversV[i].Pos.y,
(float)this.pos.y - (float)Light.recieversV[i].Pos.y);
Light.recieversV[i].Draw(
xOffset, yOffset,
minmax.x, 0, minmax.w, ZweiDe.WindowSize.y);
drawCount++;
}
if (drawCount > 0)
{
litArea.y = Math.Min(litArea.y, 0);
litArea.h = Math.Max(litArea.h, ZweiDe.WindowSize.y);
}
ZweiDe.SetBlend(blendB4);
ZweiDe.SetColor(clrB4.r, clrB4.g, clrB4.b, clrB4.a);
this.texTemp.UnbindRenderBuffer();
if (shB4 != this.shLightmap) Shader.Program.Bind(shB4);
litArea.w -= litArea.x;
litArea.h -= litArea.y;
return litArea;
}
}
public static void UpdateLightmap(float xOffset, float yOffset)
{
ZweiDe.Cls(ZweiDe.ClsMode.Accum | ZweiDe.ClsMode.Color);
if (Light.lightMap == null)
{
Light.lightMap = ZweiDe.Texture.Create(ZweiDe.WindowSize.x, ZweiDe.WindowSize.y);
if (Light.hdrEnabled)
Light.lightMap.CreateRenderBuffer(ZweiDe.Texture.TexFlag.None, false, true);
else
Light.lightMap.CreateRenderBuffer(ZweiDe.Texture.TexFlag.None, false, false);
}
// Lights
Rect<int> litArea;
for (int i = 0; i < Light.lights.Count; i++)
{
litArea = Light.lights[i].UpdateLmTex(xOffset, yOffset);
}
// Generate Lightmap texture
Clr.RGBA clsclrB4 = ZweiDe.ClsColor;
ZweiDe.ClsColor = new Clr.RGBA(0, 0, 0, 255);
Light.lightMap.BindRenderBuffer();
ZweiDe.Cls();
if (Light.hdrEnabled)
ZweiDe.SetBlend(ZweiDe.BlendMode.TotalAdd);
else
ZweiDe.SetBlend(ZweiDe.BlendMode.Light);
ZweiDe.BlendMode blendB4 = ZweiDe.DrawBlend;
if (Light.hdrEnabled)
{
Shader.Program.Bind(Light.shLightmapConv);
Shader.Program.SetUniform("mult", 0.01f * Light.ambientIntensity);
Shader.Program.SetUniform("bias", 0.0f);
}
Clr.RGBA clrB4 = ZweiDe.DrawColor;
ZweiDe.SetColor(ambient.r, ambient.g, ambient.b, Light.hdrEnabled ? (byte)255 : (byte)(255.0f * Math.Min(1.0f, Math.Max(0.0f, Light.ambientIntensity))));
if (Light.hdrEnabled)
{
if (Light.whiteTex == null)
{
Light.whiteTex = ZweiDe.Pixmap.Create(1, 1, new byte[] {255, 255, 255, 255}).ToTexture(ZweiDe.Texture.TexFlag.EdgeClamp, true);
}
ZweiDe.DrawTextureArea(Light.whiteTex, 0, 0, ZweiDe.WindowSize.x, ZweiDe.WindowSize.y, false);
ZweiDe.SetColor(clrB4.r, clrB4.g, clrB4.b, clrB4.a);
}
else
{
ZweiDe.DrawRect(0, 0, ZweiDe.WindowSize.x, ZweiDe.WindowSize.y);
}
for (int i = 0; i < Light.lights.Count; i++)
{
if (Light.lights[i].Disabled) continue;
if (Light.hdrEnabled)
Shader.Program.SetUniform("mult", 0.01f * Light.lights[i].Intensity);
else
ZweiDe.SetColor(255, 255, 255, (byte)(255.0f * Math.Min(1.0f, Math.Max(0.0f, Light.lights[i].Intensity))));
ZweiDe.DrawTexture(
Light.lights[i].texTemp,
(float)Math.Round(Light.lights[i].Pos.x - Light.lights[i].Range),
0);
}
if (!Light.hdrEnabled)
ZweiDe.SetColor(clrB4.r, clrB4.g, clrB4.b, clrB4.a);
if (Light.hdrEnabled)
Shader.Program.Bind(null);
Light.lightMap.UnbindRenderBuffer();
ZweiDe.ClsColor = clsclrB4;
ZweiDe.SetBlend(blendB4);
}
public static void ApplyLightmap()
{
ZweiDe.BlendMode blendB4 = ZweiDe.DrawBlend;
if (Light.hdrEnabled)
Shader.Program.Bind(Light.shLightmapConv);
ZweiDe.SetBlend(ZweiDe.BlendMode.Shade);
if (Light.hdrEnabled)
Shader.Program.SetUniform("mult", 100.0f);
ZweiDe.DrawTexture(Light.lightMap, 0, 0);
if (Light.hdrEnabled)
{
ZweiDe.SetBlend(ZweiDe.BlendMode.SoftLight);
Shader.Program.SetUniform("bias", -0.01f);
ZweiDe.DrawTexture(Light.lightMap, 0, 0);
ZweiDe.SetBlend(ZweiDe.BlendMode.Light);
Shader.Program.SetUniform("bias", -0.02f);
ZweiDe.DrawTexture(Light.lightMap, 0, 0);
Shader.Program.Bind(null);
}
ZweiDe.SetBlend(blendB4);
}
}
}
|
Ich freue mich über jeden Hinweis. |
|