Texture pour une bague

Questions à propos du scripting Shader.
Avatar de l’utilisateur
kealkeal
Messages : 925
Inscription : 16 Juil 2010 17:31
Localisation : Paris

Texture pour une bague

Message par kealkeal » 30 Juil 2010 11:30

Bonjour,

Je souhaite faire une bague sous Unity. :P

Existe t il un training qui présente les différents shaders : effet de diament, effet d'or, effet d'argent ... :roll:

Merci !
kealkeal


Avatar de l’utilisateur
kealkeal
Messages : 925
Inscription : 16 Juil 2010 17:31
Localisation : Paris

Re: Texture pour une bague

Message par kealkeal » 16 Août 2010 10:08

Merci pour ton aide !

On ne peut pas réver mieux ... ;)
Dernière édition par kealkeal le 05 Jan 2011 18:52, édité 1 fois.
kealkeal

Avatar de l’utilisateur
kealkeal
Messages : 925
Inscription : 16 Juil 2010 17:31
Localisation : Paris

Re: Texture pour une bague

Message par kealkeal » 08 Sep 2010 09:35

J'ai récupéré le package qui se trouve ici : http://unity3d.com/support/resources/assets/gem-shader

Dans ce package il y a un shader qui permet de donner l'aspect des diamands.

Voici le code :

Code : Tout sélectionner

Shader "FX/Diamond"
{
	Properties {
		_Color ("Color", Color) = (1,1,1,1)
		_ReflectTex ("Reflection Texture", Cube) = "dummy.jpg" {
			TexGen CubeReflect
		}
		_RefractTex ("Refraction Texture", Cube) = "dummy.jpg" {
			TexGen CubeReflect
		}
	}	
	SubShader {
		Tags {
			"Queue" = "Transparent"
		}
		// First pass - here we render the backfaces of the diamonds. Since those diamonds are more-or-less
		// convex objects, this is effectively rendering the inside of them
		Pass {
			Color (0,0,0,0)
			Offset  -1, -1
			Cull Front
			ZWrite Off
			SetTexture [_RefractTex] {
				constantColor [_Color]
				combine texture * constant, primary
			}
			SetTexture [_ReflectTex] {
				combine previous, previous +- texture
			}
		}

		// Second pass - here we render the front faces of the diamonds.
		Pass {
			Fog { Color (0,0,0,0)}
			ZWrite on
			Blend One One
			SetTexture [_RefractTex] {
				constantColor [_Color]
				combine texture * constant
			}
			SetTexture [_ReflectTex] {
				combine texture + previous, previous +- texture
			}
		}
	}

	// Older cards. Here we remove the bright specular highlight
	SubShader {
		// First pass - here we render the backfaces of the diamonds. Since those diamonds are more-or-less
		// convex objects, this is effectively rendering the inside of them
		Pass {
			Color (0,0,0,0)
			Cull Front
			SetTexture [_RefractTex] {
				constantColor [_Color]
				combine texture * constant, primary
			}
		}

		// Second pass - here we render the front faces of the diamonds.
		Pass {
			Fog { Color (0,0,0,0)}
			ZWrite on
			Blend One One
			SetTexture [_RefractTex] {
				constantColor [_Color]
				combine texture * constant
			}
		}
	}

	// Ancient cards without cubemapping support
	// We could use a 2D refletction texture, but the chances of getting one of these cards are slim, so we won't bother.
	SubShader {
		Pass {
			Color [_Color]
		}
	}
}
Ce shader semble utiliser une image qui est plaque sur différentes faces : Dessus, droite, gauche, face dessous ...

Je souhaite remplacer la texture par defaut par une autre texture mais je n'y parviens pas.

Est ce que quelqu'un peut m'aider ?

Je vois bien "dummy.jpg" dans le code mais l'image n'existe pas physiquement.

Merci pour votre aide.
kealkeal

duparcl
Messages : 25
Inscription : 26 Jan 2010 13:56
Localisation : TOULOUSE

Re: Texture pour une bague

Message par duparcl » 16 Oct 2010 17:49

Salut Michael,

Il est normal que tu ne trouve pas la texture dummy.jpg, cette texture se trouve dans le cubeMap utiliser par le shader. Si tu veux modifier la texture il faut que tu change la texture du cubemap de réflexion si je en me trompe pas.

Fait des tests, dis moi si cela te convient.
Duparc Loic
Email : duparcl@gmail.com
Phone : 06 72 59 65 31
Skype : duparcl

Répondre

Revenir vers « les Shaders »