use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class DefaultSkyRenderer method render.
public void render(RenderingInterface renderingContext) {
try {
long worldTime = renderingContext.getWorldRenderer().getWorld().getTime();
this.dayTime = (worldTime % 10000) / 10000f;
} catch (NullPointerException e) {
}
renderingContext.setDepthTestMode(DepthTestMode.DISABLED);
renderingContext.setBlendMode(BlendMode.DISABLED);
renderingContext.setCullingMode(CullingMode.DISABLED);
renderingContext.getRenderTargetManager().setDepthMask(false);
Vector3f sunPosVector = getSunPosition();
Shader skyShader = renderingContext.useShader("sky");
skyShader.setUniform1f("overcastFactor", world.getWeather());
skyShader.setUniform3f("sunPos", sunPosVector.x(), sunPosVector.y(), sunPosVector.z());
skyShader.setUniform1f("time", dayTime);
renderingContext.getCamera().setupShader(skyShader);
renderingContext.drawFSQuad();
renderingContext.setBlendMode(BlendMode.MIX);
Shader starsShader = renderingContext.useShader("stars");
starsShader.setUniform3f("sunPos", sunPosVector.x(), sunPosVector.y(), sunPosVector.z());
starsShader.setUniform3f("color", 1f, 1f, 1f);
renderingContext.getCamera().setupShader(starsShader);
int NB_STARS = 500;
// starsVertexBuffer = null;
if (starsVertexBuffer == null) {
starsVertexBuffer = renderingContext.newVertexBuffer();
ByteBuffer bb = ByteBuffer.allocateDirect(4 * 3 * NB_STARS);
bb.order(ByteOrder.LITTLE_ENDIAN);
// System.out.println(stars.order());
for (int i = 0; i < NB_STARS; i++) {
Vector3f star = new Vector3f((float) Math.random() * 2f - 1f, (float) Math.random(), (float) Math.random() * 2f - 1f);
star.normalize();
star.mul(100f);
bb.putFloat(star.x());
bb.putFloat(star.y());
bb.putFloat(star.z());
// stars.put(new float[] { star.x(), star.y(), star.z() });
}
bb.flip();
starsVertexBuffer.uploadData(bb);
}
renderingContext.bindAttribute("vertexIn", starsVertexBuffer.asAttributeSource(VertexFormat.FLOAT, 3));
renderingContext.draw(Primitive.POINT, 0, NB_STARS);
renderingContext.getRenderTargetManager().setDepthMask(true);
renderingContext.setBlendMode(BlendMode.DISABLED);
renderingContext.setDepthTestMode(DepthTestMode.LESS_OR_EQUAL);
cloudsRenderer.renderClouds(renderingContext);
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class BloomPass method render.
@Override
public void render(RenderingInterface renderer) {
bloomBuffer.setLinearFiltering(true);
renderer.setDepthTestMode(DepthTestMode.DISABLED);
renderer.setBlendMode(BlendMode.DISABLED);
Shader bloomShader = renderer.useShader("bloom");
renderer.getCamera().setupShader(bloomShader);
// bloomShader.setUniform1f("apertureModifier", 1.0f);
bloomShader.setUniform2f("screenSize", renderer.getWindow().getWidth() / 2f, renderer.getWindow().getHeight() / 2f);
renderer.getRenderTargetManager().setConfiguration(fboBloom);
renderer.drawFSQuad();
// Blur bloom
// Vertical pass
renderer.getRenderTargetManager().setConfiguration(fboBlur);
Shader blurV = renderer.useShader("blurV");
blurV.setUniform2f("screenSize", renderer.getWindow().getWidth() / 2f, renderer.getWindow().getHeight() / 2f);
blurV.setUniform1f("lookupScale", 1);
renderer.bindTexture2D("inputTexture", bloomBuffer);
renderer.drawFSQuad();
// Horizontal pass
renderer.getRenderTargetManager().setConfiguration(fboBloom);
Shader blurH = renderer.useShader("blurH");
blurH.setUniform2f("screenSize", renderer.getWindow().getWidth() / 2f, renderer.getWindow().getHeight() / 2f);
renderer.bindTexture2D("inputTexture", blurBuffer);
renderer.drawFSQuad();
renderer.getRenderTargetManager().setConfiguration(fboBlur);
blurV = renderer.useShader("blurV");
blurV.setUniform2f("screenSize", renderer.getWindow().getWidth() / 4f, renderer.getWindow().getHeight() / 4f);
blurV.setUniform1f("lookupScale", 1);
renderer.bindTexture2D("inputTexture", bloomBuffer);
renderer.drawFSQuad();
// Horizontal pass
renderer.getRenderTargetManager().setConfiguration(fboBloom);
blurH = renderer.useShader("blurH");
blurH.setUniform2f("screenSize", renderer.getWindow().getWidth() / 4f, renderer.getWindow().getHeight() / 4f);
renderer.bindTexture2D("inputTexture", blurBuffer);
renderer.drawFSQuad();
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories-core by Hugobros3.
the class DecalsPass method render.
@Override
public void render(RenderingInterface renderer) {
renderer.getRenderTargetManager().setConfiguration(fbo);
renderer.setBlendMode(BlendMode.MIX);
renderer.setCullingMode(CullingMode.DISABLED);
renderer.setDepthTestMode(DepthTestMode.LESS_OR_EQUAL);
Shader decalsShader = renderer.useShader("decals");
renderer.getCamera().setupShader(decalsShader);
renderer.getRenderTargetManager().setDepthMask(false);
worldRenderer.getDecalsRenderer().renderDecals(renderer);
renderer.getRenderTargetManager().setDepthMask(true);
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories by Hugobros3.
the class FakeImmediateModeDebugRenderer method glEnd.
public static void glEnd() {
OpenGLRenderingContext renderingContext = Client.getInstance().getGameWindow().getRenderingInterface();
renderingContext.setCullingMode(CullingMode.DISABLED);
renderingContext.setBlendMode(BlendMode.MIX);
renderingContext.setDepthTestMode(DepthTestMode.LESS_OR_EQUAL);
// ShadersLibrary.getShaderProgram("overlay");
Shader overlayProgram = renderingContext.useShader("overlay");
camera.setupShader(overlayProgram);
overlayProgram.setUniform4f("colorIn", color);
data.flip();
vertexBuffer.uploadData(data);
renderingContext.bindAttribute("vertexIn", vertexBuffer.asAttributeSource(VertexFormat.FLOAT, 3));
// renderingContext.bindAttribute("vertexIn", new FloatBufferAttributeSource(data, 3));
renderingContext.draw(mode == GL_TRIANGLES ? Primitive.TRIANGLE : Primitive.LINE, 0, size);
renderingContext.setBlendMode(BlendMode.DISABLED);
data.clear();
size = 0;
}
use of io.xol.chunkstories.api.rendering.shader.Shader in project chunkstories by Hugobros3.
the class SkyBoxBackground method render.
@Override
public void render(RenderingInterface renderer) {
if (gameWindow.getLayer() == this)
gameWindow.setLayer(new MainMenu(gameWindow, this));
try // Ugly fps caps yay
{
Thread.sleep(33L);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Render this shit boy
renderer.getRenderTargetManager().setConfiguration(unblurredFBO);
camera.setupUsingScreenSize(gameWindow.getWidth(), gameWindow.getHeight());
Shader menuSkyBox = renderer.useShader("mainMenuSkyBox");
camera.setupShader(menuSkyBox);
renderer.bindCubemap("skybox", TexturesHandler.getCubemap(skyBox));
camera.setRotationX(35 + (float) (Math.sin(camera.getRotationY() / 15)) * 5f);
camera.setRotationY((System.currentTimeMillis() % 1000000) / 200.0f);
renderer.drawFSQuad();
renderer.getRenderTargetManager().setConfiguration(blurredHFBO);
Shader blurH = renderer.useShader("blurH");
blurH.setUniform2f("screenSize", gameWindow.getWidth(), gameWindow.getHeight());
renderer.bindTexture2D("inputTexture", unblurred);
renderer.drawFSQuad();
for (int i = 0; i < 1; i++) {
renderer.getRenderTargetManager().setConfiguration(blurredVFBO);
Shader blurV = renderer.useShader("blurV");
blurV.setUniform1f("lookupScale", 1);
blurV.setUniform2f("screenSize", gameWindow.getWidth() / 2, gameWindow.getHeight() / 2);
renderer.bindTexture2D("inputTexture", blurredH);
renderer.drawFSQuad();
renderer.getRenderTargetManager().setConfiguration(blurredHFBO);
blurH = renderer.useShader("blurH");
blurH.setUniform2f("screenSize", gameWindow.getWidth() / 2, gameWindow.getHeight() / 2);
renderer.bindTexture2D("inputTexture", blurredV);
renderer.drawFSQuad();
}
renderer.getRenderTargetManager().setConfiguration(blurredVFBO);
Shader blurV = renderer.useShader("blurV");
blurV.setUniform2f("screenSize", gameWindow.getWidth(), gameWindow.getHeight());
renderer.bindTexture2D("inputTexture", blurredH);
renderer.drawFSQuad();
renderer.getRenderTargetManager().setConfiguration(null);
Shader blit = renderer.useShader("background");
blit.setUniform2f("screenSize", gameWindow.getWidth(), gameWindow.getHeight());
Texture2DGL backgroundTexture = TexturesHandler.getTexture("./textures/gui/darker.png");
backgroundTexture.setLinearFiltering(false);
renderer.bindTexture2D("diffuseTexture", backgroundTexture);
renderer.bindTexture2D("backgroundTexture", blurredV);
renderer.drawFSQuad();
Texture2DGL logoTexture = TexturesHandler.getTexture("./textures/gui/icon.png");
float alphaIcon = (float) (0.25 + Math.sin((System.currentTimeMillis() % (1000 * 60 * 60) / 3000f)) * 0.25f);
renderer.setBlendMode(BlendMode.MIX);
float diagonal = (float) Math.sqrt(gameWindow.getWidth() * gameWindow.getWidth() + gameWindow.getHeight() * gameWindow.getHeight());
float iconSize = (float) (diagonal / 3 + 50 * Math.sin((System.currentTimeMillis() % (1000 * 60 * 60) / 30000f)));
renderer.getGuiRenderer().drawBoxWindowsSpace(gameWindow.getWidth() / 2 - iconSize / 2, gameWindow.getHeight() / 2 - iconSize / 2, gameWindow.getWidth() / 2 + iconSize / 2, gameWindow.getHeight() / 2 + iconSize / 2, 0, 1, 1, 0, logoTexture, true, true, new Vector4f(1.0f, 1.0f, 1.0f, alphaIcon));
}
Aggregations