Skip to content

Instantly share code, notes, and snippets.

View aras-p's full-sized avatar

Aras Pranckevičius aras-p

View GitHub Profile
// SM3.0+
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma multi_compile_fwdbase
#include "MyCode.cginc"
ENDCG
@aras-p
aras-p / mojoshader-vertex-textures.diff
Created July 22, 2014 19:47
Mojoshader DX bytecode parser fix for SM3.0 vertex textures
# HG changeset patch
# User Aras Pranckevicius <aras@unity3d.com>
# Date 1406058338 -10800
# Tue Jul 22 22:45:38 2014 +0300
# Branch graphics/hlsl-compiler-for-dx9
# Node ID bb1b3cb72364bf306984ae7ace82db713f301f43
# Parent 0d5e0c00b1dd7313f17c2d6698802dfb150a2d85
[shaders] Mojoshader, fixed lack of support for SM3.0 vertex textures.
I've no idea what I'm doing, so just copied code from pixel shader parts.
Makes unity shader compiler tests pass.
@aras-p
aras-p / gist:d345e7292b62e7844508
Created August 21, 2014 12:28
mecanim per animation speed
Here's what the animation folks say:
"There is a speed per node in blend tree editor"
Now, if you need to change these speeds at runtime, then that feature is on their roadmap; for now you could do a workaround:
1. create a blend tree with 2 times the same clip
2. with different speeds (set in the editor)
3. then at runtime change the blend parameter of that blend tree; it will control the speed of the clip at runtime
@aras-p
aras-p / gist:4b198ffbd627454284d6
Created August 25, 2014 11:39
compiled shader
Shader "GUI/Text Shader" {
Properties {
_MainTex ("Font Texture", 2D) = "white" { }
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "PreviewType"="Plane" }
Pass {
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "PreviewType"="Plane" }
Shader "GUI/Text Shader" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Unity.Options;
using Unity.IL2CPP;
namespace il2cpp
{
@aras-p
aras-p / a.md
Last active August 29, 2015 14:07

About this: https://twitter.com/maverikou/status/522797498411540480 (http://imgur.com/8iAPNvT)

If I were to apply Occam's razor to the two narratives that are presented there, then I'd say it's 50-50 which one is "more simple" and more likely. However - these narratives are NOT AT ALL of what's happening, as far as I can tell!

My understanding:

Narrative 1:

A bunch of deranged morons decided to issue death and rape threads to handful of women in the industry (death threats are nothing new - men get them all the time too; rape threats men don't get so often). They cover it upon some "these industry figures did massive crimes involving media coverage and used their influence to bend the media". A lot more of reasonable gamers get behind the cause, since of course, games media has a bunch of issues; and there's a bunch of corruption between developers/publishers/media. The cause is a good one. Many reasonable people can get behind that good cause.

Load scene 'Assets/368-StandardSurfaceShaders.unity' time: 91.877510 ms
Opening scene 'Assets/373-StandardLightmapRealtimeShadowMix.unity'
Unloading 26 Unused Serialized files (Serialized files now loaded: 0)
System memory in use before: 127.5 MB.
System memory in use after: 127.0 MB.
Unloading 16 unused Assets to reduce memory usage. Loaded Objects now: 1070.
Total: 3.666119 ms (FindLiveObjects: 0.274649 ms CreateObjectMapping: 0.037330 ms MarkObjects: 2.393458 ms DeleteObjects: 0.956828 ms)
Load scene 'Assets/373-StandardLightmapRealtimeShadowMix.unity' time: 169.568024 ms
@aras-p
aras-p / poop.md
Last active August 29, 2015 14:09

"poop shader" reply on https://twitter.com/aras_p/status/531686754907357184

So, that shader only compiles in unity 4.x, and only for "desktop opengl" -- and that is only because that's the only platform using Cg compiler. And Cg happily accepts things like "vec4" in Cg/HLSL code (which isn't valid Cg or HLSL. hah). In 5.0 Cg is gone, so that shader wouldn't compile anywhere.

So, fixing that would require changing all vec2/vec4 to float2/float4. Also, changing mix() and lessThan() to functions that actually exist in Cg/HLSL.

Now... the actual problem seems to be:

  1. you have a shader parameter (uniform) named "black". That clashes with a built-in texture name ("black"). Confusing, yes. I'll improve the error message.
  2. why you have a shader uniform? because "const float" in Cg/HLSL is not an "actual constant", it's a uniform where you just promise to not modify it from shader itself. To get an actual contant that's inlined & optimized in the shader, you need to either use "static const blah" or "#define
@aras-p
aras-p / metacritic.md
Last active August 29, 2015 14:16
Good Unity games by metacritic score