public override void Update_Brush_Parameters_For_Preview_Shader(PlaytimePainter p) { BlitModeExtensions.SetShaderToggle(!p.IsAtlased(), PainterDataAndConfig.UV_NORMAL, PainterDataAndConfig.UV_ATLASED); }
public void Shader_BrushCFG_Update(BrushConfig brush, float brushAlpha, float textureWidth, bool RendTex, bool texcoord2, PlaytimePainter pntr) { var brushType = brush.Type(!RendTex); bool is3Dbrush = brush.IsA3Dbrush(pntr); bool isDecal = (RendTex) && (brushType.IsUsingDecals); Color c = brush.colorLinear.ToGamma(); #if UNITY_EDITOR // if (isLinearColorSpace) c = c.linear; #endif Shader.SetGlobalVector("_brushColor", c); Shader.SetGlobalVector("_brushMask", new Vector4( brush.mask.GetFlag(BrushMask.R) ? 1 : 0, brush.mask.GetFlag(BrushMask.G) ? 1 : 0, brush.mask.GetFlag(BrushMask.B) ? 1 : 0, brush.mask.GetFlag(BrushMask.A) ? 1 : 0)); if (isDecal) { Shader_UpdateDecal(brush); } if (brush.useMask && RendTex) { Shader.SetGlobalTexture("_SourceMask", Data.masks.TryGet(brush.selectedSourceMask)); } Shader.SetGlobalVector("_maskDynamics", new Vector4( brush.maskTiling, RendTex ? brush.Hardness : 0, // y - Hardness is 0 to do correct preview for Texture2D brush (brush.flipMaskAlpha ? 0 : 1) , 0)); Shader.SetGlobalVector("_maskOffset", new Vector4( brush.maskOffset.x, brush.maskOffset.y, 0, 0)); Shader.SetGlobalVector("_brushForm", new Vector4( brushAlpha // x - transparency , brush.Size(is3Dbrush) // y - scale for sphere , brush.Size(is3Dbrush) / textureWidth // z - scale for uv space , brush.blurAmount)); // w - blur amount brushType.SetKeyword(texcoord2); if (texcoord2) { Shader.EnableKeyword(PainterDataAndConfig.BRUSH_TEXCOORD_2); } else { Shader.DisableKeyword(PainterDataAndConfig.BRUSH_TEXCOORD_2); } brush.BlitMode.SetKeyword().SetGlobalShaderParameters(); if (brush.BlitMode.GetType() == typeof(BlitModeSamplingOffset)) { Shader.EnableKeyword("PREVIEW_SAMPLING_DISPLACEMENT"); Shader.DisableKeyword("PREVIEW_ALPHA"); Shader.DisableKeyword("PREVIEW_RGB"); } else { Shader.DisableKeyword("PREVIEW_SAMPLING_DISPLACEMENT"); BlitModeExtensions.SetShaderToggle(TexMGMTdata.previewAlphaChanel, "PREVIEW_ALPHA", "PREVIEW_RGB"); } if ((RendTex) && (brush.BlitMode.UsingSourceTexture)) { Shader.SetGlobalTexture("_SourceTexture", Data.sourceTextures.TryGet(brush.selectedSourceTexture)); } }