It’s always those little things

So today I have spent several hours chasing a bug about Culling, so when I set it to back culling, somehow front culling was enabled, and visa versa.

Then suddenly I tried to reverse the normals, which fixed it, so in fact there was nothing wrong with the program itself, just the mesh.

It’s always those little things that bugs us, which we never think off.

BTW. I developed a new parser for materials, so developing a new shader looks like the following:

</pre>
Any description or text can go here. The parser ignores it.

shader "Gem_Shader"
{
 // Properties go here
 info = "Gem shader showing the passes feature";

 :input
 :{
     // Define our two texture maps
     Texture2D noise;
     Texture2D reflection;
     TextureCube environment;

     // To simplify
     #define OUT output

     #define lighting_intensity 0.7f
     #define NOSHADOWS
 :}

 :pass
 {
    :properties {
       Cull [Front];
    }

    :linkage
    :{
       float3 Reflect : REF;
    :}

   :vertex
   :{
      float3 ViewDir = normalize(mul(position, worldMatrix) - eyepos);
      output.Reflect = reflect(viewvec, mul(normal, worldMatrix));
      output.Reflect.y = -output.Reflect.y;
   :}

   :pixel
   :{
      float4 colors = reflection.Sample(ss, input.texcoord)/4.0f;
      float4 cubeMap = environment.Sample(ss, input.Reflect);

      output.Diffuse = float4( colors.rgb + (cubeMap.rgb / 2.0f) , 1.0f);
   :}
 }

 :pass
 {
   :properties {
      Cull [Back];
   }

   :linkage
   :{
      float3 Reflect : REF;
   :}

   :vertex
   :{
      float3 ViewDir = normalize(mul(position, worldMatrix) - eyepos);
      output.Reflect = reflect(viewvec, mul(normalize(float4(normal.xyz, 0)), worldMatrix));
      output.Reflect.y = -output.Reflect.y;
   :}

   :pixel
   :{
      float4 colors = reflection.Sample(ss, input.texcoord)/2.0f;
      float4 cubeMap = environment.Sample(ss, input.Reflect);

      output.Diffuse = float4( colors.rgb + (cubeMap.rgb) , 0.6f);
   :}
 }
}
<pre>
Advertisements

CDK – Displacement Mapping – Planet Rendering

Hi guys,

In the graphical side of the engine I have Implemented displacement mapping, currently only for the terrain engine, but making that feature available for meshes is simply a matter of copy & pasting. 🙂

As a side project, I’m starting on a small planet rendering project, the terrain engine support planes and spherical objects for now. The planet for now I just a sphere which is tessellated and displaced on the GPU.

The ocean is on the way for now, just having some problems with the resources…

At some point I’m going to post some screenshots.

CDK – Editor + Point Lights

In cuboid engine I’ve implemented point lights, to a level where you can place unlimited, though I still have to improve the performance, I like the current results.

(100 Barrels, 30 Point Lights)

pointL

 

The point lights have also been implemented into the editor, and has been improved, fixed some bugs and stuff. So I decided to make a test level, just to see the results:

editor

And yes, that is a creepy old house floating on the ocean.

PS. CDK is Cuboid Development Kit