Exemplo n.º 1
0
    // ======================================================================================================================
    // INITIALIZE -------------------------------------------------------------------

    void Start()
    {
        // Main cam initialization ---------------------------------------------------
        mainC = Camera.main;
        if (mainC == null)
        {
            mainC = this.GetComponent <Camera>();
        }
        if (mainC == null)
        {
            mainC = GameObject.FindObjectOfType <Camera>();
        }


        // Texture and Mat initalization ---------------------------------------------
        markedIlsandes = new RenderTexture(baseTexture.width, baseTexture.height, 0, RenderTextureFormat.R8);
        albedo         = new PaintableTexture(Color.white, baseTexture.width, baseTexture.height, "_MainTex"
                                              , UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes);
        metalic = new PaintableTexture(Color.white, baseTexture.width, baseTexture.height, "_MetallicGlossMap"
                                       , UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes);

        smoothness = new PaintableTexture(Color.black, baseTexture.width, baseTexture.height, "_GlossMap"
                                          , UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes);

        metalicGlossMapCombined = new RenderTexture(metalic.runTimeTexture.descriptor)
        {
            format = RenderTextureFormat.ARGB32,
        };



        meshMaterial.SetTexture(albedo.id, albedo.runTimeTexture);
        meshMaterial.SetTexture(metalic.id, metalicGlossMapCombined);

        meshMaterial.EnableKeyword("_METALLICGLOSSMAP");


        createMetalicGlossMap = new Material(combineMetalicSmoothnes);


        // Command buffer inialzation ------------------------------------------------

        cb_markingIlsdands      = new CommandBuffer();
        cb_markingIlsdands.name = "markingIlsnads";


        cb_markingIlsdands.SetRenderTarget(markedIlsandes);
        Material mIlsandMarker = new Material(ilsandMarkerShader);

        cb_markingIlsdands.DrawMesh(meshToDraw, Matrix4x4.identity, mIlsandMarker);
        mainC.AddCommandBuffer(CameraEvent.AfterDepthTexture, cb_markingIlsdands);



        albedo.SetActiveTexture(mainC);
    }
Exemplo n.º 2
0
    // ======================================================================================================================
    // INITIALIZE -------------------------------------------------------------------
    void Start()
    {
        Vector4 mwp = new Vector4(100, 100, 100, 100);

        Shader.SetGlobalVector("_Mouse", mwp);

        // Texture and Mat initalization ---------------------------------------------
        markedIlsandes = new RenderTexture(baseTexture.width, baseTexture.height, 0, RenderTextureFormat.R8);
        albedo         = new PaintableTexture(Color.white, baseTexture.width, baseTexture.height, "_MainTex", UVShader, meshToDraw, fixIlsandEdgesShader, markedIlsandes);


        meshMaterial.SetTexture(albedo.id, albedo.runTimeTexture);

        // Command buffer inialzation ------------------------------------------------

        cb_markingIlsdands      = new CommandBuffer();
        cb_markingIlsdands.name = "markingIlsnads";


        cb_markingIlsdands.SetRenderTarget(markedIlsandes);
        Material mIlsandMarker = new Material(ilsandMarkerShader);

        cb_markingIlsdands.DrawMesh(meshToDraw, Matrix4x4.identity, mIlsandMarker);
        mainCamera.AddCommandBuffer(CameraEvent.AfterEverything, cb_markingIlsdands);


        albedo.SetActiveTexture(mainCamera);

        Shader.SetGlobalFloat("_BrushOpacity", 1);
        Shader.SetGlobalColor("_BrushColor", Color.red);
        Shader.SetGlobalFloat("_BrushSize", .13f);
        Shader.SetGlobalFloat("_BrushHardness", .1f);

        mainCamera.depthTextureMode = DepthTextureMode.Depth;

        albedo.UpdateShaderParameters(meshGameobject.transform.localToWorldMatrix);
    }
Exemplo n.º 3
0
 public void SetGlossActive()
 {
     metalic.SetInactiveTexture(mainC);
     albedo.SetInactiveTexture(mainC);
     smoothness.SetActiveTexture(mainC);
 }
Exemplo n.º 4
0
 public void SetMetalicActive()
 {
     albedo.SetInactiveTexture(mainC);
     smoothness.SetInactiveTexture(mainC);
     metalic.SetActiveTexture(mainC);
 }