Package railo.runtime.img.math

Examples of railo.runtime.img.math.Function2D


    boolean invertBumps = bumpHeight < 0;
    Vector3f position = new Vector3f(0.0f, 0.0f, 0.0f);
    Vector3f viewpoint = new Vector3f(width / 2.0f, height / 2.0f, viewDistance);
    Vector3f normal = new Vector3f();
    Color4f c = new Color4f();
    Function2D bump = bumpFunction;

    if (bumpSource == BUMPS_FROM_IMAGE || bumpSource == BUMPS_FROM_IMAGE_ALPHA || bumpSource == BUMPS_FROM_MAP || bump == null) {
      if ( bumpSoftness != 0 ) {
        int bumpWidth = width;
        int bumpHeight = height;
        int[] bumpPixels = inPixels;
        if ( bumpSource == BUMPS_FROM_MAP && bumpFunction instanceof ImageFunction2D ) {
          ImageFunction2D if2d = (ImageFunction2D)bumpFunction;
          bumpWidth = if2d.getWidth();
          bumpHeight = if2d.getHeight();
          bumpPixels = if2d.getPixels();
        }
        Kernel kernel = GaussianFilter.makeKernel( bumpSoftness );
        int [] tmpPixels = new int[bumpWidth * bumpHeight];
        int [] softPixels = new int[bumpWidth * bumpHeight];
        GaussianFilter.convolveAndTranspose( kernel, bumpPixels, tmpPixels, bumpWidth, bumpHeight, true, false, false, ConvolveFilter.CLAMP_EDGES);
        GaussianFilter.convolveAndTranspose( kernel, tmpPixels, softPixels, bumpHeight, bumpWidth, true, false, false, ConvolveFilter.CLAMP_EDGES);
        bump = new ImageFunction2D(softPixels, bumpWidth, bumpHeight, ImageFunction2D.CLAMP, bumpSource == BUMPS_FROM_IMAGE_ALPHA);
      } else
        bump = new ImageFunction2D(inPixels, width, height, ImageFunction2D.CLAMP, bumpSource == BUMPS_FROM_IMAGE_ALPHA);
    }

    Vector3f v1 = new Vector3f();
    Vector3f v2 = new Vector3f();
    Vector3f n = new Vector3f();

    // Loop through each source pixel
    for (int y = 0; y < height; y++) {
      float ny = y;
      position.y = y;
      for (int x = 0; x < width; x++) {
        float nx = x;
       
        // Calculate the normal at this point
        if (bumpSource != BUMPS_FROM_BEVEL) {
          // Complicated and slower method
          // Calculate four normals using the gradients in +/- X/Y directions
          int count = 0;
          normal.x = normal.y = normal.z = 0;
          float m0 = width45*bump.evaluate(nx, ny);
          float m1 = x > 0 ? width45*bump.evaluate(nx - 1.0f, ny)-m0 : -2;
          float m2 = y > 0 ? width45*bump.evaluate(nx, ny - 1.0f)-m0 : -2;
          float m3 = x < width-1 ? width45*bump.evaluate(nx + 1.0f, ny)-m0 : -2;
          float m4 = y < height-1 ? width45*bump.evaluate(nx, ny + 1.0f)-m0 : -2;
         
          if (m1 != -2 && m4 != -2) {
            v1.x = -1.0f; v1.y = 0.0f; v1.z = m1;
            v2.x = 0.0f; v2.y = 1.0f; v2.z = m4;
            n.cross(v1, v2);
View Full Code Here


    Vector3f viewpoint = new Vector3f(width / 2.0f, height / 2.0f, viewDistance);
    Vector3f normal = new Vector3f();
    Color4f envColor = new Color4f();
    Color4f diffuseColor = new Color4f( new Color(material.diffuseColor) );
    Color4f specularColor = new Color4f( new Color(material.specularColor) );
    Function2D bump = bumpFunction;

    // Apply the bump softness
    if (bumpSource == BUMPS_FROM_IMAGE || bumpSource == BUMPS_FROM_IMAGE_ALPHA || bumpSource == BUMPS_FROM_MAP || bump == null) {
      if ( bumpSoftness != 0 ) {
        int bumpWidth = width;
        int bumpHeight = height;
        int[] bumpPixels = inPixels;
        if ( bumpSource == BUMPS_FROM_MAP && bumpFunction instanceof ImageFunction2D ) {
          ImageFunction2D if2d = (ImageFunction2D)bumpFunction;
          bumpWidth = if2d.getWidth();
          bumpHeight = if2d.getHeight();
          bumpPixels = if2d.getPixels();
        }
        int [] tmpPixels = new int[bumpWidth * bumpHeight];
        int [] softPixels = new int[bumpWidth * bumpHeight];
/*
        for (int i = 0; i < 3; i++ ) {
          BoxBlurFilter.blur( bumpPixels, tmpPixels, bumpWidth, bumpHeight, (int)bumpSoftness );
          BoxBlurFilter.blur( tmpPixels, softPixels, bumpHeight, bumpWidth, (int)bumpSoftness );
        }
*/
        Kernel kernel = GaussianFilter.makeKernel( bumpSoftness );
        GaussianFilter.convolveAndTranspose( kernel, bumpPixels, tmpPixels, bumpWidth, bumpHeight, true, false, false, GaussianFilter.WRAP_EDGES );
        GaussianFilter.convolveAndTranspose( kernel, tmpPixels, softPixels, bumpHeight, bumpWidth, true, false, false, GaussianFilter.WRAP_EDGES );
        bump = new ImageFunction2D(softPixels, bumpWidth, bumpHeight, ImageFunction2D.CLAMP, bumpSource == BUMPS_FROM_IMAGE_ALPHA);
final Function2D bbump = bump;
if ( bumpShape != 0 ) {
  bump = new Function2D() {
    private Function2D original = bbump;

    public float evaluate(float x, float y) {
      float v = original.evaluate( x, y );
      switch ( bumpShape ) {
View Full Code Here

TOP

Related Classes of railo.runtime.img.math.Function2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.