Exemplo n.º 1
0
        internal void Init()
        {
            REngine.CheckGLError();

            defaultShader = new RShader();
            defaultShader.Load(RShaderResources.Basic2dEffectVert, RShaderResources.Basic2dEffectFrag, null);
            Fonts.Add(RFont.Default);
            quad = new RMeshBuilder();
            quad.CreateQuad(new Vector2(0, 0), new Vector2(1, 1), true);
            quadVerts    = new RVertexData2D[4];
            quadVerts[0] = new RVertexData2D(new Vector2(-1, -1), new Vector2(0, 0));
            quadVerts[1] = new RVertexData2D(new Vector2(1, -1), new Vector2(1, 0));
            quadVerts[2] = new RVertexData2D(new Vector2(1, 1), new Vector2(1, 1));
            quadVerts[3] = new RVertexData2D(new Vector2(-1, 1), new Vector2(0, 1));
            vertexQuad2D = new RVertexBuffer(quadVerts[0].Declaration, 4, RBufferUsage.WriteOnly);
            vertexQuad2D.SetData <RVertexData2D>(quadVerts);
            indexQuad2D = new RIndexBuffer(typeof(short), 6, RBufferUsage.WriteOnly);
            indexQuad2D.SetData <short>(new short[6] {
                0, 1, 2, 0, 2, 3
            }, 0, 6);
            initialized = true;
        }
Exemplo n.º 2
0
        public void CreateSkyBox(RTexture3D skyBoxTexture)
        {
            skybox = new RShader();
            skybox.Load(@"
#include ""headers.glsl""
uniform mat4 proj : PROJECTION;
uniform mat4 mv : MODELVIEW;

smooth out vec3 eye;

void main()
{
    mat3 imv = mat3(inverse(mv));
    mat4 inverseProjection = inverse(proj);
    vec3 unprojected = (inverseProjection * vec4(r_Position, 1.0)).xyz;
    eye = imv * unprojected;

    gl_Position = vec4(r_Position, 1.0);
}
", @"

smooth in vec3 eye;
uniform samplerCube diffuse;
out vec4 fragColor;
void main()
{
    fragColor = texture(diffuse, eye);
}
", null);
            sky = RScene.Instance.CreateMeshBuilder("skybox");
            sky.CreateBox(Vector3.Zero, Vector3.One, true);
            sky.Matrix     = Matrix.Identity;
            sky.DepthWrite = false;
            RMaterial skyBoxMaterial = new RMaterial("skybox");

            skyBoxMaterial.Shader = skybox;
            skyBoxMaterial.SetTexture(RTextureLayer.DIFFUSE, skyBoxTexture);
            sky.Material = skyBoxMaterial;
        }
Exemplo n.º 3
0
 public void InitHDR()
 {
     hdrFrameBuffer = new RFrameBuffer((int)_viewport.Width, (int)_viewport.Height, false, RSurfaceFormat.Vector4, RDepthFormat.Depth32Stencil8);
     hdrShader      = new RShader();
     hdrShader.Load(RShaderResources.HDRVert, RShaderResources.HDRFrag);
 }