Test with new technique texturing
This commit is contained in:
parent
bb723036c0
commit
3a7d169b30
8 changed files with 125 additions and 61 deletions
|
|
@ -16,6 +16,7 @@ namespace Map3DRendering {
|
|||
private Shader _shader;
|
||||
|
||||
private Texture _texture;
|
||||
private Texture _texture2;
|
||||
|
||||
private Camera _camera;
|
||||
|
||||
|
|
@ -53,16 +54,29 @@ namespace Map3DRendering {
|
|||
_shader.Use();
|
||||
|
||||
mapRender.OnLoad(_shader);
|
||||
_texture = Texture.LoadFromFile("atlas.jpg");
|
||||
|
||||
_texture = Texture.LoadFromFile("terrains/0.jpg");
|
||||
// Texture units are explained in Texture.cs, at the Use function.
|
||||
// First texture goes in texture unit 0.
|
||||
_texture.Use(TextureUnit.Texture0);
|
||||
|
||||
// This is helpful because System.Drawing reads the pixels differently than OpenGL expects.
|
||||
_texture2 = Texture.LoadFromFile("terrains/1.jpg");
|
||||
// Then, the second goes in texture unit 1.
|
||||
_texture2.Use(TextureUnit.Texture1);
|
||||
|
||||
// Next, we must setup the samplers in the shaders to use the right textures.
|
||||
// The int we send to the uniform indicates which texture unit the sampler should use.
|
||||
_shader.SetInt("texture0", 0);
|
||||
_shader.SetInt("texture1", 1);
|
||||
|
||||
axesGizmo = new AxesGizmo();
|
||||
|
||||
_camera = new Camera(Vector3.UnitY * 300, Size.X / (float)Size.Y);
|
||||
_camera.Fov = 60;
|
||||
//CursorState = CursorState.Grabbed;
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
|
||||
_lightPosVec = Vector3.UnitY * 1000;
|
||||
}
|
||||
|
||||
|
|
@ -73,8 +87,9 @@ namespace Map3DRendering {
|
|||
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
_shader.Use();
|
||||
_texture.Use(TextureUnit.Texture0);
|
||||
_texture2.Use(TextureUnit.Texture1);
|
||||
_shader.Use();
|
||||
|
||||
_shader.SetMatrix4("view", _camera.GetViewMatrix());
|
||||
_shader.SetMatrix4("projection", _camera.GetProjectionMatrix());
|
||||
|
|
@ -82,6 +97,7 @@ namespace Map3DRendering {
|
|||
//_shader.SetVector3("objectColor", new Vector3(0.5f, 0.5f, 0.5f));
|
||||
_shader.SetVector3("lightColor", new Vector3(1.0f, 1.0f, 1.0f));
|
||||
_shader.SetVector3("lightPos", _lightPosVec);
|
||||
|
||||
//_shader.SetVector3("viewPos", _camera.Position);
|
||||
|
||||
GL.LineWidth(5.0f);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue