[Solved][DLL] How to draw a texture "over the shadow"

Started by Rikiki, September 09, 2014, 02:16:21 PM

Previous topic - Next topic

Rikiki

Hello!

I am trying to draw a texture which should be displayed "over the shadow".
This means I want it to be visible even if some cells are undiscovered.
But for now I am unsuccessful... >:(



I use this code (adapted from Clutter):

float currentRotation = 0;
Material ScanRange = MaterialPool.MatFrom("Effects/ScanRange10x10", MatBases.Transparent);
Matrix4x4 matrix = default(Matrix4x4);
Vector3 size = new Vector3(20f, 1f, 20f);
matrix.SetTRS(base.DrawPos + Altitudes.AltIncVect, currentRotation.ToQuat(), size);
Graphics.DrawMesh(MeshPool.plane10, matrix, ScanRange, 0);


I tried changing the Mesh (MeshPool.shadow1006, MeshPool.plane30, ...), the layer (the last parameter) but with no success... :'(

Any help about how works Unity would be greatly appreciated! :D

mrofa

If you want turn off fog of war from minerals try
this.Unfog(new IntVec3(position));

I didnt try it thrugh :P

But for more info check in ILspy Verse.FogGrid and FogUtility
All i do is clutter all around.

Rikiki

Thank you mrofa, I already use that. :) This code works:

Find.FogGrid.Unfog(mineralBlock.Position);


More precision may be useful: the purpose of this little mod is to provide a mobile mineral sonar.
So it basically removes the fog on mineral blocks (and only on mineral, not rock, to be more "immersive").
But I would like to draw a "scan range" over the fogged blocks.

Any other idea? ???

mrofa

Cool im not ompletly brain dead yet :D
Try this
Vector3 size = new Vector3(20f, 24f, 20f);
All i do is clutter all around.

Rikiki

No success mrofa :(, after some researches, this vector is a scaling vector (I saw this here http://docs.unity3d.com/ScriptReference/Matrix4x4.SetTRS.html).

I also tested this:

matrix.SetTRS(base.DrawPos + Altitudes.AltIncVect + new Vector3(0f, 50f, 0f), currentRotation.ToQuat(), size);

This only changes the altitude at which the camera displays it (50f is the limit for things to be displayed when max dezoomed).

I think the solution is in the layers but I can't see how... :-[

mrofa

Ok another theory is to get ring into variable and set its applitude as a object to ForgOfWar or 24f :D
All i do is clutter all around.

Tynan

Instead of using MatBases.Transparent, use MatBases.MetaOverlay. Or try some others.

It has to do with the order of rendering of the different material bases.
Tynan Sylvester - @TynanSylvester - Tynan's Blog

RawCode

AFAIK this handled by rendering layer.

rending in GUI layer will allow to "override" fog of war.

i will check when at home.

Rikiki

Thank you Tynan! :D

So here is the working code:


private Material scanRange10Cells;
Matrix4x4 scanRange10CellsMatrix = default(Matrix4x4);
Vector3 scanRange10CellsScale = new Vector3(20f, 1f, 20f);
scanRange10Cells = MaterialPool.MatFrom("Effects/ScanRange10x10", MatBases.MetaOverlay);
scanRange10CellsMatrix.SetTRS(base.DrawPos + Altitudes.AltIncVect, (0f).ToQuat(), scanRange10CellsScale);

Graphics.DrawMesh(MeshPool.plane10, scanRange10CellsMatrix, scanRange10Cells, 0);


See you soon with this exciting scanner! ;D well at least I am excited... ::)
Screenshot:

mrofa

Cool its good to know that we can use matbase as attlitude in some way :)
All i do is clutter all around.